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 14:12:17 -0800 (Tue, 30 Nov 2010) $'
10
 * '$Revision: 5669 $'
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
	});
310
</script>
311

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

    
323
	<table class="group group_border">
324
		<tr>
325
			<th colspan="3">
326
				<p>
327
					Locate <b>data packages</b> that have been semantically annotated within the observation model by
328
					selecting concepts from OBOE extension ontologies
329
				</p>
330
			</th>
331
		</tr>
332
		
333
		<tr>
334
			<td colspan="3">
335
			
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
			</td>
436
		</tr>
437
		
438
		<tr>
439
			<td colspan="1">
440
				<!-- input type="submit" value="Search"/ -->
441
				<input type="reset" value="Clear" onclick="clearForm()"/>
442
			</td>
443
			
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
		</tr>
448
		
449
	</table>
450
		<!-- 
451
		<tr>
452
			<td>Entity: (SBC only)</td>
453
			<td><input type="text" name="entity" class="bp_form_complete-1523-uri" size="100" /></td>
454
		</tr>
455
		 -->		
456
</form>
457

    
458
<div id="searchResults">
459
	Search Results
460
</div>
461

    
462
<!-- 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
</div>
476

    
477
<script language="javascript">
478
	insertTemplateClosing("<%=CONTEXT_URL%>");
479
</script>
480

    
481
</body>
482
</html>
(5-5/14)