Changeset 7915

Feb 24, 2021, 8:24:44 AM (2 years ago)
Nicklas Nordborg

References #2237: Implement extension mechanism for query filtering

Added information to the documentation.

1 edited


  • trunk/doc/src/docbook/developer/extensions.xml

    r7548 r7915  
    24922492    </sect2>
     2494    <sect2 id="extensions_developer.query_filters">
     2495      <title>Query filters</title>
     2497      <para>
     2498        This extension point makes it possible to extend filtering
     2499        functionality for queries that are generated by list pages via the
     2500        <methodname>ItemContext.configureQuery()</methodname> method in the
     2501        <classname docapi="net.sf.basedb.core">ItemContext</classname> class.
     2503        Actions should implement the <interfacename
     2504        docapi="net.sf.basedb.core.query">QueryFilterAction</interfacename>
     2505        interface. This interface allows an extension to filter a query based
     2506        on a single column filter, a filter row or a combination of everything.
     2507      </para>
     2509      <para>
     2510        Note that the <methodname>ActionFactory.prepareContext()</methodname> is
     2511        called for all filter extensions at all times. It is recommended that
     2512        the implementation checks the current context for the type of items in the
     2513        list and if there is a filter in a column that the extension should handle.
     2514        An extension may override the default implementation of any filter, but this
     2515        is not recommended. The recommended design is to combine the filter
     2516        extension with a custom column that uses the <code>!x.</code> prefix
     2517        as the column id. Here is an example from the Variant Search extension
     2518        (<ulink url=""
     2519        ></ulink>):
     2520      </para>
     2522      <programlisting language="java">
     2524public boolean prepareContext(InvokationContext<? super QueryFilterAction> context)
     2526   // Enabled in the RAWBIOASSAY list page
     2527   // and if the !x.lucene column is present with a filter
     2528   // and if the service database is running
     2529   ItemContext ctx = context.getClientContext().getCurrentItem();
     2530   return ctx.getItemType() == Item.RAWBIOASSAY &&
     2531      ctx.hasExtensionFilter("lucene") &&
     2532      VarSearchService.getInstance().isRunning();
     2538    </sect2>
    24942540    <sect2 id="extensions_developer.login-manager">
    24952541      <title>Login manager</title>
Note: See TracChangeset for help on using the changeset viewer.