1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
|
#{ MKREGDB -- Make a Registry Database using constraints.
procedure mkregdb (query)
string query { prompt = "Query Term" }
string output = "" { prompt = "Output filename" }
string type = "" { prompt = "Resource type" }
string bandpass = "" { prompt = "Bandpass" }
string content = "" { prompt = "Content Level" }
string sql = "" { prompt = "SQL predicate" }
bool header = yes { prompt = "Print header?" }
int nresults = 0 { prompt = "Number of results?" }
int status = 0 { prompt = "status code" }
begin
string qterm, fstr, qstr, id, typ, lout
string bpass, clevel, sqlstr, stype, ch
string t, a, b, i, u, d
int res, count, istart, iend, n, vnlines, rec
bool hdr
reset clobber = yes # set the environment
lout = output
hdr = header
stype = type
bpass = bandpass
clevel = content
sqlstr = sql
if (lout == "")
lout = "STDOUT"
# Build a sql predicate string from the contraints (if any).
qstr = ""
if (stype != "") {
s1 = strlwr (stype)
if (s1 == "sia" || substr (s1,1,2) == "im")
qstr = "(Tag like '%images%')"
else
qstr = "(xml like '%" // stype // "%')"
}
if (bpass != "") {
s1 = "([coverage/waveband] like '%" // bpass // "%')"
if (qstr != "")
qstr = qstr // " AND " // s1
else
qstr = s1
}
if (clevel != "") {
s1 = "([content/contentLevel] like '%" // clevel // "%')"
if (qstr != "")
qstr = qstr // " AND " // s1
else
qstr = s1
}
if ($nargs > 0)
qterm = query
else {
qterm = ""
sqlstr = "(Title like '%')"
}
if (sqlstr != "") {
s1 = "(" // sqlstr // ")"
if (qstr != "")
qstr = qstr // " AND " // s1
else
qstr = s1
}
# Do the Registry query.
nresults = 0
if (qstr != "")
res = regSearch (qstr, qterm, 0)
else
res = regSearch (qterm, 0)
count = regResCount (res)
istart = 0
iend = count
if (count == 0) {
status = 1
return
}
# Dump the query constraints we used in the search.
printf ("", > lout)
if (hdr) {
printf ("# VO Resource utility database\n", >> lout)
printf ("# \n", >> lout)
printf ("# \t Query Term: '%s'\n", qterm, >> lout)
printf ("# \t ServiceType: %s\n", stype, >> lout)
printf ("# \t Bandpass: %s\n", bpass, >> lout)
printf ("# \tContentLevel: %s\n", clevel, >> lout)
printf ("# \t SQL: %s\n", sqlstr, >> lout)
printf ("# \n", >> lout)
printf ("# type,alias,bandpass,ivorn,url,title\n", >> lout)
printf ("# \n", >> lout)
}
for (n=istart; n < iend; n=n+1) {
t = trim (regValue (res, "ServiceType", n))
a = trim (regValue (res, "ShortName", n))
b = trim (regValue (res, "CoverageSpectral", n))
i = trim (regValue (res, "Identifier", n))
u = trim (regValue (res, "ServiceURL", n))
d = trim (regValue (res, "Title", n))
if (t == "" || u == "") # probably not a data service, skip it
next
if (b == "") # unknown bandpass matches any
b = "*"
if (a == "") # construct ShortName from IVORN
a = substr (i, strldx("/",i)+1, strlen (i))
# Fix up the values for proper entry in the database.
if (stridx (" ", a) > 0) a = strlwr (strsub (a, " ", "_"))
if (stridx (",", b) > 0) b = strlwr (strsub (b, ",", ":"))
if (stridx (" ", d) > 0) d = strsub (d, " ", ":")
if (stridx (",", d) > 0) d = strsub (d, ",", ";")
b = strlwr (b)
t = strlwr (t)
if (strstr ("image", t) > 0)
t = "I"
else if (strstr ("cone", t) > 0)
t = "C"
else if (strstr ("spectra", t) > 0)
t = "S"
else
t = "O"
printf ("%s,%s,%s,%s,%s,%s,%s\n", t, a, b, i, a, u, d, >> lout)
nresults = nresults + 1
}
end
|