package models import ( "cloud.o-forge.io/core/oc-lib/logs" r "cloud.o-forge.io/core/oc-lib/models/resources" 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" "cloud.o-forge.io/core/oc-lib/models/utils" w "cloud.o-forge.io/core/oc-lib/models/workflow" ) var models = map[string]func() utils.DBObject{ w.WORKFLOW: func() utils.DBObject { return &w.Workflow{} }, r.DATA.String(): func() utils.DBObject { return &d.Data{} }, r.DATACENTER.String(): func() utils.DBObject { return &dc.Datacenter{} }, r.STORAGE.String(): func() utils.DBObject { return &s.Storage{} }, r.PROCESSING.String(): func() utils.DBObject { return &p.Processing{} }, } func Model(model int) utils.DBObject { log := logs.CreateLogger("oclib", "") if _, ok := models[r.FromInt(model)]; ok { return models[r.FromInt(model)]() } log.Error().Msg("Can't find model " + r.FromInt(model) + ".") return nil } func GetModelsNames() []string { names := []string{} for name := range models { names = append(names, name) } return names }