Project

General

Profile

1
<%@ 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: leinfelder $'
9
 *      '$Date: 2010-11-30 15:34:49 -0800 (Tue, 30 Nov 2010) $'
10
 * '$Revision: 5672 $'
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
%>
27

    
28
<%@ include file="../../common/common-settings.jsp"%>
29
<%@ include file="../../common/configure-check.jsp"%>
30

    
31
<html>
32
<head>
33
<title>Semantic search</title>
34
<link rel="stylesheet" type="text/css" href="<%=STYLE_SKINS_URL%>/semtools/semtools.css">
35
<link rel="stylesheet" type="text/css" href="<%=STYLE_SKINS_URL%>/semtools/jqueryui/css/smoothness/jquery-ui-1.8.6.custom.css">
36
<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
<!--  
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
<!-- 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
<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
<script language="Javascript" type="text/JavaScript"><!--
58
function populateActiveDomain(divId, class) {
59
	// 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
	
66
	// 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
	//alert(divId + " selected node: " + selectedNodeId);
70
	
71
	// load the tree for the given div, passing in the other filtered values
72
	$("#" + divId).load(
73
		"<%=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
					//bind calls here
95
					.jstree({
96
						"ui" : {
97
							"select_limit" : 1,
98
							"select_multiple_modifier" : "alt",
99
							"selected_parent_close" : "select_parent"//,
100
							//"initially_select" : [ selectedNodeId ]
101
						},
102
						"themes" : {
103
							"theme" : "default",
104
							"dots" : true,
105
							"icons" : false
106
						},
107
						//"core" : { "initially_open" : [ selectedNodeId ] },
108
						"search" : { "case_insensitive" : true },
109
						//"cookies" : { 
110
						//		"save_opened" : "jstree_open_" + divId,
111
						//		"save_selected" : "jstree_select_" + divId,
112
						//},
113
						"plugins" : [ 
114
							"themes", 
115
							"html_data", 
116
							"ui", 
117
							//"cookies", 
118
							"search" ]
119
					});
120
			});
121

    
122
			// 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
						// now prune
128
						prune(divId, "jstree-search");
129
					}
130
				});
131
			
132
			// toggle the active domain prune
133
			$("#" + divId + "Only").click(function() {
134
				doActiveDomain(divId);
135
			});	
136

    
137
			// actually prune if we should
138
			doActiveDomain(divId);
139
			
140
			// open to the node to last selected
141
			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
		});
154
}
155
/**
156
* Prunes the given tree to inlcude the given matched class 
157
**/
158
function prune(divId, matchClass) {
159

    
160
	// show all nodes (reset)
161
	$("#" + divId).find("li").show();
162
	
163
	// done if we don't have any thing to prune
164
	if (!matchClass) {
165
		return;
166
	}
167
	
168
	// get all non-matched anchor tags
169
	var nonmatches = $("#" + divId).find("a").not("." + matchClass);
170
	
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
			var childMatches = $(this).find("a." + matchClass);
179
			if (childMatches && childMatches.length > 0) {
180
				return true;
181
			}
182
			// parent matches?
183
			var parentMatches = $(this).parents("li").children("a." + matchClass);
184
			if (parentMatches && parentMatches.length > 0) {
185
				return true;
186
			}
187
			// hide this node if no matches under it
188
			$(this).hide();
189
		});
190
}
191
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
function initialize(source) {
201
	// 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
	if (source) {
205
		source = $(source).attr("id");
206
	}
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
function select(item) {
224

    
225
	// 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
	
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

    
245
	// refresh the search results
246
	doSearch($("#searchForm").get(0));
247
	
248
	// refresh the other trees for active domain after this filtering action
249
	initialize($(parent).children("div"));
250
}
251
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
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
function donothing() {}
287
--></script>
288

    
289
</head>
290
<body onload="initialize()">
291
<script language="javascript">
292
	insertTemplateOpening("<%=CONTEXT_URL%>");
293
</script>
294

    
295
<div id="content_wrapper">
296
 
297
<h2>Annotation-based search</h2>
298

    
299
<div id="error">
300
	<!-- error messages here -->
301
</div>
302

    
303
<!-- 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
		$("#searchTabs").tabs("add", "#optionsTab", "Options");
310
	});
311
</script>
312

    
313
<form method="POST" 
314
		action="<%=SERVLET_URL%>" 
315
		target="_top" 
316
		id="searchForm" 
317
		name="searchForm" 
318
		onSubmit="return doSearch(this)">
319
	<input name="query" type="hidden" />
320
	<input name="qformat" value="semtools" type="hidden" />
321
	<input name="includeHeader" value="false" type="hidden" />
322
	<input name="action" value="semquery" type="hidden" />
323

    
324
	<!-- tabs for the search interface -->		
325
	<div id="searchTabs">
326
		<!-- place holder for ui tabs -->
327
		<ul></ul>
328
	
329
		<!-- other criteria tabs -->
330
		<div id="ecpTab">
331
			<table>
332
				<tr>
333
					<td>
334
						<table class="subGroup subGroup_border">
335
							
336
							<tr>
337
								<th><p>Find observations of</p></th>
338
							</tr>
339
							<tr>
340
								<td>
341
									<input type="text" id="activeEntitiesSearch" />
342
									<input type="checkbox" id="activeEntitiesOnly" title="Show only active concepts" />
343
									<div class="select">
344
										<div id="activeEntities" class="activeTree">
345
											<p>loading...</p>
346
										</div>
347
										<input type="hidden" class="value" name="activeEntitiesValue" id="activeEntitiesValue"/>
348
										<input type="hidden" name="activeEntitiesClass" id="activeEntitiesClass" value="http://ecoinformatics.org/oboe/oboe.1.0/oboe-core.owl#Entity"/>
349
									</div>
350
								</td>
351
							</tr>
352
						</table>
353
					</td>
354
					<td>
355
						<table class="subGroup subGroup_border">
356
							<tr>
357
								<th><p>with measurements of</p></th>
358
							</tr>
359
							<tr>
360
								<td>
361
									<input type="text" id="activeCharacteristicsSearch" />
362
									<input type="checkbox" id="activeCharacteristicsOnly" title="Show only active concepts" />
363
									<div class="select">
364
										<div id="activeCharacteristics" class="activeTree">
365
											<p>loading...</p>
366
										</div>
367
										<input type="hidden" class="value" name="activeCharacteristicsValue" id="activeCharacteristicsValue"/>
368
										<input type="hidden" name="activeCharacteristicsClass" id="activeCharacteristicsClass" value="http://ecoinformatics.org/oboe/oboe.1.0/oboe-core.owl#Characteristic"/>
369
									</div>
370
								</td>
371
							</tr>
372
						</table>
373
					</td>
374
					<td>
375
						<table class="subGroup subGroup_border">
376
							<tr>
377
								<th><p>using procedures outlined by</p></th>
378
							</tr>
379
							<tr>
380
								<td>
381
									<input type="text" id="activeProtocolsSearch" />
382
									<input type="checkbox" id="activeProtocolsOnly" title="Show only active concepts" />
383
									<div class="select">
384
										<div id="activeProtocols" class="activeTree">
385
											<p>loading...</p>
386
										</div>
387
										<input type="hidden" class="value" name="activeProtocolsValue" id="activeProtocolsValue" />
388
										<input type="hidden" name="activeProtocolsClass" id="activeProtocolsClass" value="http://ecoinformatics.org/oboe/oboe.1.0/oboe-core.owl#Protocol"/>
389
									</div>
390
								</td>
391
							</tr>
392
						</table>
393
					</td>
394
				</tr>
395
			</table>
396
		</div>
397
		
398
		<!-- measurement -->
399
		<div id="measurementTab">
400
			<table class="subGroup subGroup_border onehundred_percent">
401
				
402
				<tr>
403
					<th><p>a template that defines Entity, Characteristic, Standard, and/or Protocol</p></th>
404
				</tr>
405
				
406
				<tr>
407
					<td>
408
						<input type="text" id="activeMeasurementsSearch" />
409
						Only active? <input type="checkbox" id="activeMeasurementsOnly" title="Show only active concepts"/>
410
						<div class="select">
411
							<div id="activeMeasurements" class="activeTree" style="width: 100%">
412
								<p>loading...</p>
413
							</div>
414
							<input type="hidden" class="value" name="activeMeasurementsValue" id="activeMeasurementsValue"/>
415
							<input type="hidden" name="activeMeasurementsClass" id="activeMeasurementsClass" value="http://ecoinformatics.org/oboe/oboe.1.0/oboe-core.owl#Measurement"/>
416
						</div>
417
					</td>
418
				</tr>
419
			</table>
420
		</div>
421
		
422
		<!-- query options -->
423
		<div id="optionsTab">
424
			<table class="group group_border">
425
				<tr>
426
					<th colspan="2">
427
						<p>
428
							Locate <b>data packages</b> that have been semantically annotated within the observation model by
429
							selecting concepts from OBOE extension ontologies
430
						</p>
431
					</th>
432
				</tr>
433
				
434
				<tr>
435
					
436
					<td colspan="1">Match All? <input type="checkbox" name="matchAll" checked="checked"/></td>
437
				
438
					<td colspan="1">From same Observation? <input type="checkbox" name="strict"/></td>
439
				</tr>
440
				
441
			</table>
442
		</div>	
443
					
444
	</div>
445
	
446
	<br/>
447
	
448
	<!-- search results here -->	
449
	<table class="subGroup subGroup_border onehundred_percent">
450
		<tr>
451
			<th>
452
				Search Results
453
				<input type="reset" value="Clear" onclick="clearForm()"/>
454
			</th>
455
		</tr>
456
		<tr>
457
			<td>
458
				<div id="searchResults">
459
				No query has been specified	
460
				</div>
461
			</td>
462
		</tr>
463
	</table>	
464

    
465
</form>
466

    
467

    
468

    
469
<!-- Included default search/login -->
470
<% if ( PropertyService.getProperty("spatial.runSpatialOption").equals("true") ) { %>
471
<script language="javascript">
472
	insertMap("<%=CONTEXT_URL%>");
473
</script>
474
<br/>
475
<% } %>
476
  
477
<script language="javascript">
478
	insertSearchBox("<%=CONTEXT_URL%>");
479
	insertLoginBox("<%=CONTEXT_URL%>");	
480
</script>
481

    
482
</div>
483

    
484
<script language="javascript">
485
	insertTemplateClosing("<%=CONTEXT_URL%>");
486
</script>
487

    
488
</body>
489
</html>
(5-5/14)