projects/netgrif-components-core/src/lib/search/models/category/case/case-process.ts
NoConfigurationAutocompleteCategory
constructor(operators: OperatorService, logger: LoggerService, _optionalDependencies: OptionalDependencies)
|
||||||||||||
|
Parameters :
|
| Protected _uniqueOptionsMap |
Type : Map<string | Set<string>>
|
| Protected _options$ |
Type : BehaviorSubject<Array<SearchAutocompleteOption<Array<T>>>>
|
|
Inherited from
AutocompleteCategory
|
|
Defined in
AutocompleteCategory:31
|
| Protected _optionsMap |
Type : Map<string | Array<T>>
|
|
Inherited from
AutocompleteCategory
|
|
Defined in
AutocompleteCategory:29
|
|
Autocomplete categories usually require a map to represent mapping of display names of their options to objects that are needed to construct their queries. You are not required to use this map when you implement your own Category, but it comes with helpful functions and might save you some time. See options() and addToMap(). |
| Protected _generatedPredicate$ |
Type : BehaviorSubject<ElementaryPredicate | undefined>
|
|
Inherited from
Category
|
|
Defined in
Category:70
|
|
Emit a new |
| Protected _operandsFormControls |
Type : Array<FormControl>
|
|
Inherited from
Category
|
|
Defined in
Category:49
|
|
Stores the |
| Protected _operandsFormControls$ |
Type : ReplaySubject<Array | undefined>
|
|
Inherited from
Category
|
|
Defined in
Category:54
|
|
Contains the |
| Protected Readonly _OPERATOR_INPUT |
Type : ConfigurationInput
|
|
Inherited from
Category
|
|
Defined in
Category:75
|
|
Utility variable that can be used as value for the configurationInputs$ |
| Protected _operatorFormControl |
Type : FormControl
|
|
Inherited from
Category
|
|
Defined in
Category:44
|
|
Contains the The category can subscribe to it if it wishes to react to the selection change by the user. |
| Protected _operatorTemplate$ |
Type : BehaviorSubject<Array | undefined>
|
|
Inherited from
Category
|
|
Defined in
Category:59
|
|
Contains the operator template parts that make up the operands GUI. |
| Protected _trackByIdGenerator |
Type : IncrementingCounter
|
|
Inherited from
Category
|
|
Defined in
Category:64
|
|
Generates IDs for template parts supplied to ng for. |
| Public Readonly translationPath |
Type : string
|
|
Inherited from
Category
|
|
Defined in
Category:91
|
|
path to the translation string
|
| Protected createOptions |
createOptions()
|
|
Inherited from
AutocompleteCategory
|
|
Defined in
AutocompleteCategory:47
|
|
Returns :
void
|
| destroy |
destroy()
|
|
Inherited from
Category
|
|
Defined in
Category:39
|
|
Returns :
void
|
| duplicate |
duplicate()
|
|
Inherited from
Category
|
|
Defined in
Category:118
|
|
Returns :
CaseProcess
|
| Protected generateQuery | ||||||
generateQuery(userInput: Array
|
||||||
|
Inherited from
Category
|
||||||
|
Defined in
Category:102
|
||||||
|
Parameters :
Returns :
Query
|
| Protected isUniqueOption | ||||||||||||
isUniqueOption(key: string, value: string)
|
||||||||||||
|
Checks whether the provided option is unique and updates the list of unique options with it.
Parameters :
Returns :
boolean
|
| Public loadFromPfqlExpression | ||||||
loadFromPfqlExpression(expression: SimpleExpression)
|
||||||
|
Inherited from
Category
|
||||||
|
Defined in
Category:63
|
||||||
|
Parameters :
Returns :
Observable<void>
|
| serializeClass |
serializeClass()
|
|
Inherited from
Category
|
|
Defined in
Category:122
|
|
Returns :
Categories | string
|
| Protected createConfigurationFilterTextSegments |
createConfigurationFilterTextSegments()
|
|
Inherited from
Category
|
|
Defined in
Category:47
|
|
Returns :
Array<FilterTextSegment>
|
| getActiveInputFormControl | ||||||
getActiveInputFormControl(inputIndex: number)
|
||||||
|
Inherited from
NoConfigurationAutocompleteCategory
|
||||||
|
Defined in
NoConfigurationAutocompleteCategory:40
|
||||||
|
Parameters :
Returns :
FormControl
|
| Protected addToMap | ||||||||||||
addToMap(key: any, value: T)
|
||||||||||||
|
Inherited from
AutocompleteCategory
|
||||||||||||
|
Defined in
AutocompleteCategory:130
|
||||||||||||
|
Adds a new entry or pushes value into an existing entry. When a new entry is created, it is created as an Array of one element.
Parameters :
Returns :
void
|
| Protected createSearchAutocompleteOption | |||||||||
createSearchAutocompleteOption(text: string, value: Array
|
|||||||||
|
Inherited from
AutocompleteCategory
|
|||||||||
|
Defined in
AutocompleteCategory:185
|
|||||||||
|
Parameters :
Returns :
SearchAutocompleteOption<Array<T>>
|
| Protected deserializeOperandValue | ||||||
deserializeOperandValue(text)
|
||||||
|
Inherited from
Category
|
||||||
|
Defined in
Category:171
|
||||||
|
This method throws na error if the serialized value is not one of the autocomplete options.
Parameters :
Returns :
Observable<any>
the deserialized value, that can be set as FormControl value This method throws na error if the serialized value is not one of the autocomplete options. |
| Public filterOptions | ||||||||
filterOptions(userInput: Observable
|
||||||||
|
Inherited from
AutocompleteCategory
|
||||||||
|
Defined in
AutocompleteCategory:109
|
||||||||
|
The function that is used to filter shown options in the autocomplete field. By default the options that start with the input string are returned (case insensitive). By default a new value is emitted, whenever either the user input or the base set of options changes.
Parameters :
Returns :
Observable<Array<SearchAutocompleteOption<Array<T>>>>
options that satisfy the autocomplete condition |
| Protected isOperandValueSelected | ||||||
isOperandValueSelected(newValue: SearchAutocompleteOption
|
||||||
|
Inherited from
Category
|
||||||
|
Defined in
Category:138
|
||||||
|
Parameters :
Returns :
boolean
|
| Protected serializeOperandValue | ||||||
serializeOperandValue(valueFormControl: FormControl)
|
||||||
|
Inherited from
Category
|
||||||
|
Defined in
Category:161
|
||||||
|
Parameters :
|
| Protected transformCategoryValue | ||||||||
transformCategoryValue(value: SearchAutocompleteOption
|
||||||||
|
Inherited from
Category
|
||||||||
|
Defined in
Category:154
|
||||||||
|
Performs a transformation of the The default AutocompleteCategory implementation returns the SearchAutocompleteOption
Parameters :
Returns :
Array | string
the value used for query generation |
| Protected updateOptions |
updateOptions()
|
|
Inherited from
AutocompleteCategory
|
|
Defined in
AutocompleteCategory:85
|
|
Publishes a new value in the _options$ Subject generated from the _optionsMap. The default implementation iterates trough the _optionsMap and creates options with the keys as text and values as value.
Returns :
void
|
| Public clearOperatorSelection |
clearOperatorSelection()
|
|
Inherited from
Category
|
|
Defined in
Category:391
|
|
Deselects the currently selected operator (if any)
Returns :
void
|
| Public createFilterTextSegments |
createFilterTextSegments()
|
|
Inherited from
Category
|
|
Defined in
Category:556
|
|
Returns :
Array<FilterTextSegment>
an Array containing text segments representing the content of the predicate generated by this category |
| Protected createOperandFilterTextSegment | ||||||
createOperandFilterTextSegment(operandIndex: number)
|
||||||
|
Inherited from
Category
|
||||||
|
Defined in
Category:592
|
||||||
|
Parameters :
Returns :
FilterTextSegment
filter text segment representing the operand value at the specified index |
| Protected createOperatorFilterTextSegments |
createOperatorFilterTextSegments()
|
|
Inherited from
Category
|
|
Defined in
Category:575
|
|
Returns :
Array<FilterTextSegment>
an Array containing text segments representing the operators with operands of this category |
| Public generatePredicate | ||||||||
generatePredicate(userInput: Array
|
||||||||
|
Inherited from
Category
|
||||||||
|
Defined in
Category:356
|
||||||||
|
Calls the generateQuery method and creates an ElementaryPredicate with the result. arity of the selected Operator.
Parameters :
Returns :
ElementaryPredicate
Predicate with {@link Query} generated by this object's [generateQuery]{@link Category.generateQuery} method |
| Protected initializeCategory |
initializeCategory()
|
|
Inherited from
Category
|
|
Defined in
Category:448
|
|
This method is calle in the constructor. Apart from calling this method, the constructor only creates instances to fill the protected fields of this class. The default implementation manages creation of operand You can override this method to change the initialization of your category without having to rewrite the base constructor from scratch.
Returns :
void
|
| Public isOperatorSelected |
isOperatorSelected()
|
|
Inherited from
Category
|
|
Defined in
Category:384
|
|
Returns :
boolean
whether an operator is currently selected or not. |
| Protected isSelectedOperator | ||||||||
isSelectedOperator(operatorClass: Type
|
||||||||
|
Inherited from
Category
|
||||||||
|
Defined in
Category:617
|
||||||||
|
Checks for selected operator
Parameters :
Returns :
boolean
boolean of the statement |
| Protected operandValueChanges | ||||||||
operandValueChanges(operandIndex: number)
|
||||||||
|
Inherited from
Category
|
||||||||
|
Defined in
Category:487
|
||||||||
|
The method that is (by default) called whenever an operand
Parameters :
Returns :
void
|
| Public reset |
reset()
|
|
Inherited from
Category
|
|
Defined in
Category:325
|
|
Resets the state of the Category, deselecting any selected category and removing other state information if the Category defines them. This method can be used to reset the state of the category after each predicate constructed, effectively turning the category instance into a predicate builder.
Returns :
void
|
| Public selectDefaultOperator |
selectDefaultOperator()
|
|
Inherited from
Category
|
|
Defined in
Category:367
|
|
Selects the default operator that should be used for query generation, when no Operator selection is provided to the user. The default implementation selects the first operator in the _allowedOperators array. See selectOperator() for more information.
Returns :
void
|
| Public selectOperator | ||||||||
selectOperator(operatorIndex: number)
|
||||||||
|
Inherited from
Category
|
||||||||
|
Defined in
Category:286
|
||||||||
|
Changes the state of the Category. Category can create queries when an Operator is selected. This method is useful if you want to use the Category class as predicate builder. should be selected
Parameters :
Returns :
void
|
| Protected selectOperatorFromPfqlExpression | ||||||||
selectOperatorFromPfqlExpression(expression: SimpleExpression)
|
||||||||
|
Inherited from
Category
|
||||||||
|
Defined in
Category:429
|
||||||||
|
Selects an operator from the category's allowed operators based on the PFQL expression's operator type. This method searches for an operator in the allowed operators array that matches the type specified in the PFQL expression. If a matching operator is found, it is selected. If no match is found, an error is logged.
Parameters :
Returns :
boolean
|
| Public setOperands | ||||||||
setOperands(userInput: Array
|
||||||||
|
Inherited from
Category
|
||||||||
|
Defined in
Category:304
|
||||||||
|
Changes the state of the Category and generates a query if all necessary operands were set. If you are using the category as a builder. Consider using the generatePredicate() method instead. arity of the selected Operator.
Parameters :
Returns :
void
|
| inputPlaceholder |
getinputPlaceholder()
|
import {Query} from '../../query/query';
import {OperatorService} from '../../../operator-service/operator.service';
import {LoggerService} from '../../../../logger/services/logger.service';
import {Equals} from '../../operator/equals';
import {BooleanOperator} from '../../boolean-operator';
import {OptionalDependencies} from '../../../category-factory/optional-dependencies';
import {NoConfigurationAutocompleteCategory} from '../no-configuration-autocomplete-category';
import {NotEquals} from '../../operator/not-equals';
import {Categories} from '../categories';
import {Observable, of, Subscription} from 'rxjs';
import {CaseSearch} from './case-search.enum';
import {ResourceTypeQueryPrefix} from "../resource-type-query-prefix";
import {take, filter, map} from "rxjs/operators";
import {SimpleExpression} from "../../../../pfql/model/simple-expression";
import {SearchInputType} from "../search-input-type";
import {Substring} from "../../operator/substring";
export class CaseProcess extends NoConfigurationAutocompleteCategory<string> {
private static readonly _i18n = 'search.category.case.process';
protected _uniqueOptionsMap: Map<string, Set<string>>;
private _allowedNetsSub: Subscription;
private _destroyed: boolean;
constructor(operators: OperatorService, logger: LoggerService, protected _optionalDependencies: OptionalDependencies) {
super([CaseSearch.PROCESS_IDENTIFIER],
[operators.getOperator(Substring), operators.getOperator(Equals), operators.getOperator(NotEquals)],
`${CaseProcess._i18n}.name`,
logger,
operators,
ResourceTypeQueryPrefix.CASES);
this._uniqueOptionsMap = new Map<string, Set<string>>();
if (!!this._optionalDependencies.ignoreNetsOnAutocompleteCategories) {
this.inputType = SearchInputType.TEXT;
}
}
destroy() {
super.destroy();
if (this._allowedNetsSub && !this._allowedNetsSub.closed) {
this._allowedNetsSub.unsubscribe();
}
this._destroyed = true;
}
protected createOptions(): void {
if (this._destroyed) {
return;
}
this._allowedNetsSub = this._optionalDependencies.allowedNetsService.allowedNets$.subscribe(allowedNets => {
this._optionsMap.clear();
allowedNets.forEach(petriNet => {
if (this.isUniqueOption(petriNet.title, petriNet.identifier)) {
this.addToMap(petriNet.title, petriNet.identifier);
}
});
this.updateOptions();
});
}
public override loadFromPfqlExpression(expression: SimpleExpression): Observable<void> {
if (!this.selectOperatorFromPfqlExpression(expression)) {
return of(undefined);
}
if (this._optionalDependencies.ignoreNetsOnAutocompleteCategories) {
this.setOperands([expression.operandValue]);
return of(undefined);
}
return this._options$.pipe(
filter(options => options.length > 0),
take(1),
map(options => {
const found = options.find(option => option.value.includes(expression.operandValue));
if (found) {
this.setOperands([found] as any);
}
})
);
}
/**
* Checks whether the provided option is unique and updates the list of unique options with it.
* @param key autocomplete option key
* @param value autocomplete option value
* @returns `true` if the option has not yet been checked as unique. `false` if the option has been checked before.
*/
protected isUniqueOption(key: string, value: string): boolean {
if (!this._uniqueOptionsMap.has(key)) {
this._uniqueOptionsMap.set(key, new Set<string>([value]));
return true;
}
if (this._uniqueOptionsMap.get(key).has(value)) {
return false;
} else {
this._uniqueOptionsMap.get(key).add(value);
return true;
}
}
protected generateQuery(userInput: Array<Array<string> | string>): Query {
if (this.selectedOperator.numberOfOperands !== 1) {
throw new Error('Only unary operators are currently supported by the CaseProcess implementation');
}
let operand = userInput[0];
if (!Array.isArray(operand)) {
operand = [operand];
}
const queries = operand.map(id => this.selectedOperator.createQuery(this.pfqlKeywords, [id]));
return Query.combineQueries(queries, BooleanOperator.OR).ensurePrefixAndGet(ResourceTypeQueryPrefix.CASES);
}
get inputPlaceholder(): string {
return `${CaseProcess._i18n}.placeholder`;
}
duplicate(): CaseProcess {
return new CaseProcess(this._operatorService, this._log, this._optionalDependencies);
}
serializeClass(): Categories | string {
return Categories.CASE_PROCESS;
}
}