diff --git a/models/resources/processing/processing.go b/models/resources/processing/processing.go index 61503ed..4a22dc0 100644 --- a/models/resources/processing/processing.go +++ b/models/resources/processing/processing.go @@ -15,7 +15,7 @@ type ProcessingResource struct { Arguments []string `bson:"arguments,omitempty" json:"arguments,omitempty"` Environment []map[string]string `bson:"environment,omitempty" json:"environment,omitempty"` // a key/value struct is what ressembles the most a NAME=VALUE struct - ExecutionRequirements ExecutionRequirementsModel `json:"execution_requirements,omitempty"` + ExecutionRequirements *ExecutionRequirementsModel `json:"execution_requirements,omitempty"` Price uint `bson:"price,omitempty" json:"price,omitempty"` License string `bson:"license,omitempty" json:"license,omitempty"` diff --git a/models/resources/workflow/workflow_mongo_accessor.go b/models/resources/workflow/workflow_mongo_accessor.go index 84df1d3..dbb7dc6 100644 --- a/models/resources/workflow/workflow_mongo_accessor.go +++ b/models/resources/workflow/workflow_mongo_accessor.go @@ -28,7 +28,7 @@ func (wfa *WorkflowResourceMongoAccessor) CopyOne(data utils.DBObject) (utils.DB return wfa.GenericStoreOne(data, wfa) } else { data.(*WorkflowResource).UUID = res.GetID() - return wfa.GenericUpdateOne(data.Serialize(), res.GetID(), wfa) + return wfa.GenericUpdateOne(data, res.GetID(), wfa) } } diff --git a/models/utils/abstracts.go b/models/utils/abstracts.go index 5c460c0..23d0cc9 100644 --- a/models/utils/abstracts.go +++ b/models/utils/abstracts.go @@ -65,8 +65,17 @@ func (dma *AbstractAccessor) GenericDeleteOne(id string, accessor Accessor) (DBO return res, 200, nil } -func (dma *AbstractAccessor) GenericUpdateOne(set interface{}, id string, accessor Accessor) (DBObject, int, error) { - id, code, err := mongo.MONGOService.UpdateOne(set, id, accessor.GetType()) +func (dma *AbstractAccessor) GenericUpdateOne(set DBObject, id string, accessor Accessor) (DBObject, int, error) { + changeMap := set.Serialize() + r, c, err := accessor.LoadOne(id) + if err != nil { + return nil, c, err + } + original := r.Serialize() + for k, v := range changeMap { + original[k] = v + } + id, code, err := mongo.MONGOService.UpdateOne(set.Deserialize(original), id, accessor.GetType()) if err != nil { dma.Logger.Error().Msg("Could not update " + id + " to db. Error: " + err.Error()) return nil, code, err