correct workflow problem

This commit is contained in:
mr 2024-08-28 16:43:53 +02:00
parent 14d6a5f11c
commit 2f44ad0eff

View File

@ -178,7 +178,13 @@ func (wfa *workflowMongoAccessor) UpdateOne(set utils.DBObject, id string) (util
if code != 200 {
return nil, 409, err
}
new := set.(*Workflow)
avoid := set.(*Workflow).Schedule == nil || (res.(*Workflow).Schedule != nil && res.(*Workflow).ScheduleActive == set.(*Workflow).ScheduleActive && res.(*Workflow).Schedule.Start == set.(*Workflow).Schedule.Start && res.(*Workflow).Schedule.End == set.(*Workflow).Schedule.End && res.(*Workflow).Schedule.Cron == set.(*Workflow).Schedule.Cron)
for _, i := range new.Graph.Items {
if i.Datacenter == nil && i.Processing == nil && i.Storage == nil && i.Workflow == nil && i.Data == nil {
return nil, 422, errors.New("graph item should have at least one resource data is corrupted")
}
}
res, code, err = wfa.GenericUpdateOne(set, id, wfa, &Workflow{})
if code != 200 {
return nil, code, err
@ -193,6 +199,12 @@ func (wfa *workflowMongoAccessor) UpdateOne(set utils.DBObject, id string) (util
}
func (wfa *workflowMongoAccessor) StoreOne(data utils.DBObject) (utils.DBObject, int, error) {
new := data.(*Workflow)
for _, i := range new.Graph.Items {
if i.Datacenter == nil && i.Processing == nil && i.Storage == nil && i.Workflow == nil && i.Data == nil {
return nil, 422, errors.New("graph item should have at least one resource data is corrupted")
}
}
res, code, err := wfa.GenericStoreOne(data, wfa)
if err != nil {
return nil, code, err
@ -251,6 +263,7 @@ func (wfa *workflowMongoAccessor) LoadOne(id string) (utils.DBObject, int, error
}
res_mongo.Decode(&workflow)
wfa.execute(&workflow)
return &workflow, 200, nil
}