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-12-02 11:29:41 -0800 (Thu, 02 Dec 2010) $'
10
 * '$Revision: 5685 $'
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/jquery/jquery.busy.js"></script>
55

    
56
<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
<script language="Javascript" type="text/JavaScript"><!--
60
function populateActiveDomain(divId, class) {
61
	// 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
	
68
	// 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
	//alert(divId + " selected node: " + selectedNodeId);
72
	
73
	// load the tree for the given div, passing in the other filtered values
74
	$("#" + divId).load(
75
		"<%=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
					//bind calls here
97
					.jstree({
98
						"ui" : {
99
							"select_limit" : 1,
100
							"select_multiple_modifier" : "alt",
101
							"selected_parent_close" : "select_parent"//,
102
							//"initially_select" : [ selectedNodeId ]
103
						},
104
						"themes" : {
105
							"theme" : "default",
106
							"dots" : true,
107
							"icons" : false
108
						},
109
						//"core" : { "initially_open" : [ selectedNodeId ] },
110
						"search" : { "case_insensitive" : true },
111
						//"cookies" : { 
112
						//		"save_opened" : "jstree_open_" + divId,
113
						//		"save_selected" : "jstree_select_" + divId,
114
						//},
115
						"plugins" : [ 
116
							"themes", 
117
							"html_data", 
118
							"ui", 
119
							//"cookies", 
120
							"search" ]
121
					});
122
			});
123

    
124
			// enable searching on it
125
			$("#" + divId + "Search").keyup(
126
				function () {
127
					if ($("#" + divId + "Search").val().length >= 3) {
128
						// search
129
						$("#" + divId).jstree("search", $("#" + divId + "Search").val());
130
						// now prune
131
						prune(divId, "jstree-search");
132
					}
133
				});
134
			
135
			// toggle the active domain prune
136
			$("#" + divId + "Only").click(function() {
137
				doActiveDomain(divId);
138
			});	
139

    
140
			// actually prune if we should
141
			doActiveDomain(divId);
142
			
143
			// open to the node to last selected
144
			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
		});
157
}
158
/**
159
* Prunes the given tree to inlcude the given matched class 
160
**/
161
function prune(divId, matchClass) {
162

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

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

    
248
	// refresh the search results
249
	doSearch($("#searchForm").get(0));
250
	
251
	// refresh the other trees for active domain after this filtering action
252
	initialize($(parent).children("div"));
253
}
254
function doSearch(formObj) {
255
	// set the hidden parameters based on the current state of the form
256
	checkSearch(formObj);
257
	
258
	// start the busy indicator
259
	$("#searchResults").busy(
260
			{
261
				position	: 'left', 
262
				offset		: -30, 
263
				hide		: true, 
264
				img			: "<%=STYLE_SKINS_URL%>/semtools/images/busy.gif" 
265
			});
266
	
267
	//load the results
268
	$("#searchResults").load(
269
		"<%=SERVLET_URL%>" + " #content_wrapper",
270
		$(formObj).serialize(),
271
		// call back function when loading finishes
272
		function(response, status, xhr) {
273
			if (status == "error") {
274
				var msg = "Sorry but there was an error performing the search: ";
275
				$("#error").html(msg + xhr.status + " " + xhr.statusText);
276
			}
277
			// collapsible search results?
278
			$(function() {
279
				$('.accordian').click(function() {
280
					$(this).next().slideToggle("slow");
281
					return false;
282
				}).next().hide();
283
			});
284
			
285
			// stop the busy indicator
286
			$("#searchResults").busy("hide");
287
		});
288
		
289
	return false;
290
	
291
}
292
function clearForm() {
293
	// clear the form values
294
	$('#searchForm').get(0).reset();
295
	// clear each of the tree selections
296
	$(".jstree").each(function(index) {
297
		$(this).jstree("deselect_all");
298
	});
299
	$("input.value").each(function(index) {
300
		$(this).val("");
301
	});
302
	// reload the trees
303
	initialize();
304
	// reload the search results
305
	//alert($('#searchForm').get(0));
306
	doSearch($('#searchForm').get(0));
307
}
308
/**
309
 * Perform this when the page first loads
310
 */
311
function pageLoad() {
312
	initialize();
313
	doSearch($('#searchForm').get(0));
314
}
315
function donothing() {}
316
--></script>
317

    
318
</head>
319
<body onload="pageLoad()">
320
<script language="javascript">
321
	insertTemplateOpening("<%=CONTEXT_URL%>");
322
</script>
323

    
324
<div id="content_wrapper">
325
 
326
<h2>Annotation-based search</h2>
327

    
328
<div id="error">
329
	<!-- error messages here -->
330
</div>
331

    
332
<!-- set up the tabs -->
333
<script>
334
	$(function() {
335
		$("#searchTabs").tabs();
336
		$("#searchTabs").tabs("add", "#ecpTab", "Entity, Characteristic, Protocol");
337
		$("#searchTabs").tabs("add", "#measurementTab", "Measurement");
338
		$("#searchTabs").tabs("add", "#optionsTab", "Options");
339
	});
340
</script>
341

    
342
<form method="POST" 
343
		action="<%=SERVLET_URL%>" 
344
		target="_top" 
345
		id="searchForm" 
346
		name="searchForm" 
347
		onSubmit="return doSearch(this)">
348
	<input name="query" type="hidden" />
349
	<input name="qformat" value="semtools" type="hidden" />
350
	<input name="includeHeader" value="false" type="hidden" />
351
	<input name="action" value="semquery" type="hidden" />
352

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

    
494
</form>
495

    
496

    
497

    
498
<!-- Included default search/login -->
499
<% if ( PropertyService.getProperty("spatial.runSpatialOption").equals("true") ) { %>
500
<script language="javascript">
501
	insertMap("<%=CONTEXT_URL%>");
502
</script>
503
<br/>
504
<% } %>
505
  
506
<script language="javascript">
507
	insertSearchBox("<%=CONTEXT_URL%>");
508
	insertLoginBox("<%=CONTEXT_URL%>");	
509
</script>
510

    
511
</div>
512

    
513
<script language="javascript">
514
	insertTemplateClosing("<%=CONTEXT_URL%>");
515
</script>
516

    
517
</body>
518
</html>
(5-5/14)