import { EditorTag } from '../types/editor_tag'; import { DataType } from '../types/data_type'; import { MetaDataDTO } from './dto/meta_data_dto'; import { MetaEntity, MetaEntityAttr } from './meta_entity'; import { ValueEditor } from './value_editor'; /** * Represents a data model */ export declare class MetaData { /** The ID of the data mode. */ id: string; /** The name of the data model. */ name: string; /** The version of the data model. */ version: string; /** The root entity. */ rootEntity: MetaEntity; /** The list of value editors. */ editors: ValueEditor[]; protected mainEntity: MetaEntity | null; protected displayFormats: Map; /** The default constructor. */ constructor(); /** * Gets the main entity of model * @return The main entity. */ getMainEntity(): MetaEntity; createEntity(parent?: MetaEntity): MetaEntity; createEntityAttr(parent?: MetaEntity): MetaEntityAttr; createValueEditor(): ValueEditor; /** * Loads data model from JSON. * @param stringJson The JSON string. */ loadFromJSON(stringJson: string): void; /** * Loads data model from its JSON representation object. * @param data The JSON representation object. */ loadFromData(data: MetaDataDTO): void; /** * Gets the display formats. * @returns The display formats. */ getDisplayFormats(): Map; /** * Gets the display formats for type * @param type The type * @returns An array of display formats */ getDisplayFormatsForType(type: DataType): DisplayFormatDescriptor[]; /** * Gets the default display format for the provided type * @param type The type * @returns The default type format or null */ getDefaultFormat(type: DataType): DisplayFormatDescriptor | null; /** * Sets data to data model. * @param model Its JSON representation object or JSON string. */ setData(model: MetaDataDTO | string): void; /** * Checks wether the data model is empty. * @returns `true` if the data model is empty, otherwise `false`. */ isEmpty(): boolean; /** * Gets ID of the data model. * @returns The ID. */ getId(): string; /** * Gets name of the data model. * @returns The name. */ getName(): string; /** * Gets root entity of the data model. * @returns The root entity. */ getRootEntity(): MetaEntity; /** * Finds editor by its ID. * @param editorId The editor ID. * @returns The value editor or `null`. */ getEditorById(editorId: string): ValueEditor | null; /** * Gets entity attribute by its ID. * This function runs through all attributes inside specified model (it's root entity and all its sub-entities). * @param attrId The attribute ID. * @returns The attribute or `null`. */ getAttributeById(attrId: string): MetaEntityAttr | null; /** * Checks wether attribute contains such property. * @param attrId The attribute ID. * @param propName The property name. * @returns `true` if the attribute contains the property, otherwise `false`. */ checkAttrProperty(attrId: string, propName: string): boolean; /** * Gets entity attribute by its ID. * This function runs through all attributes inside specified entity and all its sub-entities. * @param entity * @param attrId * @returns The attribute or `null`. */ getEntityAttrById(entity: MetaEntity, attrId: string): MetaEntityAttr | null; private listByEntityWithFilter; private listByEntity; /** * Clears data model. */ clear(): void; /** * Add default value editors. */ addDefaultValueEditors(): void; /** * Add or update a value editor. * @param id The id. * @param tag The tag. * @param resType The result type. * @returns The value editor. */ addOrUpdateValueEditor(id: string, tag: EditorTag, resType: DataType): ValueEditor; /** * Gets entities tree. * @param opts The options. * @param filterFunc 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 The tree of the entities and their attributes according to options and the filter function */ getEntitiesTree(opts: any, filterFunc?: (ent: MetaEntity, attr: MetaEntityAttr) => boolean): any; /** * Gets entities tree due to filter. * @param filterFunc 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 The tree of the entities and their attributes according to the filter function */ getEntitiesTreeWithFilter(filterFunc: (ent: MetaEntity, attr: MetaEntityAttr) => boolean): MetaEntity[]; /** * Finds full entity path by attribute * @param attrId The attribute id. * @param sep The separator. * @returns The path. */ getFullEntityPathByAttr(attrId: string, sep: string): string; /** * Finds entity path by attribute * @param entity The entity. * @param attrId The attribute id. * @param sep The separator. * @param root The root option. * @returns The path. */ getEntityPathByAttr(entity: MetaEntity, attrId: string, sep: string, root: boolean): string; /** * Gets the attribute text. * @param attr The attribute. * @param format The format. * @returns Formatted text. */ getAttributeText(attr: MetaEntityAttr, format: string): string; /** * Scans model's entity tree and calls the callback functions for each attribute and entity. * @param processAttribute The callback function which is called for each attribute in model's entity tree. * The processed attribute is passed in the first function parameter. * @param processEntity The callback function which is called for each entity in tree. * The processed entity is passed in the first function parameter. */ runThroughEntities(processAttribute?: (attr: MetaEntityAttr, opts: any) => void, processEntity?: (entity: MetaEntity, opts: any) => void): void; /** * Finds first attribute by filter. * @param filterFunc The filter function. Takes EntityAttr object in parameter and returns boolean */ getFirstAttributeByFilter(filterFunc: (attr: MetaEntityAttr) => boolean): MetaEntityAttr; } export interface DisplayFormatDescriptor { name: string; format: string; isdef?: boolean; }