activation workspace

This commit is contained in:
mr 2024-07-31 11:29:21 +02:00
parent e311553eb1
commit 4f27aefc4b

View File

@ -134,20 +134,20 @@ func (wfa *workflowMongoAccessor) LoadOne(id string) (utils.DBObject, int, error
// add to workspace
accessor := (&workspace.Workspace{}).GetAccessor()
resource, _, err := accessor.Search(workflow.Name+"_workspace", "abstractobject.name")
if err == nil && len(resource) > 0 {
for _, r := range resource {
accessor.UpdateOne(&workspace.Workspace{
ResourceSet: resources.ResourceSet{
Datas: workflow.Datas,
Processings: workflow.Processings,
Storages: workflow.Storages,
Workflows: workflow.Workflows,
Datacenters: workflow.Datacenters,
},
}, r.GetID())
}
if err == nil && len(resource) == 1 {
accessor.UpdateOne(&workspace.Workspace{
Active: true,
ResourceSet: resources.ResourceSet{
Datas: workflow.Datas,
Processings: workflow.Processings,
Storages: workflow.Storages,
Workflows: workflow.Workflows,
Datacenters: workflow.Datacenters,
},
}, resource[0].GetID())
} else {
accessor.StoreOne(&workspace.Workspace{
Active: true,
AbstractObject: utils.AbstractObject{Name: workflow.Name + "_workspace"},
ResourceSet: resources.ResourceSet{
Datas: workflow.Datas,