2024-07-18 11:51:12 +02:00
|
|
|
package oclib
|
|
|
|
|
|
|
|
import (
|
2024-07-18 14:39:54 +02:00
|
|
|
"encoding/json"
|
|
|
|
|
2024-07-30 12:08:13 +02:00
|
|
|
"cloud.o-forge.io/core/oc-lib/models/resource_model"
|
2024-07-18 13:35:14 +02:00
|
|
|
"cloud.o-forge.io/core/oc-lib/models/utils"
|
2024-08-12 16:11:25 +02:00
|
|
|
"cloud.o-forge.io/core/oc-lib/tools"
|
2024-07-18 11:51:12 +02:00
|
|
|
)
|
|
|
|
|
2024-08-30 14:50:48 +02:00
|
|
|
// WorkflowResource is a struct that represents a workflow resource
|
|
|
|
// it defines the resource workflow
|
2024-07-19 10:54:58 +02:00
|
|
|
type WorkflowResource struct {
|
2024-07-30 12:08:13 +02:00
|
|
|
resource_model.AbstractResource
|
2024-08-30 14:50:48 +02:00
|
|
|
WorkflowID string `bson:"workflow_id,omitempty" json:"workflow_id,omitempty"` // WorkflowID is the ID of the native workflow
|
2024-07-18 11:51:12 +02:00
|
|
|
}
|
|
|
|
|
2024-08-12 16:11:25 +02:00
|
|
|
func (d *WorkflowResource) GetAccessor(caller *tools.HTTPCaller) utils.Accessor {
|
2024-08-30 14:50:48 +02:00
|
|
|
data := New() // Create a new instance of the accessor
|
2024-10-02 11:35:22 +02:00
|
|
|
data.Init(tools.WORKFLOW_RESOURCE, caller) // Initialize the accessor with the WORKFLOW_RESOURCE model type
|
2024-07-18 11:51:12 +02:00
|
|
|
return data
|
|
|
|
}
|
|
|
|
|
2024-07-19 10:54:58 +02:00
|
|
|
func (dma *WorkflowResource) Deserialize(j map[string]interface{}) utils.DBObject {
|
2024-07-18 14:39:54 +02:00
|
|
|
b, err := json.Marshal(j)
|
|
|
|
if err != nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
json.Unmarshal(b, dma)
|
|
|
|
return dma
|
|
|
|
}
|
|
|
|
|
2024-07-19 10:54:58 +02:00
|
|
|
func (dma *WorkflowResource) Serialize() map[string]interface{} {
|
2024-07-19 09:32:58 +02:00
|
|
|
var m map[string]interface{}
|
|
|
|
b, err := json.Marshal(dma)
|
|
|
|
if err != nil {
|
|
|
|
return nil
|
|
|
|
}
|
2024-07-24 09:53:30 +02:00
|
|
|
json.Unmarshal(b, &m)
|
2024-07-19 09:32:58 +02:00
|
|
|
return m
|
|
|
|
}
|