added a method to workflow which allows to retrieve items by resource type and resource id
This commit is contained in:
parent
e735f78e58
commit
76d83878eb
@ -227,6 +227,27 @@ func (wf *Workflow) Planify(start time.Time, end *time.Time, request *tools.APIR
|
|||||||
return longest, priceds, wf, nil
|
return longest, priceds, wf, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (w *Workflow) GetItemsByResources() (res map[tools.DataType]map[string][]string) {
|
||||||
|
dtMethodMap := map[tools.DataType]func() []graph.GraphItem{
|
||||||
|
tools.STORAGE_RESOURCE: func() []graph.GraphItem { return w.GetGraphItems(w.Graph.IsStorage) },
|
||||||
|
tools.DATA_RESOURCE: func() []graph.GraphItem { return w.GetGraphItems(w.Graph.IsData) },
|
||||||
|
tools.COMPUTE_RESOURCE: func() []graph.GraphItem { return w.GetGraphItems(w.Graph.IsCompute) },
|
||||||
|
tools.PROCESSING_RESOURCE: func() []graph.GraphItem { return w.GetGraphItems(w.Graph.IsProcessing) },
|
||||||
|
tools.WORKFLOW_RESOURCE: func() []graph.GraphItem { return w.GetGraphItems(w.Graph.IsWorkflow) },
|
||||||
|
}
|
||||||
|
|
||||||
|
for dt, meth := range dtMethodMap {
|
||||||
|
items := meth()
|
||||||
|
for _, i := range items {
|
||||||
|
_, r := i.GetResource()
|
||||||
|
rId := r.GetID()
|
||||||
|
res[dt][rId] = append(res[dt][rId],i.ID)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func plan[T resources.ResourceInterface](
|
func plan[T resources.ResourceInterface](
|
||||||
dt tools.DataType, wf *Workflow, priceds map[tools.DataType]map[string]pricing.PricedItemITF, request *tools.APIRequest,
|
dt tools.DataType, wf *Workflow, priceds map[tools.DataType]map[string]pricing.PricedItemITF, request *tools.APIRequest,
|
||||||
f func(graph.GraphItem) bool, start func(resources.ResourceInterface, pricing.PricedItemITF) (time.Time, float64), end func(time.Time, float64) *time.Time) ([]T, map[tools.DataType]map[string]pricing.PricedItemITF, error) {
|
f func(graph.GraphItem) bool, start func(resources.ResourceInterface, pricing.PricedItemITF) (time.Time, float64), end func(time.Time, float64) *time.Time) ([]T, map[tools.DataType]map[string]pricing.PricedItemITF, error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user