MetaData class

Represents a data model

Index

Constructors

Public Properties

Protected Properties

Public Methods

Constructors


constructor

The default constructor. ⊕ new MetaData(): MetaData


Public Properties


editors

The list of value editors.

● editors: ValueEditor[]


id

The ID of the data mode.

● id: string


name

The name of the data model.

● name: string


rootEntity

The root entity.

● rootEntity: MetaEntity


version

The version of the data model.

● version: string


Protected Properties


mainEntity

● mainEntity: MetaEntity | null = null


Public Methods


addDefaultValueEditors

Add default value editors.

▸ addDefaultValueEditors(): void

Returns void


addOrUpdateValueEditor

Add or update a value editor.

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

Parameters:

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

Returns ValueEditor - The value editor.


checkAttrProperty

Checks wether attribute contains such property.

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

Parameters:

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

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


clear

Clears data model.

▸ clear(): void

Returns void


createEntity

▸ createEntity(parent?: MetaEntity): MetaEntity

Parameters:

Returns MetaEntity


createEntityAttr

▸ createEntityAttr(parent?: MetaEntity): MetaEntityAttr

Parameters:

Returns MetaEntityAttr


createValueEditor

▸ createValueEditor(): ValueEditor

Returns ValueEditor


getAttributeById

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): MetaEntityAttr | null

Parameters:

  • attrId: string - The attribute ID.

Returns MetaEntityAttr | null - The attribute or null.


getAttributeText

Gets the attribute text.

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

Parameters:

Returns string - Formatted text.


getEditorById

Finds editor by its ID.

▸ getEditorById(editorId: string): ValueEditor | null

Parameters:

  • editorId: string - The editor ID.

Returns ValueEditor | null - The value editor or null.


getEntitiesTree

Gets entities tree.

▸ getEntitiesTree(opts: any,filterFunc?: (ent: MetaEntity, attr: MetaEntityAttr) => boolean): any

Parameters:

  • opts: any - The options.
  • filterFunc: (ent: MetaEntity, attr: MetaEntityAttr) => 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


getEntitiesTreeWithFilter

Gets entities tree due to filter.

▸ getEntitiesTreeWithFilter(filterFunc: (ent: MetaEntity, attr: MetaEntityAttr) => boolean): MetaEntity[]

Parameters:

  • filterFunc: (ent: MetaEntity, attr: MetaEntityAttr) => boolean - 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 MetaEntity[] - The tree of the entities and their attributes according to the filter function


getEntityAttrById

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

▸ getEntityAttrById(entity: MetaEntity,attrId: string): MetaEntityAttr | null

Parameters:

Returns MetaEntityAttr | null - The attribute or null.


getEntityPathByAttr

Finds entity path by attribute

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

Parameters:

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

Returns string - The path.


getFirstAttributeByFilter

Finds first attribute by filter.

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

Parameters:

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

Returns MetaEntityAttr


getFullEntityPathByAttr

Finds full entity path by attribute

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

Parameters:

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

Returns string - The path.


getId

Gets ID of the data model.

▸ getId(): string

Returns string - The ID.


getMainEntity

Gets the main entity of model

▸ getMainEntity(): MetaEntity

Returns MetaEntity - The main entity.


getName

Gets name of the data model.

▸ getName(): string

Returns string - The name.


getRootEntity

Gets root entity of the data model.

▸ getRootEntity(): MetaEntity

Returns MetaEntity - The root entity.


isEmpty

Checks wether the data model is empty.

▸ isEmpty(): boolean

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


loadFromData

Loads data model from its JSON representation object.

▸ loadFromData(data: MetaDataDTO): void

Parameters:

Returns void


loadFromJSON

Loads data model from JSON.

▸ loadFromJSON(stringJson: string): void

Parameters:

  • stringJson: string - The JSON string.

Returns void


runThroughEntities

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

▸ runThroughEntities(processAttribute?: (attr: MetaEntityAttr, opts: any) => void,processEntity?: (entity: MetaEntity, opts: any) => void): void

Parameters:

  • processAttribute: (attr: MetaEntityAttr, opts: any) => void, Optional - 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: MetaEntity, opts: any) => void, Optional - The callback function which is called for each entity in tree. The processed entity is passed in the first function parameter.

Returns void


setData

Sets data to data model.

▸ setData(model: MetaDataDTO | string): void

Parameters:

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

Returns void