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-29 15:49:54 -0800 (Mon, 29 Nov 2010) $'
10
 * '$Revision: 5667 $'
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
<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
<!--  
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
<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
<script language="Javascript" type="text/JavaScript"><!--
54
function populateActiveDomain(divId, class) {
55
	// 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
	
62
	// 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
	//alert(divId + " selected node: " + selectedNode);
66
	
67
	// load the tree for the given div, passing in the other filtered values
68
	$("#" + divId).load(
69
		"<%=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
					//bind calls here
91
					.jstree({
92
						"ui" : {
93
							"select_limit" : 1,
94
							"select_multiple_modifier" : "alt",
95
							"selected_parent_close" : "select_parent"//,
96
							//"initially_select" : [ selectedNodeId ]
97
						},
98
						"themes" : {
99
							"theme" : "default",
100
							"dots" : true,
101
							"icons" : false
102
						},
103
						//"core" : { "initially_open" : [ selectedNodeId ] },
104
						"search" : { "case_insensitive" : true },
105
						"cookies" : { 
106
								"save_opened" : "jstree_open_" + divId,
107
								"save_selected" : "jstree_select_" + divId,
108
						},
109
						"plugins" : [ 
110
							"themes", 
111
							"html_data", 
112
							"ui", 
113
							"cookies", 
114
							"search" ]
115
					});
116
			});
117

    
118
			// 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
						// now prune
124
						prune(divId, "jstree-search");
125
					}
126
				});
127
			
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

    
140
			// TODO: make this work
141
			// open to the node
142
			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
		});
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 initialize(source) {
195
	// 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
	if (source) {
199
		source = $(source).attr("id");
200
	}
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
function select(item) {
218

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

    
239
	// refresh the search results
240
	doSearch($("#searchForm").get(0));
241
	
242
	// refresh the other trees for active domain after this filtering action
243
	initialize($(parent).children("div"));
244
}
245
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
function donothing() {}
265
--></script>
266

    
267
</head>
268
<body onload="initialize()">
269
<script language="javascript">
270
	insertTemplateOpening("<%=CONTEXT_URL%>");
271
</script>
272

    
273
<div id="content_wrapper">
274

    
275
<h2>Annotation-based search</h2>
276

    
277
<div id="error">
278
	<!-- error messages here -->
279
</div>
280

    
281
<form method="POST" 
282
		action="<%=SERVLET_URL%>" 
283
		target="_top" 
284
		id="searchForm" 
285
		name="searchForm" 
286
		onSubmit="return doSearch(this)">
287
	<input name="query" type="hidden" />
288
	<input name="qformat" value="semtools" type="hidden" />
289
	<input name="includeHeader" value="false" type="hidden" />
290
	<input name="action" value="semquery" type="hidden" />
291

    
292
	<table class="group group_border">
293
		<tr>
294
			<th colspan="3">
295
				<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
		</tr>
305
		<!--  measurement -->
306
		<tr>
307
			<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
							<input type="text" id="activeMeasurementsSearch" />
320
							Only active? <input type="checkbox" id="activeMeasurementsOnly" title="Show only active concepts"/>
321
							<div class="select">
322
								<div id="activeMeasurements" class="activeTree" style="width: 100%">
323
									<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
						</td>
329
					</tr>
330
				</table>
331
			</td>
332
		</tr>
333
		<tr>
334
			<td>
335
				<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
							<input type="text" id="activeEntitiesSearch" />
347
							<input type="checkbox" id="activeEntitiesOnly" title="Show only active concepts" />
348
							<div class="select">
349
								<div id="activeEntities" class="activeTree">
350
									<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
						</td>
356
					</tr>
357
				</table>
358
			</td>
359
			<td>
360
				<table class="subGroup subGroup_border">
361
					<tr>
362
						<th colspan="1">
363
							Characteristic
364
						</th>
365
					</tr>
366
					<tr>
367
						<td>with measurements of</td>
368
					</tr>
369
					<tr>
370
						<td>
371
							<input type="text" id="activeCharacteristicsSearch" />
372
							<input type="checkbox" id="activeCharacteristicsOnly" title="Show only active concepts" />
373
							<div class="select">
374
								<div id="activeCharacteristics" class="activeTree">
375
									<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
						</td>
381
					</tr>
382
				</table>
383
			</td>
384
			<td>
385
				<table class="subGroup subGroup_border">
386
					<tr>
387
						<th colspan="1">
388
							Protocol
389
						</th>
390
					</tr>
391
					<tr>
392
						<td>using procedures outlined by</td>
393
					</tr>
394
					<tr>
395
						<td>
396
							<input type="text" id="activeProtocolsSearch" />
397
							<input type="checkbox" id="activeProtocolsOnly" title="Show only active concepts" />
398
							<div class="select">
399
								<div id="activeProtocols" class="activeTree">
400
									<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
						</td>
406
					</tr>
407
				</table>
408
			</td>
409
		</tr>
410
		<tr>
411
			<td colspan="3">Match All? <input type="checkbox" name="matchAll" checked="checked"/></td>
412
		</tr>
413
		<tr>
414
			<td colspan="3">From same Observation? <input type="checkbox" name="strict"/></td>
415
		</tr>
416
		<tr>
417
			<td colspan="3">
418
				<!-- input type="submit" value="Search"/ -->
419
				<input type="reset" value="Clear" onclick="$('#searchForm').get(0).reset(); initialize()"/>
420
			</td>
421
		</tr>
422
	</table>
423
		<!-- 
424
		<tr>
425
			<td>Entity: (SBC only)</td>
426
			<td><input type="text" name="entity" class="bp_form_complete-1523-uri" size="100" /></td>
427
		</tr>
428
		 -->		
429
</form>
430

    
431
<div id="searchResults">
432
	Search Results
433
</div>
434

    
435
<!-- 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
</div>
449

    
450
<script language="javascript">
451
	insertTemplateClosing("<%=CONTEXT_URL%>");
452
</script>
453

    
454
</body>
455
</html>
(5-5/14)