add history
This commit is contained in:
@@ -50,7 +50,7 @@ func (d *CollaborativeArea) GetName() string {
|
||||
|
||||
func (d *CollaborativeArea) GetAccessor(caller *tools.HTTPCaller) utils.Accessor {
|
||||
data := New() // Create a new instance of the accessor
|
||||
data.Init(utils.COLLABORATIVE_AREA, caller) // Initialize the accessor with the SHARED_WORKSPACE model type
|
||||
data.Init(tools.COLLABORATIVE_AREA, caller) // Initialize the accessor with the SHARED_WORKSPACE model type
|
||||
return data
|
||||
}
|
||||
|
||||
|
@@ -32,7 +32,7 @@ func (d *Rule) GetName() string {
|
||||
|
||||
func (d *Rule) GetAccessor(caller *tools.HTTPCaller) utils.Accessor {
|
||||
data := New()
|
||||
data.Init(utils.RULE, caller)
|
||||
data.Init(tools.RULE, caller)
|
||||
return data
|
||||
}
|
||||
|
||||
|
@@ -37,7 +37,7 @@ func (d *ShallowCollaborativeArea) GetName() string {
|
||||
|
||||
func (d *ShallowCollaborativeArea) GetAccessor(caller *tools.HTTPCaller) utils.Accessor {
|
||||
data := New()
|
||||
data.Init(utils.COLLABORATIVE_AREA, caller)
|
||||
data.Init(tools.COLLABORATIVE_AREA, caller)
|
||||
return data
|
||||
}
|
||||
|
||||
|
@@ -34,7 +34,7 @@ func (d *Workspace) GetName() string {
|
||||
|
||||
func (d *Workspace) GetAccessor(caller *tools.HTTPCaller) utils.Accessor {
|
||||
data := New() // Create a new instance of the accessor
|
||||
data.Init(utils.WORKSPACE, caller) // Initialize the accessor with the WORKSPACE model type
|
||||
data.Init(tools.WORKSPACE, caller) // Initialize the accessor with the WORKSPACE model type
|
||||
return data
|
||||
}
|
||||
|
||||
|
34
models/workspace/workspace_history_mongo_accessor.go
Normal file
34
models/workspace/workspace_history_mongo_accessor.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package workspace
|
||||
|
||||
import (
|
||||
"cloud.o-forge.io/core/oc-lib/models/utils"
|
||||
"cloud.o-forge.io/core/oc-lib/tools"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
type WorkspaceHistory struct{ Workspace }
|
||||
|
||||
func (d *WorkspaceHistory) GetAccessor(caller *tools.HTTPCaller) utils.Accessor {
|
||||
data := New() // Create a new instance of the accessor
|
||||
data.Init(tools.WORKSPACE_HISTORY, caller) // Initialize the accessor with the WORKSPACE model type
|
||||
return data
|
||||
}
|
||||
func (r *WorkspaceHistory) GenerateID() {
|
||||
r.UUID = uuid.New().String()
|
||||
}
|
||||
|
||||
// Workspace is a struct that represents a workspace
|
||||
type workspaceHistoryMongoAccessor struct {
|
||||
workspaceMongoAccessor // AbstractAccessor contains the basic fields of an accessor (model, caller)
|
||||
}
|
||||
|
||||
// New creates a new instance of the workspaceMongoAccessor
|
||||
func NewHistory() *workspaceHistoryMongoAccessor {
|
||||
return &workspaceHistoryMongoAccessor{}
|
||||
}
|
||||
|
||||
func (r *workspaceHistoryMongoAccessor) MapFromWorkspace(w *Workspace) *WorkspaceHistory {
|
||||
wh := &WorkspaceHistory{Workspace: *w}
|
||||
wh.GenerateID()
|
||||
return wh
|
||||
}
|
@@ -221,6 +221,8 @@ func (wfa *workspaceMongoAccessor) share(realData *Workspace, delete bool, calle
|
||||
continue
|
||||
}
|
||||
if delete { // If the workspace is deleted, share the deletion
|
||||
history := NewHistory()
|
||||
history.StoreOne(history.MapFromWorkspace(res.(*Workspace)))
|
||||
_, err = paccess.LaunchPeerExecution(p, res.GetID(), tools.WORKSPACE, tools.DELETE, map[string]interface{}{}, caller)
|
||||
} else { // If the workspace is updated, share the update
|
||||
_, err = paccess.LaunchPeerExecution(p, res.GetID(), tools.WORKSPACE, tools.PUT, res.Serialize(), caller)
|
||||
|
Reference in New Issue
Block a user