From 2f44ad0effcbb407c1f03985e3e71413bacbe708 Mon Sep 17 00:00:00 2001 From: mr Date: Wed, 28 Aug 2024 16:43:53 +0200 Subject: [PATCH] correct workflow problem --- models/workflow/workflow_mongo_accessor.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/models/workflow/workflow_mongo_accessor.go b/models/workflow/workflow_mongo_accessor.go index eaa3f1f..0d46fd7 100644 --- a/models/workflow/workflow_mongo_accessor.go +++ b/models/workflow/workflow_mongo_accessor.go @@ -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 }