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
		});
266
267
	return false;
268
269
}
270 5668 leinfelder
function clearForm() {
271
	// clear the form values
272
	$('#searchForm').get(0).reset();
273
	// clear each of the tree selections
274
	$(".jstree").each(function(index) {
275
		$(this).jstree("deselect_all");
276
	});
277
	$("input.value").each(function(index) {
278
		$(this).val("");
279
	});
280
	// reload the trees
281
	initialize();
282
	// reload the search results
283
	//alert($('#searchForm').get(0));
284
	doSearch($('#searchForm').get(0));
285
}
286 5656 leinfelder
function donothing() {}
287
--></script>
288
289 5385 leinfelder
</head>
290 5633 leinfelder
<body onload="initialize()">
291 5509 leinfelder
<script language="javascript">
292
	insertTemplateOpening("<%=CONTEXT_URL%>");
293
</script>
294 5385 leinfelder
295 5574 leinfelder
<div id="content_wrapper">
296 5669 leinfelder
297 5533 leinfelder
<h2>Annotation-based search</h2>
298 5385 leinfelder
299 5633 leinfelder
<div id="error">
300
	<!-- error messages here -->
301
</div>
302
303 5669 leinfelder
<!-- set up the tabs -->
304
<script>
305
	$(function() {
306
		$("#searchTabs").tabs();
307
		$("#searchTabs").tabs("add", "#ecpTab", "Entity, Characteristic, Protocol");
308
		$("#searchTabs").tabs("add", "#measurementTab", "Measurement");
309
	});
310
</script>
311
312 5665 leinfelder
<form method="POST"
313
		action="<%=SERVLET_URL%>"
314
		target="_top"
315
		id="searchForm"
316
		name="searchForm"
317
		onSubmit="return doSearch(this)">
318 5509 leinfelder
	<input name="query" type="hidden" />
319
	<input name="qformat" value="semtools" type="hidden" />
320 5665 leinfelder
	<input name="includeHeader" value="false" type="hidden" />
321 5533 leinfelder
	<input name="action" value="semquery" type="hidden" />
322 5509 leinfelder
323 5602 leinfelder
	<table class="group group_border">
324 5509 leinfelder
		<tr>
325 5632 leinfelder
			<th colspan="3">
326 5602 leinfelder
				<p>
327
					Locate <b>data packages</b> that have been semantically annotated within the observation model by
328 5669 leinfelder
					selecting concepts from OBOE extension ontologies
329 5602 leinfelder
				</p>
330
			</th>
331 5533 leinfelder
		</tr>
332 5669 leinfelder
333 5533 leinfelder
		<tr>
334 5632 leinfelder
			<td colspan="3">
335 5669 leinfelder
336
				<div id="searchTabs">
337
					<!-- place holder for ui tabs -->
338
					<ul></ul>
339
340
					<!-- other criteria tabs -->
341
					<div id="ecpTab">
342
						<table>
343
							<tr>
344
								<td>
345
									<table class="subGroup subGroup_border">
346
347
										<tr>
348
											<th><p>Find observations of</p></th>
349
										</tr>
350
										<tr>
351
											<td>
352
												<input type="text" id="activeEntitiesSearch" />
353
												<input type="checkbox" id="activeEntitiesOnly" title="Show only active concepts" />
354
												<div class="select">
355
													<div id="activeEntities" class="activeTree">
356
														<p>loading...</p>
357
													</div>
358
													<input type="hidden" class="value" name="activeEntitiesValue" id="activeEntitiesValue"/>
359
													<input type="hidden" name="activeEntitiesClass" id="activeEntitiesClass" value="http://ecoinformatics.org/oboe/oboe.1.0/oboe-core.owl#Entity"/>
360
												</div>
361
											</td>
362
										</tr>
363
									</table>
364
								</td>
365
								<td>
366
									<table class="subGroup subGroup_border">
367
										<tr>
368
											<th><p>with measurements of</p></th>
369
										</tr>
370
										<tr>
371
											<td>
372
												<input type="text" id="activeCharacteristicsSearch" />
373
												<input type="checkbox" id="activeCharacteristicsOnly" title="Show only active concepts" />
374
												<div class="select">
375
													<div id="activeCharacteristics" class="activeTree">
376
														<p>loading...</p>
377
													</div>
378
													<input type="hidden" class="value" name="activeCharacteristicsValue" id="activeCharacteristicsValue"/>
379
													<input type="hidden" name="activeCharacteristicsClass" id="activeCharacteristicsClass" value="http://ecoinformatics.org/oboe/oboe.1.0/oboe-core.owl#Characteristic"/>
380
												</div>
381
											</td>
382
										</tr>
383
									</table>
384
								</td>
385
								<td>
386
									<table class="subGroup subGroup_border">
387
										<tr>
388
											<th><p>using procedures outlined by</p></th>
389
										</tr>
390
										<tr>
391
											<td>
392
												<input type="text" id="activeProtocolsSearch" />
393
												<input type="checkbox" id="activeProtocolsOnly" title="Show only active concepts" />
394
												<div class="select">
395
													<div id="activeProtocols" class="activeTree">
396
														<p>loading...</p>
397
													</div>
398
													<input type="hidden" class="value" name="activeProtocolsValue" id="activeProtocolsValue" />
399
													<input type="hidden" name="activeProtocolsClass" id="activeProtocolsClass" value="http://ecoinformatics.org/oboe/oboe.1.0/oboe-core.owl#Protocol"/>
400
												</div>
401
											</td>
402
										</tr>
403
									</table>
404
								</td>
405
							</tr>
406
						</table>
407
					</div>
408
409
					<!-- measurement -->
410
					<div id="measurementTab">
411
						<table class="subGroup subGroup_border onehundred_percent">
412
413
							<tr>
414
								<th><p>a template that defines Entity, Characteristic, Standard, and/or Protocol</p></th>
415
							</tr>
416
417
							<tr>
418
								<td>
419
									<input type="text" id="activeMeasurementsSearch" />
420
									Only active? <input type="checkbox" id="activeMeasurementsOnly" title="Show only active concepts"/>
421
									<div class="select">
422
										<div id="activeMeasurements" class="activeTree" style="width: 100%">
423
											<p>loading...</p>
424
										</div>
425
										<input type="hidden" class="value" name="activeMeasurementsValue" id="activeMeasurementsValue"/>
426
										<input type="hidden" name="activeMeasurementsClass" id="activeMeasurementsClass" value="http://ecoinformatics.org/oboe/oboe.1.0/oboe-core.owl#Measurement"/>
427
									</div>
428
								</td>
429
							</tr>
430
						</table>
431
					</div>
432
433
				</div>
434
435 5632 leinfelder
			</td>
436
		</tr>
437 5669 leinfelder
438 5632 leinfelder
		<tr>
439 5669 leinfelder
			<td colspan="1">
440 5665 leinfelder
				<!-- input type="submit" value="Search"/ -->
441 5668 leinfelder
				<input type="reset" value="Clear" onclick="clearForm()"/>
442 5633 leinfelder
			</td>
443 5669 leinfelder
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 5509 leinfelder
		</tr>
448 5669 leinfelder
449 5602 leinfelder
	</table>
450
		<!--
451 5509 leinfelder
		<tr>
452 5602 leinfelder
			<td>Entity: (SBC only)</td>
453
			<td><input type="text" name="entity" class="bp_form_complete-1523-uri" size="100" /></td>
454 5509 leinfelder
		</tr>
455 5602 leinfelder
		 -->
456 5509 leinfelder
</form>
457
458 5665 leinfelder
<div id="searchResults">
459
	Search Results
460
</div>
461
462 5509 leinfelder
<!-- Included default search/login -->
463
<% if ( PropertyService.getProperty("spatial.runSpatialOption").equals("true") ) { %>
464
<script language="javascript">
465
	insertMap("<%=CONTEXT_URL%>");
466
</script>
467
<br/>
468
<% } %>
469
470
<script language="javascript">
471
	insertSearchBox("<%=CONTEXT_URL%>");
472
	insertLoginBox("<%=CONTEXT_URL%>");
473
</script>
474
475 5574 leinfelder
</div>
476
477 5509 leinfelder
<script language="javascript">
478
	insertTemplateClosing("<%=CONTEXT_URL%>");
479
</script>
480
481 5385 leinfelder
</body>
482
</html>