resource are lightest enough

This commit is contained in:
mr
2024-10-10 08:55:22 +02:00
parent 84024a143e
commit 17749c6c0b
2 changed files with 22 additions and 68 deletions

View File

@@ -35,73 +35,6 @@ func (w *AbstractWorkflow) GetWorkflows() (list_computings []graph.GraphItem) {
return
}
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) GetProcessings() (list_computings []graph.GraphItem) {
for _, item := range w.Graph.Items {
if item.Processing != nil {