resource as resource named
This commit is contained in:
@@ -12,42 +12,17 @@ import (
|
||||
"cloud.o-forge.io/core/oc-lib/models/utils"
|
||||
)
|
||||
|
||||
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"`
|
||||
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"`
|
||||
}
|
||||
|
||||
func (d *Workflow) GetAccessor() utils.Accessor {
|
||||
data := &WorkflowMongoAccessor{}
|
||||
data.SetLogger(resources.WORKFLOW)
|
||||
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 (dma *Workflow) Serialize() map[string]interface{} {
|
||||
var m map[string]interface{}
|
||||
b, err := json.Marshal(dma)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
json.Unmarshal(b, dma)
|
||||
return m
|
||||
}
|
||||
|
||||
func (w *Workflow) isDCLink(link graph.GraphLink) bool {
|
||||
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 {
|
||||
@@ -56,3 +31,34 @@ func (w *Workflow) isDCLink(link graph.GraphLink) bool {
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
type WorkflowResource struct {
|
||||
resources.AbstractResource
|
||||
AbstractWorkflow
|
||||
WorkflowID string `bson:"workflow_id,omitempty" json:"workflow_id,omitempty"`
|
||||
}
|
||||
|
||||
func (d *WorkflowResource) GetAccessor() utils.Accessor {
|
||||
data := &WorkflowResourceMongoAccessor{}
|
||||
data.SetLogger(utils.WORKFLOW_RESOURCE)
|
||||
return data
|
||||
}
|
||||
|
||||
func (dma *WorkflowResource) Deserialize(j map[string]interface{}) utils.DBObject {
|
||||
b, err := json.Marshal(j)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
json.Unmarshal(b, dma)
|
||||
return dma
|
||||
}
|
||||
|
||||
func (dma *WorkflowResource) Serialize() map[string]interface{} {
|
||||
var m map[string]interface{}
|
||||
b, err := json.Marshal(dma)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
json.Unmarshal(b, dma)
|
||||
return m
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user