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