package tools

type DataType int

// DataType - Enum for the different types of resources in db accessible from the outside
const (
	INVALID DataType = iota
	DATA_RESOURCE
	PROCESSING_RESOURCE
	STORAGE_RESOURCE
	COMPUTE_RESOURCE
	WORKFLOW_RESOURCE
	WORKFLOW
	WORKFLOW_EXECUTION
	WORKSPACE
	RESOURCE_MODEL
	PEER
	COLLABORATIVE_AREA
	RULE
	BOOKING
	WORKFLOW_HISTORY
	WORKSPACE_HISTORY
)

var NOAPI = ""
var CATALOGAPI = "oc-catalog"
var SHAREDAPI = "oc-shared"
var WORKFLOWAPI = "oc-workflow"
var WORKSPACEAPI = "oc-workspace"
var PEERSAPI = "oc-peer"
var DATACENTERAPI = "oc-datacenter"

// Bind the standard API name to the data type
var DefaultAPI = [...]string{
	NOAPI,
	CATALOGAPI,
	CATALOGAPI,
	CATALOGAPI,
	CATALOGAPI,
	CATALOGAPI,
	WORKFLOWAPI,
	NOAPI,
	WORKSPACEAPI,
	CATALOGAPI,
	PEERSAPI,
	SHAREDAPI,
	SHAREDAPI,
	DATACENTERAPI,
	NOAPI,
	NOAPI,
}

// Bind the standard data name to the data type
var Str = [...]string{
	"invalid",
	"data_resource",
	"processing_resource",
	"storage_resource",
	"compute_resource",
	"workflow_resource",
	"workflow",
	"workflow_execution",
	"workspace",
	"resource_model",
	"peer",
	"collaborative_area",
	"rule",
	"booking",
	"workflow_history",
	"workspace_history",
}

func FromInt(i int) string {
	return Str[i]
}

func (d DataType) API() string { // API - Returns the API name of the data type
	return DefaultAPI[d]
}

func (d DataType) String() string { // String - Returns the string name of the data type
	return Str[d]
}

// EnumIndex - Creating common behavior - give the type a EnumIndex functio
func (d DataType) EnumIndex() int {
	return int(d)
}
