Skip to content

Commit 88ec218

Browse files
committed
Finish updating the query mapper section
1 parent a226120 commit 88ec218

File tree

1 file changed

+42
-32
lines changed

1 file changed

+42
-32
lines changed

source/plugin-querymap.rst

Lines changed: 42 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -198,34 +198,41 @@ The second step would be to filter the incoming query tree
198198
by the prefix using the **Query.getPrefixedTree(...)** method, than map it to Cayenne Expressions,
199199
and finally join the obtained expressions with the Expression.andExp() method.
200200

201+
202+
.. raw:: latex
203+
204+
\newpage
205+
201206
Query Mapping Library
202207
--------------------------
203208

204-
As a part of Java node software, a Query Mapper implementation is provided.
205-
It is able to map incoming query trees into cayenne Expression objects.
206-
Query Mapper implementation is a part of **vamdctap-querymapper** library,
207-
represented by two interfaces and two generic implementations within a package
208-
*org.vamdc.tapservice.querymapper*
209+
As a part of the Java Node software, a Query Mapper library (**vamdctap-querymapper**) is provided.
210+
It is able to map the incoming query trees into cayenne Expression objects.
211+
Two interfaces and generic implementations within a package
212+
*org.vamdc.tapservice.querymapper* are provided:
209213

210214

211-
* **KeywordMapper** interface defining an interface of RestrictExpression mapper;
212-
* **KeywordMapperImpl** generic implementation, providing one-to-one mapping of
213-
Restrictable keywords to database fields without value transformation.
214-
In many cases node plugin may use extensions of this class, implementing value translation,
215-
to-many fields mapping or prefix-conditional mapping.
216-
217-
* **QueryMapper** interface defining the library main interface;
218-
* **QueryMapperImpl** generic implementation, keeping references to KeywordMappers
219-
and responsible for mapping parsed query trees to Cayenne Expressions. Boolean logic operations
220-
between nodes are translated one-to-one with Cayenne andExp, orExp and notExp, KeywordMappers are
221-
called for each RestrictExpression encountered.
222-
223-
Using QueryMapper library
215+
* **KeywordMapper** defining an interface of a RestrictExpression mapper;
216+
* **KeywordMapperImpl** a generic implementation, providing one-to-one mapping of
217+
Restrictable keywords to the database fields. No value transformation is performed.
218+
The node plugin may extend this class to implement the value translation,
219+
one-to-many fields mapping, or even the prefix-conditional mapping.
220+
221+
* **QueryMapper** defining the library main interface;
222+
* **QueryMapperImpl** providing a generic implementation.
223+
That implementation keeps the references to all the defined **KeywordMapper** instances.
224+
It is capable of mapping the parsed query trees to Cayenne Expressions.
225+
Boolean logic of **LogicNode** tree is translated one-to-one
226+
by using the Apache Cayenne **Expression** *andExp()*, *orExp()* and *notExp()*.
227+
For leaf nodes the registered **KeywordMapper** instances are called
228+
to translate the **RestrictExpression** into the Cayenne Expression objects.
229+
230+
Using the querymapper library
224231
++++++++++++++++++++++++++++++++++
225-
From the plugin side work with the mapper library is performed the following way:
232+
From the plugin point of view the mapper library is used in the following way:
226233

227-
* In some class we initialize a static variable QueryMapper,
228-
in constructor adding keyword mappers for each keyword supported by the node::
234+
* A static instance of QueryMapper is initialized.
235+
For each supported Restrictable keyword a new mapper is added::
229236

230237

231238
public final static QueryMapper queryMapper= new QueryMapperImpl(){{
@@ -236,17 +243,20 @@ From the plugin side work with the mapper library is performed the following way
236243
);
237244
}};
238245
239-
Here subsequent calls to **addNewPath** method define cayenne relations path
240-
originating from different primary tables, both used for mapping.
241-
The first call is for species query, the second for processes.
242-
243-
* Own extensions of KeywordMapperImpl may be implemented to add the possibility to map
244-
keywords to multiple fields, translate values from query units to database units, or
245-
add any other specific handling.
246+
To define the database relations paths originating from different primary tables,
247+
subsequent calls to **addNewPath** method are used.
248+
Here for example the first path originates from the Species table, the second one
249+
originates from the Processes.
250+
251+
* If the advanced mapping is necessary, the class **KeywordMapperImpl**
252+
may be extended. Extension classes may add for example a possibility to map
253+
keywords to multiple fields, translate values from query units to database units.
246254

247-
* QueryMapper automatically keeps a list of Restrictable keywords supported by node,
248-
it can be fetched using **public Collection<Restrictable> getRestrictables();** method.
255+
* The **QueryMapper** implementation automatically handles a list of
256+
Restrictable keywords supported by the node.
257+
That list may be fetched by the **public Collection<Restrictable> getRestrictables()** method.
249258

250-
* From XSAMS builder methods **mapAliasedTree(...)** or **mapTree(...)** methods are called to construct
251-
Cayenne Expressions from incoming query trees or filtered subtrees.
259+
* The mapping of the incoming query trees or filtered subtrees is performed using
260+
the **QueryMapper** methods **mapAliasedTree(...)** or **mapTree(...)**.
261+
Cayenne **Expression** objects are produced as the output.
252262

0 commit comments

Comments
 (0)