Interface FilterRangeInterface

The FilterRangeInterface interface is a FilterItemInterface to elect part instances that have a numeric/date metadata inside or that intersects a fixed set of ranges.

The filter range interface works on metadata of type :

The type of the metadata is given by the getAttributeType from the AttributesDictionaryInterface once the DMU is loaded.

This interface allows to create range items FilterRangeItemInterface to allow the creation of an union of ranges, to be tested against a value or another range (be it numeric or a date).

The API only exposes numbers. Indeed, date types must be converted to a number : dates must be expressed as number of milliseconds since January 1, 1970, 00:00:00 UTC, dates must be converted with the use of the getTime functions, and created or modified with the Date constructor from a number (the number of milliseconds since January 1, 1970, 00:00:00 UTC) or with the setTime function. Negative values are accepted.

Suppose the user wants to get all part instances that are created between yesterday and the current date time. The relevant part instances have the metadata CreationDate with the ATTR_DATE type :

/** 
* Sample to illustrate how to use a FilterRangeInterface with dates.
*/
import {
FilterSolverInterface,
AttributesDictionaryInterface, AttributeInfoInterface,
AttributeType, FilterRangeItemInterface,
ConfContextInterface, VisibilityContextInterface, FilterSolverInterfaceSignal, tListenerCallback, FilterRangeInterface, DataSessionInterface,
} from 'generated/documentation/appinfiniteapi';

// the DataSessionInterface has been created previously and is connected
let lDataSession : DataSessionInterface;
// we will try to find all `part instances` that have
// a "CreationDate" between today and yesterday
const lPartInstanceName : string = 'CreationDate';

// what to do when result has been computed ?
let onResultReady : tListenerCallback;

/* MAKE SURE the attribute "CreationDate" is relevant */
const lAttributeDictionary : AttributesDictionaryInterface = lDataSession.getAttributesDictionary();
const lAttributeInfo : AttributeInfoInterface | undefined = lAttributeDictionary.getAttributeInfo(lPartInstanceName);
// make sure the attribute is a date one
console.assert((lAttributeInfo !== undefined) && (lAttributeInfo.getAttributeType() === AttributeType.ATTR_DATE));

/* FILTERING CONTEXT / CONF CONTEXT */
// create the resolution chain :
// create a filtering context "unconfigured"
// first create ConfContextInterface "unconfigured"
const lConfCtx : ConfContextInterface = lDataSession.createConfContext();
// and create the filtering context and bind it to the unconfigured ConfContextInterface
const lConfVisibilityCtx: VisibilityContextInterface = lDataSession.createVisibilityContext();
lConfVisibilityCtx.setConfContext(lConfCtx);

/* SOLVER */
// create the solver to retrieve the result
const lGlobalSolver : FilterSolverInterface = lDataSession.createFilterSolver();
lGlobalSolver.setVisibilityContext(lConfVisibilityCtx);
// we want to retrieve `geometric instance ids` and `part instance ids` on the solver
lGlobalSolver.setRetrievePartInstanceIds(true);
// bind the solver to custom implementation when the result is ready
lGlobalSolver.addEventListener(FilterSolverInterfaceSignal.SolverReady, onResultReady);

/* RANGE FILTER */
// create the today time
const lToday : Date = new Date();
// yesterday is today minus 24 hours
const lYesterday : Date = new Date();
// 1000 ms in a sec, 3600 secs in an hour, 24 hours in a day
const lMillisecondsInADay : number = 24 * 3600 * 1000;
lYesterday.setTime(lToday.getTime() - lMillisecondsInADay);
// we may have used lYesterday = new Date(lToday.getTime() - lMillisecondsInADay);

// create a range filter
const lRangeFilter : FilterRangeInterface = lDataSession.createFilterRange();
// useless, FilterOperator.FO_UNION is the default operator when creating a new filter
// lRangeFilter.setFilterOperator(FilterOperator.FO_UNION);

// on the given attribute
lRangeFilter.setAttributeName(lPartInstanceName);
// and add a range to test ([yesterday, today] included)
const lRangeFilterContent : FilterRangeItemInterface = lRangeFilter.createFilterRangeItem();
// include lower bound
lRangeFilterContent.setIncludedLower(true);
// include upper bound
lRangeFilterContent.setIncludedUpper(true);
// set the lower bound as yesterday (Dates must be expressed as number of milliseconds since January 1, 1970, 00:00:00 UTC)
lRangeFilterContent.setLowerBound(lYesterday.getTime());
// set the upper bound to today (Dates must be expressed as number of milliseconds since January 1, 1970, 00:00:00 UTC)
lRangeFilterContent.setUpperBound(lToday.getTime());

// add the filter to the solver
lGlobalSolver.insertFilter(0, lRangeFilter);
// and go => make the DataSessionInterface compute the result
lDataSession.update();

This interface MUST be used in a [FilterSolverInterface](FilterSolverInterface.html), which in turn should refer to a valid [VisibilityContextInterface](VisibilityContextInterface.html) (see Filtering Context).
Metadata/Filters

See

FilterRangeItemInterface

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 name of the attribute to filter with.

    Returns

    The name of the attribute to filter with.

    Returns string

  • Gets the depth contribution of the FilterItemInterface.

    This value is usually one.

    Returns

    The depth contribution of the FilterItemInterface.

    Returns number

  • Gets a deep copy of the internal data of the FilterItemInterface.

    Returns

    The internal FilterItemInterface data.

    Returns any

  • Gets the identifier of the FilterItemInterface.

    Returns

    The identifier of the FilterItemInterface.

    Returns string

  • Gets the range item at index pRangeIndex.

    If pRangeIndex is negative or superior or equal to the number of range items, this function does nothing and returns undefined.

    Returns

    The given FilterRangeItemInterface (this is the actual data held by the FilterRangeInterface, and not a copy) if pRangeIndex is valid else return undefined.

    Parameters

    • pRangeIndex: number
      in
      Index of the range item to get.

    Returns undefined | FilterRangeItemInterface

  • Gets the list of all range items.

    This function should not be used to add or remove range items, the FilterRangeInterface will not see the modifications if the array is modified.

    However, modifying items inside the array is allowed.

    Returns

    warning
    all range items inside the FilterRangeInterface.

    Returns FilterRangeItemInterface[]

  • 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

  • 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](FilterRangeInterface.html#addEventListener) that you want to remove.

    Returns boolean

  • Removes the range item at the position pRangeIndex.

    If pRangeIndex is negative or superior or equal to the number of range items, this function does nothing and returns false. Returns true if the item is effectively removed.

    Returns

    true if the item was removed else return false.

    Parameters

    • pRangeIndex: number
      in
      Index of the range item to remove.

    Returns boolean

  • Sets the name of the attribute to filter with.

    Using an unknown attribute name or an invalid attribute type (only ATTR_NUMBER, ATTR_DATE ATTR_NUMBER_RANGE and ATTR_DATE_RANGE types are accepted) will return false and leave the FilterRangeInterface unchanged.

    Setting the same attribute name will return true and leave the FilterRangeInterface unchanged.

    Setting a valid and new attribute name will clear the ranges that may have previously created by createFilterRangeItem.

    Use addEventListener on the event FilterDataChanged to know when the filter data is changed.

    Returns

    true if pAttributeName refers to an existing and valid attribute.

    Parameters

    • pAttributeName: string
      in
      The name of the attribute to filter.

    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 content of the FilterItemInterface from a former call to getFilterData.

    Use addEventListener on the event FilterDataChanged to know when the FilterItemInterface internal data changed.

    Returns

    true if the data is set.

    Parameters

    • pFilterData: any
      in
      Internal FilterItemInterface data to set.

    Returns boolean

  • 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