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 // add to workspace
accessor := (&workspace.Workspace{}).GetAccessor() accessor := (&workspace.Workspace{}).GetAccessor()
resource, _, err := accessor.Search(workflow.Name+"_workspace", "abstractobject.name") resource, _, err := accessor.Search(workflow.Name+"_workspace", "abstractobject.name")
if err == nil && len(resource) > 0 { if err == nil && len(resource) == 1 {
for _, r := range resource { accessor.UpdateOne(&workspace.Workspace{
accessor.UpdateOne(&workspace.Workspace{ Active: true,
ResourceSet: resources.ResourceSet{ ResourceSet: resources.ResourceSet{
Datas: workflow.Datas, Datas: workflow.Datas,
Processings: workflow.Processings, Processings: workflow.Processings,
Storages: workflow.Storages, Storages: workflow.Storages,
Workflows: workflow.Workflows, Workflows: workflow.Workflows,
Datacenters: workflow.Datacenters, Datacenters: workflow.Datacenters,
}, },
}, r.GetID()) }, resource[0].GetID())
}
} else { } else {
accessor.StoreOne(&workspace.Workspace{ accessor.StoreOne(&workspace.Workspace{
Active: true,
AbstractObject: utils.AbstractObject{Name: workflow.Name + "_workspace"}, AbstractObject: utils.AbstractObject{Name: workflow.Name + "_workspace"},
ResourceSet: resources.ResourceSet{ ResourceSet: resources.ResourceSet{
Datas: workflow.Datas, Datas: workflow.Datas,