add workflow func tools
This commit is contained in:
parent
de0b910e09
commit
2de218782f
@ -26,6 +26,100 @@ type AbstractWorkflow struct {
|
||||
Shared []string `json:"shared,omitempty" bson:"shared,omitempty"` // Shared is the ID of the shared workflow
|
||||
}
|
||||
|
||||
func (w AbstractWorkflow) isADependancy(id string) (bool, []string) {
|
||||
dependancyOfIDs := []string{}
|
||||
isDeps := false
|
||||
for _, link := range w.Graph.Links {
|
||||
source := w.Graph.Items[link.Destination.ID].Processing
|
||||
if id == link.Source.ID && source != nil {
|
||||
isDeps = true
|
||||
dependancyOfIDs = append(dependancyOfIDs, link.Destination.ID)
|
||||
}
|
||||
wourceWF := w.Graph.Items[link.Destination.ID].Workflow
|
||||
if id == link.Source.ID && wourceWF != nil {
|
||||
isDeps = true
|
||||
dependancyOfIDs = append(dependancyOfIDs, link.Destination.ID)
|
||||
}
|
||||
}
|
||||
return isDeps, dependancyOfIDs
|
||||
}
|
||||
|
||||
func (w *AbstractWorkflow) GetStoragesByRelatedProcessing(processingID string, relatedToData bool, ignoreRelation bool) (map[string][]utils.DBObject, map[string]map[string][]utils.DBObject) {
|
||||
storages := make(map[string][]utils.DBObject)
|
||||
datasRelatedToStorage := make(map[string]map[string][]utils.DBObject)
|
||||
for _, link := range w.Graph.Links {
|
||||
inout := "in"
|
||||
storageID := link.Source.ID // Default value because we are looking for the input storage cause processing is destination
|
||||
nodeID := link.Destination.ID // we considers that the processing is the destination
|
||||
node := w.Graph.Items[link.Source.ID].Storage // 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
|
||||
inout = "out"
|
||||
storageID = link.Destination.ID // then we are looking for the output storage
|
||||
nodeID = link.Source.ID // and the processing is the source
|
||||
node = w.Graph.Items[link.Destination.ID].Storage // we are looking for the storage as destination
|
||||
}
|
||||
if processingID == nodeID && node != nil { // if the storage is linked to the processing
|
||||
if storages[inout] == nil {
|
||||
storages[inout] = []utils.DBObject{}
|
||||
}
|
||||
if !ignoreRelation {
|
||||
datasRelatedToStorage[storageID], _ = w.GetDatasByRelatedProcessing(processingID, false, true)
|
||||
if relatedToData && len(datasRelatedToStorage[storageID]) > 0 {
|
||||
storages[inout] = append(storages[inout], node)
|
||||
} else if !relatedToData && len(datasRelatedToStorage[storageID]) == 0 {
|
||||
storages[inout] = append(storages[inout], node)
|
||||
}
|
||||
} else {
|
||||
storages[inout] = append(storages[inout], node)
|
||||
}
|
||||
}
|
||||
}
|
||||
return storages, datasRelatedToStorage
|
||||
}
|
||||
|
||||
func (w *AbstractWorkflow) GetDatasByRelatedProcessing(dataID string, relatedToStorage bool, ignoreRelation bool) (map[string][]utils.DBObject, map[string]map[string][]utils.DBObject) {
|
||||
datas := make(map[string][]utils.DBObject)
|
||||
datasRelatedToData := make(map[string]map[string][]utils.DBObject)
|
||||
for _, link := range w.Graph.Links {
|
||||
inout := "in"
|
||||
dataID := link.Source.ID // Default value because we are looking for the input storage cause processing is destination
|
||||
nodeID := link.Destination.ID // we considers that the processing is the destination
|
||||
node := w.Graph.Items[link.Source.ID].Data // 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
|
||||
inout = "out"
|
||||
dataID = link.Destination.ID // then we are looking for the output storage
|
||||
nodeID = link.Source.ID // and the processing is the source
|
||||
node = w.Graph.Items[link.Destination.ID].Data // we are looking for the storage as destination
|
||||
}
|
||||
if dataID == nodeID && node != nil { // if the storage is linked to the processing
|
||||
if datas[inout] == nil {
|
||||
datas[inout] = []utils.DBObject{}
|
||||
}
|
||||
datas[inout] = append(datas[inout], node)
|
||||
if !ignoreRelation {
|
||||
datasRelatedToData[dataID], _ = w.GetStoragesByRelatedProcessing(dataID, false, true)
|
||||
if relatedToStorage && len(datasRelatedToData[dataID]) > 0 {
|
||||
datas[inout] = append(datas[inout], node)
|
||||
} else if !relatedToStorage && len(datasRelatedToData[dataID]) == 0 {
|
||||
datas[inout] = append(datas[inout], node)
|
||||
}
|
||||
} else {
|
||||
datas[inout] = append(datas[inout], node)
|
||||
}
|
||||
}
|
||||
}
|
||||
return datas, datasRelatedToData
|
||||
}
|
||||
|
||||
func (w *AbstractWorkflow) getProcessingsByRelatedProcessing() (list_computings []graph.GraphItem) {
|
||||
for _, item := range w.Graph.Items {
|
||||
if item.Processing != nil {
|
||||
list_computings = append(list_computings, item)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// tool function to check if a link is a link between a datacenter and a resource
|
||||
func (w *AbstractWorkflow) isDCLink(link graph.GraphLink) (bool, string) {
|
||||
if w.Graph == nil || w.Graph.Items == nil {
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user