@@ -33,101 +33,112 @@ would map into the tree
33
33
.. image :: img/queryTree.png
34
34
35
35
36
- Tree objects
37
- ---------------------
38
-
39
- Following objects are representing the incoming query tree
36
+ QueryParser library interface
37
+ -----------------------------
40
38
39
+ The QueryParser libary provides an interface *org.vamdc.tapservice.vss2. * **Query **
40
+ providing several methods to access the incoming query elements.
41
41
42
42
.. _query :
43
43
44
44
Query
45
45
++++++++++++
46
46
47
- Main interface of the query parser library,
48
- provides access to the query tree and few utility methods.
47
+ The methods to access the incoming query elements are:
48
+
49
49
50
50
* **public LogicNode getRestrictsTree() **
51
51
is the main method, returning the root of the query tree.
52
52
53
- Accompanying are two methods, **getFilteredTree ** and **getPrefixedTree **, returning subsets of tree .
53
+ Accompanying are two methods, **getFilteredTree ** and **getPrefixedTree **, returning the subsets .
54
54
55
55
* **public LogicNode getFilteredTree(Collection<Restrictable> allowedKeywords) **
56
- returns a subtree containing only keywords listed in collection passed as a parameter.
56
+ returns a subtree containing only the keywords present in the collection
57
+ that is passed as a parameter.
57
58
58
59
* **public LogicNode getPrefixedTree(VSSPrefix prefix, int index) **
59
- returns a subtree containing only keywords having the defined prefix and index.
60
- If *null * is passed as a prefix, returned tree would only contain nodes without any prefix.
60
+ returns a subtree containing only the keywords having the prefix and index that are passed to the method .
61
+ If *null * is passed as a prefix, returned tree would only contain nodes that have a * null * prefix.
61
62
62
63
* **public Collection<Prefix> getPrefixes() **
63
- returns a collection of prefixes present in the query
64
+ returns a collection of prefixes that are present in the query
64
65
65
66
* **public List<RestrictExpression> getRestrictsList() **
66
- is the most dummy method, returning a list of all keywords specified in the query.
67
- Using that list as a main source for query mapping is discourages since it leads to the loss of logic.
68
-
67
+ returns a list of all the keywords that are present in the query.
68
+ The logic of relations between the elements is lost.
69
69
70
- In ** getFilteredTree() ** and ** getPrefixedTree() ** the filtering algorithm removes the irrelevant RestrictExpression
71
- objects from LogicNodes, then removes logicNodes that has no children.
70
+ LogicNode
71
+ +++++++++++++++++
72
72
73
- For example, in case of filtering by the prefix:
73
+ The *LogicNode * interface represents a node of the query tree.
74
+ **getOperator() ** method provides access to the node operator (**OR **, **AND **, **NOT **),
75
+ **getValues() ** returns a collection of child nodes.
74
76
75
- * Original query::
77
+ For the single-value operators like **NOT **, the **getValue() ** method may be used to obtain
78
+ the child element directly.
76
79
77
- select ALL where reactant1.AtomSymbol='C' and reactant1.AtomIonCharge=1
78
- and reactant2.AtomSymbol='H' and reactant2.AtomIonCharge=-1 and EnvironmentTemperature > 100
79
80
80
- * Effective query for getPrefixedTree(VSSPrefix.REACTANT, 1)::
81
+ RestrictExpression
82
+ +++++++++++++++++++++
81
83
82
- select ALL where reactant1.AtomSymbol='C' and reactant1.AtomIonCharge=1
84
+ The leaf nodes of the logic tree are implementing the RestrictExpression interface,
85
+ representing the query expressions.
83
86
84
- * Effective query for getPrefixedTree(VSSPrefix.REACTANT, 2)::
87
+ The *RestrictExpression * interface is the extension of the *LogicNode * interface
88
+ providing the **getOperator() **, **getValues() ** and **getValue() ** methods,
89
+ as well as few additional methods:
85
90
86
- select ALL where reactant2.AtomSymbol='H' and reactant2.AtomIonCharge=-1
87
-
88
- * Effective query for getPrefixedTree(null, 0)::
91
+ * **public Prefix getPrefix() ** a method returning the prefix used in the expression.
89
92
90
- select ALL where EnvironmentTemperature > 100
91
-
92
- * Effective query for getFilteredTree() with a collection containing only AtomSymbol::
93
+ * **public Restrictable getColumn() ** a method returning the Restrictable keyword
94
+ used by the expression.
93
95
94
- select ALL where reactant1.AtomSymbol='C' and reactant2.AtomSymbol='H'
95
96
97
+ Prefix
98
+ +++++++++++++
96
99
97
- LogicNode
98
- +++++++++++++++++
100
+ Prefix is a simple class, keeping the ** VSSPrefix ** keyword of the dictionary,
101
+ plus an integer index of the prefix.
99
102
100
- LogicNode interface represents a node of the query tree.
101
- **getOperator() ** method provides access to the node operator,
102
- **getValues() ** returns a collection of child nodes.
103
+ * **int getIndex() ** method provides access to the index, and
103
104
104
- For certain operators like **NOT **, **getValue() ** method also makes sense, returning a single
105
- child element.
105
+ * **VSSPrefix getPrefix() ** gives access to the prefix name.
106
106
107
+ .. raw :: latex
107
108
108
- RestrictExpression
109
- +++++++++++++++++++++
109
+ \newpage
110
110
111
- RestrictExpression elements are the leafs of the logic tree, representing the actual query restriction keywords.
111
+ Filtering logic
112
+ ----------------
112
113
113
- Same as the LogicNode, RestrictExpression provides **getOperator() **, **getValues() ** and **getValue() ** methods,
114
- plus
114
+ The algorithm implemented for the **getFilteredTree() ** and **getPrefixedTree() ** methods of the
115
+ :ref: `query ` interface works the following way:
116
+ It removes the irrelevant RestrictExpression objects from LogicNodes,
117
+ than removes the Nodes of the tree that have no child expression elements.
115
118
116
- * ** public Prefix getPrefix() ** method, returning this expression prefix
119
+ For example, in the case of filtering by the prefix:
117
120
118
- * **public Restrictable getColumn() ** method, returning a restriction keyword from the dictionary
119
- for this expression
121
+ * Original query::
120
122
123
+ select ALL where reactant1.AtomSymbol='C' and reactant1.AtomIonCharge=1
124
+ and reactant2.AtomSymbol='H' and reactant2.AtomIonCharge=-1 and EnvironmentTemperature > 100
121
125
122
- Prefix
123
- +++++++++++++
126
+ * Effective query for getPrefixedTree(VSSPrefix.REACTANT, 1)::
124
127
125
- Prefix is a simple class, keeping **VSSPrefix ** from the dictionary
126
- and integer index of the prefix.
128
+ select ALL where reactant1.AtomSymbol='C' and reactant1.AtomIonCharge=1
127
129
128
- * **int getIndex() ** method provides access to index, and
130
+ * Effective query for getPrefixedTree(VSSPrefix.REACTANT, 2)::
131
+
132
+ select ALL where reactant2.AtomSymbol='H' and reactant2.AtomIonCharge=-1
133
+
134
+ * Effective query for getPrefixedTree(null, 0)::
135
+
136
+ select ALL where EnvironmentTemperature > 100
137
+
138
+ * Effective query for getFilteredTree(Collection<Restrictable>{AtomSymbol}) with a collection containing only the AtomSymbol element::
139
+
140
+ select ALL where reactant1.AtomSymbol='C' and reactant2.AtomSymbol='H'
129
141
130
- * **VSSPrefix getPrefix() ** gives access to the prefix name.
131
142
132
143
133
144
.. _QueryMap :
0 commit comments