Project

General

Profile

1 5509 leinfelder
<%@ page language="java"%>
2
<%
3
/**
4
 *
5
 * '$RCSfile$'
6
 * Copyright: 2008 Regents of the University of California and the
7
 *             National Center for Ecological Analysis and Synthesis
8
 *    '$Author$'
9
 *      '$Date$'
10
 * '$Revision$'
11
 *
12
 * This program is free software; you can redistribute it and/or modify
13
 * it under the terms of the GNU General Public License as published by
14
 * the Free Software Foundation; either version 2 of the License, or
15
 * (at your option) any later version.
16
 *
17
 * This program is distributed in the hope that it will be useful,
18
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
 * GNU General Public License for more details.
21
22
 * You should have received a copy of the GNU General Public License
23
 * along with this program; if not, write to the Free Software
24
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
25
 */
26 5385 leinfelder
%>
27 5632 leinfelder
28 5509 leinfelder
<%@ include file="../../common/common-settings.jsp"%>
29
<%@ include file="../../common/configure-check.jsp"%>
30 5604 leinfelder
31 5385 leinfelder
<html>
32
<head>
33 5509 leinfelder
<title>Semantic search</title>
34
<link rel="stylesheet" type="text/css" href="<%=STYLE_SKINS_URL%>/semtools/semtools.css">
35 5669 leinfelder
<link rel="stylesheet" type="text/css" href="<%=STYLE_SKINS_URL%>/semtools/jqueryui/css/smoothness/jquery-ui-1.8.6.custom.css">
36 5509 leinfelder
<script type="text/javascript"
37
	src="<%=STYLE_SKINS_URL%>/semtools/search.js"></script>
38
39
<script type="text/javascript">
40
                    	    // Set defaults for this installation
41
                    	    //var BP_SEARCH_SERVER = "http://oor-01.cim3.net";
42
                    	    //var BP_SITE = "Sandbox";
43
                    	    //var BP_ORG = "OOR";
44
                    	  </script>
45 5656 leinfelder
<!--
46
<script language="Javascript" type="text/JavaScript" src="<%=STYLE_SKINS_URL%>/semtools/bioportal/form_complete.js"></script>
47
-->
48
<script language="javascript" type="text/javascript" src="<%=STYLE_SKINS_URL%>/semtools/jsTree/_lib/jquery.js"></script>
49
<script language="javascript" type="text/javascript" src="<%=STYLE_SKINS_URL%>/semtools/jsTree/_lib/jquery.cookie.js"></script>
50
<script language="javascript" type="text/javascript" src="<%=STYLE_SKINS_URL%>/semtools/jsTree/jquery.jstree.js"></script>
51 5669 leinfelder
<!-- jquery ui -->
52
<script language="javascript" type="text/javascript" src="<%=STYLE_SKINS_URL%>/semtools/jqueryui/js/jquery-ui-1.8.6.custom.min.js"></script>
53
54 5509 leinfelder
<script language="javascript" type="text/javascript" src="<%=STYLE_SKINS_URL%>/semtools/semtools.js"></script>
55
<script language="javascript" type="text/javascript" src="<%=STYLE_COMMON_URL%>/branding.js"></script>
56
57 5656 leinfelder
<script language="Javascript" type="text/JavaScript"><!--
58 5633 leinfelder
function populateActiveDomain(divId, class) {
59 5656 leinfelder
	// collect the filtering values we have so far
60
	// these are hidden input fields in the form for holding the selected values
61
	var entity = $("#activeEntitiesValue").val() ? $("#activeEntitiesValue").val() : "";
62
	var characteristic = $("#activeCharacteristicsValue").val() ? $("#activeCharacteristicsValue").val() : "";
63
	var protocol = $("#activeProtocolsValue").val() ? $("#activeProtocolsValue").val() : "";
64
	var measurement = $("#activeMeasurementsValue").val() ? $("#activeMeasurementsValue").val() : "";
65 5633 leinfelder
66 5656 leinfelder
	// TODO: remember the selected value for this when filtering by active domain
67
	var selectedNode = $("#" + divId).jstree("get_selected", $("#" + divId));
68
	var selectedNodeId = $(selectedNode).attr("id");
69 5668 leinfelder
	//alert(divId + " selected node: " + selectedNodeId);
70 5656 leinfelder
71
	// load the tree for the given div, passing in the other filtered values
72 5633 leinfelder
	$("#" + divId).load(
73 5656 leinfelder
		"<%=SERVLET_URL%>",
74
		{
75
			'action': "getactivedomain",
76
			'class': class,
77
			'entity': entity,
78
			'characteristic': characteristic,
79
			'protocol': protocol,
80
			'measurement': measurement
81
		},
82
		// call back function when loading finishes
83
		function(response, status, xhr) {
84
			//alert("callback for: " + divId + " selected node: " + selectedNodeId);
85
			// error
86
			if (status == "error") {
87
				var msg = "Sorry but there was an error: ";
88
				$("#error").html(msg + xhr.status + " " + xhr.statusText);
89
			}
90
91
			// make it a js tree
92
			$(function () {
93
				$("#" + divId)
94 5660 leinfelder
					//bind calls here
95 5656 leinfelder
					.jstree({
96
						"ui" : {
97
							"select_limit" : 1,
98
							"select_multiple_modifier" : "alt",
99
							"selected_parent_close" : "select_parent"//,
100
							//"initially_select" : [ selectedNodeId ]
101 5659 leinfelder
						},
102
						"themes" : {
103
							"theme" : "default",
104
							"dots" : true,
105
							"icons" : false
106
						},
107 5656 leinfelder
						//"core" : { "initially_open" : [ selectedNodeId ] },
108 5658 leinfelder
						"search" : { "case_insensitive" : true },
109 5668 leinfelder
						//"cookies" : {
110
						//		"save_opened" : "jstree_open_" + divId,
111
						//		"save_selected" : "jstree_select_" + divId,
112
						//},
113 5666 leinfelder
						"plugins" : [
114
							"themes",
115
							"html_data",
116
							"ui",
117 5668 leinfelder
							//"cookies",
118 5666 leinfelder
							"search" ]
119 5656 leinfelder
					});
120
			});
121
122 5658 leinfelder
			// enable searching on it
123
			$("#" + divId + "Search").keyup(
124
				function () {
125
					if ($("#" + divId + "Search").val().length >= 3) {
126
						$("#" + divId).jstree("search", $("#" + divId + "Search").val());
127 5663 leinfelder
						// now prune
128 5664 leinfelder
						prune(divId, "jstree-search");
129 5658 leinfelder
					}
130
				});
131 5664 leinfelder
132
			// toggle the active domain prune
133 5668 leinfelder
			$("#" + divId + "Only").click(function() {
134
				doActiveDomain(divId);
135
			});
136 5658 leinfelder
137 5668 leinfelder
			// actually prune if we should
138
			doActiveDomain(divId);
139
140
			// open to the node to last selected
141 5667 leinfelder
			var nodePath = $("#" + divId).jstree("get_path", $(selectedNode));
142
			if (nodePath) {
143
				for (var index = 0; index < nodePath.length; index++) {
144
					$("#" + divId).jstree("open_node", $("#" + nodePath[index]));
145
				}
146
				// select the original node
147
				$("#" + divId).jstree("select_node", $(selectedNode), false);
148
				$("#" + divId).jstree("refresh", $(selectedNode));
149
				// TODO: scroll to selected node.
150
				// This is supposed to be part of jsTree 1.0-rc2 but appears to be broken
151
			}
152
153 5656 leinfelder
		});
154 5633 leinfelder
}
155 5664 leinfelder
/**
156
* Prunes the given tree to inlcude the given matched class
157
**/
158
function prune(divId, matchClass) {
159 5663 leinfelder
160
	// show all nodes (reset)
161
	$("#" + divId).find("li").show();
162
163 5664 leinfelder
	// done if we don't have any thing to prune
164
	if (!matchClass) {
165
		return;
166
	}
167
168 5663 leinfelder
	// get all non-matched anchor tags
169 5664 leinfelder
	var nonmatches = $("#" + divId).find("a").not("." + matchClass);
170 5663 leinfelder
171
	// get their parent nodes
172
	nonmatches = $(nonmatches).parents("li");
173
174
	// are there any matches under each parent node?
175
	$(nonmatches).each(
176
		function(index) {
177
			// do any chidren match?
178 5664 leinfelder
			var childMatches = $(this).find("a." + matchClass);
179 5663 leinfelder
			if (childMatches && childMatches.length > 0) {
180
				return true;
181
			}
182
			// parent matches?
183 5664 leinfelder
			var parentMatches = $(this).parents("li").children("a." + matchClass);
184 5663 leinfelder
			if (parentMatches && parentMatches.length > 0) {
185
				return true;
186
			}
187
			// hide this node if no matches under it
188
			$(this).hide();
189
		});
190
}
191 5668 leinfelder
function doActiveDomain(divId) {
192
	if ($("#" + divId + "Only").is(":checked")) {
193
		// prune to active
194
		prune(divId, "bold");
195
	} else {
196
		// reset
197
		prune(divId, null);
198
	}
199
}
200 5633 leinfelder
function initialize(source) {
201 5656 leinfelder
	// we don't want to reload the source of the filtering request
202
	// but we do want to reload the other trees for active domains
203
	// we reload all of them if no source is given - first time the page loads
204 5633 leinfelder
	if (source) {
205 5656 leinfelder
		source = $(source).attr("id");
206 5633 leinfelder
	}
207
	if (!source) {
208
		source = "";
209
	}
210
	if (source != 'activeEntities') {
211
		populateActiveDomain('activeEntities', 'org.ecoinformatics.sms.annotation.Entity');
212
	}
213
	if (source != 'activeCharacteristics') {
214
		populateActiveDomain('activeCharacteristics', 'org.ecoinformatics.sms.annotation.Characteristic');
215
	}
216
	if (source != 'activeProtocols') {
217
		populateActiveDomain('activeProtocols', 'org.ecoinformatics.sms.annotation.Protocol');
218
	}
219
	if (source != 'activeMeasurements') {
220
		populateActiveDomain('activeMeasurements', 'org.ecoinformatics.sms.annotation.Measurement');
221
	}
222
}
223 5656 leinfelder
function select(item) {
224 5633 leinfelder
225 5656 leinfelder
	// get the selected value, stored in the title attribute of the item <a> tag
226
	var value = $(item).attr("title");
227
	//alert("value: " + value);
228
229
	// get the parent div so we know what kind of class it is meant to filter
230
	// this is "the first parent of the class 'select'"
231
	var parent = $(item).parents("div.select:first");
232
	//alert("parent: " + parent);
233
234
	// set the value for the hidden input value
235
	// the input field of class "value" will hold it, this way we don't need to know the id
236
	var input = $(parent).children("input.value");
237
	$(input).val(value);
238
	//alert("input: " + input);
239 5662 leinfelder
240
	// set it in the search field
241
	var treeInstance = $(item).parents("div.jstree:first");
242
	var shortName = $(item).parent().attr("id");
243
	$("#" + $(treeInstance).attr("id") + "Search").val(shortName)
244 5656 leinfelder
245 5665 leinfelder
	// refresh the search results
246
	doSearch($("#searchForm").get(0));
247
248 5656 leinfelder
	// refresh the other trees for active domain after this filtering action
249 5666 leinfelder
	initialize($(parent).children("div"));
250 5656 leinfelder
}
251 5665 leinfelder
function doSearch(formObj) {
252
	// set the hidden parameters based on the current state of the form
253
	checkSearch(formObj);
254
255
	//load the results
256
	$("#searchResults").load(
257
		"<%=SERVLET_URL%>" + " #content_wrapper",
258
		$(formObj).serialize(),
259
		// call back function when loading finishes
260
		function(response, status, xhr) {
261
			if (status == "error") {
262
				var msg = "Sorry but there was an error performing the search: ";
263
				$("#error").html(msg + xhr.status + " " + xhr.statusText);
264
			}
265 5675 leinfelder
			// collapsible search results?
266
			$(function() {
267
				$('.accordian').click(function() {
268 5676 leinfelder
					$(this).next().slideToggle("slow");
269 5675 leinfelder
					return false;
270
				}).next().hide();
271
			});
272
273 5665 leinfelder
		});
274
275
	return false;
276
277
}
278 5668 leinfelder
function clearForm() {
279
	// clear the form values
280
	$('#searchForm').get(0).reset();
281
	// clear each of the tree selections
282
	$(".jstree").each(function(index) {
283
		$(this).jstree("deselect_all");
284
	});
285
	$("input.value").each(function(index) {
286
		$(this).val("");
287
	});
288
	// reload the trees
289
	initialize();
290
	// reload the search results
291
	//alert($('#searchForm').get(0));
292
	doSearch($('#searchForm').get(0));
293
}
294 5656 leinfelder
function donothing() {}
295
--></script>
296
297 5385 leinfelder
</head>
298 5633 leinfelder
<body onload="initialize()">
299 5509 leinfelder
<script language="javascript">
300
	insertTemplateOpening("<%=CONTEXT_URL%>");
301
</script>
302 5385 leinfelder
303 5574 leinfelder
<div id="content_wrapper">
304 5669 leinfelder
305 5533 leinfelder
<h2>Annotation-based search</h2>
306 5385 leinfelder
307 5633 leinfelder
<div id="error">
308
	<!-- error messages here -->
309
</div>
310
311 5669 leinfelder
<!-- set up the tabs -->
312
<script>
313
	$(function() {
314
		$("#searchTabs").tabs();
315
		$("#searchTabs").tabs("add", "#ecpTab", "Entity, Characteristic, Protocol");
316
		$("#searchTabs").tabs("add", "#measurementTab", "Measurement");
317 5672 leinfelder
		$("#searchTabs").tabs("add", "#optionsTab", "Options");
318 5669 leinfelder
	});
319
</script>
320
321 5665 leinfelder
<form method="POST"
322
		action="<%=SERVLET_URL%>"
323
		target="_top"
324
		id="searchForm"
325
		name="searchForm"
326
		onSubmit="return doSearch(this)">
327 5509 leinfelder
	<input name="query" type="hidden" />
328
	<input name="qformat" value="semtools" type="hidden" />
329 5665 leinfelder
	<input name="includeHeader" value="false" type="hidden" />
330 5533 leinfelder
	<input name="action" value="semquery" type="hidden" />
331 5509 leinfelder
332 5672 leinfelder
	<!-- tabs for the search interface -->
333
	<div id="searchTabs">
334
		<!-- place holder for ui tabs -->
335
		<ul></ul>
336
337
		<!-- other criteria tabs -->
338
		<div id="ecpTab">
339
			<table>
340
				<tr>
341
					<td>
342
						<table class="subGroup subGroup_border">
343
344 5669 leinfelder
							<tr>
345 5672 leinfelder
								<th><p>Find observations of</p></th>
346
							</tr>
347
							<tr>
348 5669 leinfelder
								<td>
349 5672 leinfelder
									<input type="text" id="activeEntitiesSearch" />
350
									<input type="checkbox" id="activeEntitiesOnly" title="Show only active concepts" />
351
									<div class="select">
352
										<div id="activeEntities" class="activeTree">
353
											<p>loading...</p>
354
										</div>
355
										<input type="hidden" class="value" name="activeEntitiesValue" id="activeEntitiesValue"/>
356
										<input type="hidden" name="activeEntitiesClass" id="activeEntitiesClass" value="http://ecoinformatics.org/oboe/oboe.1.0/oboe-core.owl#Entity"/>
357
									</div>
358 5669 leinfelder
								</td>
359 5672 leinfelder
							</tr>
360
						</table>
361
					</td>
362
					<td>
363
						<table class="subGroup subGroup_border">
364
							<tr>
365
								<th><p>with measurements of</p></th>
366
							</tr>
367
							<tr>
368 5669 leinfelder
								<td>
369 5672 leinfelder
									<input type="text" id="activeCharacteristicsSearch" />
370
									<input type="checkbox" id="activeCharacteristicsOnly" title="Show only active concepts" />
371
									<div class="select">
372
										<div id="activeCharacteristics" class="activeTree">
373
											<p>loading...</p>
374
										</div>
375
										<input type="hidden" class="value" name="activeCharacteristicsValue" id="activeCharacteristicsValue"/>
376
										<input type="hidden" name="activeCharacteristicsClass" id="activeCharacteristicsClass" value="http://ecoinformatics.org/oboe/oboe.1.0/oboe-core.owl#Characteristic"/>
377
									</div>
378 5669 leinfelder
								</td>
379
							</tr>
380
						</table>
381 5672 leinfelder
					</td>
382
					<td>
383
						<table class="subGroup subGroup_border">
384 5669 leinfelder
							<tr>
385 5672 leinfelder
								<th><p>using procedures outlined by</p></th>
386 5669 leinfelder
							</tr>
387
							<tr>
388
								<td>
389 5672 leinfelder
									<input type="text" id="activeProtocolsSearch" />
390
									<input type="checkbox" id="activeProtocolsOnly" title="Show only active concepts" />
391 5669 leinfelder
									<div class="select">
392 5672 leinfelder
										<div id="activeProtocols" class="activeTree">
393 5669 leinfelder
											<p>loading...</p>
394
										</div>
395 5672 leinfelder
										<input type="hidden" class="value" name="activeProtocolsValue" id="activeProtocolsValue" />
396
										<input type="hidden" name="activeProtocolsClass" id="activeProtocolsClass" value="http://ecoinformatics.org/oboe/oboe.1.0/oboe-core.owl#Protocol"/>
397 5669 leinfelder
									</div>
398
								</td>
399
							</tr>
400
						</table>
401 5672 leinfelder
					</td>
402
				</tr>
403
			</table>
404
		</div>
405
406
		<!-- measurement -->
407
		<div id="measurementTab">
408
			<table class="subGroup subGroup_border onehundred_percent">
409 5669 leinfelder
410 5672 leinfelder
				<tr>
411
					<th><p>a template that defines Entity, Characteristic, Standard, and/or Protocol</p></th>
412
				</tr>
413
414
				<tr>
415
					<td>
416
						<input type="text" id="activeMeasurementsSearch" />
417
						Only active? <input type="checkbox" id="activeMeasurementsOnly" title="Show only active concepts"/>
418
						<div class="select">
419
							<div id="activeMeasurements" class="activeTree" style="width: 100%">
420
								<p>loading...</p>
421
							</div>
422
							<input type="hidden" class="value" name="activeMeasurementsValue" id="activeMeasurementsValue"/>
423
							<input type="hidden" name="activeMeasurementsClass" id="activeMeasurementsClass" value="http://ecoinformatics.org/oboe/oboe.1.0/oboe-core.owl#Measurement"/>
424
						</div>
425
					</td>
426
				</tr>
427
			</table>
428
		</div>
429 5669 leinfelder
430 5672 leinfelder
		<!-- query options -->
431
		<div id="optionsTab">
432
			<table class="group group_border">
433
				<tr>
434
					<th colspan="2">
435
						<p>
436
							Locate <b>data packages</b> that have been semantically annotated within the observation model by
437
							selecting concepts from OBOE extension ontologies
438
						</p>
439
					</th>
440
				</tr>
441
442
				<tr>
443
444
					<td colspan="1">Match All? <input type="checkbox" name="matchAll" checked="checked"/></td>
445
446
					<td colspan="1">From same Observation? <input type="checkbox" name="strict"/></td>
447
				</tr>
448
449
			</table>
450
		</div>
451
452
	</div>
453
454
	<br/>
455
456
	<!-- search results here -->
457
	<table class="subGroup subGroup_border onehundred_percent">
458 5632 leinfelder
		<tr>
459 5672 leinfelder
			<th>
460
				Search Results
461 5668 leinfelder
				<input type="reset" value="Clear" onclick="clearForm()"/>
462 5672 leinfelder
			</th>
463 5509 leinfelder
		</tr>
464
		<tr>
465 5672 leinfelder
			<td>
466
				<div id="searchResults">
467
				No query has been specified
468
				</div>
469
			</td>
470 5509 leinfelder
		</tr>
471 5672 leinfelder
	</table>
472
473 5509 leinfelder
</form>
474
475 5665 leinfelder
476 5672 leinfelder
477 5509 leinfelder
<!-- Included default search/login -->
478
<% if ( PropertyService.getProperty("spatial.runSpatialOption").equals("true") ) { %>
479
<script language="javascript">
480
	insertMap("<%=CONTEXT_URL%>");
481
</script>
482
<br/>
483
<% } %>
484
485
<script language="javascript">
486
	insertSearchBox("<%=CONTEXT_URL%>");
487
	insertLoginBox("<%=CONTEXT_URL%>");
488
</script>
489
490 5574 leinfelder
</div>
491
492 5509 leinfelder
<script language="javascript">
493
	insertTemplateClosing("<%=CONTEXT_URL%>");
494
</script>
495
496 5385 leinfelder
</body>
497
</html>