Interface FilterCompoundInterface

The FilterCompoundInterface interface is a very specialized FilterSetInterface.

A FilterCompoundInterface is a combination of metadata filters ((FilterAttributeInterface, FilterRangeInterface, FilterHasFieldInterface, FilterBooleanInterface)) that works on individual metadata documents and not on the joined attribute set (see Available Filters).

Only FilterAttributeInterface, FilterRangeInterface, FilterHasFieldInterface and FilterBooleanInterface may be included in a FilterCompoundInterface by insertFilter.

The FilterItemInterfaces are combined with their operators, but are all matched against the SAME metadata document.

Any empty FilterCompoundInterface is valid and is represented by all the part instances and all the geometric instances.

The FilterCompoundInterface interface is created through the createCompoundFilter.

The FilterCompoundInterface has the type FT_COMPOUND (getFilterType).

The FilterCompoundInterface has a depth contribution of 1 + Maximum depth contribution of each included FilterItemInterface.

/**
* Sample to illustrate :
* Select electrical `part instances` whose replacement date is within the next 10 days (we assume we are the 26th of jan 2021).
* Test : create two filters in a [[FilterCompoundInterface]] and put them in intersection.
*/
import {
AttributesDictionaryInterface, AttributeInfoInterface, AttributeType, DataSessionInterface,
FilterCompoundInterface, FilterRangeItemInterface, FilterSolverInterface, FilterAttributeInterface, FilterOperator, FilterRangeInterface,
} from 'generated/documentation/appinfiniteapi';

// the DataSessionInterface has been created previously and is connected
let lDataSession : DataSessionInterface;

// The Filter Solver has been created previously, its filtering context has been set
let lFilterSolver : FilterSolverInterface;

// MAKE SURE the attributes "type" and "replacement" are relevant */
const lAttributeDictionary : AttributesDictionaryInterface = lDataSession.getAttributesDictionary();
let lAttributeInfo : AttributeInfoInterface | undefined = lAttributeDictionary.getAttributeInfo('type');
// make sure the attribute is a string one
console.assert((lAttributeInfo !== undefined) && (lAttributeInfo.getAttributeType() === AttributeType.ATTR_STRING));

lAttributeInfo = lAttributeDictionary.getAttributeInfo('replacement');
// make sure the attribute is a date one
console.assert((lAttributeInfo !== undefined) && (lAttributeInfo.getAttributeType() === AttributeType.ATTR_DATE));

// create the electrical filter
const lElectricalFilter : FilterAttributeInterface = lDataSession.createFilterAttribute();
// type set to electrical (exactly)
lElectricalFilter.setAttributeName('type');
lElectricalFilter.setExactValues(['electrical']);
// the filter will be used inside a [[FilterCompoundInterface]], N/A cannot be used (limitation on [[FilterCompoundInterface]])
// lElectricalFilter.setNaValueChecked(false);
// useless, FilterOperator.FO_UNION is the default operator when creating a new filter
// lElectricalFilter.setFilterOperator(FilterOperator.FO_UNION);

const lReplacementFilter : FilterRangeInterface = lDataSession.createFilterRange();
// work on "replacement" metadata
lReplacementFilter.setAttributeName('replacement');
// create a range
{
const lRepRange : FilterRangeItemInterface = lReplacementFilter.createFilterRangeItem();
// we want to include the bounds in the query
lRepRange.setIncludedLower(true);
lRepRange.setIncludedUpper(true);
const lCurrentTime : number = Date.now();
const lCurrentTimePlus10Days : number = lCurrentTime + 10 * 24 * 3600 * 1000;
// range between now and 10 days
lRepRange.setLowerBound(lCurrentTime);
lRepRange.setUpperBound(lCurrentTimePlus10Days);
}
// intersection is the way to go since intersection of type electrical and instances that should be replaced within the next 10 days
lReplacementFilter.setFilterOperator(FilterOperator.FO_INTERSECTION);

const lCompoundFilter : FilterCompoundInterface = lDataSession.createCompoundFilter();
// useless, FilterOperator.FO_UNION is the default operator when creating a new filter
// lCompoundFilter.setFilterOperator(FilterOperator.FO_UNION);

// add the filters inside the FilterCompoundInterface
// push back (-1) the electrical filter
lCompoundFilter.insertFilter(-1, lElectricalFilter);
// push back (-1) the replacement filter, as it is the second one, its operator is used and therefore
// intersection is used
lCompoundFilter.insertFilter(-1, lReplacementFilter);

// and add the compound filter
lFilterSolver.insertFilter(-1, lCompoundFilter);

// and tell the DataSessionInterface to update the modified FilterSolverInterfaces
lDataSession.update();

.
Metadata/Filters

See

Hierarchy

Methods

  • Adds a listener to an event type.

    When an event of the type pType fires, the callback pListener will be called. This function returns a unique string id that may be used in removeEventListenerById to allow simple listener removal. It is possible to add an object that will be included in the callback to avoid creating too many closures.

    Returns

    The id of the inserted callback (actually an UUID).

    Parameters

    • pType: string
      in
      The type of the event pListener will be called upon.
    • pListener: tListenerCallback
      in
      The listener function that fires when the given event type occurs.
    • pObject: undefined | Object
      in
      The optional object the callback will be called with when the given event fires.

    Returns string

  • Adds a listener to an event type.

    When an event of the type pType fires, the callback pListener will be called. This function returns a unique string id that may be used in removeEventListenerById to allow simple listener removal.

    Returns

    The id of the inserted callback (actually an UUID).

    Parameters

    • pType: string
      in
      The type of the event pListener will be called upon.
    • pListener: tListenerCallback
      in
      The listener function that fires when the given event type occurs.

    Returns string

  • Gets the depth contribution of the FilterItemInterface.

    This value is usually one.

    Returns

    The depth contribution of the FilterItemInterface.

    Returns number

  • Gets the identifier of the FilterItemInterface.

    Returns

    The identifier of the FilterItemInterface.

    Returns string

  • Gets the order of the FilterItemInterface represented by the given identifier.

    Returns

    The order of the FilterItemInterface in the solver, or -1 if not found.

    Parameters

    • pFilterId: string
      in
      The identifier of the [FilterItemInterface](FilterItemInterface.html) to query.

    Returns number

  • Tells if the EventDispatcher has such a callback registered for the given event type.

    Returns

    true if such a listener is installed for the given type of event.

    Parameters

    • pType: string
      in
      The type of the event to test.
    • pListener: tListenerCallback
      in
      The listener function that gets tested.

    Returns boolean

  • Tells if this object has been gotten rid off.

    Returns

    true if dispose has been called on this object.

    Returns boolean

  • Tells if the FilterItemInterface is enabled.

    If disabled, this FilterItemInterface is completely ignored during all the computations (the behavior is the same as if it had not been created).

    A FilterItemInterface is enabled by default.

    Returns

    true if the FilterItemInterface is enabled.

    Returns boolean

  • Tells if the FilterItemInterface is "inverted".

    When "inverted", a FilterItemInterface elects all the part instances that were not selected if it was not inverted.

    A FilterItemInterface is not "inverted" by default.

    Returns

    true if such a FilterItemInterface is "inverted".

    Returns boolean

  • Changes the order of the given FilterItemInterface in the container list by its filter id.

    Orders number must be in the range of existing orders i.e. [0,getFilterCount()-1].

    Returns

    true if the FilterItemInterface was found and changed.

    Parameters

    • pFilterId: string
      in
      The identifier of the [FilterItemInterface](FilterItemInterface.html) to move.
    • pOrder: number
      in
      The new order of the [FilterItemInterface](FilterItemInterface.html).

    Returns boolean

  • Removes a listener from an event type.

    If no such listener is found, then the function returns false and does nothing. You must use the exact parameters that were used in addEventListener to actually remove the listener.

    Returns

    true if the callback was removed else false.

    Parameters

    • pType: string
      in
      The type of the listener that gets removed.
    • pListener: tListenerCallback

      The listener function that gets removed.

    • pObject: undefined | Object

      The listener object that was used when addEventListener was called.

    Returns boolean

  • Removes a listener from an event type.

    If no such listener is found, then the function returns false and does nothing. You must use the exact parameters that were used in addEventListener to actually remove the listener.

    Returns

    true if the callback was removed else false.

    Parameters

    • pType: string
      in
      The type of the listener that gets removed.
    • pListener: tListenerCallback

      The listener function that gets removed.

    Returns boolean

  • Removes a listener by its id.

    If no such listener is found, then the function returns false and does nothing. You must use the return value of addEventListener to actually remove the listener.

    Returns

    true if the callback was removed else false.

    Parameters

    • pId: string
      in
      The id returned by the call to [addEventListener](FilterCompoundInterface.html#addEventListener) that you want to remove.

    Returns boolean

  • Sets the FilterItemInterface enabled/disabled status.

    If disabled, this FilterItemInterface is completely ignored during all the computations (the behavior is the same as if it had not been created). Use addEventListener on the event FilterEnabledChanged to know when the FilterItemInterface has changed its enabled status.

    A FilterItemInterface is enabled by default.

    Parameters

    • pEnabled: boolean
      in
      If true, the given FilterItemInterface is enabled.

    Returns void

  • Sets the identifier of the FilterItemInterface. Make sure the id is unique. A unique FilterItemInterface identifier is created if the identifier is not overridden.

    Parameters

    • pFilterId: string
      in
      The new identifier of the FilterItemInterface.

    Returns void

  • Sets the "inverted" status of the FilterItemInterface.

    When "inverted", a FilterItemInterface elects all the part instances that were not selected if it was not inverted. Use addEventListener on the event FilterInvertedChanged to know when the FilterItemInterface has changed its "inverted" status.

    A FilterItemInterface is not "inverted" by default.

    Parameters

    • pInverted: boolean
      in
      If true, such a FilterItemInterface will be "inverted".

    Returns void