package oclib import ( "encoding/json" "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/utils" "cloud.o-forge.io/core/oc-lib/models/workflow/graph" tool "cloud.o-forge.io/core/oc-lib/utils" ) const WORKFLOW = "workflow" type Workflow struct { resources.AbstractResource Graph graph.Graph `bson:"graph,omitempty" json:"graph,omitempty"` Datas map[string]data.Data `bson:"datas,omitempty" json:"datas,omitempty"` Storages map[string]storage.Storage `bson:"storages,omitempty" json:"storages,omitempty"` Processing map[string]processing.Processing `bson:"processing,omitempty" json:"processing,omitempty"` Datacenters map[string]datacenter.Datacenter `bson:"datacenters,omitempty" json:"datacenters,omitempty"` Schedule WorkflowSchedule `bson:"schedule,omitempty" json:"schedule,omitempty"` } func (d *Workflow) GetAccessor(driver tool.Driver) utils.Accessor { var data utils.Accessor switch driver { case tool.MONGO: data = &WorkflowMongoAccessor{} default: data = &WorkflowMongoAccessor{} } data.SetLogger() return data } func (dma *Workflow) Deserialize(j map[string]interface{}) utils.DBObject { b, err := json.Marshal(j) if err != nil { return nil } json.Unmarshal(b, dma) return dma } func (w *Workflow) isDCLink(link graph.GraphLink) bool { if _, exists := w.Datacenters[link.Destination.ID]; exists { return true } else if _, exists := w.Datacenters[link.Source.ID]; exists { return true } return false }