Interface FilterAttributeInterface

The FilterAttributeInterface interface is a FilterItemInterface to elect part instances from their string attributes metadata.

This FilterItemInterface selects part instances based on their string attributes or their parent string attributes (as defined in Documents). Each part instance is considered to have the union between their own attributes and the attributes of its genealogy (parent, grand-parent, etc ...) : the joined attribute set.

The list of attributes and their types is available through the getDictionary function.

The FilterAttributeInterface defines 2 sets of string values : two search attribute sets:

  • exact search attribute set.
  • full text search attribute set.

This FilterItemInterface selects part instances having a string attribute inside their joined attribute set whose value :

  • setExactValues : is exactly inside the exact search attribute set (an item in the exact search attribute set is exactly the value of the attribute).
  • or setContainsValues : contains at least one of the values (full text search) of the full text search attribute set.

If the given attribute has only a limited number of possible values across the DMU (less than 1024), and its values are not too large, then such a string attribute is enumerable (see isEnumerable). If an attribute is enumerable, then the special value N/A (not applicable) is available and selected as default (hasNaValueAvailable, setNaValueActivated, setNaValueChecked). The special value N/A selects all other part instances than the union of all possible values of such a string attribute. Due to this special handling and implementation details, using the N/A value is not compatible with using the setContainsValues function. Moreover, the N/A value is not available if the FilterAttributeInterface is used inside a FilterCompoundInterface. Any FilterAttributeInterface on an enumerable attribute has hasNaValueAvailable true. The hasNaValueAvailable is updated only on a setAttributeName call.
The FilterAttributeInterface has also a boolean property telling if the N/A value should be handled (setNaValueActivated, hasNaValueActivated) in order to use or discard the N/A value if the given attribute is enumerable. The hasNaValueActivated boolean property is not changed when setAttributeName is called. The hasNaValueActivated is true as default.
If you want to use the setContainsValues function, you will have to make a setNaValueActivated(false); call.
Finally, the FilterAttributeInterface has an internal property telling to use the N/A value if it is available (setNaValueChecked, isNaValueChecked), this internal property is only changed on a setNaValueChecked call, but isNaValueChecked will return true only if hasNaValueActivated, hasNaValueAvailable and this internal property are true. This internal property is true as default.

In the case of a setContainsValues call, the search attribute set is a full text search. It is case insensitive and allows the use of wildcards symbols :

  • ? replaces one and only one character,
  • * replaces any number of characters (by default, the engine prefixes and postfixes the search with *)
  • $ prevents the default addition of the prefix or postfix * wildcard (if $ is positioned at the beginning of the text, no * prefix added; if $ is positioned at the end, no * postfix added). This allows to make queries like : gets all the part instances whose type begins by "electrical" ($electrical). Please see 3djuump infinite literal and search query language for more information about using special characters.

The FilterAttributeInterface interface is created through the createFilterAttribute.

The FilterAttributeInterface has the type FT_ATTRIBUTE (getFilterType).

The FilterAttributeInterface has a depth contribution of 2.

/**
* Sample to illustrate :
* Select electrical `part instances` which were plugged on the 01/01/2020.
* Test : create three filters directly in a [[FilterSolverInterface]] and put them in intersection.
*/
import {
AttributesDictionaryInterface, AttributeInfoInterface, AttributeType, DataSessionInterface,
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", "history.date" and "history.state" 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('history.date');
// make sure the attribute is a date one
console.assert((lAttributeInfo !== undefined) && (lAttributeInfo.getAttributeType() === AttributeType.ATTR_DATE));

lAttributeInfo = lAttributeDictionary.getAttributeInfo('history.state');
// make sure the attribute is a string one
console.assert((lAttributeInfo !== undefined) && (lAttributeInfo.getAttributeType() === AttributeType.ATTR_STRING));

// create the electrical filter
const lElectricalFilter : FilterAttributeInterface = lDataSession.createFilterAttribute();
// type set to electrical (exactly)
lElectricalFilter.setAttributeName('type');
lElectricalFilter.setExactValues(['electrical']);
// warning : n/a is set to true as default, we do not want to include other `part instances`
lElectricalFilter.setNaValueChecked(false);
// useless, FilterOperator.FO_UNION is the default operator when creating a new filter (and it will be the first one)
// lElectricalFilter.setFilterOperator(FilterOperator.FO_UNION);

const lDateFilter : FilterRangeInterface = lDataSession.createFilterRange();
// work on "date" metadata
lDateFilter.setAttributeName('history.date');
// create a range
{
const lDateRange : FilterRangeItemInterface = lDateFilter.createFilterRangeItem();
// we want to include the lower bound in the query, but exclude the upper bound (it is the next day !!!)
lDateRange.setIncludedLower(true);
lDateRange.setIncludedUpper(false);
const lExpectedDate : number = Date.UTC(2020, 0, 1, 0, 0, 0, 0);
const lExpiredDate : number = lExpectedDate + 24 * 3600 * 1000;

// range between the 1st of january and the end of the first of january
lDateRange.setLowerBound(lExpectedDate);
lDateRange.setUpperBound(lExpiredDate);
}
// intersection is the way to go since intersection of type electrical and instances with the given state at the given time
lDateFilter.setFilterOperator(FilterOperator.FO_INTERSECTION);

// create the state filter
const lStateFilter : FilterAttributeInterface = lDataSession.createFilterAttribute();
// type set to plugged (exactly)
lStateFilter.setAttributeName('history.state');
lStateFilter.setExactValues(['plugged']);
/// warning : n/a is set to true as default, we do not want to include other `part instances`
lStateFilter.setNaValueChecked(false);
// intersection is the way to go since intersection of type electrical and instances with the given state at the given time
lStateFilter.setFilterOperator(FilterOperator.FO_INTERSECTION);

// add the filters inside the FilterSolverInterface
// push back (-1) the electrical filter
lFilterSolver.insertFilter(-1, lElectricalFilter);
// push back (-1) the date filter, as it is the second one, its operator is used and therefore
// intersection is used
lFilterSolver.insertFilter(-1, lDateFilter);
// push back (-1) the state filter, as it is the third one, its operator is used and therefore
// intersection is used
lFilterSolver.insertFilter(-1, lStateFilter);

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

Please refer to Available Filters for a list of other [FilterItemInterfaces](FilterItemInterface.html).
Metadata/Filters

See

Hierarchy

Methods

  • Adds a value in the full text search attribute set.

    Elects all the part instances having the attribute whose name set with setAttributeName in their joined attribute set that have a value that contains at least one of the values in the given string array.

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

    Do not forget to call update to trigger a recomputation of the changed filters when you have done all your changes.

    Making this call is not legal if hasNaValueActivated and hasNaValueAvailable return true. In this case, the call is disregarded (the FilterAttributeInterface is left unchanged) and returns false.

    Returns

    true if the FilterAttributeInterface is updated.

    Parameters

    • pValue: string
      in
      The value to add in the full text search attribute set.

    Returns boolean

  • 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

  • Adds a value in the exact search attribute set.

    Elects all the part instances having the attribute whose name set with setAttributeName in their joined attribute set that have a value in the exact search attribute set.

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

    Do not forget to call update to trigger a recomputation of the changed filters when you have done all your changes.

    Parameters

    • pValue: string
      in
      The exact value to add in the exact search attribute set.

    Returns void

  • Gets the name of the attribute to filter with.

    Returns

    The name of the attribute to use.

    Returns string

  • Gets a copy of the full text search attribute set.

    Parameters

    • pFullTextValuesOut: string[]
      out
      The array that will be the copy of the full text search attribute set.

    Returns void

  • Gets the depth contribution of the FilterItemInterface.

    This value is usually one.

    Returns

    The depth contribution of the FilterItemInterface.

    Returns number

  • Gets a copy of the exact search attribute set.

    Parameters

    • pExactValuesOut: string[]
      out
      The array that will be the copy of the exact search attribute set.

    Returns void

  • 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

  • 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 the N/A value handling should be used if available.

    This boolean property tells if the N/A value should be handled in order to use or discard the N/A value if the given attribute is enumerable. The hasNaValueActivated boolean property is not changed when setAttributeName is called.

    The hasNaValueActivated is true as default.

    This call returns the internal property : it is legal that hasNaValueAvailable returns false and hasNaValueActivated returns true.

    NB : this does not include necessarily part instances with a N/A value, setNaValueChecked(true) should be called in order to include part instances with the N/A value.

    Returns

    true if the N/A value handling is activated.

    Returns boolean

  • Tells if the N/A value is available.

    The N/A value is available if setAttributeName is called with an attribute that has isEnumerable true.

    This property is updated only on a setAttributeName call.

    Returns

    true is the filter has the NA value available.

    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

  • Tests if a value is in the full text search attribute set.

    Returns

    true if pValue is in the full text search attribute set.

    Parameters

    • pValue: string
      in
      The value to query.

    Returns boolean

  • Tests if a value is in the exact search attribute set.

    Returns

    true if pValue is in the exact search attribute set.

    Parameters

    • pValue: string
      in
      The value to query.

    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

  • Tells if the N/A value is included in the exact search attribute set.

    The FilterAttributeInterface has an internal property that tells to include part instances with the N/A value if if is available (setNaValueChecked), but isNaValueChecked will return true if and only if hasNaValueActivated, hasNaValueAvailable and this internal property are true.
    This internal property is not reset on a setAttributeName call.

    It is legal to make setNaValueChecked(true) but isNaValueChecked returns false.

    This internal property is true as default.

    Returns

    true if the N/A value is included in the exact search attribute set.

    Returns boolean

  • Removes a value from the full text search attribute set.

    Elects all the part instances having the attribute whose name set with setAttributeName in their joined attribute set that have a value that contains at least one of the values in the given string array.

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

    Do not forget to call update to trigger a recomputation of the changed filters when you have done all your changes.

    Making this call is not legal if hasNaValueActivated and hasNaValueAvailable return true. In this case, the call is disregarded (the FilterAttributeInterface is left unchanged) and returns false.

    Returns

    true if the call is legal and such a value was found in the full text search attribute set and therefore the FilterAttributeInterface was modified.

    Parameters

    • pValue: string
      in
      The value to remove from the full text search attribute set.

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

    Returns boolean

  • Removes a value from the exact search attribute set.

    Elects all the part instances having the attribute whose name set with setAttributeName in their joined attribute set that have a value exactly included in the exact search attribute set.

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

    Do not forget to call update to trigger a recomputation of the changed filters when you have done all your changes.

    Returns

    true if such a value was found in the exact search attribute set and therefore the FilterAttributeInterface was modified.

    Parameters

    • pValue: string
      in
      The exact value to remove from the search attribute set.

    Returns boolean

  • Sets the name of the attribute to filter with.

    Calling this function with the same attribute name that was set previously does nothing and returns true. If the attribute name is changed and valid, this function will clear any values previously set by setExactValues, setContainsValues.
    Calling this function with an unknown attribute, or an attribute that does not have a string value is illegal. In that case, the FilterAttributeInterface is left unchanged and false is returned. Please refer to the getDictionary to get the list of available attributes and their types.

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

    A FilterAttributeInterface has an empty (invalid) attribute name by default.

    Returns

    true if the new attribute name was set and legal.

    Parameters

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

    Returns boolean

  • Sets the full text search attribute set.

    Elects all the part instances having the attribute whose name set with setAttributeName in their joined attribute set that have a value that contains at least one of the values in the given string array.

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

    Do not forget to call update to trigger a recomputation of the changed filters when you have done all your changes.

    Making this call is not legal if hasNaValueActivated and hasNaValueAvailable return true. In this case, the call is disregarded (the FilterAttributeInterface is left unchanged) and returns false.

    If the call is legal, there is no check to make sure the new search attribute set is different from the former search attribute set. In this case, the FilterAttributeInterface is modified and recomputed even if the search attribute set is not modified.

    Returns

    true if the FilterAttributeInterface is updated.

    Parameters

    • pValues: string[]
      in
      The full text acceptable values.

    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 exact search attribute set.

    Elects all the part instances having the attribute whose name set with setAttributeName in their joined attribute set that have a value exactly included in the given string array.

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

    Do not forget to call update to trigger a recomputation of the changed filters when you have done all your changes.

    There is no check to make sure the new search attribute set is different from the former search attribute set. In this case, the FilterAttributeInterface is modified and recomputed even if the search attribute set is not modified.

    Parameters

    • pValues: string[]
      in
      The exact acceptable values.

    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

  • Enables/disables the N/A value handling if it is available.

    This boolean property tells if the N/A value should be handled (hasNaValueActivated) in order to use or discard the N/A value if the given attribute is enumerable. The hasNaValueActivated boolean property is not changed when setAttributeName is called.

    The hasNaValueActivated is true as default.

    Remember that If you want to use the setContainsValues function, you will have to make a {@link setNaValueActivated | setNaValueActivated(false);} call.

    NB : this does not include necessarily part instances with a N/A value, setNaValueChecked(true) should be called in order to include part instances with the N/A value.

    Parameters

    • pEnabled: boolean
      in
      If true, enables the special N/A value handling.

    Returns void

  • Includes/removes the N/A value in the exact search attribute set.

    Sets if part instances with the N/A value should be included in the FilterAttributeInterface.

    The FilterAttributeInterface has an internal property that tells to include part instances with the N/A value if if is available, this call updates this internal property, but isNaValueChecked will return true if and only if hasNaValueActivated, hasNaValueAvailable and this internal property are true.
    This internal property is not reset on a setAttributeName call.

    It is legal to make setNaValueChecked(true) but isNaValueChecked returns false.

    This internal property is true as default.

    Returns true if the call will change the content of the FilterAttributeInterface, e.g. calling setNaValueChecked when hasNaValueActivated or hasNaValueActivated is false will return false.

    Returns

    true if the FilterAttributeInterface is updated.

    Parameters

    • pChecked: boolean
      in
      Tells if the N/A value should be included/removed in the exact search attribute set.

    Returns boolean