///
import { IFilterReference, MxObject, SortSpecifies, TMapLookup } from "../interfaces";
export declare abstract class AbstractEntityHandler {
protected _entity: string;
protected _entityPath: string;
protected _isConstraintPath: boolean;
private _onUpdated;
/**
* Data is Id of updated Entity
*/
onEntityUpdated: (listener: import("../connect/typedEventEmitter").Listener) => void;
private _onDeleted;
/**
* Data is Id of deleted Entity
*/
onEntityDeleted: (listener: import("../connect/typedEventEmitter").Listener) => void;
private _onEntityCreated;
/**
* Data is New Mendix Object
*/
onEntityCreated: (listener: import("../connect/typedEventEmitter").Listener) => void;
/**
* Function to return boolean to specify if skip update entity.
* There are cases that the update of entity doesn't require to update,
* so for optimization, we config this entity so
* the Handler knows and skip the update(which require retrieve).Undefined to check
*/
protected skipUpdateEntity: () => boolean | undefined;
protected _entityLookup: TMapLookup;
protected filterAttributes: string[];
/**
* Attached entitiy is the entity which only be used in this handler.
* For example, TreeEntity will have Entity (in datamodel) as "Attachted Entity"
* because it is only existed in the context of TreeEntiy
* (So we will not create an EntityHandler for Entity).
*/
protected _attachted_entity: string;
protected _attachted_entity_reference: string;
protected _attachted_entity_attributes: string[];
protected _required_associations: string[];
protected _subcribeHandlers: TMapLookup;
/**
* this property is to store the association from the entity to other entity Id throught the association name
* Suppose we have A---->B, A---->C
* this will have format of {"A-B":{AId->B1Id, AId->B2Id},"A-C":...}
*/
protected _association_refId_entId_map_map: TMapLookup>;
/**
* this property is to store the association from the entity to other entities throught the association name
* Suppose we have A---->B, A---->C
* this will have format of {"A-B":{AId->B1Objs[]},"A-C":...}
*/
protected _xpath_Id_MxObjs_map_map: TMapLookup>;
constructor(_entity: string, _entityPath: string, _isConstraintPath: boolean);
setSkipUpdateEntity(skipFunction: () => boolean): void;
setFilterAttributes(values: string[]): void;
configAttachedEntity(attachedEntity: string, attachedEntityRef: string, attachedEntityAttributes: string[]): void;
/**
* If we config reference, mendix only retrieve what we sepecify, so we have to config what we need
*/
addRequiredAssociation(association: string): void;
protected hasAttachtedEntity(): boolean;
protected generateFilterReferences(): IFilterReference;
getAttachtedEntity(entityId: string): any;
/**
* Load all instances of the configured entity by a path.
*/
loadData(refObjIds: string[], otherContrains?: string[], sortSpec?: SortSpecifies, limit?: number): Promise;
/**
* Load referenced entity through association
* @param otherEntity
* @param association
*/
fillManyToOneAssociation(otherEntity: string, association: string): Promise;
/**
* Function to retrieve referenced entity from entity of this handler by constraint
* then put it in a map with format {entityId->referencedEntities[]}
*/
fillOneToReferenceSet(otherEntity: string, constraint: string, filters: string[]): Promise;
/**
* Create, Commit then set the initialized values. Return new created object
* - sepecializationType: one of specialization of this entityType
* - initializeNameValues dictionary of (entity attribute name -> init value).
* These values will be set right after we commit object
* - commit: if yes, commit and otherwise
*/
createThenCommitEntity(specialziationType?: string, initializeNameValues?: TMapLookup, commit?: boolean): Promise;
/**
* Implement this function to set the new attribute of the object then commit.
* @param id Id of entity has new data
* @param changedInfo A map of change from ChangedAttributeName => NewValue
*/
abstract setThenCommitEntity(id: string, changedInfo: TMapLookup): Promise;
/** Destroy */
destroy(): void;
/**
* Update an entity based on guid.
* - ForceUpdate will trigger the update entity even value of skipUpdateEntity is true.
* It is used in case we need to get most uptodate version of entity to open form in readonly mode
* - If entity is existed in database, retrieve then update it
* - othewise, delete entity WITHOUT DELETE SUBSCRIPTION
* - if resolve an undefined, it means that we skip
* - otherwise, return id
*
*/
updateEntity(guid: string, forceUpdate?: boolean): Promise;
protected updateLookupMapFromArray(entities: MxObject[]): void;
protected updateLookupMap(entity: MxObject): void;
protected addNewEntity(newEntity: MxObject): void;
protected updateExistingEntity(newEntity: MxObject, guid: string): void;
protected deleteEntity(entityId: string, willSubscribe?: boolean): void;
protected checkEntityAndAddToAssociationMap(entity: MxObject, associatedEntities: MxObject[], associationMap: TMapLookup): void;
getRefercenceSetMapLookup(constraint: string): TMapLookup | undefined;
getAssociationMapLookup(association: string): TMapLookup | undefined;
getEntityMap(): TMapLookup;
getEntities(): mendix.lib.MxObject[];
has(id: string): boolean;
getFirstEntity(): MxObject | undefined;
protected subscribeEntities(entities: MxObject[]): void;
subscribeEntity(entityId: string): void;
/**
* Implement this function in concreted class to handle entity changes
* @param guid Id of Entity just changed
*/
protected abstract onEntityChanged(guid: string): Promise;
protected unsubscribeAll(): void;
unsubscribeEntity(guid: string): void;
}