From 14fe694fd370e3244c84e17f3e85992d6b9befcd Mon Sep 17 00:00:00 2001 From: mr Date: Thu, 14 Nov 2024 10:02:18 +0100 Subject: [PATCH] state execution --- models/workflow/workflow.go | 16 ++++++++++++++++ models/workspace/workspace_mongo_accessor.go | 6 ++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/models/workflow/workflow.go b/models/workflow/workflow.go index 1365ce5..f59ccca 100644 --- a/models/workflow/workflow.go +++ b/models/workflow/workflow.go @@ -36,6 +36,22 @@ func (w *AbstractWorkflow) GetWorkflows() (list_computings []graph.GraphItem) { return } +func (w *AbstractWorkflow) GetComputeByRelatedProcessing(processingID string) []*compute.ComputeResource { + storages := []*compute.ComputeResource{} + for _, link := range w.Graph.Links { + nodeID := link.Destination.ID // we considers that the processing is the destination + node := w.Graph.Items[link.Source.ID].Compute // we are looking for the storage as source + if node == nil { // if the source is not a storage, we consider that the destination is the storage + nodeID = link.Source.ID // and the processing is the source + node = w.Graph.Items[link.Destination.ID].Compute // we are looking for the storage as destination + } + if processingID == nodeID && node != nil { // if the storage is linked to the processing + storages = append(storages, node) + } + } + return storages +} + func (w *AbstractWorkflow) GetStoragesByRelatedProcessing(processingID string) []*storage.StorageResource { storages := []*storage.StorageResource{} for _, link := range w.Graph.Links { diff --git a/models/workspace/workspace_mongo_accessor.go b/models/workspace/workspace_mongo_accessor.go index a7360a2..cf7b16b 100644 --- a/models/workspace/workspace_mongo_accessor.go +++ b/models/workspace/workspace_mongo_accessor.go @@ -2,13 +2,14 @@ package workspace import ( "errors" + "fmt" "cloud.o-forge.io/core/oc-lib/dbs" "cloud.o-forge.io/core/oc-lib/dbs/mongo" "cloud.o-forge.io/core/oc-lib/models/collaborative_area/shallow_collaborative_area" "cloud.o-forge.io/core/oc-lib/models/peer" - "cloud.o-forge.io/core/oc-lib/models/resources/data" "cloud.o-forge.io/core/oc-lib/models/resources/compute" + "cloud.o-forge.io/core/oc-lib/models/resources/data" "cloud.o-forge.io/core/oc-lib/models/resources/processing" "cloud.o-forge.io/core/oc-lib/models/resources/storage" w "cloud.o-forge.io/core/oc-lib/models/resources/workflow" @@ -205,7 +206,8 @@ func (wfa *workspaceMongoAccessor) Search(filters *dbs.Filters, search string) ( This function is used to share the workspace with the peers */ func (wfa *workspaceMongoAccessor) share(realData *Workspace, method tools.METHOD, caller *tools.HTTPCaller) { - if realData.Shared == "" || caller.Disabled { + fmt.Println("Sharing workspace", realData, caller) + if realData == nil || realData.Shared == "" || caller == nil || caller.Disabled { return } access := (&shallow_collaborative_area.ShallowCollaborativeArea{}).GetAccessor(nil)