cast at root lib
This commit is contained in:
		@@ -4,7 +4,15 @@ import (
 | 
			
		||||
	"cloud.o-forge.io/core/oc-lib/dbs/mongo"
 | 
			
		||||
	"cloud.o-forge.io/core/oc-lib/logs"
 | 
			
		||||
	"cloud.o-forge.io/core/oc-lib/models"
 | 
			
		||||
	"cloud.o-forge.io/core/oc-lib/models/resources/data"
 | 
			
		||||
	"cloud.o-forge.io/core/oc-lib/models/resources/datacenter"
 | 
			
		||||
	"cloud.o-forge.io/core/oc-lib/models/resources/processing"
 | 
			
		||||
	"cloud.o-forge.io/core/oc-lib/models/resources/storage"
 | 
			
		||||
	w "cloud.o-forge.io/core/oc-lib/models/resources/workflow"
 | 
			
		||||
	"cloud.o-forge.io/core/oc-lib/models/utils"
 | 
			
		||||
	w2 "cloud.o-forge.io/core/oc-lib/models/workflow"
 | 
			
		||||
	"cloud.o-forge.io/core/oc-lib/models/workflow_execution"
 | 
			
		||||
	"cloud.o-forge.io/core/oc-lib/models/workspace"
 | 
			
		||||
	"github.com/rs/zerolog"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
@@ -109,3 +117,56 @@ func CopyOne(collection LibDataEnum, object map[string]interface{}) LibData {
 | 
			
		||||
	}
 | 
			
		||||
	return LibData{Data: d, Code: code}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ================ CAST ========================= //
 | 
			
		||||
 | 
			
		||||
func (l *LibData) ToDataResource() *data.DataResource {
 | 
			
		||||
	if l.Data.GetAccessor().GetType() == utils.DATA_RESOURCE.String() {
 | 
			
		||||
		return l.Data.(*data.DataResource)
 | 
			
		||||
	}
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (l *LibData) ToDatacenterResource() *datacenter.DatacenterResource {
 | 
			
		||||
	if l.Data != nil && l.Data.GetAccessor().GetType() == utils.DATACENTER_RESOURCE.String() {
 | 
			
		||||
		return l.Data.(*datacenter.DatacenterResource)
 | 
			
		||||
	}
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
func (l *LibData) ToStorageResource() *storage.StorageResource {
 | 
			
		||||
	if l.Data.GetAccessor().GetType() == utils.STORAGE_RESOURCE.String() {
 | 
			
		||||
		return l.Data.(*storage.StorageResource)
 | 
			
		||||
	}
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
func (l *LibData) ToProcessingResource() *processing.ProcessingResource {
 | 
			
		||||
	if l.Data.GetAccessor().GetType() == utils.PROCESSING_RESOURCE.String() {
 | 
			
		||||
		return l.Data.(*processing.ProcessingResource)
 | 
			
		||||
	}
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
func (l *LibData) ToWorkflowResource() *w.WorkflowResource {
 | 
			
		||||
	if l.Data.GetAccessor().GetType() == utils.WORKFLOW_RESOURCE.String() {
 | 
			
		||||
		return l.Data.(*w.WorkflowResource)
 | 
			
		||||
	}
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (l *LibData) ToWorkflow() *w2.Workflow {
 | 
			
		||||
	if l.Data.GetAccessor().GetType() == utils.WORKFLOW.String() {
 | 
			
		||||
		return l.Data.(*w2.Workflow)
 | 
			
		||||
	}
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
func (l *LibData) ToWorkspace() *workspace.Workspace {
 | 
			
		||||
	if l.Data.GetAccessor().GetType() == utils.WORKSPACE.String() {
 | 
			
		||||
		return l.Data.(*workspace.Workspace)
 | 
			
		||||
	}
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
func (l *LibData) ToWorkflowExecution() *workflow_execution.WorkflowExecution {
 | 
			
		||||
	if l.Data.GetAccessor().GetType() == utils.WORKSPACE.String() {
 | 
			
		||||
		return l.Data.(*workflow_execution.WorkflowExecution)
 | 
			
		||||
	}
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user