46 lines
1.4 KiB
Go
46 lines
1.4 KiB
Go
|
package oclib
|
||
|
|
||
|
import (
|
||
|
"oc-lib/models/resources"
|
||
|
"oc-lib/models/resources/data"
|
||
|
"oc-lib/models/resources/datacenter"
|
||
|
"oc-lib/models/resources/processing"
|
||
|
"oc-lib/models/resources/storage"
|
||
|
"oc-lib/models/utils"
|
||
|
"oc-lib/models/workflow/graph"
|
||
|
)
|
||
|
|
||
|
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 utils.Driver) utils.Accessor {
|
||
|
var data utils.Accessor
|
||
|
switch driver {
|
||
|
case utils.MONGO:
|
||
|
data = &WorkflowMongoAccessor{}
|
||
|
default:
|
||
|
data = &WorkflowMongoAccessor{}
|
||
|
}
|
||
|
data.SetLogger()
|
||
|
return data
|
||
|
}
|
||
|
|
||
|
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
|
||
|
}
|