test copy

This commit is contained in:
mr
2024-07-19 13:41:10 +02:00
parent 3f9814e649
commit e89b5aae84
14 changed files with 38 additions and 17 deletions

View File

@@ -57,8 +57,6 @@ type WorkflowResource struct {
WorkflowID string `bson:"workflow_id,omitempty" json:"workflow_id,omitempty"`
}
func (d *WorkflowResource) BindID(id string) { d.WorkflowID = id }
func (d *WorkflowResource) GetAccessor() utils.Accessor {
data := &WorkflowResourceMongoAccessor{}
data.SetLogger(utils.WORKFLOW_RESOURCE)

View File

@@ -21,6 +21,17 @@ func (wfa *WorkflowResourceMongoAccessor) StoreOne(data utils.DBObject) (utils.D
return wfa.GenericStoreOne(data, wfa)
}
func (wfa *WorkflowResourceMongoAccessor) CopyOne(data utils.DBObject) (utils.DBObject, int, error) {
res, _, _ := wfa.LoadOne(data.GetID())
data.(*WorkflowResource).WorkflowID = data.GetID()
if res == nil {
return wfa.GenericStoreOne(data, wfa)
} else {
data.(*WorkflowResource).UUID = res.GetID()
return wfa.GenericUpdateOne(data.Serialize(), res.GetID(), wfa)
}
}
func (wfa *WorkflowResourceMongoAccessor) LoadOne(id string) (utils.DBObject, int, error) {
var workflow WorkflowResource
res_mongo, code, err := mongo.MONGOService.LoadOne(id, wfa.GetType())