Skip to content

DataModelEx class

DataModel


The default constructor. ⊕ new DataModelEx(): DataModelEx



The list of aggregate functions.

● aggrFunctions: AggrFunction[]


The list of value editors.

● editors: ValueEditor[]


The License.

● eqlcns: EqLcns


The ID of the data mode.

● id: string


The list of links. It is used in odata broker.

● links: Link[]


The name of the data model.

● name: string


The list of operators.

● operators: Operator[]


The root entity.

● rootEntity: Entity


The version of the data model.

● version: string



● mainEntity: Entity | null



Add default value editors.

▸ addDefaultValueEditors(): void

Returns void


Add or update an operator.

▸ addOrUpdateOperator(id: string,caption: string,expr: string,format: string,kind?: DataKind): Operator

  • id: string - The id.
  • caption: string - The caption.
  • expr: string - The epxrpession.
  • format: string - The display format.
  • kind: DataKind, Optional - The def operand’s kind.

Returns Operator - The operator.


Add or update a value editor.

▸ addOrUpdateValueEditor(id: string,tag: EditorTag,resType: DataType): ValueEditor

  • id: string - The id.
  • tag: EditorTag - The tag.
  • resType: DataType - The result type.

Returns ValueEditor - The value editor.


▸ buildQueryPath(query: Query): Tree<Entity>

Returns Tree<Entity>


Checks wether attribute contains such property.

▸ checkAttrProperty(attrId: string,propName: string): boolean

  • attrId: string - The attribute ID.
  • propName: string - The property name.

Returns boolean - true if the attribute contains the property, otherwise false.


Clears data model.

▸ clear(): void

Returns void


Creates query.

▸ createQuery(): Query

Returns Query - The Query.


Finds link between two entities.

▸ findLink(entityFrom: Entity,entityTo: Entity): Link | null

  • entityFrom: Entity - The entity from.
  • entityTo: Entity - The entity to.

Returns Link | null - The link.


Finds operator in model by its ID. This function runs through all operators inside specified model and returns the one with specified ID.

▸ findOperatorById(operatorId: string): Operator | null

  • operatorId: string - An operator ID.

Returns Operator | null - The operator or null.


Gets caption of the aggregate function.

▸ getAggrFunctionCaption(funcId: string): string

  • funcId: string - The function id.

Returns string - The caption.


Gets format of the aggregate function.

▸ getAggrFunctionFormat(funcId: string): string

  • funcId: string - The function id.

Returns string - The caption.


Gets the list of aggegate functions.

▸ getAggrFunctions(): AggrFunction[]

Returns AggrFunction[] - AN array of aggregate functions.


Gets entity attribute by its ID. This function runs through all attributes inside specified model (it’s root entity and all its sub-entities).

▸ getAttributeById(attrId: string): EntityAttr | null

  • attrId: string - The attribute ID.

Returns EntityAttr | null - The attribute or null.


Gets the attribute text.

▸ getAttributeText(attr: EntityAttr,format: string): string

  • attr: EntityAttr - The attribute.
  • format: string - The format.

Returns string - Formatted text.


Gets date by its macro value.

▸ getDateMacroValue(macro: string): Date | null

  • macro: string - The macro value.

Returns Date | null - The date or null


Gets date or macro by macro value.

▸ getDateOrMacroValue(macroValue: string): string | Date

  • macroValue: string - The macro value.

Returns string | Date - The date or macro valu.


Gets default operator for an attribute.

▸ getDefaultOperatorForAttr(attr: EntityAttr): Operator

Returns Operator - The operator.


▸ getDefaultOperatorIdForAttr(attr: EntityAttr): string

Returns string


Finds editor by its ID.

▸ getEditorById(editorId: string): ValueEditor | null

  • editorId: string - The editor ID.

Returns ValueEditor | null - The value editor or null.


Get Entities used in query.

▸ getEntitiesInQuery(query: Query): Entity[]

  • query: Query - The query.

Returns Entity[]


Gets entities tree.

▸ getEntitiesTree(opts: any,filterFunc?: (ent: Entity, attr: EntityAttr) => boolean): any

  • opts: any - The options.
  • filterFunc: (ent: Entity, attr: EntityAttr) => boolean, Optional - The filter function. Takes two parameters, Entity and EntityAttr (second parameter will be null for entities), and returns boolean (true if the corresponding entity or attribute).

Returns any - The tree of the entities and their attributes according to options and the filter function


Gets entities tree due to filter.

▸ getEntitiesTreeWithFilter(filterFunc: any): Entity[]

  • filterFunc: any - The filter function. Takes two parameters, Entity and EntityAttr (second parameter will be null for entities), and returns boolean (true if the corresponding entity or attribute).

Returns Entity[] - The tree of the entities and their attributes according to the filter function


Gets entity attribute by its ID. This function runs through all attributes inside specified entity and all its sub-entities.

▸ getEntityAttrById(entity: Entity,attrId: string): EntityAttr | null

  • entity: Entity
  • attrId: string

Returns EntityAttr | null - The attribute or null.


Finds entity path by attribute

▸ getEntityPathByAttr(entity: Entity,attrId: string,sep: string,root: boolean): string

  • entity: Entity - The entity.
  • attrId: string - The attribute id.
  • sep: string - The separator.
  • root: boolean - The root option.

Returns string - The path.


Finds first attribute by filter.

▸ getFirstAttributeByFilter(filterFunc: (attr: EntityAttr) => boolean): EntityAttr

  • filterFunc: (attr: EntityAttr) => boolean - The filter function. Takes EntityAttr object in parameter and returns boolean

Returns EntityAttr


▸ getFirstUICAttr(): EntityAttr

Returns EntityAttr


Finds full entity path by attribute

▸ getFullEntityPathByAttr(attrId: string,sep: string): string

  • attrId: string - The attribute id.
  • sep: string - The separator.

Returns string - The path.


Gets ID of the data model.

▸ getId(): string

Returns string - The ID.


Get links with the entity.

▸ getLinksByEntity(entity: Entity): Link[]

  • entity: Entity - The entity.

Returns Link[] - The link.


Gets the main entity of model

▸ getMainEntity(): Entity

Returns Entity - The main entity.


Gets name of the data model.

▸ getName(): string

Returns string - The name.


Gets the data model object.

▸ getObject(): DataModel

Returns DataModel - Tha data model.


Gets operand.

▸ getOperand(attr: EntityAttr,operator: Operator,index: number): Operand

  • attr: EntityAttr - The attribute.
  • operator: Operator - The operator.
  • index: number - The index.

Returns Operand - The operand.


Finds operator in model by its ID. his function runs through all operators inside specified model and returns the one with specified ID.

▸ getOperatorById(operatorId: string): Operator

  • operatorId: string - Operator ID.

Returns Operator - The operator or special NullOperator object if operator is not found.


Get operators for data type.

▸ getOperatorIdsByDataType(type: DataType): string[]

Returns string[] - The array of operator ids.


Gets root entity of the data model.

▸ getRootEntity(): Entity

Returns Entity - The root entity.


Gets time by its macro value.

▸ getTimeMacroValue(macro: string): Date | null

  • macro: string - The macro value.

Returns Date | null - The date or null.


Gets time or macro by macro value.

▸ getTimeOrMacroValue(time: string): string | Date

  • time: string

Returns string | Date - The time or macro valu.


Checks wether macro value is date.

▸ isDateMacro(macro: string): boolean

  • macro: string - The macro value.

Returns boolean


Checks wether the data model is empty.

▸ isEmpty(): boolean

Returns boolean - true if the data model is empty, otherwise false.


Checks wether macro value is time.

▸ isTimeMacro(macro: string): boolean

  • macro: string - The macro value.

Returns boolean


Loads data model from its JSON representation object.

▸ loadFromData(data: ModelPlainData): void

Returns void


Loads data model from JSON.

▸ loadFromJSON(stringJson: string): void

  • stringJson: string - The JSON string.

Returns void


Gets license.

▸ rgdlce(): boolean

Returns boolean - The license.


Scans model’s entity tree and calls the callback functions for each attribute and entity.

▸ runThroughEntities(processAttribute: (attr: EntityAttr, opts: any) => void,processEntity: (entity: Entity, opts: any) => void): void

  • processAttribute: (attr: EntityAttr, opts: any) => void - The callback function which is called for each attribute in model’s entity tree. The processed attribute is passed in the first function parameter.
  • processEntity: (entity: Entity, opts: any) => void - The callback function which is called for each entity in tree. The processed entity is passed in the first function parameter.

Returns void


Sets data to data model.

▸ setData(model: ModelPlainData | string): void

  • model: ModelPlainData | string - Its JSON representation object or JSON string.

Returns void