Not a proper WF model

This commit is contained in:
mr 2024-07-23 08:59:39 +02:00
parent 0c825b65b0
commit febabe67e7

View File

@ -2,33 +2,27 @@ package oclib
import (
"encoding/json"
"slices"
"cloud.o-forge.io/core/oc-lib/models/resources"
"cloud.o-forge.io/core/oc-lib/models/resources/data"
"cloud.o-forge.io/core/oc-lib/models/resources/datacenter"
"cloud.o-forge.io/core/oc-lib/models/resources/processing"
"cloud.o-forge.io/core/oc-lib/models/resources/storage"
"cloud.o-forge.io/core/oc-lib/models/resources/workflow/graph"
"cloud.o-forge.io/core/oc-lib/models/utils"
)
type AbstractWorkflow struct {
Graph *graph.Graph `bson:"graph,omitempty" json:"graph,omitempty"`
Datas map[string]data.DataResource `bson:"datas,omitempty" json:"datas,omitempty"`
Storages map[string]storage.StorageResource `bson:"storages,omitempty" json:"storages,omitempty"`
ProcessingResource map[string]processing.ProcessingResource `bson:"processing,omitempty" json:"processing,omitempty"`
Datacenters map[string]datacenter.DatacenterResource `bson:"datacenters,omitempty" json:"datacenters,omitempty"`
Workflows map[string]WorkflowResource `bson:"workflows,omitempty" json:"workflows,omitempty"`
Schedule *WorkflowSchedule `bson:"schedule,omitempty" json:"schedule,omitempty"`
Graph *graph.Graph `bson:"graph,omitempty" json:"graph,omitempty"`
Datas []string `bson:"datas,omitempty" json:"datas,omitempty"`
Storages []string `bson:"storages,omitempty" json:"storages,omitempty"`
ProcessingResource []string `bson:"processing,omitempty" json:"processing,omitempty"`
Datacenters []string `bson:"datacenters,omitempty" json:"datacenters,omitempty"`
Workflows []string `bson:"workflows,omitempty" json:"workflows,omitempty"`
Schedule *WorkflowSchedule `bson:"schedule,omitempty" json:"schedule,omitempty"`
}
func (w *AbstractWorkflow) isDCLink(link graph.GraphLink) bool {
if _, exists := w.Datacenters[link.Destination.ID]; exists {
return true
} else if _, exists := w.Datacenters[link.Source.ID]; exists {
if slices.Contains(w.Datacenters, link.Destination.ID) || slices.Contains(w.Datacenters, link.Source.ID) {
return true
}
return false
}