projects/netgrif-components-core/src/lib/filter/models/filter.ts
Abstraction of backend search requests that defines a limited set of operations on them.
Methods |
|
Accessors |
Protected
constructor(_id: string, _type: FilterType, _title: string, _isPfql: boolean)
|
||||||||||||||||||||
|
If no name is provided the filter will be identified by it's ID when necessary.
Parameters :
|
| Public Abstract addFullTextFields | ||||||
addFullTextFields(fullTextFields: literal type)
|
||||||
|
Adds the full-text fields into filter implementation. It can be later used for a search request
Parameters :
Returns :
void
|
| Public Abstract bodyContainsQuery |
bodyContainsQuery()
|
|
Returns :
boolean
|
| Public Abstract clearFullTextFields |
clearFullTextFields()
|
|
Clears full-text fields
Returns :
void
|
| Public Abstract clone |
clone()
|
|
Creates a deep copy of the filter object.
Returns :
Filter
deep copy of the filter object |
| Public Abstract containsFullTextFields |
containsFullTextFields()
|
|
Returns :
boolean
|
| Protected deepCopy | ||||||||
deepCopy(obj: object)
|
||||||||
|
Creates a deep copy of a simple object.
Parameters :
Returns :
object
a deep copy of the argument |
| Public Abstract getFullTextFields |
getFullTextFields()
|
|
Returns :
literal type
map of full-text fields loaded in the filter |
| Public Abstract getRequestBody |
getRequestBody()
|
|
search request body specified by this filter. Type of the result is determined by the |
| Public getRequestParams |
getRequestParams()
|
|
Returns the necessary request params for the filter. Default implementation returns an empty object. The params are added on top of the request when sending it to the backend by the respective service methods.
Returns :
Params
an empty object |
| Public Abstract merge | ||||||||||||
merge(filter: Filter, operator: MergeOperator)
|
||||||||||||
|
Combines two filters together with the given operator. Library implementation always returns a MergedFilter object instance.
Parameters :
Returns :
Filter
a new filter that is the combination of this filter and the filter passed trough the argument. Library implementation always returns a {@link MergedFilter} object instance. |
| id | ||||||
getid()
|
||||||
|
Unique filter identifier
Returns :
string
|
||||||
setid(id: string)
|
||||||
|
Parameters :
Returns :
void
|
| isPfql | ||||||
getisPfql()
|
||||||
setisPfql(isPfql: boolean)
|
||||||
|
Parameters :
Returns :
void
|
| type |
gettype()
|
|
Determines the type of resource this Filter can filter.
Returns :
FilterType
|
| title |
gettitle()
|
|
Human readable filter title. Defaults to empty string.
Returns :
string
|
import {MergeOperator} from './merge-operator';
import {TaskSearchRequestBody} from './task-search-request-body';
import {CaseSearchRequestBody} from './case-search-request-body';
import {FilterType} from './filter-type';
import {Params} from '../../resources/resource-provider.service';
/**
* Abstraction of backend search requests that defines a limited set of operations on them.
*/
export abstract class Filter {
/**
* If no name is provided the filter will be identified by it's ID when necessary.
* @param _id identifier of the filter
* @param _type type of resources that the filter can query
* @param _title human readable filter name
* @param _isPfql true if the Filter should cooperate with PFQL API
*/
protected constructor(protected _id: string, protected readonly _type: FilterType, protected readonly _title: string = '',
protected _isPfql: boolean = false) {
}
/**
* Unique filter identifier
*/
public get id(): string {
return this._id;
}
public set id(id: string) {
this._id = id;
}
public get isPfql(): boolean {
return this._isPfql;
}
public set isPfql(isPfql: boolean) {
this._isPfql = isPfql;
}
/**
* Determines the type of resource this Filter can filter.
*/
public get type(): FilterType {
return this._type;
}
/**
* Human readable filter title.
*
* Defaults to empty string.
*/
public get title(): string {
return this._title;
}
/**
* Creates a deep copy of the filter object.
* @returns deep copy of the filter object
*/
public abstract clone(): Filter;
/**
* Combines two filters together with the given operator.
* @param filter filter that should be combined with this filter
* @param operator operator that is used to combine the two filters
* @returns a new filter that is the combination of this filter and the filter passed trough the argument.
* Library implementation always returns a {@link MergedFilter} object instance.
*/
public abstract merge(filter: Filter, operator: MergeOperator): Filter;
/**
* @returns search request body specified by this filter. Type of the result is determined by the `type` of the Filter instance.
*/
public abstract getRequestBody():
TaskSearchRequestBody | CaseSearchRequestBody | Array<TaskSearchRequestBody> | Array<CaseSearchRequestBody>;
/**
* @returns `true` if at least one of the filter bodies contains the `query` attribute. Returns `false` otherwise.
*/
public abstract bodyContainsQuery(): boolean;
/**
* Adds the full-text fields into filter implementation. It can be later used for a search request
*/
public abstract addFullTextFields(fullTextFields: {[fieldId: string]: number}): void;
/**
* Clears full-text fields
*/
public abstract clearFullTextFields(): void;
/**
* @returns `true` if the filter contains any full-text field
*/
public abstract containsFullTextFields(): boolean;
/**
* @returns map of full-text fields loaded in the filter
*/
public abstract getFullTextFields(): {[fieldId: string]: number};
/**
* Returns the necessary request params for the filter. Default implementation returns an empty object.
* The params are added on top of the request when sending it to the backend by the respective service methods.
* @returns an empty object `{}`
*/
public getRequestParams(): Params {
return {};
}
/**
* Creates a deep copy of a simple object.
* @param obj object that should be copied
* @returns a deep copy of the argument
*/
protected deepCopy(obj: object): object {
return JSON.parse(JSON.stringify(obj));
}
}