Get on Workspace auto load full data
This commit is contained in:
parent
d5c5b454f4
commit
6c83e54d37
@ -55,10 +55,6 @@ func LoadAll(collection LibDataEnum) LibDataShallow {
|
|||||||
return LibDataShallow{Data: d, Code: code}
|
return LibDataShallow{Data: d, Code: code}
|
||||||
}
|
}
|
||||||
|
|
||||||
func Model(t int) utils.DBObject {
|
|
||||||
return models.Model(t)
|
|
||||||
}
|
|
||||||
|
|
||||||
func LoadOne(collection LibDataEnum, id string) LibData {
|
func LoadOne(collection LibDataEnum, id string) LibData {
|
||||||
d, code, err := models.Model(collection.EnumIndex()).GetAccessor().LoadOne(id)
|
d, code, err := models.Model(collection.EnumIndex()).GetAccessor().LoadOne(id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -3,12 +3,11 @@ package data
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
resources "cloud.o-forge.io/core/oc-lib/models/resources"
|
|
||||||
"cloud.o-forge.io/core/oc-lib/models/utils"
|
"cloud.o-forge.io/core/oc-lib/models/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
type DataResource struct {
|
type DataResource struct {
|
||||||
resources.AbstractResource
|
utils.AbstractResource
|
||||||
Protocols []string `json:"protocol,omitempty" bson:"protocol,omitempty"` //TODO Enum type
|
Protocols []string `json:"protocol,omitempty" bson:"protocol,omitempty"` //TODO Enum type
|
||||||
DataType string `json:"datatype,omitempty" bson:"datatype,omitempty"`
|
DataType string `json:"datatype,omitempty" bson:"datatype,omitempty"`
|
||||||
Example string `json:"example,omitempty" bson:"example,omitempty" description:"base64 encoded data"`
|
Example string `json:"example,omitempty" bson:"example,omitempty" description:"base64 encoded data"`
|
||||||
|
@ -3,7 +3,6 @@ package data
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
resources "cloud.o-forge.io/core/oc-lib/models/resources"
|
|
||||||
"cloud.o-forge.io/core/oc-lib/models/utils"
|
"cloud.o-forge.io/core/oc-lib/models/utils"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
@ -11,7 +10,7 @@ import (
|
|||||||
|
|
||||||
func TestStoreOneData(t *testing.T) {
|
func TestStoreOneData(t *testing.T) {
|
||||||
d := DataResource{DataType: "jpeg", Example: "123456",
|
d := DataResource{DataType: "jpeg", Example: "123456",
|
||||||
AbstractResource: resources.AbstractResource{
|
AbstractResource: utils.AbstractResource{
|
||||||
AbstractObject: utils.AbstractObject{Name: "testData"},
|
AbstractObject: utils.AbstractObject{Name: "testData"},
|
||||||
Description: "Lorem Ipsum",
|
Description: "Lorem Ipsum",
|
||||||
Logo: "azerty.com",
|
Logo: "azerty.com",
|
||||||
@ -29,7 +28,7 @@ func TestStoreOneData(t *testing.T) {
|
|||||||
|
|
||||||
func TestLoadOneDate(t *testing.T) {
|
func TestLoadOneDate(t *testing.T) {
|
||||||
d := DataResource{DataType: "jpeg", Example: "123456",
|
d := DataResource{DataType: "jpeg", Example: "123456",
|
||||||
AbstractResource: resources.AbstractResource{
|
AbstractResource: utils.AbstractResource{
|
||||||
AbstractObject: utils.AbstractObject{Name: "testData"},
|
AbstractObject: utils.AbstractObject{Name: "testData"},
|
||||||
Description: "Lorem Ipsum",
|
Description: "Lorem Ipsum",
|
||||||
Logo: "azerty.com",
|
Logo: "azerty.com",
|
||||||
|
@ -3,12 +3,11 @@ package datacenter
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
resources "cloud.o-forge.io/core/oc-lib/models/resources"
|
|
||||||
"cloud.o-forge.io/core/oc-lib/models/utils"
|
"cloud.o-forge.io/core/oc-lib/models/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
type DatacenterResource struct {
|
type DatacenterResource struct {
|
||||||
resources.AbstractResource
|
utils.AbstractResource
|
||||||
BookingPrice int `bson:"booking_price,omitempty" json:"booking_price,omitempty"`
|
BookingPrice int `bson:"booking_price,omitempty" json:"booking_price,omitempty"`
|
||||||
|
|
||||||
CPU *DatacenterCpuModel `bson:"cpu,omitempty" json:"cpu,omitempty"`
|
CPU *DatacenterCpuModel `bson:"cpu,omitempty" json:"cpu,omitempty"`
|
||||||
|
@ -3,7 +3,6 @@ package datacenter
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
resources "cloud.o-forge.io/core/oc-lib/models/resources"
|
|
||||||
"cloud.o-forge.io/core/oc-lib/models/utils"
|
"cloud.o-forge.io/core/oc-lib/models/utils"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
@ -11,7 +10,7 @@ import (
|
|||||||
|
|
||||||
func TestStoreOneDatacenter(t *testing.T) {
|
func TestStoreOneDatacenter(t *testing.T) {
|
||||||
dc := DatacenterResource{BookingPrice: 123,
|
dc := DatacenterResource{BookingPrice: 123,
|
||||||
AbstractResource: resources.AbstractResource{
|
AbstractResource: utils.AbstractResource{
|
||||||
AbstractObject: utils.AbstractObject{Name: "testDatacenter"},
|
AbstractObject: utils.AbstractObject{Name: "testDatacenter"},
|
||||||
Description: "Lorem Ipsum",
|
Description: "Lorem Ipsum",
|
||||||
Logo: "azerty.com",
|
Logo: "azerty.com",
|
||||||
@ -29,7 +28,7 @@ func TestStoreOneDatacenter(t *testing.T) {
|
|||||||
|
|
||||||
func TestLoadOneDatacenter(t *testing.T) {
|
func TestLoadOneDatacenter(t *testing.T) {
|
||||||
dc := DatacenterResource{BookingPrice: 123,
|
dc := DatacenterResource{BookingPrice: 123,
|
||||||
AbstractResource: resources.AbstractResource{
|
AbstractResource: utils.AbstractResource{
|
||||||
AbstractObject: utils.AbstractObject{Name: "testDatacenter"},
|
AbstractObject: utils.AbstractObject{Name: "testDatacenter"},
|
||||||
Description: "Lorem Ipsum",
|
Description: "Lorem Ipsum",
|
||||||
Logo: "azerty.com",
|
Logo: "azerty.com",
|
||||||
|
@ -3,12 +3,11 @@ package processing
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
resources "cloud.o-forge.io/core/oc-lib/models/resources"
|
|
||||||
"cloud.o-forge.io/core/oc-lib/models/utils"
|
"cloud.o-forge.io/core/oc-lib/models/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ProcessingResource struct {
|
type ProcessingResource struct {
|
||||||
resources.AbstractResource
|
utils.AbstractResource
|
||||||
CPUs uint `bson:"cp_us,omitempty" json:"cp_us,omitempty"`
|
CPUs uint `bson:"cp_us,omitempty" json:"cp_us,omitempty"`
|
||||||
GPUs uint `bson:"gp_us,omitempty" json:"gp_us,omitempty"`
|
GPUs uint `bson:"gp_us,omitempty" json:"gp_us,omitempty"`
|
||||||
RAM uint `bson:"ram,omitempty" json:"ram,omitempty"`
|
RAM uint `bson:"ram,omitempty" json:"ram,omitempty"`
|
||||||
|
@ -1,7 +1,11 @@
|
|||||||
package resources
|
package resources
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"cloud.o-forge.io/core/oc-lib/models/utils"
|
"cloud.o-forge.io/core/oc-lib/models/resources/data"
|
||||||
|
"cloud.o-forge.io/core/oc-lib/models/resources/datacenter"
|
||||||
|
"cloud.o-forge.io/core/oc-lib/models/resources/processing"
|
||||||
|
"cloud.o-forge.io/core/oc-lib/models/resources/storage"
|
||||||
|
w "cloud.o-forge.io/core/oc-lib/models/resources/workflow"
|
||||||
)
|
)
|
||||||
|
|
||||||
// AbstractResource is the struct containing all of the attributes commons to all ressources
|
// AbstractResource is the struct containing all of the attributes commons to all ressources
|
||||||
@ -9,21 +13,16 @@ import (
|
|||||||
// Resource is the interface to be implemented by all classes inheriting from Resource to have the same behavior
|
// Resource is the interface to be implemented by all classes inheriting from Resource to have the same behavior
|
||||||
|
|
||||||
// http://www.inanzzz.com/index.php/post/wqbs/a-basic-usage-of-int-and-string-enum-types-in-golang
|
// http://www.inanzzz.com/index.php/post/wqbs/a-basic-usage-of-int-and-string-enum-types-in-golang
|
||||||
type AbstractResource struct {
|
type ResourceSet struct {
|
||||||
utils.AbstractObject
|
Datas []string `bson:"datas,omitempty" json:"datas,omitempty"`
|
||||||
ShortDescription string `json:"short_description,omitempty" bson:"short_description,omitempty" validate:"required"`
|
Storages []string `bson:"storages,omitempty" json:"storages,omitempty"`
|
||||||
Description string `json:"description,omitempty" bson:"description,omitempty"`
|
Processings []string `bson:"processing,omitempty" json:"processing,omitempty"`
|
||||||
Logo string `json:"logo,omitempty" bson:"logo,omitempty" validate:"required"`
|
Datacenters []string `bson:"datacenters,omitempty" json:"datacenters,omitempty"`
|
||||||
Owner string `json:"owner,omitempty" bson:"owner,omitempty" validate:"required"`
|
Workflows []string `bson:"workflows,omitempty" json:"workflows,omitempty"`
|
||||||
OwnerLogo string `json:"owner_logo,omitempty" bson:"owner_logo,omitempty"`
|
|
||||||
SourceUrl string `json:"source_url,omitempty" bson:"source_url,omitempty" validate:"required"`
|
|
||||||
Proxy *ResourceProxy `json:"proxy,omitempty" bson:"proxy,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type ResourceProxy struct {
|
DataResources []*data.DataResource `bson:"-" json:"data_resources,omitempty"`
|
||||||
Host string `json:"host,omitempty" bson:"host,omitempty"`
|
StorageResources []*storage.StorageResource `bson:"-" json:"storage_resources,omitempty"`
|
||||||
Port int `json:"port,omitempty" bson:"port,omitempty"`
|
ProcessingResources []*processing.ProcessingResource `bson:"-" json:"processing_resources,omitempty"`
|
||||||
Command string `json:"command,omitempty" bson:"command,omitempty"`
|
DatacenterResources []*datacenter.DatacenterResource `bson:"-" json:"datacenter_resources,omitempty"`
|
||||||
Args []string `json:"args,omitempty" bson:"args,omitempty"`
|
WorkflowResources []*w.WorkflowResource `bson:"-" json:"workflow_resources,omitempty"`
|
||||||
EnvArgs map[string]interface{} `json:"env_args,omitempty" bson:"env_args,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ package storage
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
resources "cloud.o-forge.io/core/oc-lib/models/resources"
|
|
||||||
"cloud.o-forge.io/core/oc-lib/models/utils"
|
"cloud.o-forge.io/core/oc-lib/models/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -13,7 +12,7 @@ type URL struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type StorageResource struct {
|
type StorageResource struct {
|
||||||
resources.AbstractResource
|
utils.AbstractResource
|
||||||
|
|
||||||
Capacity uint `bson:"capacity,omitempty" json:"capacity,omitempty"`
|
Capacity uint `bson:"capacity,omitempty" json:"capacity,omitempty"`
|
||||||
Url *URL `bson:"url,omitempty" json:"url,omitempty"` // Will allow to select between several protocols
|
Url *URL `bson:"url,omitempty" json:"url,omitempty"` // Will allow to select between several protocols
|
||||||
|
@ -3,7 +3,6 @@ package storage
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
resources "cloud.o-forge.io/core/oc-lib/models/resources"
|
|
||||||
"cloud.o-forge.io/core/oc-lib/models/utils"
|
"cloud.o-forge.io/core/oc-lib/models/utils"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
@ -11,7 +10,7 @@ import (
|
|||||||
|
|
||||||
func TestStoreOneStorage(t *testing.T) {
|
func TestStoreOneStorage(t *testing.T) {
|
||||||
s := StorageResource{Capacity: 123, Url: &URL{Protocol: "http", Path: "azerty.fr"},
|
s := StorageResource{Capacity: 123, Url: &URL{Protocol: "http", Path: "azerty.fr"},
|
||||||
AbstractResource: resources.AbstractResource{
|
AbstractResource: utils.AbstractResource{
|
||||||
AbstractObject: utils.AbstractObject{Name: "testData"},
|
AbstractObject: utils.AbstractObject{Name: "testData"},
|
||||||
Description: "Lorem Ipsum",
|
Description: "Lorem Ipsum",
|
||||||
Logo: "azerty.com",
|
Logo: "azerty.com",
|
||||||
@ -29,7 +28,7 @@ func TestStoreOneStorage(t *testing.T) {
|
|||||||
|
|
||||||
func TestLoadOneStorage(t *testing.T) {
|
func TestLoadOneStorage(t *testing.T) {
|
||||||
s := StorageResource{Capacity: 123, Url: &URL{Protocol: "http", Path: "azerty.fr"},
|
s := StorageResource{Capacity: 123, Url: &URL{Protocol: "http", Path: "azerty.fr"},
|
||||||
AbstractResource: resources.AbstractResource{
|
AbstractResource: utils.AbstractResource{
|
||||||
AbstractObject: utils.AbstractObject{Name: "testData"},
|
AbstractObject: utils.AbstractObject{Name: "testData"},
|
||||||
Description: "Lorem Ipsum",
|
Description: "Lorem Ipsum",
|
||||||
Logo: "azerty.com",
|
Logo: "azerty.com",
|
||||||
|
@ -2,28 +2,12 @@ package oclib
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"slices"
|
|
||||||
|
|
||||||
"cloud.o-forge.io/core/oc-lib/models/resources"
|
|
||||||
"cloud.o-forge.io/core/oc-lib/models/resources/workflow/graph"
|
|
||||||
"cloud.o-forge.io/core/oc-lib/models/utils"
|
"cloud.o-forge.io/core/oc-lib/models/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
type AbstractWorkflow struct {
|
|
||||||
utils.ResourceSet
|
|
||||||
Graph *graph.Graph `bson:"graph,omitempty" json:"graph,omitempty"`
|
|
||||||
Schedule *WorkflowSchedule `bson:"schedule,omitempty" json:"schedule,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w *AbstractWorkflow) isDCLink(link graph.GraphLink) bool {
|
|
||||||
if slices.Contains(w.Datacenters, link.Destination.ID) || slices.Contains(w.Datacenters, link.Source.ID) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
type WorkflowResource struct {
|
type WorkflowResource struct {
|
||||||
resources.AbstractResource
|
utils.AbstractResource
|
||||||
WorkflowID string `bson:"workflow_id,omitempty" json:"workflow_id,omitempty"`
|
WorkflowID string `bson:"workflow_id,omitempty" json:"workflow_id,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,14 +3,13 @@ package oclib
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"cloud.o-forge.io/core/oc-lib/models/resources"
|
|
||||||
"cloud.o-forge.io/core/oc-lib/models/utils"
|
"cloud.o-forge.io/core/oc-lib/models/utils"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestStoreOneWorkflow(t *testing.T) {
|
func TestStoreOneWorkflow(t *testing.T) {
|
||||||
w := WorkflowResource{AbstractResource: resources.AbstractResource{
|
w := WorkflowResource{AbstractResource: utils.AbstractResource{
|
||||||
AbstractObject: utils.AbstractObject{Name: "testWorkflow"},
|
AbstractObject: utils.AbstractObject{Name: "testWorkflow"},
|
||||||
Description: "Lorem Ipsum",
|
Description: "Lorem Ipsum",
|
||||||
Logo: "azerty.com",
|
Logo: "azerty.com",
|
||||||
@ -27,7 +26,7 @@ func TestStoreOneWorkflow(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestLoadOneWorkflow(t *testing.T) {
|
func TestLoadOneWorkflow(t *testing.T) {
|
||||||
w := WorkflowResource{AbstractResource: resources.AbstractResource{
|
w := WorkflowResource{AbstractResource: utils.AbstractResource{
|
||||||
AbstractObject: utils.AbstractObject{Name: "testWorkflow"},
|
AbstractObject: utils.AbstractObject{Name: "testWorkflow"},
|
||||||
Description: "Lorem Ipsum",
|
Description: "Lorem Ipsum",
|
||||||
Logo: "azerty.com",
|
Logo: "azerty.com",
|
||||||
|
@ -10,14 +10,6 @@ import (
|
|||||||
|
|
||||||
var validate = validator.New(validator.WithRequiredStructEnabled())
|
var validate = validator.New(validator.WithRequiredStructEnabled())
|
||||||
|
|
||||||
type ResourceSet struct {
|
|
||||||
Datas []string `bson:"datas,omitempty" json:"datas,omitempty"`
|
|
||||||
Storages []string `bson:"storages,omitempty" json:"storages,omitempty"`
|
|
||||||
Processings []string `bson:"processing,omitempty" json:"processing,omitempty"`
|
|
||||||
Datacenters []string `bson:"datacenters,omitempty" json:"datacenters,omitempty"`
|
|
||||||
Workflows []string `bson:"workflows,omitempty" json:"workflows,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type AbstractObject struct {
|
type AbstractObject struct {
|
||||||
UUID string `json:"id,omitempty" bson:"id,omitempty" validate:"required"`
|
UUID string `json:"id,omitempty" bson:"id,omitempty" validate:"required"`
|
||||||
Name string `json:"name,omitempty" bson:"name,omitempty" validate:"required"`
|
Name string `json:"name,omitempty" bson:"name,omitempty" validate:"required"`
|
||||||
@ -95,3 +87,21 @@ func (dma *AbstractAccessor) GenericUpdateOne(set DBObject, id string, accessor
|
|||||||
}
|
}
|
||||||
return accessor.LoadOne(id)
|
return accessor.LoadOne(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type AbstractResource struct {
|
||||||
|
AbstractObject
|
||||||
|
ShortDescription string `json:"short_description,omitempty" bson:"short_description,omitempty" validate:"required"`
|
||||||
|
Description string `json:"description,omitempty" bson:"description,omitempty"`
|
||||||
|
Logo string `json:"logo,omitempty" bson:"logo,omitempty" validate:"required"`
|
||||||
|
Owner string `json:"owner,omitempty" bson:"owner,omitempty" validate:"required"`
|
||||||
|
OwnerLogo string `json:"owner_logo,omitempty" bson:"owner_logo,omitempty"`
|
||||||
|
SourceUrl string `json:"source_url,omitempty" bson:"source_url,omitempty" validate:"required"`
|
||||||
|
Proxy *ResourceProxy `json:"proxy,omitempty" bson:"proxy,omitempty"`
|
||||||
|
}
|
||||||
|
type ResourceProxy struct {
|
||||||
|
Host string `json:"host,omitempty" bson:"host,omitempty"`
|
||||||
|
Port int `json:"port,omitempty" bson:"port,omitempty"`
|
||||||
|
Command string `json:"command,omitempty" bson:"command,omitempty"`
|
||||||
|
Args []string `json:"args,omitempty" bson:"args,omitempty"`
|
||||||
|
EnvArgs map[string]interface{} `json:"env_args,omitempty" bson:"env_args,omitempty"`
|
||||||
|
}
|
||||||
|
@ -2,14 +2,29 @@ package oclib
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"slices"
|
||||||
|
|
||||||
w "cloud.o-forge.io/core/oc-lib/models/resources/workflow"
|
"cloud.o-forge.io/core/oc-lib/models/resources"
|
||||||
|
"cloud.o-forge.io/core/oc-lib/models/resources/workflow/graph"
|
||||||
"cloud.o-forge.io/core/oc-lib/models/utils"
|
"cloud.o-forge.io/core/oc-lib/models/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type AbstractWorkflow struct {
|
||||||
|
resources.ResourceSet
|
||||||
|
Graph *graph.Graph `bson:"graph,omitempty" json:"graph,omitempty"`
|
||||||
|
Schedule *WorkflowSchedule `bson:"schedule,omitempty" json:"schedule,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *AbstractWorkflow) isDCLink(link graph.GraphLink) bool {
|
||||||
|
if slices.Contains(w.Datacenters, link.Destination.ID) || slices.Contains(w.Datacenters, link.Source.ID) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
type Workflow struct {
|
type Workflow struct {
|
||||||
utils.AbstractObject
|
utils.AbstractObject
|
||||||
w.AbstractWorkflow
|
AbstractWorkflow
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Workflow) GetName() string {
|
func (d *Workflow) GetName() string {
|
||||||
|
@ -3,13 +3,14 @@ package workspace
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
|
"cloud.o-forge.io/core/oc-lib/models/resources"
|
||||||
"cloud.o-forge.io/core/oc-lib/models/utils"
|
"cloud.o-forge.io/core/oc-lib/models/utils"
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Workspace struct {
|
type Workspace struct {
|
||||||
utils.AbstractObject
|
utils.AbstractObject
|
||||||
utils.ResourceSet
|
resources.ResourceSet
|
||||||
Active bool `json:"active" bson:"active" default:"false"`
|
Active bool `json:"active" bson:"active" default:"false"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,11 @@ package workspace
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"cloud.o-forge.io/core/oc-lib/dbs/mongo"
|
"cloud.o-forge.io/core/oc-lib/dbs/mongo"
|
||||||
|
"cloud.o-forge.io/core/oc-lib/models/resources/data"
|
||||||
|
"cloud.o-forge.io/core/oc-lib/models/resources/datacenter"
|
||||||
|
"cloud.o-forge.io/core/oc-lib/models/resources/processing"
|
||||||
|
"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"
|
"cloud.o-forge.io/core/oc-lib/models/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -14,11 +19,23 @@ func (wfa *WorkspaceMongoAccessor) DeleteOne(id string) (utils.DBObject, int, er
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (wfa *WorkspaceMongoAccessor) UpdateOne(set utils.DBObject, id string) (utils.DBObject, int, error) {
|
func (wfa *WorkspaceMongoAccessor) UpdateOne(set utils.DBObject, id string) (utils.DBObject, int, error) {
|
||||||
|
d := set.(*Workspace)
|
||||||
|
d.DataResources = nil
|
||||||
|
d.DatacenterResources = nil
|
||||||
|
d.StorageResources = nil
|
||||||
|
d.ProcessingResources = nil
|
||||||
|
d.WorkflowResources = nil
|
||||||
return wfa.GenericUpdateOne(set, id, wfa, &Workspace{})
|
return wfa.GenericUpdateOne(set, id, wfa, &Workspace{})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (wfa *WorkspaceMongoAccessor) StoreOne(data utils.DBObject) (utils.DBObject, int, error) {
|
func (wfa *WorkspaceMongoAccessor) StoreOne(data utils.DBObject) (utils.DBObject, int, error) {
|
||||||
return wfa.GenericStoreOne(data, wfa)
|
d := data.(*Workspace)
|
||||||
|
d.DataResources = nil
|
||||||
|
d.DatacenterResources = nil
|
||||||
|
d.StorageResources = nil
|
||||||
|
d.ProcessingResources = nil
|
||||||
|
d.WorkflowResources = nil
|
||||||
|
return wfa.GenericStoreOne(d, wfa)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (wfa *WorkspaceMongoAccessor) CopyOne(data utils.DBObject) (utils.DBObject, int, error) {
|
func (wfa *WorkspaceMongoAccessor) CopyOne(data utils.DBObject) (utils.DBObject, int, error) {
|
||||||
@ -38,6 +55,51 @@ func (wfa *WorkspaceMongoAccessor) LoadOne(id string) (utils.DBObject, int, erro
|
|||||||
obj = &Workspace{Active: true}
|
obj = &Workspace{Active: true}
|
||||||
wfa.UpdateOne(obj, id)
|
wfa.UpdateOne(obj, id)
|
||||||
|
|
||||||
|
if workflow.Datas != nil && len(workflow.Datas) > 0 {
|
||||||
|
dataAccessor := &data.DataMongoAccessor{}
|
||||||
|
for _, id := range workflow.Datas {
|
||||||
|
d, _, e := dataAccessor.LoadOne(id)
|
||||||
|
if e == nil {
|
||||||
|
workflow.DataResources = append(workflow.DataResources, d.(*data.DataResource))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if workflow.Datacenters != nil && len(workflow.Datacenters) > 0 {
|
||||||
|
dataAccessor := &datacenter.DatacenterMongoAccessor{}
|
||||||
|
for _, id := range workflow.Datacenters {
|
||||||
|
d, _, e := dataAccessor.LoadOne(id)
|
||||||
|
if e == nil {
|
||||||
|
workflow.DatacenterResources = append(workflow.DatacenterResources, d.(*datacenter.DatacenterResource))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if workflow.Storages != nil && len(workflow.Storages) > 0 {
|
||||||
|
dataAccessor := &storage.StorageMongoAccessor{}
|
||||||
|
for _, id := range workflow.Storages {
|
||||||
|
d, _, e := dataAccessor.LoadOne(id)
|
||||||
|
if e == nil {
|
||||||
|
workflow.StorageResources = append(workflow.StorageResources, d.(*storage.StorageResource))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if workflow.Processings != nil && len(workflow.Processings) > 0 {
|
||||||
|
dataAccessor := &processing.ProcessingMongoAccessor{}
|
||||||
|
for _, id := range workflow.Processings {
|
||||||
|
d, _, e := dataAccessor.LoadOne(id)
|
||||||
|
if e == nil {
|
||||||
|
workflow.ProcessingResources = append(workflow.ProcessingResources, d.(*processing.ProcessingResource))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if workflow.Workflows != nil && len(workflow.Workflows) > 0 {
|
||||||
|
dataAccessor := &w.WorkflowResourceMongoAccessor{}
|
||||||
|
for _, id := range workflow.Workflows {
|
||||||
|
d, _, e := dataAccessor.LoadOne(id)
|
||||||
|
if e == nil {
|
||||||
|
workflow.WorkflowResources = append(workflow.WorkflowResources, d.(*w.WorkflowResource))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return &workflow, 200, nil
|
return &workflow, 200, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user