Debian Codegraph @

gavo/resources/inputs/__system__/pql.rd

raw
1 <resource schema="dc" resdir="__system">
2 <meta name="description">Helper objects for the support of the VO's
3 ad-hoc "parameter query language" as used in various DAL protocols.
4 </meta>
5
6 <procDef id="coneParameter" type="phraseMaker">
7 <doc>
8 A parameter containing a cone search with a single position-like
9 key (the first, expecting a coordinate pair fairly leniently) and
10 a cone search (a float, in the second input key).
11
12 The generated expression uses pgsphere.
13 </doc>
14
15 <setup>
16 <par name="posCol" description="Name of the database column
17 to be compared against the input value(s). It must be of
18 type spoint."/>
19 </setup>
20
21 <code>
22 try:
23 posKey = inputKeys[0].name
24 sizeKey = inputKeys[1].name
25 except IndexError:
26 raise base.ValidationError("Operator error: the cone condition"
27 " is lacking input keys.", "query")
28 parsedPos = pql.PQLPositionPar.fromLiteral(
29 inPars.get(posKey, None), posKey)
30 size = inputKeys[1]._parse(inPars.get(sizeKey, None))
31 if parsedPos is not None and size is not None:
32 yield parsedPos.getConeSQL(posCol, outPars, size)
33 </code>
34 </procDef>
35
36 <procDef id="dateParameter">
37 <doc>
38 A parameter constraining an epoch or similar.
39 </doc>
40
41 <setup>
42 <par name="consCol" description="Name of the database column
43 constrained by the input value."/>
44 <par name="consColKind" description="The kind of date specification
45 of consCol; this can be timestamp (also good for dates), jd, mjd,
46 or jy (julian year).">"timestamp"</par>
47 </setup>
48
49 <code>
50 inputKey = inputKeys[0]
51 if consColKind=="timestamp":
52 convertTo = None
53 else:
54 convertTo = consColKind
55
56 key = inputKey.name
57 parsed = pql.PQLDatePar.fromLiteral(inPars.get(key, None), key)
58 if parsed is not None:
59 yield parsed.getSQL(consCol, outPars, convertTo)
60 </code>
61 </procDef>
62
63 <procDef id="floatParameter">
64 <setup>
65 <par name="consCol" description="Name of the database column
66 constrained by the input value."/>
67 </setup>
68
69 <code>
70 key = inputKeys[0].name
71 parsed = pql.PQLFloatPar.fromLiteral(inPars.get(key, None), key)
72 if parsed is not None:
73 yield parsed.getSQL(consCol, outPars)
74 </code>
75 </procDef>
76
77 <procDef id="stringParameter">
78 <doc>
79 A parameter that constrains a string-valued column. Matches
80 are literal and case-sensitive; the collation (for ranges)
81 is that given by the database. Steps are not allowed.
82 </doc>
83
84 <setup>
85 <par name="consCol" description="Name of the database column
86 constrained by the input value."/>
87 </setup>
88
89 <code>
90 key = inputKeys[0].name
91 parsed = pql.PQLStringPar.fromLiteral(inPars.get(key, None), key)
92 if parsed is not None:
93 yield parsed.getSQL(consCol, outPars)
94 </code>
95 </procDef>
96
97 <procDef id="irStringParameter">
98 <doc>
99 A parameter that constrains a string-valued column, where both
100 the column values and the search value are interpreted as
101 document vectors and compared according to the information retrieval
102 functions of Postgres -- i.e., more or less like google matches
103 queries.
104
105 Since it is hard to figure out what they could mean, neither
106 steps nor ranges are supported.
107 </doc>
108
109 <setup>
110 <par name="consCol" description="Name of the database column
111 constrained by the input value."/>
112 </setup>
113
114 <code>
115 key = inputKeys[0].name
116 parsed = pql.PQLTextParIR.fromLiteral(inPars.get(key, None), key)
117 if parsed is not None:
118 yield parsed.getSQL(consCol, outPars)
119 </code>
120 </procDef>
121
122
123 <!-- For lack of a better place: Descriptors of the standard DALI parameters
124 vodal-based services interpret. -->
125
126 <NXSTREAM id="DALIPars">
127 <doc>
128 This stream includes the standard DALI service parameters
129 (RESPONSEFORMAT, MAXREC, VERB). For services available through
130 IVOA-standard protocols (renderers scs.xml, siap.xml, ssap.xml,
131 and also api), this is included automatically, so you will
132 not usually have to manually FEED this.
133 </doc>
134 <inputKey name="responseformat" type="text"
135 ucd="meta.code.mime"
136 tablehead="Output Format"
137 description="File format requested for output."
138 multiplicity="single" std="True">
139 <property key="notForRenderer">form</property>
140 <property key="std">1</property>
141 <preparse>
142 return input and input.lower()
143 </preparse>
144 <values>
145 <LOOP>
146 <codeItems>
147 from gavo import formats
148 for key in formats.iterFormats():
149 yield {"item": formats.getMIMEFor(key).lower(),
150 "title": formats.getLabelFor(key)}
151 for alias in formats.getAliasesFor(key):
152 yield {"item": alias.lower(),
153 "title": "Alias for %s"%formats.getLabelFor(key)}
154 </codeItems>
155 <events>
156 <option title="\\title">\\item</option>
157 </events>
158 </LOOP>
159 </values>
160 </inputKey>
161
162 <inputKey name="maxrec" type="integer"
163 tablehead="Match limit"
164 description="Maximum number of records returned. Pass 0 to
165 retrieve service parameters."
166 multiplicity="single" std="True">
167 <property key="notForRenderer">form</property>
168 <property key="std">1</property>
169 </inputKey>
170
171 <inputKey name="verb" type="integer"
172 tablehead="Verbosity"
173 description="Exhaustiveness of column selection. VERB=1 only
174 returns the most important columns, VERB=2 selects the columns
175 deemed useful to the average user, VERB=3 returns a table
176 with all available columns."
177 multiplicity="single" std="True">
178 <property key="notForRenderer">form</property>
179 <values>
180 <option title="terse">1</option>
181 <option title="normal">2</option>
182 <option title="everything">3</option>
183 </values>
184 </inputKey>
185
186 </NXSTREAM>
187
188 <NXSTREAM id="DALIUpload">
189 <doc>
190 This stream includes a DALI UPLOAD parameter. This is purely
191 declarative for now, as the interpretation is done anyway
192 for VO renderers and not at all otherwise.
193 </doc>
194
195 <inputKey name="UPLOAD" type="text"
196 multiplicity="multiple"
197 tablehead="Upload"
198 description="DALI-style upload; this is essentially &lt;name>,&lt;spec>,
199 where name is a regular SQL identifier and spec a URL or param:Foo.
200 In the latter case, give a file upload in a parameter named Foo.">
201 </inputKey>
202 </NXSTREAM>
203
204 </resource>