From 2df71c65712b386712cf96d7860900d85af34ec6 Mon Sep 17 00:00:00 2001 From: mr Date: Wed, 25 Sep 2024 10:02:10 +0200 Subject: [PATCH] test booking --- models/workflow/workflow_mongo_accessor.go | 9 ++------- models/workspace/workspace_mongo_accessor.go | 4 +++- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/models/workflow/workflow_mongo_accessor.go b/models/workflow/workflow_mongo_accessor.go index 4484919..c249df4 100644 --- a/models/workflow/workflow_mongo_accessor.go +++ b/models/workflow/workflow_mongo_accessor.go @@ -97,8 +97,8 @@ func (wfa *workflowMongoAccessor) DeleteOne(id string) (utils.DBObject, int, err res, code, err := wfa.GenericDeleteOne(id, wfa) if res != nil && code == 200 { wfa.execute(res.(*Workflow), false, false) // up to date the workspace for the workflow + wfa.share(res.(*Workflow), true, wfa.Caller) } - wfa.share(res.(*Workflow), true, wfa.Caller) // send the deletion to the peers where workflow is shared return res, code, err } @@ -206,25 +206,20 @@ func (wfa *workflowMongoAccessor) execution(id string, realData *Workflow, delet } accessor := (&workflow_execution.WorkflowExecution{}).GetAccessor(nil) execs, err := wfa.getExecutions(id, realData) // get the executions of the workflow - fmt.Println("EXECUTIONS", execs) if err != nil { return 422, err } err = wfa.book(id, realData, execs) // book the workflow on the peers - fmt.Println("BOOKING", err) if err != nil { return 409, err // if the booking fails, return an error for integrity between peers } - fmt.Println("BOOKING2", err, delete) if delete { // if delete is set to true, delete the executions return 200, nil } - fmt.Println("EXECS", err, len(execs)) if len(execs) > 0 { // if the executions are set, store them for _, obj := range execs { _, code, err := accessor.StoreOne(obj) - fmt.Println("EXECS LOOP", err, code) if code != 200 { return code, err } @@ -263,7 +258,7 @@ func (wfa *workflowMongoAccessor) UpdateOne(set utils.DBObject, id string) (util // StoreOne stores a workflow in the database func (wfa *workflowMongoAccessor) StoreOne(data utils.DBObject) (utils.DBObject, int, error) { res, code, err := wfa.GenericStoreOne(data, wfa) - if err != nil { + if err != nil || code != 200 { return nil, code, err } wfa.share(res.(*Workflow), false, wfa.Caller) // share the creation to the peers diff --git a/models/workspace/workspace_mongo_accessor.go b/models/workspace/workspace_mongo_accessor.go index 696c283..bac3468 100644 --- a/models/workspace/workspace_mongo_accessor.go +++ b/models/workspace/workspace_mongo_accessor.go @@ -30,7 +30,9 @@ func New() *workspaceMongoAccessor { // it checks if a workspace with the same name already exists func (wfa *workspaceMongoAccessor) DeleteOne(id string) (utils.DBObject, int, error) { res, code, err := wfa.GenericDeleteOne(id, wfa) - wfa.share(res.(*Workspace), true, wfa.Caller) // Share the deletion to the peers + if code == 200 && res != nil { + wfa.share(res.(*Workspace), true, wfa.Caller) // Share the deletion to the peers + } return res, code, err }