| 
						 
						
						
						
						 
					 | 
					 | 
					@@ -1,6 +1,8 @@
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					package workflow
 | 
					 | 
					 | 
					 | 
					package workflow
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import (
 | 
					 | 
					 | 
					 | 
					import (
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
						"errors"
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						"cloud.o-forge.io/core/oc-lib/dbs"
 | 
					 | 
					 | 
					 | 
						"cloud.o-forge.io/core/oc-lib/dbs"
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						"cloud.o-forge.io/core/oc-lib/logs"
 | 
					 | 
					 | 
					 | 
						"cloud.o-forge.io/core/oc-lib/logs"
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						"cloud.o-forge.io/core/oc-lib/models/collaborative_area/shallow_collaborative_area"
 | 
					 | 
					 | 
					 | 
						"cloud.o-forge.io/core/oc-lib/models/collaborative_area/shallow_collaborative_area"
 | 
				
			
			
		
	
	
		
		
			
				
					
					| 
						
					 | 
					 | 
					@@ -47,7 +49,7 @@ func (a *workflowMongoAccessor) DeleteOne(id string) (utils.DBObject, int, error
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							a.execute(res.(*Workflow), true, false) // up to date the workspace for the workflow
 | 
					 | 
					 | 
					 | 
							a.execute(res.(*Workflow), true, false) // up to date the workspace for the workflow
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							a.share(res.(*Workflow), true, a.GetCaller())
 | 
					 | 
					 | 
					 | 
							a.share(res.(*Workflow), true, a.GetCaller())
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						}
 | 
					 | 
					 | 
					 | 
						}
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						return res, code, err
 | 
					 | 
					 | 
					 | 
						return a.verifyResource(res), code, err
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					}
 | 
					 | 
					 | 
					 | 
					}
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					/*
 | 
					 | 
					 | 
					 | 
					/*
 | 
				
			
			
		
	
	
		
		
			
				
					
					| 
						
					 | 
					 | 
					@@ -89,7 +91,11 @@ func (a *workflowMongoAccessor) share(realData *Workflow, delete bool, caller *t
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					// UpdateOne updates a workflow in the database
 | 
					 | 
					 | 
					 | 
					// UpdateOne updates a workflow in the database
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					func (a *workflowMongoAccessor) UpdateOne(set utils.DBObject, id string) (utils.DBObject, int, error) {
 | 
					 | 
					 | 
					 | 
					func (a *workflowMongoAccessor) UpdateOne(set utils.DBObject, id string) (utils.DBObject, int, error) {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						// avoid the update if the schedule is the same
 | 
					 | 
					 | 
					 | 
						// avoid the update if the schedule is the same
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						res, code, err := utils.GenericUpdateOne(set, id, a, &Workflow{})
 | 
					 | 
					 | 
					 | 
						set = a.verifyResource(set)
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
						if set.(*Workflow).Graph.Partial {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
							return nil, 403, errors.New("you are not allowed to update a partial workflow")
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
						}
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
						res, code, err := utils.GenericUpdateOne(a.verifyResource(set), id, a, &Workflow{})
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						if code != 200 {
 | 
					 | 
					 | 
					 | 
						if code != 200 {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							return nil, code, err
 | 
					 | 
					 | 
					 | 
							return nil, code, err
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						}
 | 
					 | 
					 | 
					 | 
						}
 | 
				
			
			
		
	
	
		
		
			
				
					
					| 
						
					 | 
					 | 
					@@ -101,7 +107,11 @@ func (a *workflowMongoAccessor) UpdateOne(set utils.DBObject, id string) (utils.
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					// StoreOne stores a workflow in the database
 | 
					 | 
					 | 
					 | 
					// StoreOne stores a workflow in the database
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					func (a *workflowMongoAccessor) StoreOne(data utils.DBObject) (utils.DBObject, int, error) {
 | 
					 | 
					 | 
					 | 
					func (a *workflowMongoAccessor) StoreOne(data utils.DBObject) (utils.DBObject, int, error) {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
						data = a.verifyResource(data)
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						d := data.(*Workflow)
 | 
					 | 
					 | 
					 | 
						d := data.(*Workflow)
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
						if d.Graph.Partial {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
							return nil, 403, errors.New("you are not allowed to update a partial workflow")
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
						}
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						res, code, err := utils.GenericStoreOne(d, a)
 | 
					 | 
					 | 
					 | 
						res, code, err := utils.GenericStoreOne(d, a)
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						if err != nil || code != 200 {
 | 
					 | 
					 | 
					 | 
						if err != nil || code != 200 {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							return nil, code, err
 | 
					 | 
					 | 
					 | 
							return nil, code, err
 | 
				
			
			
		
	
	
		
		
			
				
					
					| 
						
					 | 
					 | 
					@@ -121,7 +131,6 @@ func (a *workflowMongoAccessor) CopyOne(data utils.DBObject) (utils.DBObject, in
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					// execute is a function that executes a workflow
 | 
					 | 
					 | 
					 | 
					// execute is a function that executes a workflow
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					// it stores the workflow resources in a specific workspace to never have a conflict in UI and logic
 | 
					 | 
					 | 
					 | 
					// it stores the workflow resources in a specific workspace to never have a conflict in UI and logic
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					func (a *workflowMongoAccessor) execute(workflow *Workflow, delete bool, active bool) {
 | 
					 | 
					 | 
					 | 
					func (a *workflowMongoAccessor) execute(workflow *Workflow, delete bool, active bool) {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						filters := &dbs.Filters{
 | 
					 | 
					 | 
					 | 
						filters := &dbs.Filters{
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							Or: map[string][]dbs.Filter{ // filter by standard workspace name attached to a workflow
 | 
					 | 
					 | 
					 | 
							Or: map[string][]dbs.Filter{ // filter by standard workspace name attached to a workflow
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								"abstractobject.name": {{Operator: dbs.LIKE.String(), Value: workflow.Name + "_workspace"}},
 | 
					 | 
					 | 
					 | 
								"abstractobject.name": {{Operator: dbs.LIKE.String(), Value: workflow.Name + "_workspace"}},
 | 
				
			
			
		
	
	
		
		
			
				
					
					| 
						
					 | 
					 | 
					@@ -164,7 +173,7 @@ func (a *workflowMongoAccessor) LoadOne(id string) (utils.DBObject, int, error)
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						return utils.GenericLoadOne[*Workflow](id, func(d utils.DBObject) (utils.DBObject, int, error) {
 | 
					 | 
					 | 
					 | 
						return utils.GenericLoadOne[*Workflow](id, func(d utils.DBObject) (utils.DBObject, int, error) {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							w := d.(*Workflow)
 | 
					 | 
					 | 
					 | 
							w := d.(*Workflow)
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							a.execute(w, false, true) // if no workspace is attached to the workflow, create it
 | 
					 | 
					 | 
					 | 
							a.execute(w, false, true) // if no workspace is attached to the workflow, create it
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							return d, 200, nil
 | 
					 | 
					 | 
					 | 
							return a.verifyResource(d), 200, nil
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						}, a)
 | 
					 | 
					 | 
					 | 
						}, a)
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					}
 | 
					 | 
					 | 
					 | 
					}
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
	
		
		
			
				
					
					| 
						
					 | 
					 | 
					@@ -173,5 +182,36 @@ func (a *workflowMongoAccessor) LoadAll(isDraft bool) ([]utils.ShallowDBObject,
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					}
 | 
					 | 
					 | 
					 | 
					}
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					func (a *workflowMongoAccessor) Search(filters *dbs.Filters, search string, isDraft bool) ([]utils.ShallowDBObject, int, error) {
 | 
					 | 
					 | 
					 | 
					func (a *workflowMongoAccessor) Search(filters *dbs.Filters, search string, isDraft bool) ([]utils.ShallowDBObject, int, error) {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						return utils.GenericSearch[*Workflow](filters, search, (&Workflow{}).GetObjectFilters(search), func(d utils.DBObject) utils.ShallowDBObject { return d }, isDraft, a)
 | 
					 | 
					 | 
					 | 
						return utils.GenericSearch[*Workflow](filters, search, (&Workflow{}).GetObjectFilters(search), func(d utils.DBObject) utils.ShallowDBObject { return a.verifyResource(d) }, isDraft, a)
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					}
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					func (a *workflowMongoAccessor) verifyResource(obj utils.DBObject) utils.DBObject {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
						wf := obj.(*Workflow)
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
						if wf.Graph == nil {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
							return nil
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
						}
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
						for _, item := range wf.Graph.Items {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
							t, resource := item.GetResource()
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
							if resource == nil {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
								continue
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
							}
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
							var access utils.Accessor
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
							if t == tools.COMPUTE_RESOURCE {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
								access = resources.NewAccessor[*resources.ComputeResource](t, a.GetRequest(), func() utils.DBObject { return &resources.ComputeResource{} })
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
							} else if t == tools.PROCESSING_RESOURCE {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
								access = resources.NewAccessor[*resources.ProcessingResource](t, a.GetRequest(), func() utils.DBObject { return &resources.ProcessingResource{} })
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
							} else if t == tools.STORAGE_RESOURCE {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
								access = resources.NewAccessor[*resources.StorageResource](t, a.GetRequest(), func() utils.DBObject { return &resources.StorageResource{} })
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
							} else if t == tools.WORKFLOW_RESOURCE {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
								access = resources.NewAccessor[*resources.WorkflowResource](t, a.GetRequest(), func() utils.DBObject { return &resources.WorkflowResource{} })
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
							} else if t == tools.DATA_RESOURCE {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
								access = resources.NewAccessor[*resources.DataResource](t, a.GetRequest(), func() utils.DBObject { return &resources.DataResource{} })
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
							} else {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
								wf.Graph.Clear(item.Data.GetID())
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
							}
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
							if error := utils.VerifyAccess(access, resource.GetID()); error != nil {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
								wf.Graph.Clear(item.Data.GetID())
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
							}
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
						}
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
						return wf
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					}
 | 
					 | 
					 | 
					 | 
					}
 | 
				
			
			
		
	
	
		
		
			
				
					
					| 
						 
						
						
						
						 
					 | 
					 | 
					 
 |