52 lines
925 B
Go
52 lines
925 B
Go
|
package workspace
|
||
|
|
||
|
import (
|
||
|
"encoding/json"
|
||
|
|
||
|
"cloud.o-forge.io/core/oc-lib/models/utils"
|
||
|
"github.com/google/uuid"
|
||
|
)
|
||
|
|
||
|
type Workspace struct {
|
||
|
utils.AbstractObject
|
||
|
utils.ResourceSet
|
||
|
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 := &WorkspaceMongoAccessor{}
|
||
|
data.SetLogger(utils.WORKFLOW)
|
||
|
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
|
||
|
}
|