MetaData class
Represents a data model
- addDefaultValueEditors
- addOrUpdateValueEditor
- checkAttrProperty
- clear
- createEntity
- createEntityAttr
- createValueEditor
- getAttributeById
- getAttributeText
- getEditorById
- getEntitiesTree
- getEntitiesTreeWithFilter
- getEntityAttrById
- getEntityPathByAttr
- getFirstAttributeByFilter
- getFullEntityPathByAttr
- getId
- getMainEntity
- getName
- getRootEntity
- isEmpty
- loadFromData
- loadFromJSON
- runThroughEntities
- setData
Constructors
Section titled “Constructors”constructor
Section titled “constructor”The default constructor. ⊕ new MetaData(): MetaData
Public Properties
Section titled “Public Properties”editors
Section titled “editors”The list of value editors.
● editors: ValueEditor[]
The ID of the data mode.
● id: string
The name of the data model.
● name: string
rootEntity
Section titled “rootEntity”The root entity.
● rootEntity: MetaEntity
version
Section titled “version”The version of the data model.
● version: string
Protected Properties
Section titled “Protected Properties”mainEntity
Section titled “mainEntity”● mainEntity: MetaEntity | null
= null
Public Methods
Section titled “Public Methods”addDefaultValueEditors
Section titled “addDefaultValueEditors”Add default value editors.
▸ addDefaultValueEditors(): void
Returns void
addOrUpdateValueEditor
Section titled “addOrUpdateValueEditor”Add or update a value editor.
▸ addOrUpdateValueEditor(id: string
,tag: EditorTag
,resType: DataType): ValueEditor
Parameters:
Section titled “Parameters:”- id:
string
- The id. - tag:
EditorTag
- The tag. - resType: DataType - The result type.
Returns ValueEditor - The value editor.
checkAttrProperty
Section titled “checkAttrProperty”Checks wether attribute contains such property.
▸ checkAttrProperty(attrId: string
,propName: string
): boolean
Parameters:
Section titled “Parameters:”- 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
createEntity
Section titled “createEntity”▸ createEntity(parent?: MetaEntity): MetaEntity
Parameters:
Section titled “Parameters:”- parent: MetaEntity, Optional
Returns MetaEntity
createEntityAttr
Section titled “createEntityAttr”▸ createEntityAttr(parent?: MetaEntity): MetaEntityAttr
Parameters:
Section titled “Parameters:”- parent: MetaEntity, Optional
Returns MetaEntityAttr
createValueEditor
Section titled “createValueEditor”▸ createValueEditor(): ValueEditor
Returns ValueEditor
getAttributeById
Section titled “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:
Section titled “Parameters:”- attrId:
string
- The attribute ID.
Returns MetaEntityAttr | null
- The attribute or null
.
getAttributeText
Section titled “getAttributeText”Gets the attribute text.
▸ getAttributeText(attr: MetaEntityAttr,format: string
): string
Parameters:
Section titled “Parameters:”- attr: MetaEntityAttr - The attribute.
- format:
string
- The format.
Returns string
- Formatted text.
getEditorById
Section titled “getEditorById”Finds editor by its ID.
▸ getEditorById(editorId: string
): ValueEditor | null
Parameters:
Section titled “Parameters:”- editorId:
string
- The editor ID.
Returns ValueEditor | null
- The value editor or null
.
getEntitiesTree
Section titled “getEntitiesTree”Gets entities tree.
▸ getEntitiesTree(opts: any
,filterFunc?: (ent: MetaEntity, attr: MetaEntityAttr) => boolean
): any
Parameters:
Section titled “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
Section titled “getEntitiesTreeWithFilter”Gets entities tree due to filter.
▸ getEntitiesTreeWithFilter(filterFunc: (ent: MetaEntity, attr: MetaEntityAttr) => boolean
): MetaEntity[]
Parameters:
Section titled “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
Section titled “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:
Section titled “Parameters:”- entity: MetaEntity
- attrId:
string
Returns MetaEntityAttr | null
- The attribute or null
.
getEntityPathByAttr
Section titled “getEntityPathByAttr”Finds entity path by attribute
▸ getEntityPathByAttr(entity: MetaEntity,attrId: string
,sep: string
,root: boolean
): string
Parameters:
Section titled “Parameters:”- entity: MetaEntity - The entity.
- attrId:
string
- The attribute id. - sep:
string
- The separator. - root:
boolean
- The root option.
Returns string
- The path.
getFirstAttributeByFilter
Section titled “getFirstAttributeByFilter”Finds first attribute by filter.
▸ getFirstAttributeByFilter(filterFunc: (attr: MetaEntityAttr) => boolean
): MetaEntityAttr
Parameters:
Section titled “Parameters:”- filterFunc: (attr: MetaEntityAttr) =>
boolean
- The filter function. Takes EntityAttr object in parameter and returns boolean
Returns MetaEntityAttr
getFullEntityPathByAttr
Section titled “getFullEntityPathByAttr”Finds full entity path by attribute
▸ getFullEntityPathByAttr(attrId: string
,sep: string
): string
Parameters:
Section titled “Parameters:”- 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.
getMainEntity
Section titled “getMainEntity”Gets the main entity of model
▸ getMainEntity(): MetaEntity
Returns MetaEntity - The main entity.
getName
Section titled “getName”Gets name of the data model.
▸ getName(): string
Returns string
- The name.
getRootEntity
Section titled “getRootEntity”Gets root entity of the data model.
▸ getRootEntity(): MetaEntity
Returns MetaEntity - The root entity.
isEmpty
Section titled “isEmpty”Checks wether the data model is empty.
▸ isEmpty(): boolean
Returns boolean
- true
if the data model is empty, otherwise false
.
loadFromData
Section titled “loadFromData”Loads data model from its JSON representation object.
▸ loadFromData(data: MetaDataDTO): void
Parameters:
Section titled “Parameters:”- data: MetaDataDTO - The JSON representation object.
Returns void
loadFromJSON
Section titled “loadFromJSON”Loads data model from JSON.
▸ loadFromJSON(stringJson: string
): void
Parameters:
Section titled “Parameters:”- stringJson:
string
- The JSON string.
Returns void
runThroughEntities
Section titled “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:
Section titled “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
Section titled “setData”Sets data to data model.
▸ setData(model: MetaDataDTO | string
): void
Parameters:
Section titled “Parameters:”- model: MetaDataDTO |
string
- Its JSON representation object or JSON string.
Returns void