import { Record , Map , List } from 'immutable' ; import { Size , Position , PortDirection , PortRecord as PortRecordType , } from '../customTypings/index.d' ; export const NONE = 'NONE' ; export const SELECTED = 'SELECTED' ; export const DROP_TARGET = 'DROP_TARGET' ; export const FORBIDDEN_DROP_TARGET = 'FORBIDDEN_DROP_TARGET' ; export const PositionRecord = Record ( { x : undefined , y : undefined , } ) ; export const SizeRecord = Record ( { width : undefined , height : undefined , } ) ; /** TO BE REMOVED */ export const NodeGraphicalAttributes = Record ( { position : new PositionRecord ( ) , nodeSize : new SizeRecord ( ) , nodeType : undefined , label : '' , description : '' , properties : Map ( ) , } ) ; /** TO BE REMOVED */ export const NodeData = Record ( { properties : Map ( ) , label : '' , description : '' , datasetInfo : Map ( ) , } ) ; /** TO BE REMOVED */ export const LinkGraphicalAttributes = Record ( { linkType : undefined , properties : Map ( ) , } ) ; /** TO BE REMOVED */ export const LinkData = Record ( { properties : Map ( ) , } ) ; /** TO BE REMOVED */ export const PortGraphicalAttributes = Record ( { position : PositionRecord , portType : undefined , properties : Map ( ) , } ) ; /** TO BE REMOVED */ export const PortData = Record ( { properties : Map ( ) , flowType : undefined , } ) ; const nodeRecordDefinition = { id : undefined , type : undefined , data : Map ( { properties : Map ( ) , label : '' , description : '' , datasetInfo : Map ( ) , } ) , graphicalAttributes : Map ( { position : new PositionRecord ( ) , nodeSize : new SizeRecord ( ) , nodeType : undefined , label : '' , description : '' , properties : Map ( ) , } ) , } ; export class NodeRecord extends Record ( { ... nodeRecordDefinition , getPosition ( ) { return this . getIn ( [ 'graphicalAttributes' , 'position' ] ) ; } , getSize ( ) { return this . getIn ( [ 'graphicalAttributes' , 'nodeSize' ] ) ; } , getNodeType ( ) { return this . getIn ( [ 'graphicalAttributes' , 'nodeType' ] ) ; } , } ) { } export class NestedNodeRecord extends Record ( { ... nodeRecordDefinition , components : List ( ) , getComponents ( ) { return this . get ( 'components' ) ; } , setComponents ( components ) { return this . set ( 'components' , components ) ; } , getPosition ( ) { return this . getIn ( [ 'graphicalAttributes' , 'position' ] ) ; } , getSize ( ) { return this . getIn ( [ 'graphicalAttributes' , 'nodeSize' ] ) ; } , getNodeType ( ) { return this . getIn ( [ 'graphicalAttributes' , 'nodeType' ] ) ; } , } ) { } export const LinkRecord = Record ( { id : undefined , sourceId : undefined , targetId : undefined , data : Map ( { properties : Map ( ) , } ) , graphicalAttributes : Map ( { linkType : undefined , properties : Map ( ) , } ) , /** methods TO BE REMOVED */ getLinkType ( ) { return this . getIn ( [ 'graphicalAttributes' , 'linkType' ] ) ; } , } ) ; export const PortRecord = Record ( { id : undefined , nodeId : undefined , data : Map ( { properties : Map ( ) , flowType : undefined , } ) , graphicalAttributes : Map ( { position : PositionRecord , portType : undefined , properties : Map ( ) , } ) , /** methods TO BE REMOVED */ getPosition ( ) { return this . getIn ( [ 'graphicalAttributes' , 'position' ] ) ; } , setPosition ( position ) { return this . setIn ( [ 'graphicalAttributes' , 'position' ] , position ) ; } , getPortType ( ) { return this . getIn ( [ 'graphicalAttributes' , 'portType' ] ) ; } , getPortDirection ( ) { return this . getIn ( [ 'graphicalAttributes' , 'properties' , 'type' ] ) ; } , getPortFlowType ( ) { return this . getIn ( [ 'data' , 'flowType' ] ) ; } , getIndex ( ) { return this . getIn ( [ 'graphicalAttributes' , 'properties' , 'index' ] ) ; } , setIndex ( index ) { return this . setIn ( [ 'graphicalAttributes' , 'properties' , 'index' ] , index ) ; } , } ) ;