add with http code
This commit is contained in:
@@ -9,26 +9,26 @@ type DataMongoAccessor struct {
|
||||
utils.AbstractAccessor
|
||||
}
|
||||
|
||||
func (dma *DataMongoAccessor) DeleteOne(id string) (utils.DBObject, error) {
|
||||
func (dma *DataMongoAccessor) DeleteOne(id string) (utils.DBObject, int, error) {
|
||||
return dma.GenericDeleteOne(id, dma)
|
||||
}
|
||||
|
||||
func (dma *DataMongoAccessor) UpdateOne(set map[string]interface{}, id string) (utils.DBObject, error) {
|
||||
func (dma *DataMongoAccessor) UpdateOne(set map[string]interface{}, id string) (utils.DBObject, int, error) {
|
||||
return dma.GenericUpdateOne(set, id, dma)
|
||||
}
|
||||
|
||||
func (dma *DataMongoAccessor) StoreOne(data utils.DBObject) (utils.DBObject, error) {
|
||||
func (dma *DataMongoAccessor) StoreOne(data utils.DBObject) (utils.DBObject, int, error) {
|
||||
return dma.GenericStoreOne(data, dma)
|
||||
}
|
||||
|
||||
func (dma *DataMongoAccessor) LoadOne(id string) (utils.DBObject, error) {
|
||||
func (dma *DataMongoAccessor) LoadOne(id string) (utils.DBObject, int, error) {
|
||||
var data DataResource
|
||||
res_mongo, err := mongo.MONGOService.LoadOne(id, dma.GetType())
|
||||
res_mongo, code, err := mongo.MONGOService.LoadOne(id, dma.GetType())
|
||||
if err != nil {
|
||||
dma.Logger.Error().Msg("Could not retrieve " + id + " from db. Error: " + err.Error())
|
||||
return nil, err
|
||||
return nil, code, err
|
||||
}
|
||||
res_mongo.Decode(&data)
|
||||
|
||||
return &data, nil
|
||||
return &data, 200, nil
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ func TestStoreOneData(t *testing.T) {
|
||||
}
|
||||
|
||||
dma := DataMongoAccessor{}
|
||||
id, _ := dma.StoreOne(&d)
|
||||
id, _, _ := dma.StoreOne(&d)
|
||||
|
||||
assert.NotEmpty(t, id)
|
||||
}
|
||||
@@ -40,6 +40,6 @@ func TestLoadOneDate(t *testing.T) {
|
||||
}
|
||||
|
||||
dma := DataMongoAccessor{}
|
||||
new_d, _ := dma.StoreOne(&d)
|
||||
new_d, _, _ := dma.StoreOne(&d)
|
||||
assert.Equal(t, d, new_d)
|
||||
}
|
||||
|
||||
@@ -9,28 +9,28 @@ type DatacenterMongoAccessor struct {
|
||||
utils.AbstractAccessor
|
||||
}
|
||||
|
||||
func (dca *DatacenterMongoAccessor) DeleteOne(id string) (utils.DBObject, error) {
|
||||
func (dca *DatacenterMongoAccessor) DeleteOne(id string) (utils.DBObject, int, error) {
|
||||
return dca.GenericDeleteOne(id, dca)
|
||||
}
|
||||
|
||||
func (dca *DatacenterMongoAccessor) UpdateOne(set map[string]interface{}, id string) (utils.DBObject, error) {
|
||||
func (dca *DatacenterMongoAccessor) UpdateOne(set map[string]interface{}, id string) (utils.DBObject, int, error) {
|
||||
return dca.GenericUpdateOne(set, id, dca)
|
||||
}
|
||||
|
||||
func (dca *DatacenterMongoAccessor) StoreOne(data utils.DBObject) (utils.DBObject, error) {
|
||||
func (dca *DatacenterMongoAccessor) StoreOne(data utils.DBObject) (utils.DBObject, int, error) {
|
||||
return dca.GenericStoreOne(data, dca)
|
||||
}
|
||||
|
||||
func (dca *DatacenterMongoAccessor) LoadOne(id string) (utils.DBObject, error) {
|
||||
func (dca *DatacenterMongoAccessor) LoadOne(id string) (utils.DBObject, int, error) {
|
||||
var datacenter DatacenterResource
|
||||
|
||||
res_mongo, err := mongo.MONGOService.LoadOne(id, dca.GetType())
|
||||
res_mongo, code, err := mongo.MONGOService.LoadOne(id, dca.GetType())
|
||||
if err != nil {
|
||||
dca.Logger.Error().Msg("Could not retrieve " + id + " from db. Error: " + err.Error())
|
||||
return nil, err
|
||||
return nil, code, err
|
||||
}
|
||||
|
||||
res_mongo.Decode(&datacenter)
|
||||
|
||||
return &datacenter, nil
|
||||
return &datacenter, 200, nil
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ func TestStoreOneDatacenter(t *testing.T) {
|
||||
}
|
||||
|
||||
dcma := DatacenterMongoAccessor{}
|
||||
id, _ := dcma.StoreOne(&dc)
|
||||
id, _, _ := dcma.StoreOne(&dc)
|
||||
|
||||
assert.NotEmpty(t, id)
|
||||
}
|
||||
@@ -40,7 +40,7 @@ func TestLoadOneDatacenter(t *testing.T) {
|
||||
}
|
||||
|
||||
dcma := DatacenterMongoAccessor{}
|
||||
new_dc, _ := dcma.StoreOne(&dc)
|
||||
new_dc, _, _ := dcma.StoreOne(&dc)
|
||||
|
||||
assert.Equal(t, dc, new_dc)
|
||||
}
|
||||
|
||||
@@ -9,29 +9,29 @@ type ProcessingMongoAccessor struct {
|
||||
utils.AbstractAccessor
|
||||
}
|
||||
|
||||
func (pma *ProcessingMongoAccessor) DeleteOne(id string) (utils.DBObject, error) {
|
||||
func (pma *ProcessingMongoAccessor) DeleteOne(id string) (utils.DBObject, int, error) {
|
||||
return pma.GenericDeleteOne(id, pma)
|
||||
}
|
||||
|
||||
func (pma *ProcessingMongoAccessor) UpdateOne(set map[string]interface{}, id string) (utils.DBObject, error) {
|
||||
func (pma *ProcessingMongoAccessor) UpdateOne(set map[string]interface{}, id string) (utils.DBObject, int, error) {
|
||||
return pma.GenericUpdateOne(set, id, pma)
|
||||
}
|
||||
|
||||
func (pma *ProcessingMongoAccessor) StoreOne(data utils.DBObject) (utils.DBObject, error) {
|
||||
func (pma *ProcessingMongoAccessor) StoreOne(data utils.DBObject) (utils.DBObject, int, error) {
|
||||
return pma.GenericStoreOne(data, pma)
|
||||
}
|
||||
|
||||
func (pma *ProcessingMongoAccessor) LoadOne(id string) (utils.DBObject, error) {
|
||||
func (pma *ProcessingMongoAccessor) LoadOne(id string) (utils.DBObject, int, error) {
|
||||
|
||||
var processing ProcessingResource
|
||||
|
||||
res_mongo, err := mongo.MONGOService.LoadOne(id, pma.GetType())
|
||||
res_mongo, code, err := mongo.MONGOService.LoadOne(id, pma.GetType())
|
||||
if err != nil {
|
||||
pma.Logger.Error().Msg("Could not retrieve " + id + " from db. Error: " + err.Error())
|
||||
return nil, err
|
||||
return nil, code, err
|
||||
}
|
||||
|
||||
res_mongo.Decode(&processing)
|
||||
|
||||
return &processing, nil
|
||||
return &processing, 200, nil
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ func TestStoreOneProcessing(t *testing.T) {
|
||||
}
|
||||
|
||||
sma := ProcessingMongoAccessor{}
|
||||
id, _ := sma.StoreOne(&p)
|
||||
id, _, _ := sma.StoreOne(&p)
|
||||
|
||||
assert.NotEmpty(t, id)
|
||||
}
|
||||
@@ -40,6 +40,6 @@ func TestLoadOneProcessing(t *testing.T) {
|
||||
}
|
||||
|
||||
sma := ProcessingMongoAccessor{}
|
||||
new_s, _ := sma.StoreOne(&p)
|
||||
new_s, _, _ := sma.StoreOne(&p)
|
||||
assert.Equal(t, p, new_s)
|
||||
}
|
||||
|
||||
@@ -9,29 +9,29 @@ type StorageMongoAccessor struct {
|
||||
utils.AbstractAccessor
|
||||
}
|
||||
|
||||
func (sma *StorageMongoAccessor) DeleteOne(id string) (utils.DBObject, error) {
|
||||
func (sma *StorageMongoAccessor) DeleteOne(id string) (utils.DBObject, int, error) {
|
||||
return sma.GenericDeleteOne(id, sma)
|
||||
}
|
||||
|
||||
func (sma *StorageMongoAccessor) UpdateOne(set map[string]interface{}, id string) (utils.DBObject, error) {
|
||||
func (sma *StorageMongoAccessor) UpdateOne(set map[string]interface{}, id string) (utils.DBObject, int, error) {
|
||||
return sma.GenericUpdateOne(set, id, sma)
|
||||
}
|
||||
|
||||
func (sma *StorageMongoAccessor) StoreOne(data utils.DBObject) (utils.DBObject, error) {
|
||||
func (sma *StorageMongoAccessor) StoreOne(data utils.DBObject) (utils.DBObject, int, error) {
|
||||
return sma.GenericStoreOne(data, sma)
|
||||
}
|
||||
|
||||
func (sma *StorageMongoAccessor) LoadOne(id string) (utils.DBObject, error) {
|
||||
func (sma *StorageMongoAccessor) LoadOne(id string) (utils.DBObject, int, error) {
|
||||
|
||||
var storage StorageResource
|
||||
|
||||
res_mongo, err := mongo.MONGOService.LoadOne(id, sma.GetType())
|
||||
res_mongo, code, err := mongo.MONGOService.LoadOne(id, sma.GetType())
|
||||
if err != nil {
|
||||
sma.Logger.Error().Msg("Could not retrieve " + id + " from db. Error: " + err.Error())
|
||||
return nil, err
|
||||
return nil, code, err
|
||||
}
|
||||
|
||||
res_mongo.Decode(&storage)
|
||||
|
||||
return &storage, nil
|
||||
return &storage, 200, nil
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ func TestStoreOneStorage(t *testing.T) {
|
||||
}
|
||||
|
||||
sma := StorageMongoAccessor{}
|
||||
id, _ := sma.StoreOne(&s)
|
||||
id, _, _ := sma.StoreOne(&s)
|
||||
|
||||
assert.NotEmpty(t, id)
|
||||
}
|
||||
@@ -40,7 +40,7 @@ func TestLoadOneStorage(t *testing.T) {
|
||||
}
|
||||
|
||||
sma := StorageMongoAccessor{}
|
||||
new_s, _ := sma.StoreOne(&s)
|
||||
new_s, _, _ := sma.StoreOne(&s)
|
||||
|
||||
assert.Equal(t, s, new_s)
|
||||
}
|
||||
|
||||
@@ -9,25 +9,25 @@ type WorkflowResourceMongoAccessor struct {
|
||||
utils.AbstractAccessor
|
||||
}
|
||||
|
||||
func (wfa *WorkflowResourceMongoAccessor) DeleteOne(id string) (utils.DBObject, error) {
|
||||
func (wfa *WorkflowResourceMongoAccessor) DeleteOne(id string) (utils.DBObject, int, error) {
|
||||
return wfa.GenericDeleteOne(id, wfa)
|
||||
}
|
||||
|
||||
func (wfa *WorkflowResourceMongoAccessor) UpdateOne(set map[string]interface{}, id string) (utils.DBObject, error) {
|
||||
func (wfa *WorkflowResourceMongoAccessor) UpdateOne(set map[string]interface{}, id string) (utils.DBObject, int, error) {
|
||||
return wfa.GenericUpdateOne(set, id, wfa)
|
||||
}
|
||||
|
||||
func (wfa *WorkflowResourceMongoAccessor) StoreOne(data utils.DBObject) (utils.DBObject, error) {
|
||||
func (wfa *WorkflowResourceMongoAccessor) StoreOne(data utils.DBObject) (utils.DBObject, int, error) {
|
||||
return wfa.GenericStoreOne(data, wfa)
|
||||
}
|
||||
|
||||
func (wfa *WorkflowResourceMongoAccessor) LoadOne(id string) (utils.DBObject, error) {
|
||||
func (wfa *WorkflowResourceMongoAccessor) LoadOne(id string) (utils.DBObject, int, error) {
|
||||
var workflow WorkflowResource
|
||||
res_mongo, err := mongo.MONGOService.LoadOne(id, wfa.GetType())
|
||||
res_mongo, code, err := mongo.MONGOService.LoadOne(id, wfa.GetType())
|
||||
if err != nil {
|
||||
wfa.Logger.Error().Msg("Could not retrieve " + id + " from db. Error: " + err.Error())
|
||||
return nil, err
|
||||
return nil, code, err
|
||||
}
|
||||
res_mongo.Decode(&workflow)
|
||||
return &workflow, nil
|
||||
return &workflow, 200, nil
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ func TestStoreOneWorkflow(t *testing.T) {
|
||||
}
|
||||
|
||||
wma := WorkflowResourceMongoAccessor{}
|
||||
id, _ := wma.StoreOne(&w)
|
||||
id, _, _ := wma.StoreOne(&w)
|
||||
|
||||
assert.NotEmpty(t, id)
|
||||
}
|
||||
@@ -38,6 +38,6 @@ func TestLoadOneWorkflow(t *testing.T) {
|
||||
}
|
||||
|
||||
wma := WorkflowResourceMongoAccessor{}
|
||||
new_w, _ := wma.StoreOne(&w)
|
||||
new_w, _, _ := wma.StoreOne(&w)
|
||||
assert.Equal(t, w, new_w)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user