54 lines
1.0 KiB
Go
54 lines
1.0 KiB
Go
package workspace
|
|
|
|
import (
|
|
"encoding/json"
|
|
|
|
"cloud.o-forge.io/core/oc-lib/models/resources"
|
|
"cloud.o-forge.io/core/oc-lib/models/utils"
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
type Workspace struct {
|
|
utils.AbstractObject
|
|
resources.ResourceSet
|
|
IsContextual bool `json:"is_contextual" bson:"is_contextual" default:"false"`
|
|
Active bool `json:"active" bson:"active" default:"false"`
|
|
}
|
|
|
|
func (ao *Workspace) GetID() string {
|
|
return ao.UUID
|
|
}
|
|
|
|
func (r *Workspace) GenerateID() {
|
|
r.UUID = uuid.New().String()
|
|
}
|
|
|
|
func (d *Workspace) GetName() string {
|
|
return d.Name
|
|
}
|
|
|
|
func (d *Workspace) GetAccessor() utils.Accessor {
|
|
data := New()
|
|
data.SetLogger(utils.WORKSPACE)
|
|
return data
|
|
}
|
|
|
|
func (dma *Workspace) Deserialize(j map[string]interface{}) utils.DBObject {
|
|
b, err := json.Marshal(j)
|
|
if err != nil {
|
|
return nil
|
|
}
|
|
json.Unmarshal(b, dma)
|
|
return dma
|
|
}
|
|
|
|
func (dma *Workspace) Serialize() map[string]interface{} {
|
|
var m map[string]interface{}
|
|
b, err := json.Marshal(dma)
|
|
if err != nil {
|
|
return nil
|
|
}
|
|
json.Unmarshal(b, &m)
|
|
return m
|
|
}
|