correct workflow problem
This commit is contained in:
parent
a53e3c987d
commit
2e8246fb2f
@ -21,6 +21,9 @@ type AbstractWorkflow struct {
|
||||
}
|
||||
|
||||
func (w *AbstractWorkflow) isDCLink(link graph.GraphLink) (bool, string) {
|
||||
if w.Graph == nil || w.Graph.Items == nil {
|
||||
return false, ""
|
||||
}
|
||||
if d, ok := w.Graph.Items[link.Source.ID]; ok && d.Datacenter != nil {
|
||||
return true, d.Datacenter.UUID
|
||||
}
|
||||
|
@ -82,7 +82,11 @@ func (wfa *workflowMongoAccessor) DeleteOne(id string) (utils.DBObject, int, err
|
||||
wfa.execution(id, &Workflow{
|
||||
AbstractWorkflow: AbstractWorkflow{ScheduleActive: false},
|
||||
}, true)
|
||||
return wfa.GenericDeleteOne(id, wfa)
|
||||
res, code, err := wfa.GenericDeleteOne(id, wfa)
|
||||
if res != nil && code == 200 {
|
||||
wfa.execute(res.(*Workflow), false)
|
||||
}
|
||||
return res, code, err
|
||||
}
|
||||
|
||||
func (wfa *workflowMongoAccessor) book(id string, realData *Workflow, execs []*workflow_execution.WorkflowExecution) error {
|
||||
@ -157,6 +161,7 @@ func (wfa *workflowMongoAccessor) execution(id string, realData *Workflow, delet
|
||||
"workflow_id": id,
|
||||
"state": 1,
|
||||
}, utils.WORKFLOW_EXECUTION.String())
|
||||
wfa.book(id, realData, []*workflow_execution.WorkflowExecution{})
|
||||
nats.SetNATSPub(utils.WORKFLOW.String(), tools.REMOVE, realData)
|
||||
}
|
||||
if len(execs) > 0 {
|
||||
@ -194,7 +199,7 @@ func (wfa *workflowMongoAccessor) UpdateOne(set utils.DBObject, id string) (util
|
||||
return nil, code, err
|
||||
}
|
||||
}
|
||||
wfa.execute(res.(*Workflow))
|
||||
wfa.execute(res.(*Workflow), false)
|
||||
return res, code, err
|
||||
}
|
||||
|
||||
@ -212,7 +217,7 @@ func (wfa *workflowMongoAccessor) StoreOne(data utils.DBObject) (utils.DBObject,
|
||||
if code, err := wfa.execution(res.GetID(), res.(*Workflow), false); err != nil {
|
||||
return nil, code, err
|
||||
}
|
||||
wfa.execute(res.(*Workflow))
|
||||
wfa.execute(res.(*Workflow), false)
|
||||
return res, code, err
|
||||
}
|
||||
|
||||
@ -220,7 +225,8 @@ func (wfa *workflowMongoAccessor) CopyOne(data utils.DBObject) (utils.DBObject,
|
||||
return wfa.GenericStoreOne(data, wfa)
|
||||
}
|
||||
|
||||
func (wfa *workflowMongoAccessor) execute(workflow *Workflow) {
|
||||
func (wfa *workflowMongoAccessor) execute(workflow *Workflow, delete bool) {
|
||||
|
||||
accessor := (&workspace.Workspace{}).GetAccessor(nil)
|
||||
filters := &dbs.Filters{
|
||||
Or: map[string][]dbs.Filter{
|
||||
@ -228,6 +234,12 @@ func (wfa *workflowMongoAccessor) execute(workflow *Workflow) {
|
||||
},
|
||||
}
|
||||
resource, _, err := accessor.Search(filters, "")
|
||||
if delete {
|
||||
for _, r := range resource {
|
||||
accessor.DeleteOne(r.GetID())
|
||||
}
|
||||
return
|
||||
}
|
||||
if err == nil && len(resource) > 0 {
|
||||
accessor.UpdateOne(&workspace.Workspace{
|
||||
Active: true,
|
||||
@ -262,7 +274,7 @@ func (wfa *workflowMongoAccessor) LoadOne(id string) (utils.DBObject, int, error
|
||||
return nil, code, err
|
||||
}
|
||||
res_mongo.Decode(&workflow)
|
||||
wfa.execute(&workflow)
|
||||
wfa.execute(&workflow, false)
|
||||
|
||||
return &workflow, 200, nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user