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