Package com.orchestranetworks.schema

# Interface TableRefFilterContext

All Superinterfaces:
  `DependenciesDefinitionContext`, `SchemaNodeContext`

public interface TableRefFilterContext extends DependenciesDefinitionContext
Provides methods for setting up a `TableRefFilter` in the context of its data model.

See Also:
  - `SchemaFacetTableRef`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `addFilterErrorMessage(String anErrorMessage)`
  Adds a static non-localized error message to this filter.
  `void`
  `addFilterErrorMessage(String anErrorMessage, Locale aLocale)`
  Adds a static localized error message to this filter.
  `void`
  `setFilterForSearch(String anXPathPredicate)`
  Specifies an XPath filter that will be applied in the user interface to perform a search on the associated foreign key field.
  `void`
  `setFilterValidationMessage(UserMessageLocalized aUserMessage)`
  Sets a static validation message on this filter.
  `void`
  `setPrefilter(String anXPathPredicate)`
  Specifies an XPath filter that will be applied before evaluating `TableRefFilter.accept(Adaptation, ValueContext)`.

  ### Methods inherited from interface com.orchestranetworks.schema.DependenciesDefinitionContext

  `addDependencyToInsertAndDelete, addDependencyToInsertAndDelete, addDependencyToInsertAndDeleteInOtherInstance, addDependencyToInsertAndDeleteInOtherInstance, addDependencyToInsertDeleteAndModify, addDependencyToInsertDeleteAndModify, addDependencyToInsertDeleteAndModifyInOtherInstance, addDependencyToInsertDeleteAndModifyInOtherInstance, addDependencyToInsertDeleteAndModifyInOtherInstance, addDependencyToInsertDeleteAndModifyInOtherInstance, addDependencyToModify, addDependencyToModify`

  ### Methods inherited from interface com.orchestranetworks.schema.SchemaNodeContext

  `addError, addError, addInfo, addMessage, addWarning, getSchemaNode`

- ## Method Details

  - ### addFilterErrorMessage

    void addFilterErrorMessage(String anErrorMessage, Locale aLocale)
    Adds a static localized error message to this filter. This localized error message will be displayed to the end user at validation time if a record is not accepted by this filter.
    Throws:
      `IllegalStateException` - if a validation message has already been set using the method `setFilterValidationMessage(UserMessageLocalized)`.
    See Also:
      - `addFilterErrorMessage(String)`

  - ### addFilterErrorMessage

    void addFilterErrorMessage(String anErrorMessage)
    Adds a static non-localized error message to this filter. This error message will be used by default and will be displayed to the end user at validation time if no error messages are defined for a given locale.
    Throws:
      `IllegalStateException` - if a validation message has already been set using the method `setFilterValidationMessage(UserMessageLocalized)`.
    See Also:
      - `addFilterErrorMessage(String, Locale)`

  - ### setFilterValidationMessage

    void setFilterValidationMessage(UserMessageLocalized aUserMessage)
    Sets a static validation message on this filter. This message will be displayed to the end user at validation time if a record is not accepted by this filter.

    This method also allows specifying the severity of the message added at validation time if a record is not accepted by this filter.

    Throws:
      `IllegalStateException` - if a default or localized error message has already been set using the method `addFilterErrorMessage(String)` or `addFilterErrorMessage(String, Locale)`.
    See Also:
      - `TableRefFilter.getValidationMessage(com.onwbp.adaptation.Adaptation, com.orchestranetworks.instance.ValueContext)`

  - ### setFilterForSearch

    void setFilterForSearch(String anXPathPredicate)
    Specifies an XPath filter that will be applied in the user interface to perform a search on the associated foreign key field. The result displayed in the combo-box used to perform a search in the user interface will only include the records which satisfy the specified filter.
    Throws:
      `IllegalArgumentException` -
      - if the specified predicate is `null`;
      - if the specified predicate contains contextual criterion (such as `${../aField}`);
      - if the specified predicate is invalid.
    Since:
      5.8.1

  - ### setPrefilter

    void setPrefilter(String anXPathPredicate)
    Specifies an XPath filter that will be applied before evaluating `TableRefFilter.accept(Adaptation, ValueContext)`. The prefilter
    - must be consistent with `TableRefFilter.accept(Adaptation, ValueContext)`, i.e., it must evaluate to true for all records where the `accept` method returns `true`.
    - may not use parameters.
    - should be selective, i.e., it should evaluate to true only for a relatively small part of the records of the table where the filter is applied on.
    - should be "index-friendly" for best performance, i.e., it should be evaluated using indexes only. This can be checked by activating the debug level of the request log and executing the request created by `SchemaFacetTableRef.getTableRefRequest(Adaptation)`. The logged physical plan should have a Lucene scan operation with a filter corresponding to the specified prefilter.

    The prefilter is applied in all contexts except for the advanced search, where `setFilterForSearch(String)` has to be used. The prefilter predicate may use contextual values, as defined in the supported XPath syntax.

    Throws:
      `IllegalArgumentException` -
      - if the specified predicate is `null`;
      - if the specified predicate contains a contextual criterion (such as `${../aField}`);
      - if the specified predicate is invalid.
    Since:
      6.2
    See Also:
      - `PrefilteredAdaptationFilter`