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
<script type="text/javascript"
36
	src="<%=STYLE_SKINS_URL%>/semtools/search.js"></script>
37
38
<script type="text/javascript">
39
                    	    // Set defaults for this installation
40
                    	    //var BP_SEARCH_SERVER = "http://oor-01.cim3.net";
41
                    	    //var BP_SITE = "Sandbox";
42
                    	    //var BP_ORG = "OOR";
43
                    	  </script>
44 5656 leinfelder
<!--
45
<script language="Javascript" type="text/JavaScript" src="<%=STYLE_SKINS_URL%>/semtools/bioportal/form_complete.js"></script>
46
-->
47
<script language="javascript" type="text/javascript" src="<%=STYLE_SKINS_URL%>/semtools/jsTree/_lib/jquery.js"></script>
48
<script language="javascript" type="text/javascript" src="<%=STYLE_SKINS_URL%>/semtools/jsTree/_lib/jquery.cookie.js"></script>
49
<script language="javascript" type="text/javascript" src="<%=STYLE_SKINS_URL%>/semtools/jsTree/jquery.jstree.js"></script>
50 5509 leinfelder
<script language="javascript" type="text/javascript" src="<%=STYLE_SKINS_URL%>/semtools/semtools.js"></script>
51
<script language="javascript" type="text/javascript" src="<%=STYLE_COMMON_URL%>/branding.js"></script>
52
53 5656 leinfelder
<script language="Javascript" type="text/JavaScript"><!--
54 5633 leinfelder
function populateActiveDomain(divId, class) {
55 5656 leinfelder
	// collect the filtering values we have so far
56
	// these are hidden input fields in the form for holding the selected values
57
	var entity = $("#activeEntitiesValue").val() ? $("#activeEntitiesValue").val() : "";
58
	var characteristic = $("#activeCharacteristicsValue").val() ? $("#activeCharacteristicsValue").val() : "";
59
	var protocol = $("#activeProtocolsValue").val() ? $("#activeProtocolsValue").val() : "";
60
	var measurement = $("#activeMeasurementsValue").val() ? $("#activeMeasurementsValue").val() : "";
61 5633 leinfelder
62 5656 leinfelder
	// TODO: remember the selected value for this when filtering by active domain
63
	var selectedNode = $("#" + divId).jstree("get_selected", $("#" + divId));
64
	var selectedNodeId = $(selectedNode).attr("id");
65 5667 leinfelder
	//alert(divId + " selected node: " + selectedNode);
66 5656 leinfelder
67
	// load the tree for the given div, passing in the other filtered values
68 5633 leinfelder
	$("#" + divId).load(
69 5656 leinfelder
		"<%=SERVLET_URL%>",
70
		{
71
			'action': "getactivedomain",
72
			'class': class,
73
			'entity': entity,
74
			'characteristic': characteristic,
75
			'protocol': protocol,
76
			'measurement': measurement
77
		},
78
		// call back function when loading finishes
79
		function(response, status, xhr) {
80
			//alert("callback for: " + divId + " selected node: " + selectedNodeId);
81
			// error
82
			if (status == "error") {
83
				var msg = "Sorry but there was an error: ";
84
				$("#error").html(msg + xhr.status + " " + xhr.statusText);
85
			}
86
87
			// make it a js tree
88
			$(function () {
89
				$("#" + divId)
90 5660 leinfelder
					//bind calls here
91 5656 leinfelder
					.jstree({
92
						"ui" : {
93
							"select_limit" : 1,
94
							"select_multiple_modifier" : "alt",
95
							"selected_parent_close" : "select_parent"//,
96
							//"initially_select" : [ selectedNodeId ]
97 5659 leinfelder
						},
98
						"themes" : {
99
							"theme" : "default",
100
							"dots" : true,
101
							"icons" : false
102
						},
103 5656 leinfelder
						//"core" : { "initially_open" : [ selectedNodeId ] },
104 5658 leinfelder
						"search" : { "case_insensitive" : true },
105 5667 leinfelder
						"cookies" : {
106
								"save_opened" : "jstree_open_" + divId,
107
								"save_selected" : "jstree_select_" + divId,
108
						},
109 5666 leinfelder
						"plugins" : [
110
							"themes",
111
							"html_data",
112
							"ui",
113
							"cookies",
114
							"search" ]
115 5656 leinfelder
					});
116
			});
117
118 5658 leinfelder
			// enable searching on it
119
			$("#" + divId + "Search").keyup(
120
				function () {
121
					if ($("#" + divId + "Search").val().length >= 3) {
122
						$("#" + divId).jstree("search", $("#" + divId + "Search").val());
123 5663 leinfelder
						// now prune
124 5664 leinfelder
						prune(divId, "jstree-search");
125 5658 leinfelder
					}
126
				});
127 5664 leinfelder
128
			// toggle the active domain prune
129
			$("#" + divId + "Only").click(
130
				function () {
131
					if ($("#" + divId + "Only").is(":checked")) {
132
						// prune to active
133
						prune(divId, "bold");
134
					} else {
135
						// reset
136
						prune(divId, null);
137
					}
138
				});
139 5658 leinfelder
140 5666 leinfelder
			// TODO: make this work
141
			// open to the node
142 5667 leinfelder
			var nodePath = $("#" + divId).jstree("get_path", $(selectedNode));
143
			//alert("nodePath=" + nodePath);
144
			if (nodePath) {
145
				for (var index = 0; index < nodePath.length; index++) {
146
					$("#" + divId).jstree("open_node", $("#" + nodePath[index]));
147
					//$("#" + divId).jstree("select_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 5633 leinfelder
function initialize(source) {
195 5656 leinfelder
	// we don't want to reload the source of the filtering request
196
	// but we do want to reload the other trees for active domains
197
	// we reload all of them if no source is given - first time the page loads
198 5633 leinfelder
	if (source) {
199 5656 leinfelder
		source = $(source).attr("id");
200 5633 leinfelder
	}
201
	if (!source) {
202
		source = "";
203
	}
204
	if (source != 'activeEntities') {
205
		populateActiveDomain('activeEntities', 'org.ecoinformatics.sms.annotation.Entity');
206
	}
207
	if (source != 'activeCharacteristics') {
208
		populateActiveDomain('activeCharacteristics', 'org.ecoinformatics.sms.annotation.Characteristic');
209
	}
210
	if (source != 'activeProtocols') {
211
		populateActiveDomain('activeProtocols', 'org.ecoinformatics.sms.annotation.Protocol');
212
	}
213
	if (source != 'activeMeasurements') {
214
		populateActiveDomain('activeMeasurements', 'org.ecoinformatics.sms.annotation.Measurement');
215
	}
216
}
217 5656 leinfelder
function select(item) {
218 5633 leinfelder
219 5656 leinfelder
	// get the selected value, stored in the title attribute of the item <a> tag
220
	var value = $(item).attr("title");
221
	//alert("value: " + value);
222
223
	// get the parent div so we know what kind of class it is meant to filter
224
	// this is "the first parent of the class 'select'"
225
	var parent = $(item).parents("div.select:first");
226
	//alert("parent: " + parent);
227
228
	// set the value for the hidden input value
229
	// the input field of class "value" will hold it, this way we don't need to know the id
230
	var input = $(parent).children("input.value");
231
	$(input).val(value);
232
	//alert("input: " + input);
233 5662 leinfelder
234
	// set it in the search field
235
	var treeInstance = $(item).parents("div.jstree:first");
236
	var shortName = $(item).parent().attr("id");
237
	$("#" + $(treeInstance).attr("id") + "Search").val(shortName)
238 5656 leinfelder
239 5665 leinfelder
	// refresh the search results
240
	doSearch($("#searchForm").get(0));
241
242 5656 leinfelder
	// refresh the other trees for active domain after this filtering action
243 5666 leinfelder
	initialize($(parent).children("div"));
244 5656 leinfelder
}
245 5665 leinfelder
function doSearch(formObj) {
246
	// set the hidden parameters based on the current state of the form
247
	checkSearch(formObj);
248
249
	//load the results
250
	$("#searchResults").load(
251
		"<%=SERVLET_URL%>" + " #content_wrapper",
252
		$(formObj).serialize(),
253
		// call back function when loading finishes
254
		function(response, status, xhr) {
255
			if (status == "error") {
256
				var msg = "Sorry but there was an error performing the search: ";
257
				$("#error").html(msg + xhr.status + " " + xhr.statusText);
258
			}
259
		});
260
261
	return false;
262
263
}
264 5656 leinfelder
function donothing() {}
265
--></script>
266
267 5385 leinfelder
</head>
268 5633 leinfelder
<body onload="initialize()">
269 5509 leinfelder
<script language="javascript">
270
	insertTemplateOpening("<%=CONTEXT_URL%>");
271
</script>
272 5385 leinfelder
273 5574 leinfelder
<div id="content_wrapper">
274
275 5533 leinfelder
<h2>Annotation-based search</h2>
276 5385 leinfelder
277 5633 leinfelder
<div id="error">
278
	<!-- error messages here -->
279
</div>
280
281 5665 leinfelder
<form method="POST"
282
		action="<%=SERVLET_URL%>"
283
		target="_top"
284
		id="searchForm"
285
		name="searchForm"
286
		onSubmit="return doSearch(this)">
287 5509 leinfelder
	<input name="query" type="hidden" />
288
	<input name="qformat" value="semtools" type="hidden" />
289 5665 leinfelder
	<input name="includeHeader" value="false" type="hidden" />
290 5533 leinfelder
	<input name="action" value="semquery" type="hidden" />
291 5509 leinfelder
292 5602 leinfelder
	<table class="group group_border">
293 5509 leinfelder
		<tr>
294 5632 leinfelder
			<th colspan="3">
295 5602 leinfelder
				<p>
296
					Locate <b>data packages</b> that have been semantically annotated within the observation model by
297
					selecting concepts from
298
					<br/>
299
					(a) existing semantic annotations
300
					<br/>
301
					(b) registered OBOE extension ontologies
302
				</p>
303
			</th>
304 5533 leinfelder
		</tr>
305 5632 leinfelder
		<!--  measurement -->
306 5533 leinfelder
		<tr>
307 5632 leinfelder
			<td colspan="3">
308
				<table class="subGroup subGroup_border onehundred_percent">
309
					<tr>
310
						<th colspan="2">
311
							Measurement
312
						</th>
313
					</tr>
314
					<tr>
315
						<td>a template that defines Entity, Characteristic, Standard, and/or Protocol</td>
316
					</tr>
317
					<tr>
318
						<td>
319 5658 leinfelder
							<input type="text" id="activeMeasurementsSearch" />
320 5664 leinfelder
							Only active? <input type="checkbox" id="activeMeasurementsOnly" title="Show only active concepts"/>
321 5656 leinfelder
							<div class="select">
322 5664 leinfelder
								<div id="activeMeasurements" class="activeTree" style="width: 100%">
323 5656 leinfelder
									<p>loading...</p>
324
								</div>
325
								<input type="hidden" class="value" name="activeMeasurementsValue" id="activeMeasurementsValue"/>
326
								<input type="hidden" name="activeMeasurementsClass" id="activeMeasurementsClass" value="http://ecoinformatics.org/oboe/oboe.1.0/oboe-core.owl#Measurement"/>
327
							</div>
328 5632 leinfelder
						</td>
329
					</tr>
330
				</table>
331
			</td>
332
		</tr>
333
		<tr>
334 5533 leinfelder
			<td>
335 5602 leinfelder
				<table class="subGroup subGroup_border">
336
					<tr>
337
						<th colspan="1">
338
							Entity
339
						</th>
340
					</tr>
341
					<tr>
342
						<td>Find observations of</td>
343
					</tr>
344
					<tr>
345
						<td>
346 5658 leinfelder
							<input type="text" id="activeEntitiesSearch" />
347 5664 leinfelder
							<input type="checkbox" id="activeEntitiesOnly" title="Show only active concepts" />
348 5656 leinfelder
							<div class="select">
349 5664 leinfelder
								<div id="activeEntities" class="activeTree">
350 5656 leinfelder
									<p>loading...</p>
351
								</div>
352
								<input type="hidden" class="value" name="activeEntitiesValue" id="activeEntitiesValue"/>
353
								<input type="hidden" name="activeEntitiesClass" id="activeEntitiesClass" value="http://ecoinformatics.org/oboe/oboe.1.0/oboe-core.owl#Entity"/>
354
							</div>
355 5602 leinfelder
						</td>
356
					</tr>
357
				</table>
358 5533 leinfelder
			</td>
359
			<td>
360 5602 leinfelder
				<table class="subGroup subGroup_border">
361
					<tr>
362
						<th colspan="1">
363
							Characteristic
364
						</th>
365
					</tr>
366
					<tr>
367 5632 leinfelder
						<td>with measurements of</td>
368 5602 leinfelder
					</tr>
369
					<tr>
370
						<td>
371 5658 leinfelder
							<input type="text" id="activeCharacteristicsSearch" />
372 5664 leinfelder
							<input type="checkbox" id="activeCharacteristicsOnly" title="Show only active concepts" />
373 5656 leinfelder
							<div class="select">
374 5664 leinfelder
								<div id="activeCharacteristics" class="activeTree">
375 5656 leinfelder
									<p>loading...</p>
376
								</div>
377
								<input type="hidden" class="value" name="activeCharacteristicsValue" id="activeCharacteristicsValue"/>
378
								<input type="hidden" name="activeCharacteristicsClass" id="activeCharacteristicsClass" value="http://ecoinformatics.org/oboe/oboe.1.0/oboe-core.owl#Characteristic"/>
379
							</div>
380 5602 leinfelder
						</td>
381
					</tr>
382
				</table>
383 5533 leinfelder
			</td>
384
			<td>
385 5602 leinfelder
				<table class="subGroup subGroup_border">
386
					<tr>
387
						<th colspan="1">
388
							Protocol
389
						</th>
390
					</tr>
391
					<tr>
392 5632 leinfelder
						<td>using procedures outlined by</td>
393 5602 leinfelder
					</tr>
394
					<tr>
395
						<td>
396 5658 leinfelder
							<input type="text" id="activeProtocolsSearch" />
397 5664 leinfelder
							<input type="checkbox" id="activeProtocolsOnly" title="Show only active concepts" />
398 5656 leinfelder
							<div class="select">
399 5664 leinfelder
								<div id="activeProtocols" class="activeTree">
400 5656 leinfelder
									<p>loading...</p>
401
								</div>
402
								<input type="hidden" class="value" name="activeProtocolsValue" id="activeProtocolsValue" />
403
								<input type="hidden" name="activeProtocolsClass" id="activeProtocolsClass" value="http://ecoinformatics.org/oboe/oboe.1.0/oboe-core.owl#Protocol"/>
404
							</div>
405 5602 leinfelder
						</td>
406
					</tr>
407
				</table>
408 5533 leinfelder
			</td>
409
		</tr>
410
		<tr>
411 5632 leinfelder
			<td colspan="3">Match All? <input type="checkbox" name="matchAll" checked="checked"/></td>
412 5509 leinfelder
		</tr>
413
		<tr>
414 5632 leinfelder
			<td colspan="3">From same Observation? <input type="checkbox" name="strict"/></td>
415 5509 leinfelder
		</tr>
416
		<tr>
417 5633 leinfelder
			<td colspan="3">
418 5665 leinfelder
				<!-- input type="submit" value="Search"/ -->
419 5633 leinfelder
				<input type="reset" value="Clear" onclick="$('#searchForm').get(0).reset(); initialize()"/>
420
			</td>
421 5509 leinfelder
		</tr>
422 5602 leinfelder
	</table>
423
		<!--
424 5509 leinfelder
		<tr>
425 5602 leinfelder
			<td>Entity: (SBC only)</td>
426
			<td><input type="text" name="entity" class="bp_form_complete-1523-uri" size="100" /></td>
427 5509 leinfelder
		</tr>
428 5602 leinfelder
		 -->
429 5509 leinfelder
</form>
430
431 5665 leinfelder
<div id="searchResults">
432
	Search Results
433
</div>
434
435 5509 leinfelder
<!-- Included default search/login -->
436
<% if ( PropertyService.getProperty("spatial.runSpatialOption").equals("true") ) { %>
437
<script language="javascript">
438
	insertMap("<%=CONTEXT_URL%>");
439
</script>
440
<br/>
441
<% } %>
442
443
<script language="javascript">
444
	insertSearchBox("<%=CONTEXT_URL%>");
445
	insertLoginBox("<%=CONTEXT_URL%>");
446
</script>
447
448 5574 leinfelder
</div>
449
450 5509 leinfelder
<script language="javascript">
451
	insertTemplateClosing("<%=CONTEXT_URL%>");
452
</script>
453
454 5385 leinfelder
</body>
455
</html>