QuerySearch Metamodel
The QuerySearch can be modeled using the elements in the QuerySearch metamodel. To retain backwards compatibility, when adding the option enableQuerySearch
to a DataElement
, the expanders will implicitly create an instance of the QuerySearch
element linked to that DataElement
and has the name of the DataElement
. This will generate the QuerySearch in mostly the same way as version 1.x did.
QuerySearch element
The QuerySearch
element is linked to a DataElement
. This means that it is possible to create more than one QuerySearch implementation for a single DataElement
.
Like DataElement
, XML model files for QuerySearch
elements are stored in a folder under the Component
's model
folder, with the name querySearchs
. Similarly, the name of the QuerySearch
will also be the name of the file.
Let's say we wish to create a QuerySearch
with name MyFirst
, for the element Example
in component examples
, the file will be as follows:
Path: <sourceBase>/components/examples/model/querySearchs/MyFirst.xml
<querySearch name="MyFirst">
</querySearch>
This will generate files such as the QuerySearch
class as <dataElement.packageName>.query.MyFirstQuerySearch
and the QueryFilter
as <dataElement.packageName>.query.MyFirstQueryFilter
.
QuerySearch
To avoid databases returning differently ordered results in between queries on the same dataset, this option will automatically append an ordering constraint that orders ascending on the id
field.
This functionality can be especially important when dealing with pagination of data.
<options>
<useDefaultOrder/>
</options>
QueryFilterField element
It is possible to model the fields in a QuerySearch
's QueryFilter
class. To this end there is a QueryFilterField
element to model these fields. The types of these fields are defines as regular ValueTypes.
Fields are defined in the XML model file of the QuerySearch
instance itself. The field types can be defined either in an expander bundle's data resources or directly under the component model in the queryFilterFieldTypes
folder as its own file.
In the following example two fields are added to the QuerySearch
instance:
<querySearch name="MyFirst">
<fields>
<field name="name">
<type name="String">
</field>
<field name="someReference">
<type name="DataRef">
</field>
</fields>
</querySearch>