| 1 |
<?xml version="1.0" encoding="utf-8"?> |
| 2 |
|
| 3 |
<resource resdir="__system" schema="dc"> |
| 4 |
<meta name="creationDate">2007-11-22T13:02:00Z</meta> |
| 5 |
<meta name="subject">virtual-observatories</meta> |
| 6 |
<meta name="description">\metaString{site.description}</meta> |
| 7 |
|
| 8 |
<!-- Tables related to resources (this used to be for services exclusively, |
| 9 |
hence the names.) |
| 10 |
|
| 11 |
These have to match whatever is done in gavo.registry; most explanations |
| 12 |
are around there, but quickly: RD+id identify a resource uniquely. |
| 13 |
Publication takes into account the renderer for services; renderer |
| 14 |
is rcdisplay for non-rendered services. |
| 15 |
|
| 16 |
The main reason we're not using foreign keys here is that we need |
| 17 |
to handle deleted records and much of the automatic management |
| 18 |
afforded by foreign keys would work against us here. |
| 19 |
--> |
| 20 |
|
| 21 |
<execute id="backup-system-tables" title="Backup system tables" at="0:20"> |
| 22 |
<job> |
| 23 |
<code> |
| 24 |
if not base.getConfig("db", "dumpsystemtables"): |
| 25 |
return |
| 26 |
|
| 27 |
from gavo import utils |
| 28 |
from gavo.rsc import dumping |
| 29 |
|
| 30 |
with utils.safeReplaced( |
| 31 |
os.path.join( |
| 32 |
base.getConfig("stateDir"), |
| 33 |
"systemtables.dump")) as f: |
| 34 |
dumping.createDump([ |
| 35 |
"//services", |
| 36 |
"//users", |
| 37 |
"//rds", |
| 38 |
"//dc_tables", |
| 39 |
],f) |
| 40 |
</code> |
| 41 |
</job> |
| 42 |
</execute> |
| 43 |
|
| 44 |
<table system="True" id="resources" onDisk="True" |
| 45 |
dupePolicy="overwrite" primary="sourceRD,resId"> |
| 46 |
<meta name="description"> |
| 47 |
The table of published "resources" (i.e., services, tables, |
| 48 |
data collections) within this data center. There are separate |
| 49 |
tables of the interfaces these resources have, their authors, |
| 50 |
subjects, and the sets they belong to. |
| 51 |
|
| 52 |
Manipulate through gavo pub; to remove entries from this table, remove |
| 53 |
the publication element of the service or table in question |
| 54 |
and re-run gavo pub on the resource descriptor. |
| 55 |
</meta> |
| 56 |
|
| 57 |
<column name="sourceRD" type="text" |
| 58 |
tablehead="Source RD" required="True" |
| 59 |
description="Id of the RD (essentially, the inputsDir-relative |
| 60 |
path, with the .rd cut off)."/> |
| 61 |
<column name="resId" type="text" |
| 62 |
tablehead="RD-relative id" displayHint="type=hidden" |
| 63 |
description="Id of the service, data or table within the RD. |
| 64 |
Together with the RD id, this uniquely identifies the resource |
| 65 |
to DaCHS."/> |
| 66 |
<column name="shortName" type="text" |
| 67 |
description="The content of the service's shortName metadata. |
| 68 |
This is not currently used by the root pages delivered with |
| 69 |
DaCHS, so this column essentially is ignored." |
| 70 |
tablehead="Short"/> |
| 71 |
<column name="title" type="text" required="True" |
| 72 |
description="The content of the service's title metadata |
| 73 |
(gavo pub will fall back to the resource's title if |
| 74 |
the service doesn't have a description of its own)."/> |
| 75 |
<column name="description" type="text" |
| 76 |
description="The content of the service's description metadata |
| 77 |
(gavo pub will fall back to the resource's description if |
| 78 |
the service doesn't have a description of its own)."/> |
| 79 |
<column name="owner" type="text" description="NULL for public |
| 80 |
services, otherwise whatever is in limitTo. The root pages delivered |
| 81 |
with DaCHS put a [P] in front of services with a non-NULL owner."/> |
| 82 |
<!-- the dateUpdated column should no longer be used; this is |
| 83 |
superseded by the data_updated column in dc.rdmeta --> |
| 84 |
<column name="dateUpdated" type="timestamp" |
| 85 |
description="Date of last update on the resource itself (i.e., |
| 86 |
run of gavo imp)."/> |
| 87 |
<column name="recTimestamp" type="timestamp" |
| 88 |
description="UTC of gavo publish run on the source RD"/> |
| 89 |
<column name="deleted" type="boolean" required="True" |
| 90 |
description="True if the service is deleted. On deletion, |
| 91 |
services are not removed from the resources and sets tables |
| 92 |
so the OAI-PMH service can notify incremental harvesters that |
| 93 |
a resource is gone."/> |
| 94 |
<column name="ivoid" type="text" description="The full ivo-id of |
| 95 |
the resource. This is usually ivo://auth/rdid/frag but may |
| 96 |
be overridden (but you have to claim an authority for DaCHS to |
| 97 |
publish a record outside of its own auth)."/> |
| 98 |
<column name="authors" type="text" description="Resource authors |
| 99 |
in source sequence"/> |
| 100 |
<column name="rank" type="integer" |
| 101 |
description="The schema-rank of this RD"> |
| 102 |
<values nullLiteral="32767"/> |
| 103 |
</column> |
| 104 |
</table> |
| 105 |
|
| 106 |
<table system="True" id="interfaces" onDisk="True" dupePolicy="overwrite" |
| 107 |
primary="accessURL" namePath="resources"> |
| 108 |
<meta name="description"> |
| 109 |
A table that has "interfaces", i.e., actual URLs under which |
| 110 |
services are accessible. This is in a separate table, as services |
| 111 |
can have multiple interfaces (e.g., SCS and form). |
| 112 |
|
| 113 |
Manipulate through gavo pub; to remove entries from this table, remove |
| 114 |
the publication element of the service or table in question |
| 115 |
and re-run gavo pub on the resource descriptor. |
| 116 |
</meta> |
| 117 |
|
| 118 |
<column original="sourceRD"/> |
| 119 |
<column original="resId"/> |
| 120 |
<column name="accessURL" type="text" description="The URL |
| 121 |
this service with the given renderer can be accessed under."/> |
| 122 |
<column name="referenceURL" type="text" description="The URL |
| 123 |
this interface is explained at. In DaCHS, as in VOResource, |
| 124 |
this column should actually be in dc.resources, but we don't consider |
| 125 |
that wart bad enough to risk any breakage."/> |
| 126 |
<column name="browseable" type="boolean" required="True" |
| 127 |
description="True if this interface can sensibly be operated |
| 128 |
with a web browser (e.g., form, but not scs.xml; browseable |
| 129 |
service interfaces are eligible for being put below the |
| 130 |
'Use this service with your browser' button on the service |
| 131 |
info page."/> |
| 132 |
<column name="renderer" type="text" description="The renderer |
| 133 |
used for this interface."/> |
| 134 |
</table> |
| 135 |
|
| 136 |
<table system="True" id="sets" onDisk="True" |
| 137 |
dupePolicy="overwrite" |
| 138 |
primary="sourceRD, resId, renderer, setName" |
| 139 |
namePath="resources"> |
| 140 |
<meta name="description"> |
| 141 |
A table that contains set membership of published resources. |
| 142 |
For DaCHS, the sets ivo_managed ("publish to the VO") and local |
| 143 |
("show on a generated root page" if using one of the shipped |
| 144 |
root pages) have a special role. |
| 145 |
|
| 146 |
Manipulate through gavo pub; to remove entries from this table, remove |
| 147 |
the publication element of the service or table in question |
| 148 |
and re-run gavo pub on the resource descriptor. |
| 149 |
</meta> |
| 150 |
|
| 151 |
<column original="sourceRD"/> |
| 152 |
<column original="resId"/> |
| 153 |
<column name="setName" type="text" tablehead="Set name" |
| 154 |
description="Name of an OAI set."/> |
| 155 |
<column name="renderer" type="text" description="The renderer |
| 156 |
used for the publication belonging to this set. Typically, |
| 157 |
protocol renderers (e.g., scs.xml) will be used in VO publications, |
| 158 |
whereas form and friends might be both in local and ivo_managed"/> |
| 159 |
<column original="deleted"/> |
| 160 |
</table> |
| 161 |
|
| 162 |
<table system="True" id="subjects" onDisk="True" dupePolicy="check" |
| 163 |
primary="sourceRD, resId, subject" namePath="resources"> |
| 164 |
<meta name="description"> |
| 165 |
A table that contains the subject metadata for published services. It is |
| 166 |
used by the shipped templates of the root pages ("...by subject"). |
| 167 |
|
| 168 |
Manipulate through gavo pub; to remove entries from this table, remove |
| 169 |
the publication element of the service or table in question |
| 170 |
and re-run gavo pub on the resource descriptor. |
| 171 |
</meta> |
| 172 |
|
| 173 |
<column original="sourceRD"/> |
| 174 |
<column original="resId"/> |
| 175 |
<column name="subject" type="text" description="A subject heading. |
| 176 |
Terms should ideally come from the IVOA thesaurus."/> |
| 177 |
</table> |
| 178 |
|
| 179 |
<table system="True" id="authors" dupePolicy="check" |
| 180 |
onDisk="True" primary="sourceRD, resId, author"> |
| 181 |
<meta name="description"> |
| 182 |
A table that contains the (slightly processed) creator.name |
| 183 |
metadata from published services. It is used by the shipped |
| 184 |
templates of the root pages. |
| 185 |
|
| 186 |
Manipulate through gavo pub; to remove entries from this table, remove |
| 187 |
the publication element of the service or table in question |
| 188 |
and re-run gavo pub on the resource descriptor. |
| 189 |
</meta> |
| 190 |
<foreignKey inTable="resources" source="sourceRD,resId"/> |
| 191 |
<column original="resources.sourceRD"/> |
| 192 |
<column original="resources.resId"/> |
| 193 |
<column name="author" type="unicode" |
| 194 |
description="An author name taken from creator.name; DaCHS assumes |
| 195 |
this to be in the form Last, I."/> |
| 196 |
</table> |
| 197 |
|
| 198 |
<table system="True" id="res_dependencies" |
| 199 |
onDisk="True" primary="rd, prereq" dupePolicy="overwrite"> |
| 200 |
<meta name="description">An RD-level map of dependencies, meaning |
| 201 |
that before generating resource records from rd, prereq should |
| 202 |
be imported (think: TAP needs the metadata of all dependent tables). |
| 203 |
|
| 204 |
This is managed by gavo pub and used in the OAI-PMH interface. |
| 205 |
</meta> |
| 206 |
<column name="rd" type="text" description="id of an RD"/> |
| 207 |
<column name="prereq" type="text" description="id of an RD that |
| 208 |
should be imported before records from rd are generated."/> |
| 209 |
<column name="sourceRD" type="text" description="id of the RD |
| 210 |
that introduced this dependency"/> |
| 211 |
</table> |
| 212 |
|
| 213 |
<data id="tables"> |
| 214 |
<meta name="description">gavo imp --system this to create the service |
| 215 |
tables. servicelist has special grammars to feed these.</meta> |
| 216 |
<nullGrammar/> |
| 217 |
|
| 218 |
<!-- the scripts in the makes mark services from the rd as deleted |
| 219 |
in sets and services since oai may query those. In interfaces |
| 220 |
and subjects we can safely delete them. All that will be overwritten |
| 221 |
by new entries if they come. --> |
| 222 |
<make table="resources" role="resources"> |
| 223 |
<script type="newSource" lang="python" id="markDeleted" |
| 224 |
notify="False"> |
| 225 |
table.connection.execute("UPDATE \curtable SET deleted=True" |
| 226 |
" WHERE sourceRD=%(sourceRD)s", |
| 227 |
{"sourceRD": sourceToken.sourceId}) |
| 228 |
</script> |
| 229 |
</make> |
| 230 |
|
| 231 |
<make table="interfaces" role="interfaces"> |
| 232 |
<rowmaker idmaps="*"> |
| 233 |
<ignoreOn> |
| 234 |
<keyIs key="accessURL" value="__NULL__"/> |
| 235 |
</ignoreOn> |
| 236 |
</rowmaker> |
| 237 |
|
| 238 |
<script type="newSource" lang="python" id="deleteByRDId" |
| 239 |
notify="False"> |
| 240 |
table.deleteMatching( |
| 241 |
"sourceRD=%(sourceRD)s", {"sourceRD": sourceToken.sourceId}) |
| 242 |
</script> |
| 243 |
</make> |
| 244 |
|
| 245 |
<make table="sets" role="sets"> |
| 246 |
<script original="markDeleted"/> |
| 247 |
</make> |
| 248 |
|
| 249 |
<make table="subjects" role="subjects"> |
| 250 |
<script original="deleteByRDId"/> |
| 251 |
</make> |
| 252 |
|
| 253 |
<make table="authors" role="authors"> |
| 254 |
<script original="deleteByRDId"/> |
| 255 |
</make> |
| 256 |
</data> |
| 257 |
|
| 258 |
<data id="deptable" updating="True"> |
| 259 |
<meta name="description">import the RD-dependencies from an RD.</meta> |
| 260 |
|
| 261 |
<embeddedGrammar> |
| 262 |
<iterator> |
| 263 |
<code> |
| 264 |
rd = self.sourceToken |
| 265 |
for rdId, reqId in rd.rdDependencies: |
| 266 |
yield { |
| 267 |
'rd': rdId, |
| 268 |
'prereq': reqId, |
| 269 |
'sourceRD': rd.sourceId, |
| 270 |
} |
| 271 |
</code> |
| 272 |
</iterator> |
| 273 |
</embeddedGrammar> |
| 274 |
|
| 275 |
<make table="res_dependencies"> |
| 276 |
<script original="deleteByRDId"/> |
| 277 |
</make> |
| 278 |
</data> |
| 279 |
|
| 280 |
<table id="resources_join" namePath="resources" onDisk="true"> |
| 281 |
<meta name="description"> |
| 282 |
A join of resources, interfaces, and sets used internally. |
| 283 |
</meta> |
| 284 |
|
| 285 |
<column original="sourceRD"/> |
| 286 |
<column original="resId"/> |
| 287 |
<column original="title"/> |
| 288 |
<column original="description"/> |
| 289 |
<column original="owner"/> |
| 290 |
<column original="dateUpdated"/> |
| 291 |
<column original="recTimestamp"/> |
| 292 |
<column original="deleted"/> |
| 293 |
<column original="interfaces.accessURL"/> |
| 294 |
<column original="interfaces.referenceURL"/> |
| 295 |
<column original="interfaces.browseable"/> |
| 296 |
<column original="interfaces.renderer"/> |
| 297 |
<column original="sets.setName"/> |
| 298 |
<column original="ivoid"/> |
| 299 |
<column original="rank"/> |
| 300 |
|
| 301 |
<viewStatement> |
| 302 |
CREATE OR REPLACE VIEW dc.resources_join AS ( |
| 303 |
SELECT \colNames |
| 304 |
FROM |
| 305 |
dc.resources |
| 306 |
NATURAL JOIN dc.sets |
| 307 |
NATURAL LEFT OUTER JOIN dc.interfaces) |
| 308 |
</viewStatement> <!-- The left outer join is crucial for resource records |
| 309 |
without interfaces --> |
| 310 |
</table> |
| 311 |
|
| 312 |
<table id="subjects_join" namePath="resources" onDisk="true"> |
| 313 |
<meta name="description"> |
| 314 |
A join of resources, subjects, and sets used internally. |
| 315 |
</meta> |
| 316 |
|
| 317 |
<column original="subjects.subject"/> |
| 318 |
<column original="sourceRD"/> |
| 319 |
<column original="resId"/> |
| 320 |
<column original="title"/> |
| 321 |
<column original="owner"/> |
| 322 |
<column original="interfaces.accessURL"/> |
| 323 |
<column original="interfaces.referenceURL"/> |
| 324 |
<column original="interfaces.browseable"/> |
| 325 |
<column original="sets.setName"/> |
| 326 |
<column original="ivoid"/> |
| 327 |
|
| 328 |
<viewStatement> |
| 329 |
CREATE OR REPLACE VIEW dc.subjects_join AS ( |
| 330 |
SELECT \colNames |
| 331 |
FROM |
| 332 |
dc.interfaces |
| 333 |
NATURAL JOIN dc.resources |
| 334 |
NATURAL JOIN dc.subjects |
| 335 |
NATURAL JOIN dc.sets |
| 336 |
ORDER BY subject) |
| 337 |
</viewStatement> |
| 338 |
</table> |
| 339 |
|
| 340 |
<data id="views"> |
| 341 |
<make table="resources_join"/> |
| 342 |
<make table="subjects_join"/> |
| 343 |
</data> |
| 344 |
|
| 345 |
<dbCore queriedTable="resources_join" id="overviewcore"> |
| 346 |
<condDesc buildFrom="setName"/> |
| 347 |
</dbCore> |
| 348 |
|
| 349 |
<service id="overview" core="overviewcore" |
| 350 |
allowed="form,admin,rdinfo"> |
| 351 |
<meta name="shortName">_cs_srv</meta> |
| 352 |
<meta name="title">Published Services</meta> |
| 353 |
<meta name="description">A list of all services published on the |
| 354 |
\getConfig{web}{sitename}, with links to information pages |
| 355 |
about them</meta> |
| 356 |
<meta name="_related" title="Validate registry" |
| 357 |
>http://rofr.ivoa.net/regvalidate/HarvestValidater?endpoint=\getConfig{web}{serverURL}/oai.xml</meta> |
| 358 |
<meta name="_related" title="Stats">/logs/logs/stats/form</meta> |
| 359 |
|
| 360 |
<outputTable namePath="resources_join"> |
| 361 |
<outputField original="sourceRD"/> |
| 362 |
<outputField original="resId"/> |
| 363 |
<outputField original="title"/> |
| 364 |
<outputField original="owner"/> |
| 365 |
<outputField original="dateUpdated" displayHint="type=humanDatetime"/> |
| 366 |
<outputField original="renderer"/> |
| 367 |
<outputField original="setName"/> |
| 368 |
<outputField original="deleted"/> |
| 369 |
</outputTable> |
| 370 |
</service> |
| 371 |
|
| 372 |
<FEED source="%#registry-interfacerecords"/> |
| 373 |
|
| 374 |
<service id="root" allowed="fixed"> |
| 375 |
<!-- this is just a placeholder for data and render functions |
| 376 |
the root page may need. To fetch service metadata, several data |
| 377 |
functions are available: |
| 378 |
|
| 379 |
* chunkedServiceList – services chunked by the first letter of |
| 380 |
the service title (not in use with current templates) |
| 381 |
* subjectServiceList – services chunked by subject keyword |
| 382 |
(used in the default root.html) |
| 383 |
* rankedServiceList – services ranked by schema-rank roughly the way |
| 384 |
TOPCAT does it (used in the default root.html) |
| 385 |
* subjectServiceList – intended for consumption in a javascript- |
| 386 |
infested environment, used in root-tree.html |
| 387 |
--> |
| 388 |
<template key="fixed">//root.html</template> |
| 389 |
<meta name="title">\getConfig{web}{sitename}</meta> |
| 390 |
|
| 391 |
<nullCore/> |
| 392 |
|
| 393 |
<customDF name="chunkedServiceList"> |
| 394 |
rd = service.rd |
| 395 |
if not hasattr(rd, "chunkedServiceList"): |
| 396 |
from gavo.registry import servicelist |
| 397 |
rd.chunkedServiceList = servicelist.getChunkedServiceList('local') |
| 398 |
return rd.chunkedServiceList |
| 399 |
</customDF> |
| 400 |
|
| 401 |
<customDF name="rankedServiceList"> |
| 402 |
rd = service.rd |
| 403 |
if not hasattr(rd, "rankedServiceList"): |
| 404 |
from gavo.registry import servicelist |
| 405 |
rd.rankedServiceList = servicelist.getRankedServiceList('local') |
| 406 |
return rd.rankedServiceList |
| 407 |
</customDF> |
| 408 |
|
| 409 |
<customDF name="titleList"> |
| 410 |
rd = service.rd |
| 411 |
if not hasattr(rd, "portal__titleList"): |
| 412 |
with base.getTableConn() as conn: |
| 413 |
rd.portal__titleList = list(conn.queryToDicts("SELECT" |
| 414 |
" title, dateUpdated, accessURL, referenceURL, browseable, owner," |
| 415 |
" sourceRD, resId, rank" |
| 416 |
" FROM dc.resources_join" |
| 417 |
" WHERE setName='local' AND NOT deleted" |
| 418 |
" ORDER BY rank, title")) |
| 419 |
return rd.portal__titleList |
| 420 |
</customDF> |
| 421 |
|
| 422 |
<customDF name="subjectServiceList"> |
| 423 |
rd = service.rd |
| 424 |
if not hasattr(rd, "subjectServiceList"): |
| 425 |
from gavo.registry import servicelist |
| 426 |
rd.subjectServiceList = servicelist.querySubjectsList() |
| 427 |
return rd.subjectServiceList |
| 428 |
</customDF> |
| 429 |
|
| 430 |
<customRF name="ifprotected"> |
| 431 |
if data["owner"]: |
| 432 |
return ctx.tag |
| 433 |
else: |
| 434 |
return "" |
| 435 |
</customRF> |
| 436 |
|
| 437 |
<customRF name="ifpublictap"> |
| 438 |
if not hasattr(service.rd, "portal__tapispublic"): |
| 439 |
with base.getTableConn() as conn: |
| 440 |
res = [r[0] for r in conn.query("SELECT resid FROM dc.resources" |
| 441 |
" WHERE sourcerd='__system__/tap'" |
| 442 |
" AND NOT deleted")] |
| 443 |
service.rd.portal__tapispublic = "run" in res |
| 444 |
|
| 445 |
if service.rd.portal__tapispublic: |
| 446 |
return ctx.tag |
| 447 |
else: |
| 448 |
return "" |
| 449 |
</customRF> |
| 450 |
</service> |
| 451 |
|
| 452 |
<service id="cacheclear" allowed="form" limitTo="gavoadmin"> |
| 453 |
<meta name="title">Cache Clearer</meta> |
| 454 |
<pythonCore> |
| 455 |
<inputTable> |
| 456 |
<inputKey name="rdId" type="text" |
| 457 |
tablehead="RD Id" |
| 458 |
description="Id of an RD (or some other cached thing) to |
| 459 |
expunge from DaCHS' internal cache"/> |
| 460 |
</inputTable> |
| 461 |
<outputTable> |
| 462 |
<outputField name="result" type="text" |
| 463 |
description="Ok if all went ok"/> |
| 464 |
</outputTable> |
| 465 |
<coreProc> |
| 466 |
<code> |
| 467 |
rdId = inputTable.args["rdId"] |
| 468 |
if rdId.startswith("//"): |
| 469 |
rdId = "__system__"+rdId[1:] |
| 470 |
|
| 471 |
base.caches.clearForName(rdId) |
| 472 |
return rsc.TableForDef(self.outputTable, |
| 473 |
rows=[{"result": "Ok"}]) |
| 474 |
</code> |
| 475 |
</coreProc> |
| 476 |
</pythonCore> |
| 477 |
</service> |
| 478 |
</resource> |