copy resource in workflow
This commit is contained in:
@@ -3,11 +3,12 @@ package data
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"cloud.o-forge.io/core/oc-lib/models/resource_model"
|
||||
"cloud.o-forge.io/core/oc-lib/models/utils"
|
||||
)
|
||||
|
||||
type DataResource struct {
|
||||
utils.AbstractResource
|
||||
resource_model.AbstractResource
|
||||
Protocols []string `json:"protocol,omitempty" bson:"protocol,omitempty"` //TODO Enum type
|
||||
DataType string `json:"datatype,omitempty" bson:"datatype,omitempty"`
|
||||
Example string `json:"example,omitempty" bson:"example,omitempty" description:"base64 encoded data"`
|
||||
|
||||
@@ -14,10 +14,12 @@ func (dma *DataMongoAccessor) DeleteOne(id string) (utils.DBObject, int, error)
|
||||
}
|
||||
|
||||
func (dma *DataMongoAccessor) UpdateOne(set utils.DBObject, id string) (utils.DBObject, int, error) {
|
||||
set.(*DataResource).ResourceModel = nil
|
||||
return dma.GenericUpdateOne(set, id, dma, &DataResource{})
|
||||
}
|
||||
|
||||
func (dma *DataMongoAccessor) StoreOne(data utils.DBObject) (utils.DBObject, int, error) {
|
||||
data.(*DataResource).ResourceModel = nil
|
||||
return dma.GenericStoreOne(data, dma)
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package data
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"cloud.o-forge.io/core/oc-lib/models/resource_model"
|
||||
"cloud.o-forge.io/core/oc-lib/models/utils"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
@@ -10,7 +11,7 @@ import (
|
||||
|
||||
func TestStoreOneData(t *testing.T) {
|
||||
d := DataResource{DataType: "jpeg", Example: "123456",
|
||||
AbstractResource: utils.AbstractResource{
|
||||
AbstractResource: resource_model.AbstractResource{
|
||||
AbstractObject: utils.AbstractObject{Name: "testData"},
|
||||
Description: "Lorem Ipsum",
|
||||
Logo: "azerty.com",
|
||||
@@ -28,7 +29,7 @@ func TestStoreOneData(t *testing.T) {
|
||||
|
||||
func TestLoadOneDate(t *testing.T) {
|
||||
d := DataResource{DataType: "jpeg", Example: "123456",
|
||||
AbstractResource: utils.AbstractResource{
|
||||
AbstractResource: resource_model.AbstractResource{
|
||||
AbstractObject: utils.AbstractObject{Name: "testData"},
|
||||
Description: "Lorem Ipsum",
|
||||
Logo: "azerty.com",
|
||||
|
||||
Reference in New Issue
Block a user