/** Core */ import { Generic } from "cmf.core/src/core"; import { Cmf } from "cmf.lbos"; /** Components */ import { EntityPropertyJoin } from "../components/entityPropertyPicker/entityPropertyPicker"; export { EntityPropertyJoin }; /** * Filter item options concerning parameter */ export interface FilterItemOptions { /** * True if item is parameter */ parameter?: boolean; /** * True if item is optional */ optional?: boolean; } /** * Information held by one filter (used to get and set filters) */ export interface FilterInfo extends FilterInfoNode { /** * Full path to the filter */ filterPath: EntityPropertyJoin[]; /** * Filter logical operator */ logicalOp: Cmf.Foundation.Common.LogicalOperator; /** * Filter operator */ fieldOp: Cmf.Foundation.Common.FieldOperator; /** * Filter value */ value: any; /** * True if this filter is parameter */ isParameter?: boolean; /** * True if this filter is parameter and optional */ isOptional?: boolean; } /** * Interface to hold either a FilterInfo or a FilterInfoGroup (containing a flag to distinguish them) */ export interface FilterInfoNode { /** * Flag to distinguish wether this is a group or a filter info */ isGroup?: boolean; } /** * Filter Info Group */ export interface FilterInfoGroup extends FilterInfoNode { /** * Array of inner filter Infos */ filterInfos: FilterInfoNode[]; } /** * Property data interface that holds all the necessary configuration * of a query property (column) */ export interface PropertyData { /** * Id of the entity property that represents this column */ entityProperty: Cmf.Foundation.BusinessObjects.EntityTypeProperty; /** * Full path to the entity property */ entityPropertyPath: EntityPropertyJoin[]; /** * Display name of the property on the column options */ entityPropertyDisplayName: string; /** * Alias of the property */ entityPropertyAlias: string; /** * Defines if this property is a user attribute */ isUserAttribute: boolean; /** * Position of the property */ position: number; /** * Sorting of this column */ sort: Cmf.Foundation.Common.FieldSort; /** * If this property is a reference property */ isReferenceProperty: boolean; /** * Aggregate function for this column */ aggregateFunction?: Cmf.Foundation.BusinessObjects.QueryObject.Enums.FieldAggregateFunction; /** * Display style for this field */ displayStyle?: Cmf.Foundation.BusinessObjects.QueryObject.FieldDisplayStyle; /** * Conditional display style for this field */ displayConditionalStyle?: Cmf.Foundation.BusinessObjects.QueryObject.FieldDisplayStyle; } /** * Prefix for conditional styles */ export declare const CONDITIONAl_COLUMN_PREFIX: string; /** * This query service provides a wide range of utility methods for manipulating query objects */ export declare class AdvancedQueryService extends Generic { /** * Generic framework accessor */ private static _generic; /** * Role token used that enabels support for all user roles */ static roleToken: Cmf.Foundation.Security.Role; /** * Role token used that enabels support for all user roles */ static userToken: Cmf.Foundation.Security.User; /** * Get all the filter info nodes from a query. * @param query Query to extract the filters from */ static getQueryFilters(query: Cmf.Foundation.BusinessObjects.QueryObject.QueryObject): Promise; /** * Gets an array of filter nodes from a given filter, including children * @param filter Filter to get the nodes from * @param query the query where we are extracting the filter from */ private static getQueryFilterNodes; /** * Brute-forces the way into the entity type property depending on the available data. * Try it with the propertyName (Area) and if that doesn't work, fallback to try to guess its name (AreaId -> Area). * @param entityTypeName Name of the entity type where the property is from * @param propertyName Name of the property * @returns the entity type property or null if not possible */ private static getEntityTypePropertyByName; /** * Get the options for a given filter * @param filter filter to get the properties from * @param query Query to check for parameters */ private static getParametersOptions; /** * Retrieves the joined path for a given property in an object name/alias * @param objectName Object name where the property is set * @param propertyName Property name * @param objectAlias Object alias where the property is set * @param relations Relations context * @param queryEntityTypeName Base entity type name that marks the end of the path together with the alias * @param queryBaseAlias Base entity alias that marks the end of the path * @param joinType Current property join type * @param pushThis Boolean that considers wether this property should be appended to the path * @param suppressWarning Boolean value that suppresses a warning in case we reached a dead-end while building the path * @returns The path or null in case of failure */ private static getQueryJoinsPath; /** * Handles a path struggle between the source and target of an entity relation, searching for the source entity first. * This is useful when we have no way of telling where we should go to next, and need to try both ways. It will fail with a warning if * no path provided a solution. * @param relation Relation to evaluate * @param relations Relation context where the original relation is set * @param queryEntityTypeName Base entity type name that marks the end of the path together with the alias * @param queryBaseAlias Base entity alias that marks the end of the path * @returns The correct path or null in case of failure */ private static deathMatchRelationEntities; /** * Looks for the relation connection from a given alias and object name * @param objectAlias Object alias to seek * @param objectName Object name to seek * @param relations Relations context to extract from */ private static extractRelationConnection; /** * Converts the filter set were the name is set as a path into a filter info node. * @param filter Filter to convert. * @param queryEntityTypeName Query base entity type name. */ private static pathFilterToFilterInfoNode; /** * This method merges a FilterCollection with the existing filters on a QueryObject. * @param queryObject Query that is going to altered. * @param filterCollection This filter can have fields that require the addition of additional filters such as "Product.Name" on * on a material entity filter. */ static mergeFilterCollectionWithExistingQueryObject(queryObject: Cmf.Foundation.BusinessObjects.QueryObject.QueryObject, filterCollection: Cmf.Foundation.BusinessObjects.QueryObject.FilterCollection): Promise; /** * Set the filter info nodes on a query * @param filtersInfo Filters info nodes to insert * @param initialQuery Query to change * @param keepProperties If false, will not keep the existing query properties */ static setQueryFilters(filtersInfo: FilterInfoNode[], initialQuery: Cmf.Foundation.BusinessObjects.QueryObject.QueryObject, keepProperties?: boolean): Promise; /** * Prepares a query with the relations necessary for this node * @param filterInfoNode Filter info node to prepare the pathing for * @param query Query to insert the path into * @param relationEntities Utility relations context with the target and source entity type names * @param queryEntityTypeName Query base entity type name * @returns The new filter ready for insertion */ private static prepareFilter; /** * Creates a new connection using a relation, if it does not already exist * @param entityTypeName Entity type name the relation is connecting to * @param path Path the relation is connecting to * @param depth Current depth * @param query Query to insert the relation into * @param joinType Type of join for this connection * @param previousPropertyName Previous property connection * @param previousRelationData Previous property relation * @returns The path we connected to, void of the depth */ private static createQueryConnection; /** * Extracts the information data from all relations in a set of filter info nodes. * This method is used to keep the info in memory in case so that for an entity relation we have the target and source entity type names * @param filterInfos Filter info nodes to extract the relation data from * @returns The array of relation info */ private static getFiltersRelationsData; /** * Create a relation on the query based on input * @param relation Relation entity type * @param path Path to this relation * @param depth Depth so far * @param query Query to change * @param joinType Type of join * @param nextJoinType Type of next join * @param targetEntityName Target name * @param sourceEntityName Source name * @param previousRelationData Previous data */ private static createAndConnectRelation; /** * Gets the default query alias of a query * @param query query to get alias from * @returns default query alias */ static getBaseQueryAlias(query: Cmf.Foundation.BusinessObjects.QueryObject.QueryObject): string; /** * Extract the existing properties in a query * @param query Query to extract properties from * @returns An array of property data containing the query properties */ static getQueryProperties(query: Cmf.Foundation.BusinessObjects.QueryObject.QueryObject): Promise; /** * Get a query display style based on name * @param styleName Name of the referenced style * @param query Query where the style should exist * @returns The display style */ private static findDisplayStyleByName; /** * Get a query conditional display style based on name * @param styleName Name of the referenced style * @param query Query where the style should exist * @returns The conditional display style */ private static findConditionalDisplayStyleByName; /** * Set the properties passed as input into the query provided * @param propertiesData array of properties to set * @param initialQuery query to insert the properties into * @param reconstruct If set to true (default) reconstructs the query with no fields (only filters) and only then sets the properties * @returns The updated query */ static setQueryProperties(propertiesData: PropertyData[], initialQuery: Cmf.Foundation.BusinessObjects.QueryObject.QueryObject, reconstructFilters?: boolean): Promise; /** * Creates que query connection path (relations) for a given property path * Does not create the final field/filter for the property, only the path to it * @param path Path to the property * @param query Query to alter * @param baseEntityTypeName Base entity type name of the query * @param relationEntities Utility relation target and source entities to avoid loading from the cache * @returns The reference alias to the start of the path */ private static createQueryConnectionPath; /** * Extracts the information data from all relations in a set of property data. * This method is used to keep the info in memory in case so that for an entity relation we have the target and source entity type names * @param filterInfos Filter info nodes to extract the relation data from * @returns The array of relation info */ private static getColumnsRelationsData; /** * Gets the data for the relations of a given path * @param path Path to find the elements to cache from * @returns The array of relation data for every relation found */ private static getEntityPropertyPathRelationData; /** * Clears all properties in the query * @param query QueryObject to clear */ static clearProperties(query: Cmf.Foundation.BusinessObjects.QueryObject.QueryObject): void; /** * Get a query by id * @param queryId Id of the query to fetch */ static loadQuery(queryId: string): Promise; /** * Gets the default display name for each property by concatenating each name of the path * @param properties Array of properties * @returns string with the display name */ static getDefaultDisplayName(properties: EntityPropertyJoin[]): string; /** * Checks if the property is a reference to other properties * @param property Property to check * @returns true if it is a reference */ static isReferenceProperty(property: Cmf.Foundation.BusinessObjects.EntityTypeProperty): boolean; /** * Return the number of filters on a query * @param query Query to count the filters on * @returns The query filter count */ static countFilters(query: Cmf.Foundation.BusinessObjects.QueryObject.QueryObject): number; /** * Count the number of filters in a filter collection * @param filterCollection Filter collection to count the filters on * @returns The filter collection filter count */ static countFilterCollectionFilters(filterCollection: Cmf.Foundation.BusinessObjects.QueryObject.FilterCollection): number; /** * Utility method to countFilters to count both the filter and it's inner filters * @param filter Filter to count * @returns the count for this filter and inner filters. */ private static countInnerFilters; /** * Get an empty query to feed a new query object * @param entityTypeName name of query base entity type * @returns The empty query */ static getEmptyQuery(entityTypeName: string): Promise; /** * Gets the entity property join from a dot connected path * @param entityTypeName entity type name where the path begins * @param path path string to the property * @returns Entity property join path */ static propertyPathToEntityPropertyJoinPath(entityTypeName: string, path: string): Promise; /** * Recursive function that builds a string path into an entity property join * @param entityTypeName Name of the entity type for the next property * @param path remainder path */ private static getEntityTypePropertyPathByString; /** * Converts the entity property join array into a dot separated string to represent the path * @param path entity property path string */ static entityPropertyJoinToPath(path: EntityPropertyJoin[]): string; /** * Runs over a tree of filter info nodes and extracts only the filter infos, disregarding the nodes and grouping * @param filterInfoNodes Filter info nodes to iterate and extract from * @returns The relevant filter infos */ static getFilterInfosFromNodes(filterInfoNodes: FilterInfoNode[]): FilterInfo[]; /** * Restores the entity, transforming the source object into a proper business object * @param query Query that originated the source objects * @param sourceObjects Source object to restore * @returns A promise to the restored object */ static restoreQueryEntity(query: Cmf.Foundation.BusinessObjects.QueryObject.QueryObject, sourceObject: any): Promise; /** * Restores the entities, transforming the source objects into an array of proper business objects * @param query Query that originated the source objects * @param sourceObjects Source objects to restore * @returns A promise to an array of restored objects */ static restoreQueryEntities(query: Cmf.Foundation.BusinessObjects.QueryObject.QueryObject, sourceObjects: any[]): Promise; static setEntityProperty(instance: Cmf.Foundation.BusinessObjects.Entity, properties: EntityPropertyJoin[], value: string, index?: number): void; /** * Builds an empty entity shell for a given entity, creating the required references for each path * @param entityTypeName Name of the base entity type * @param properties Array of property paths to set */ static buildEntityShell(entityTypeName: string, properties: EntityPropertyJoin[][]): Promise; /** * Sets the path from an array of entity properties * @param shell Object to alter and build the shell on * @param properties Properties to set * @param index Index of the property being processed (recursive stop condition) */ private static buildShell; /** * Deceive the filters that reference this optional parameter by setting them to always true * @param query Query to change * @param parameter Parameter to look for */ static deceiveQueryParameterFilters(filterCollection: Cmf.Foundation.BusinessObjects.QueryObject.FilterCollection, parameter: Cmf.Foundation.BusinessObjects.QueryObject.QueryParameter): void; /** * Deceive the filters that reference this optional parameter by setting them to always true * @param query Query to change * @param parameterCollection Parameter to look for */ static fillQueryFiltersByParameters(query: Cmf.Foundation.BusinessObjects.QueryObject.QueryObject, parameterCollection: Cmf.Foundation.BusinessObjects.QueryObject.QueryParameterCollection): Promise; /** * Method used to delete all of the objects that only have the default shell values */ private static deleteEmptyEntityNullId; }