models

package
v0.0.0-...-50ff0a0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 20, 2020 License: MIT Imports: 5 Imported by: 11

Documentation

Overview

Package models contains the models required by the brain platform

Index

Constants

View Source
const (
	//DatasetAccessTypeDashboard gives minimum access to the user.
	//The user won't get the dataset listed in datasets list. But will have minimum access to see the data through dashboard
	DatasetAccessTypeDashboard = 0
	//DatasetAccessTypeCreator gives user access to delete/update and all the previleges on the dataset
	DatasetAccessTypeCreator = 10
)
View Source
const (
	//NodeMetadataPropWord is the metadata property of a node for word
	NodeMetadataPropWord = "Word"
	//NodeMetadataPropName is the metadata property of a node for name
	NodeMetadataPropName = "Name"
	//NodeMetadataPropDimension is the metadata property of a node for dimension
	NodeMetadataPropDimension = "Dimension"
	//NodeMetadataPropMeasure is the metadata property of a node for measure
	NodeMetadataPropMeasure = "Measure"
	//NodeMetadataPropAggregationFn is the metadata property of a node for aggregation function
	NodeMetadataPropAggregationFn = "AggregationFn"
	//NodeMetadataPropDataType is the metadata property of a node for data type
	NodeMetadataPropDataType = "DataType"
	//NodeMetadataPropDescription is the metadata property of a node for description
	NodeMetadataPropDescription = "Description"
	//NodeMetadataPropDefaultDateFieldUID is the metadata property of a node for default date field uid
	NodeMetadataPropDefaultDateFieldUID = "DefaultDateFieldUID"
	//NodeMetadataPropDatastoreID is the metadata property of a node for giving the datastore to which the node belongs to
	NodeMetadataPropDatastoreID = "NodeMetadataPropDatastoreID"
	//NodeMetadataPropKBType is the metadata property of a knowledge base node for giving kb type of the kb node
	NodeMetadataPropKBType = "KBType"
	//NodeMetadataPropOperation is the metadata property of a operation node for giving the type of the operation
	NodeMetadataPropOperation = "Operation"
	//NodeMetadataPropDateFormat is the metadata property of a column's csv data if the given column is of data type date
	NodeMetadataPropDateFormat = "DateFormat"
)
View Source
const (
	//NodeMetadataPropValueTrue is the value to be put for true as metadata value
	NodeMetadataPropValueTrue = "true"
	//NodeMetadataPropValueFalse is the value to be put for false as metadata value
	NodeMetadataPropValueFalse = "false"
	//NodeMetadataPropValueSystemKB is the value to be put for SystemKB as KBType metadata value
	NodeMetadataPropValueSystemKB = "1"
	//NodeMetadataPropValueUserKB is the value to be put for UserKB as KBType metadata value
	NodeMetadataPropValueUserKB = "2"
	//NodeMetadataPropValueEqOperator is the value to be put for Equal operator as operation of operator node
	NodeMetadataPropValueEqOperator = "="
	//NodeMetadataPropValueNotEqOperator is the value to be put for Not Equal operator as operation of operator node
	NodeMetadataPropValueNotEqOperator = "<>"
	//NodeMetadataPropValueGreaterOperator is the value to be put for Greater than or Equal operator as operation of operator node
	NodeMetadataPropValueGreaterOperator = ">="
	//NodeMetadataPropValueLessOperator is the value to be put for Less than or Equal operator as operation of operator node
	NodeMetadataPropValueLessOperator = "<="
	//NodeMetadataPropValueContainsOperator is the value to be put for Contains operator as operation of operator node
	NodeMetadataPropValueContainsOperator = "HAS"
	//NodeMetadataPropValueLikeOperator is the value to be put for Like operator as operation of operator node
	NodeMetadataPropValueLikeOperator = "LIKE"
)
View Source
const (
	//InfoNotification is the notitfication for info type of notification
	InfoNotification = "INFO_NOTIFICATION"
	//ErrorNotification is the notitfication for error type of notification
	ErrorNotification = "ERROR_NOTIFICATION"
	//SuccessNotification is the notitfication for success type of notification
	SuccessNotification = "SUCCESS_NOTIFICATION"
	//ActionNotification is the notification that will show a message and suggests to do an action.
	//eg:- When a dataset is deleted, user has to be notified on the same and the existing datasets list must be updated
	ActionNotification = "ACTION_NOTIFICATION"
)
View Source
const (
	//ActionFetchDatasets directs the client to refetch the list datasets api
	ActionFetchDatasets = "DATASETS"
)
View Source
const (
	//DatasetSourceFile indicates that the dataset source is file
	DatasetSourceFile = "FILE"
)

Variables

View Source
var (
	//NodeMetadataAggregationFns is the map containing the supported aggregation functions
	NodeMetadataAggregationFns = map[string]struct{}{
		interpreter.AggregationFnAvg:   {},
		interpreter.AggregationFnCount: {},
		interpreter.AggregationFnSum:   {},
	}
	//NodeMetadataDataTypes is the map containing the supported datatypes
	NodeMetadataDataTypes = map[string]struct{}{
		interpreter.DataTypeDate:   {},
		interpreter.DataTypeFloat:  {},
		interpreter.DataTypeInt:    {},
		interpreter.DataTypeString: {},
	}
)

Functions

func HasUserAccess

func HasUserAccess(l log.Log, conn *gorm.DB, datasetIds []uint, userID uint) (bool, error)

HasUserAccess will return true if the user has access to all the given datasets

func UpdateNodeMetadata

func UpdateNodeMetadata(l log.Log, conn *gorm.DB, metadata []NodeMetadata) error

UpdateNodeMetadata updates the given node metadata. If the node metadata is not created, will create the same

Types

type ActionNotificationPayload

type ActionNotificationPayload struct {
	//Message of the notification
	Message string `json:"message,omitempty"`
	//Action to be performed
	Action string `json:"action,omitempty"`
}

ActionNotificationPayload has info for sending an action notification with message and required action

type Dataset

type Dataset struct {
	gorm.Model
	//Name of the dataset
	Name string
	//Description is the description for the dataset
	Description string
	//UserID is the id of the user with whom the file is associated with
	UserID uint
	//Source is the type of dataset source. It can be file, database etc
	Source string
	//ResourceID is the lid of the underlying dataset like file id for a dataset who source is file
	ResourceID uint
	//UploadedDataset is the uploaded data set info
	UploadedDataset interface{} `gorm:"-"`
	//TableCreated indicates whether the table is created for the dataset in the datastore
	TableCreated bool
	//DatastoreID is the id of the datastore where the data is physically stored for the dataset
	DatastoreID uint
}

Dataset represents a dataset

func (*Dataset) Get

func (d *Dataset) Get(conn *gorm.DB) error

Get will find the dataset values and set in the instance. Returns an error if couldn't find

func (Dataset) GetColumns

func (d Dataset) GetColumns(conn *gorm.DB) ([]Node, error)

GetColumns get the columns corresponding to a dataset

func (Dataset) GetTable

func (d Dataset) GetTable(conn *gorm.DB) (Node, error)

GetTable get the tables corresponding to a dataset

func (*Dataset) UpdateColumns

func (d *Dataset) UpdateColumns(l log.Log, conn *gorm.DB, cols []Node) ([]Node, error)

UpdateColumns updates the columns in the database. It will create the columns if not existing

func (*Dataset) UpdateTable

func (d *Dataset) UpdateTable(conn *gorm.DB, table Node) (Node, error)

UpdateTable will update the given table

type DatsetUserMapping

type DatsetUserMapping struct {
	gorm.Model
	//DatasetID is the ID of the dataset
	DatasetID uint
	//UserID is the ID of the user
	UserID uint
	//AccessType is the type of access for the user to the dataset
	AccessType int
}

DatsetUserMapping has the mapping of a dataset to user. this includes the access type. All users with creator access and dashboard access will be listed in this table.

type Node

type Node struct {
	gorm.Model
	//UID is the unique id of the node
	UID uuid.UUID
	//Type of the node
	Type interpreter.Type
	//PUID is the unique id of the parent node
	PUID uuid.UUID
	//DatasetID is the id of the dataset to which the node belongs to
	DatasetID uint
	//NodeMetadatas holds the metadata corresponding to the node
	NodeMetadatas []NodeMetadata
	//Parent denotes the the parent for the node
	Parent *Node `gorm:"-"`
	//DefaultDateField holds the default date field if any for a table
	DefaultDateField *interpreter.ColumnNode `gorm:"-"`
}

Node represents a octopus node's db record

func (Node) ColumnNode

func (n Node) ColumnNode() interpreter.ColumnNode

ColumnNode returns column node converted form of the node

func (Node) FromColumn

func (n Node) FromColumn(c interpreter.ColumnNode) Node

FromColumn converts the interpreter column node to node

func (Node) FromKnowledgeBase

func (n Node) FromKnowledgeBase(k interpreter.KnowledgeBaseNode) Node

FromKnowledgeBase converts the interpreter knowledgebase node to node

func (Node) FromOperatorNode

func (n Node) FromOperatorNode(o interpreter.OperatorNode) Node

FromOperatorNode converts the interpreter operator node to node

func (Node) FromTable

func (n Node) FromTable(t interpreter.TableNode) Node

FromTable converts the interpreter table node to node

func (Node) InterpreterNode

func (n Node) InterpreterNode() (interpreter.Node, bool)

InterpreterNode will convert a node to corresponding interpreter node

func (Node) KnowledgeBaseNode

func (n Node) KnowledgeBaseNode() interpreter.KnowledgeBaseNode

KnowledgeBaseNode returns the knowledgebase node converted form of the node

func (Node) OperatorNode

func (n Node) OperatorNode() interpreter.OperatorNode

OperatorNode returns the operator node converted form of the node

func (Node) TableNode

func (n Node) TableNode() interpreter.TableNode

TableNode returns table node converted form of the node

type NodeMetadata

type NodeMetadata struct {
	gorm.Model
	//NodeID is the id of the node to which the metadata belongs to
	NodeID uint
	//DatasetID is the id of the dataset to which the node belongs to
	DatasetID uint
	//Prop stores the metadata property
	Prop string
	//Value stores the metadata value
	Value string
}

NodeMetadata stores the metadata associated with a node

type Notification

type Notification struct {
	//Event is the event to be called
	Event string
	//Payload is the payload to be send with the notification
	Payload interface{}
}

Notification is the data translation object for sending notifications

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL