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-23 17:02:52 -0800 (Tue, 23 Nov 2010) $'
10
 * '$Revision: 5666 $'
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: " + selectedNodeId);
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
						"plugins" : [ 
106
							"themes", 
107
							"html_data", 
108
							"ui", 
109
							"cookies", 
110
							"search" ]
111
					});
112
			});
113

    
114
			// enable searching on it
115
			$("#" + divId + "Search").keyup(
116
				function () {
117
					if ($("#" + divId + "Search").val().length >= 3) {
118
						$("#" + divId).jstree("search", $("#" + divId + "Search").val());
119
						// now prune
120
						prune(divId, "jstree-search");
121
					}
122
				});
123
			
124
			// toggle the active domain prune
125
			$("#" + divId + "Only").click(
126
				function () {
127
					if ($("#" + divId + "Only").is(":checked")) {
128
						// prune to active
129
						prune(divId, "bold");
130
					} else {
131
						// reset
132
						prune(divId, null);
133
					}
134
				});	
135

    
136
			// TODO: make this work
137
			// open to the node
138
			$("#" + divId).jstree("open_node", $(selectedNode));
139
			// select the original node 
140
			$("#" + divId).jstree("select_node", $(selectedNode));
141
		});
142
}
143
/**
144
* Prunes the given tree to inlcude the given matched class 
145
**/
146
function prune(divId, matchClass) {
147

    
148
	// show all nodes (reset)
149
	$("#" + divId).find("li").show();
150
	
151
	// done if we don't have any thing to prune
152
	if (!matchClass) {
153
		return;
154
	}
155
	
156
	// get all non-matched anchor tags
157
	var nonmatches = $("#" + divId).find("a").not("." + matchClass);
158
	
159
	// get their parent nodes
160
	nonmatches = $(nonmatches).parents("li");
161

    
162
	// are there any matches under each parent node?
163
	$(nonmatches).each(
164
		function(index) {
165
			// do any chidren match?
166
			var childMatches = $(this).find("a." + matchClass);
167
			if (childMatches && childMatches.length > 0) {
168
				return true;
169
			}
170
			// parent matches?
171
			var parentMatches = $(this).parents("li").children("a." + matchClass);
172
			if (parentMatches && parentMatches.length > 0) {
173
				return true;
174
			}
175
			// hide this node if no matches under it
176
			$(this).hide();
177
		});
178
}
179
function initialize(source) {
180
	// we don't want to reload the source of the filtering request
181
	// but we do want to reload the other trees for active domains
182
	// we reload all of them if no source is given - first time the page loads
183
	if (source) {
184
		source = $(source).attr("id");
185
	}
186
	if (!source) {
187
		source = "";
188
	}
189
	if (source != 'activeEntities') {
190
		populateActiveDomain('activeEntities', 'org.ecoinformatics.sms.annotation.Entity');
191
	}
192
	if (source != 'activeCharacteristics') {
193
		populateActiveDomain('activeCharacteristics', 'org.ecoinformatics.sms.annotation.Characteristic');
194
	}
195
	if (source != 'activeProtocols') {
196
		populateActiveDomain('activeProtocols', 'org.ecoinformatics.sms.annotation.Protocol');
197
	}
198
	if (source != 'activeMeasurements') {
199
		populateActiveDomain('activeMeasurements', 'org.ecoinformatics.sms.annotation.Measurement');
200
	}
201
}
202
function select(item) {
203

    
204
	// get the selected value, stored in the title attribute of the item <a> tag
205
	var value = $(item).attr("title");
206
	//alert("value: " + value);
207
	
208
	// get the parent div so we know what kind of class it is meant to filter
209
	// this is "the first parent of the class 'select'"
210
	var parent = $(item).parents("div.select:first");
211
	//alert("parent: " + parent);
212
	
213
	// set the value for the hidden input value
214
	// the input field of class "value" will hold it, this way we don't need to know the id
215
	var input = $(parent).children("input.value");
216
	$(input).val(value);
217
	//alert("input: " + input);
218
	
219
	// set it in the search field
220
	var treeInstance = $(item).parents("div.jstree:first");
221
	var shortName = $(item).parent().attr("id");
222
	$("#" + $(treeInstance).attr("id") + "Search").val(shortName)
223

    
224
	// refresh the search results
225
	doSearch($("#searchForm").get(0));
226
	
227
	// refresh the other trees for active domain after this filtering action
228
	initialize($(parent).children("div"));
229
}
230
function doSearch(formObj) {
231
	// set the hidden parameters based on the current state of the form
232
	checkSearch(formObj);
233
	
234
	//load the results
235
	$("#searchResults").load(
236
		"<%=SERVLET_URL%>" + " #content_wrapper",
237
		$(formObj).serialize(),
238
		// call back function when loading finishes
239
		function(response, status, xhr) {
240
			if (status == "error") {
241
				var msg = "Sorry but there was an error performing the search: ";
242
				$("#error").html(msg + xhr.status + " " + xhr.statusText);
243
			}
244
		});
245
		
246
	return false;
247
	
248
}
249
function donothing() {}
250
--></script>
251

    
252
</head>
253
<body onload="initialize()">
254
<script language="javascript">
255
	insertTemplateOpening("<%=CONTEXT_URL%>");
256
</script>
257

    
258
<div id="content_wrapper">
259

    
260
<h2>Annotation-based search</h2>
261

    
262
<div id="error">
263
	<!-- error messages here -->
264
</div>
265

    
266
<form method="POST" 
267
		action="<%=SERVLET_URL%>" 
268
		target="_top" 
269
		id="searchForm" 
270
		name="searchForm" 
271
		onSubmit="return doSearch(this)">
272
	<input name="query" type="hidden" />
273
	<input name="qformat" value="semtools" type="hidden" />
274
	<input name="includeHeader" value="false" type="hidden" />
275
	<input name="action" value="semquery" type="hidden" />
276

    
277
	<table class="group group_border">
278
		<tr>
279
			<th colspan="3">
280
				<p>
281
					Locate <b>data packages</b> that have been semantically annotated within the observation model by
282
					selecting concepts from
283
					<br/>
284
					(a) existing semantic annotations
285
					<br/>
286
					(b) registered OBOE extension ontologies
287
				</p>
288
			</th>
289
		</tr>
290
		<!--  measurement -->
291
		<tr>
292
			<td colspan="3">
293
				<table class="subGroup subGroup_border onehundred_percent">
294
					<tr>
295
						<th colspan="2">
296
							Measurement
297
						</th>
298
					</tr>
299
					<tr>
300
						<td>a template that defines Entity, Characteristic, Standard, and/or Protocol</td>
301
					</tr>
302
					<tr>
303
						<td>
304
							<input type="text" id="activeMeasurementsSearch" />
305
							Only active? <input type="checkbox" id="activeMeasurementsOnly" title="Show only active concepts"/>
306
							<div class="select">
307
								<div id="activeMeasurements" class="activeTree" style="width: 100%">
308
									<p>loading...</p>
309
								</div>
310
								<input type="hidden" class="value" name="activeMeasurementsValue" id="activeMeasurementsValue"/>
311
								<input type="hidden" name="activeMeasurementsClass" id="activeMeasurementsClass" value="http://ecoinformatics.org/oboe/oboe.1.0/oboe-core.owl#Measurement"/>
312
							</div>
313
						</td>
314
					</tr>
315
				</table>
316
			</td>
317
		</tr>
318
		<tr>
319
			<td>
320
				<table class="subGroup subGroup_border">
321
					<tr>
322
						<th colspan="1">
323
							Entity
324
						</th>
325
					</tr>
326
					<tr>
327
						<td>Find observations of</td>
328
					</tr>
329
					<tr>
330
						<td>
331
							<input type="text" id="activeEntitiesSearch" />
332
							<input type="checkbox" id="activeEntitiesOnly" title="Show only active concepts" />
333
							<div class="select">
334
								<div id="activeEntities" class="activeTree">
335
									<p>loading...</p>
336
								</div>
337
								<input type="hidden" class="value" name="activeEntitiesValue" id="activeEntitiesValue"/>
338
								<input type="hidden" name="activeEntitiesClass" id="activeEntitiesClass" value="http://ecoinformatics.org/oboe/oboe.1.0/oboe-core.owl#Entity"/>
339
							</div>
340
						</td>
341
					</tr>
342
				</table>
343
			</td>
344
			<td>
345
				<table class="subGroup subGroup_border">
346
					<tr>
347
						<th colspan="1">
348
							Characteristic
349
						</th>
350
					</tr>
351
					<tr>
352
						<td>with measurements of</td>
353
					</tr>
354
					<tr>
355
						<td>
356
							<input type="text" id="activeCharacteristicsSearch" />
357
							<input type="checkbox" id="activeCharacteristicsOnly" title="Show only active concepts" />
358
							<div class="select">
359
								<div id="activeCharacteristics" class="activeTree">
360
									<p>loading...</p>
361
								</div>
362
								<input type="hidden" class="value" name="activeCharacteristicsValue" id="activeCharacteristicsValue"/>
363
								<input type="hidden" name="activeCharacteristicsClass" id="activeCharacteristicsClass" value="http://ecoinformatics.org/oboe/oboe.1.0/oboe-core.owl#Characteristic"/>
364
							</div>
365
						</td>
366
					</tr>
367
				</table>
368
			</td>
369
			<td>
370
				<table class="subGroup subGroup_border">
371
					<tr>
372
						<th colspan="1">
373
							Protocol
374
						</th>
375
					</tr>
376
					<tr>
377
						<td>using procedures outlined by</td>
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
		<tr>
396
			<td colspan="3">Match All? <input type="checkbox" name="matchAll" checked="checked"/></td>
397
		</tr>
398
		<tr>
399
			<td colspan="3">From same Observation? <input type="checkbox" name="strict"/></td>
400
		</tr>
401
		<tr>
402
			<td colspan="3">
403
				<!-- input type="submit" value="Search"/ -->
404
				<input type="reset" value="Clear" onclick="$('#searchForm').get(0).reset(); initialize()"/>
405
			</td>
406
		</tr>
407
	</table>
408
		<!-- 
409
		<tr>
410
			<td>Entity: (SBC only)</td>
411
			<td><input type="text" name="entity" class="bp_form_complete-1523-uri" size="100" /></td>
412
		</tr>
413
		 -->		
414
</form>
415

    
416
<div id="searchResults">
417
	Search Results
418
</div>
419

    
420
<!-- Included default search/login -->
421
<% if ( PropertyService.getProperty("spatial.runSpatialOption").equals("true") ) { %>
422
<script language="javascript">
423
	insertMap("<%=CONTEXT_URL%>");
424
</script>
425
<br/>
426
<% } %>
427
  
428
<script language="javascript">
429
	insertSearchBox("<%=CONTEXT_URL%>");
430
	insertLoginBox("<%=CONTEXT_URL%>");	
431
</script>
432

    
433
</div>
434

    
435
<script language="javascript">
436
	insertTemplateClosing("<%=CONTEXT_URL%>");
437
</script>
438

    
439
</body>
440
</html>
(5-5/14)