44 lines
1.7 KiB
Go
44 lines
1.7 KiB
Go
package models
|
|
|
|
import (
|
|
"cloud.o-forge.io/core/oc-lib/logs"
|
|
|
|
d "cloud.o-forge.io/core/oc-lib/models/resources/data"
|
|
dc "cloud.o-forge.io/core/oc-lib/models/resources/datacenter"
|
|
p "cloud.o-forge.io/core/oc-lib/models/resources/processing"
|
|
s "cloud.o-forge.io/core/oc-lib/models/resources/storage"
|
|
w "cloud.o-forge.io/core/oc-lib/models/resources/workflow"
|
|
"cloud.o-forge.io/core/oc-lib/models/utils"
|
|
w2 "cloud.o-forge.io/core/oc-lib/models/workflow"
|
|
"cloud.o-forge.io/core/oc-lib/models/workflow_execution"
|
|
w3 "cloud.o-forge.io/core/oc-lib/models/workspace"
|
|
)
|
|
|
|
var models = map[string]func() utils.DBObject{
|
|
utils.WORKFLOW_RESOURCE.String(): func() utils.DBObject { return &w.WorkflowResource{} },
|
|
utils.DATA_RESOURCE.String(): func() utils.DBObject { return &d.DataResource{} },
|
|
utils.DATACENTER_RESOURCE.String(): func() utils.DBObject { return &dc.DatacenterResource{} },
|
|
utils.STORAGE_RESOURCE.String(): func() utils.DBObject { return &s.StorageResource{} },
|
|
utils.PROCESSING_RESOURCE.String(): func() utils.DBObject { return &p.ProcessingResource{} },
|
|
utils.WORKFLOW.String(): func() utils.DBObject { return &w2.Workflow{} },
|
|
utils.WORKFLOW_EXECUTION.String(): func() utils.DBObject { return &workflow_execution.WorkflowExecution{} },
|
|
utils.WORKSPACE.String(): func() utils.DBObject { return &w3.Workspace{} },
|
|
}
|
|
|
|
func Model(model int) utils.DBObject {
|
|
log := logs.GetLogger()
|
|
if _, ok := models[utils.FromInt(model)]; ok {
|
|
return models[utils.FromInt(model)]()
|
|
}
|
|
log.Error().Msg("Can't find model " + utils.FromInt(model) + ".")
|
|
return nil
|
|
}
|
|
|
|
func GetModelsNames() []string {
|
|
names := []string{}
|
|
for name := range models {
|
|
names = append(names, name)
|
|
}
|
|
return names
|
|
}
|