forked from ArctosDB/arctos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo.cfm
468 lines (428 loc) · 13.8 KB
/
demo.cfm
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
<cfinclude template="/includes/_pickHeader.cfm">
<cfquery name="d" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#">
select barcode from container where container_type ='cryovial label' and parent_cotnaine
</cfquery>
<script>
function settaxaPickPrefs (v) {
jQuery.getJSON("/component/functions.cfc",
{
method : "setSessionTaxaPickPrefs",
val : v,
returnformat : "json",
queryformat : 'column'
}
);
}
// test
</script>
<cfoutput>
<cfif not isdefined ("scientific_name")>
<cfset scientific_name="Rattus">
</cfif>
<cfif not isdefined("session.taxaPickPrefs") or len(session.taxaPickPrefs) is 0>
<cfset session.taxaPickPrefs="anyterm">
</cfif>
<cfset taxaPickPrefs=session.taxaPickPrefs>
<form name="s" method="post" action="demo.cfm">
<label for="scientific_name">Scientific Name (STARTS WITH)</label>
<input type="text" name="scientific_name" id="scientific_name" size="50" value="#scientific_name#">
<label for="taxaPickPrefs">Filter Results by...</label>
<select name="taxaPickPrefs" id="taxaPickPrefs" onchange="settaxaPickPrefs(this.value);">
<option <cfif session.taxaPickPrefs is "anyterm"> selected="selected" </cfif> value="anyterm">Any Term (best performance)</option>
<option <cfif session.taxaPickPrefs is "relatedterm"> selected="selected" </cfif> value="relatedterm">Include terms from relationships</option>
<option <cfif session.taxaPickPrefs is "mycollections"> selected="selected" </cfif> value="mycollections">Include only terms with classifications preferred by my collections</option>
<option <cfif session.taxaPickPrefs is "usedbymycollections"> selected="selected" </cfif> value="usedbymycollections">Include only terms used by my collections</option>
</select>
<br><input type="submit" class="lnkBtn" value="Search">
</form>
<cfif len(scientific_name) is 0 or scientific_name is 'undefined'>
<cfabort>
</cfif>
<hr>
<p>
Basic, names only.
</p>
<cfquery name="d" result="tmpResult" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#">
SELECT
scientific_name,
taxon_name_id
from
taxon_name
where
UPPER(scientific_name) LIKE '#ucase(scientific_name)#%'
order by
scientific_name
</cfquery>
<p>
ExecutionTime: #tmpResult.ExecutionTime#
</p>
<div style="max-height:20em;width: 50%; overflow:scroll;;">
<cfloop query="d">
<br>#scientific_name#
</cfloop>
</div>
<hr>
<p>
Names only, include relationships.
</p>
<cfquery name="d" result="tmpResult" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#">
select * from (
SELECT
scientific_name,
taxon_name_id
from
taxon_name
where
UPPER(taxon_name.scientific_name) LIKE '#ucase(scientific_name)#%'
UNION
SELECT
a.scientific_name,
a.taxon_name_id
from
taxon_name a,
taxon_relations,
taxon_name b
where
a.taxon_name_id = taxon_relations.taxon_name_id (+) and
taxon_relations.related_taxon_name_id = b.taxon_name_id (+) and
UPPER(B.scientific_name) LIKE '#ucase(scientific_name)#%'
UNION
SELECT
b.scientific_name,
b.taxon_name_id
from
taxon_name a,
taxon_relations,
taxon_name b
where
a.taxon_name_id = taxon_relations.taxon_name_id (+) and
taxon_relations.related_taxon_name_id = b.taxon_name_id (+) and
UPPER(a.scientific_name) LIKE '#ucase(scientific_name)#%'
)
where
taxon_name_id is not null
group by
scientific_name,
taxon_name_id
ORDER BY
scientific_name
</cfquery>
<p>
ExecutionTime: #tmpResult.ExecutionTime#
</p>
<div style="max-height:20em;width: 50%; overflow:scroll;;">
<cfloop query="d">
<br>#scientific_name#
</cfloop>
</div>
<hr>
<p>
Names only, used in IDs by collections to which you have access
</p>
<cfquery name="d" result="tmpResult" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#">
SELECT
taxon_name.scientific_name,
taxon_name.taxon_name_id
from
taxon_name,
identification_taxonomy,
identification,
cataloged_item
where
taxon_name.taxon_name_id=identification_taxonomy.taxon_name_id and
identification_taxonomy.identification_id=identification.identification_id and
identification.collection_object_id=cataloged_item.collection_object_id and
UPPER(taxon_name.scientific_name) LIKE '#ucase(scientific_name)#%'
group by
taxon_name.scientific_name,
taxon_name.taxon_name_id
order by
taxon_name.scientific_name
</cfquery>
<p>
ExecutionTime: #tmpResult.ExecutionTime#
</p>
<div style="max-height:20em;width: 50%; overflow:scroll;;">
<cfloop query="d">
<br>#scientific_name#
</cfloop>
</div>
<hr>
<p>
Names only, has preferred classification
</p>
<cfquery name="d" result="tmpResult" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#">
SELECT
taxon_name.scientific_name,
taxon_name.taxon_name_id
from
taxon_name,
taxon_term,
collection
where
taxon_name.taxon_name_id=taxon_term.taxon_name_id and
taxon_term.SOURCE=collection.PREFERRED_TAXONOMY_SOURCE and
UPPER(taxon_name.scientific_name) LIKE '#ucase(scientific_name)#%'
group by
taxon_name.scientific_name,
taxon_name.taxon_name_id
order by
taxon_name.scientific_name
</cfquery>
<p>
ExecutionTime: #tmpResult.ExecutionTime#
</p>
<div style="max-height:20em;width: 50%; overflow:scroll;;">
<cfloop query="d">
<br>#scientific_name#
</cfloop>
</div>
<hr>
<hr>
<p>
Names only, flag has preferred classification
</p>
<cfquery name="d" result="tmpResult" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#">
SELECT
taxon_name.scientific_name,
taxon_name.taxon_name_id,
decode(taxon_term.taxon_name_id,null,'no','yes') hasclass
from
taxon_name,
taxon_term,
collection,
cataloged_item
where
taxon_name.taxon_name_id=taxon_term.taxon_name_id (+) and
taxon_term.SOURCE=collection.PREFERRED_TAXONOMY_SOURCE (+) and
collection.collection_id=cataloged_item.collection_id (+) and
UPPER(taxon_name.scientific_name) LIKE '#ucase(scientific_name)#%'
group by
taxon_name.scientific_name,
taxon_name.taxon_name_id,
decode(taxon_term.taxon_name_id,null,'no','yes')
order by
taxon_name.scientific_name
</cfquery>
<p>
ExecutionTime: #tmpResult.ExecutionTime#
</p>
<div style="max-height:20em;width: 50%; overflow:scroll;;">
<cfloop query="d">
<br>#scientific_name# (#hasclass#)
</cfloop>
</div>
<hr>
<p>
everything or something
</p>
<cfquery name="raw" result="tmpResult" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#">
SELECT
taxon_name.scientific_name,
taxon_name.taxon_name_id,
taxon_term.term,
taxon_term.term_type,
taxon_term.POSITION_IN_CLASSIFICATION
from
taxon_name,
taxon_term,
collection
where
taxon_name.taxon_name_id=taxon_term.taxon_name_id and
taxon_term.SOURCE=collection.PREFERRED_TAXONOMY_SOURCE and
POSITION_IN_CLASSIFICATION is not null and
UPPER(taxon_name.scientific_name) LIKE '#ucase(scientific_name)#%'
</cfquery>
<cfquery name="d" dbtype="query" result="tmpResult2" >
select scientific_name,taxon_name_id from raw group by scientific_name,taxon_name_id order by scientific_name
</cfquery>
<p>
ExecutionTime: #tmpResult.ExecutionTime#
</p><p>
ExecutionTime2: #tmpResult2.ExecutionTime#
</p>
<div style="max-height:20em;width: 50%; overflow:scroll;;">
<cfloop query="d">
<br>#scientific_name#
<cfquery name="thisclass" dbtype="query">
select term,POSITION_IN_CLASSIFICATION from raw where taxon_name_id=#d.taxon_name_id#
group by term,POSITION_IN_CLASSIFICATION order by POSITION_IN_CLASSIFICATION
</cfquery>
<cfloop query="thisclass">
<br>--#term#
</cfloop>
</cfloop>
</div>
<hr>
<p>
everything or something from relationships
</p>
<cfquery name="raw" result="tmpResult" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#">
SELECT
taxon_name.scientific_name,
taxon_name.taxon_name_id,
taxon_term.term,
taxon_term.term_type,
taxon_term.POSITION_IN_CLASSIFICATION
from
taxon_name,
taxon_term,
collection
where
taxon_name.taxon_name_id=taxon_term.taxon_name_id and
taxon_term.SOURCE=collection.PREFERRED_TAXONOMY_SOURCE and
POSITION_IN_CLASSIFICATION is not null and
UPPER(taxon_name.scientific_name) LIKE '#ucase(scientific_name)#%'
</cfquery>
<cfquery name="d" dbtype="query" result="tmpResult2" >
select scientific_name,taxon_name_id from raw group by scientific_name,taxon_name_id order by scientific_name
</cfquery>
<p>
ExecutionTime: #tmpResult.ExecutionTime#
</p><p>
ExecutionTime2: #tmpResult2.ExecutionTime#
</p>
<div style="max-height:20em;width: 50%; overflow:scroll;;">
<cfloop query="d">
<br>#scientific_name#
<cfquery name="thisclass" dbtype="query">
select term,POSITION_IN_CLASSIFICATION from raw where taxon_name_id=#d.taxon_name_id#
group by term,POSITION_IN_CLASSIFICATION order by POSITION_IN_CLASSIFICATION
</cfquery>
<cfloop query="thisclass">
<br>--#term#
</cfloop>
</cfloop>
</div>
</cfoutput>
<!----- oldstuff
<cfif taxaPickPrefs is "anyterm">
<cfset sql="SELECT
scientific_name,
taxon_name_id
from
taxon_name
where
UPPER(scientific_name) LIKE '#ucase(scientific_name)#%'
order by
scientific_name">
<cfelseif taxaPickPrefs is "usedbymycollections">
<!--- VPD limits users to seeing only their collections, so just make the joins --->
<cfset sql="select scientific_name,taxon_name_id from (
SELECT
taxon_name.scientific_name,
taxon_name.taxon_name_id
from
taxon_name,
identification_taxonomy,
identification,
cataloged_item
where
taxon_name.taxon_name_id=identification_taxonomy.taxon_name_id and
identification_taxonomy.identification_id=identification.identification_id and
identification.collection_object_id=cataloged_item.collection_object_id and
UPPER(taxon_name.scientific_name) LIKE '#ucase(scientific_name)#%'
)
group by
scientific_name,
taxon_name_id
order by
scientific_name">
<cfelseif taxaPickPrefs is "mycollections">
<!--- VPD limits users to seeing only their collections, so just make the joins --->
<cfset sql="select scientific_name,taxon_name_id from (
SELECT
taxon_name.scientific_name,
taxon_name.taxon_name_id
from
taxon_name,
taxon_term,
collection
where
taxon_name.taxon_name_id=taxon_term.taxon_name_id and
taxon_term.SOURCE=collection.PREFERRED_TAXONOMY_SOURCE and
UPPER(taxon_name.scientific_name) LIKE '#ucase(scientific_name)#%'
)
group by
scientific_name,
taxon_name_id
order by
scientific_name">
<cfelseif taxaPickPrefs is "relatedterm">
<cfset sql="select * from (
SELECT
scientific_name,
taxon_name_id
from
taxon_name
where
UPPER(taxon_name.scientific_name) LIKE '#ucase(scientific_name)#%'
UNION
SELECT
a.scientific_name,
a.taxon_name_id
from
taxon_name a,
taxon_relations,
taxon_name b
where
a.taxon_name_id = taxon_relations.taxon_name_id (+) and
taxon_relations.related_taxon_name_id = b.taxon_name_id (+) and
UPPER(B.scientific_name) LIKE '#ucase(scientific_name)#%'
UNION
SELECT
b.scientific_name,
b.taxon_name_id
from
taxon_name a,
taxon_relations,
taxon_name b
where
a.taxon_name_id = taxon_relations.taxon_name_id (+) and
taxon_relations.related_taxon_name_id = b.taxon_name_id (+) and
UPPER(a.scientific_name) LIKE '#ucase(scientific_name)#%'
)
where
taxon_name_id is not null
group by
scientific_name,
taxon_name_id
ORDER BY
scientific_name
">
</cfif>
<cfquery name="getTaxa" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#">
#PreserveSingleQuotes(sql)#
</cfquery>
<cfif getTaxa.recordcount is 0>
<p>
No Match
</p>
<cfelse>
<cfloop query="getTaxa">
<br>#scientific_name#
</cfloop>
</cfif>
</cfoutput>
<!----
<cfif getTaxa.recordcount is 1>
<cfoutput>
<script>
opener.document.#formName#.#taxonIdFld#.value='#getTaxa.taxon_name_id#';opener.document.#formName#.#taxonNameFld#.value='#getTaxa.scientific_name#';self.close();
</script>
</cfoutput>
<cfelseif #getTaxa.recordcount# is 0>
<cfoutput>
Nothing matched #scientific_name#. <a href="javascript:void(0);" onClick="opener.document.#formName#.#taxonIdFld#.value='';opener.document.#formName#.#taxonNameFld#.value='';opener.document.#formName#.#taxonNameFld#.focus();self.close();">Try again.</a>
</cfoutput>
<cfelse>
<cfoutput query="getTaxa">
<br><a href="##" onClick="javascript: opener.document.#formName#.#taxonIdFld#.value='#taxon_name_id#';opener.document.#formName#.#taxonNameFld#.value='#scientific_name#';self.close();">#scientific_name#</a>
<!---
<br><a href="##" onClick="javascript: document.selectedAgent.agentID.value='#agent_id#';document.selectedAgent.agentName.value='#agent_name#';document.selectedAgent.submit();">#agent_name# - #agent_id#</a> -
--->
</cfoutput>
</CFIF>
---->
oldstuff ---->
<cfinclude template="/includes/_pickFooter.cfm">