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 16:18:35 -0800 (Tue, 23 Nov 2010) $'
10
 * '$Revision: 5665 $'
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" : [ "themes", "html_data", "ui", "cookies", "search" ]
106
					});
107
			});
108

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

    
131
			// TODO: try to select the original node after refresh with active domain
132
			//$("#" + divId).jstree("open_node", $(selectedNode));
133
			//$("#" + divId).jstree("select_node", $(selectedNode));
134
		});
135
}
136
/**
137
* Prunes the given tree to inlcude the given matched class 
138
**/
139
function prune(divId, matchClass) {
140

    
141
	// show all nodes (reset)
142
	$("#" + divId).find("li").show();
143
	
144
	// done if we don't have any thing to prune
145
	if (!matchClass) {
146
		return;
147
	}
148
	
149
	// get all non-matched anchor tags
150
	var nonmatches = $("#" + divId).find("a").not("." + matchClass);
151
	
152
	// get their parent nodes
153
	nonmatches = $(nonmatches).parents("li");
154

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

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

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

    
246
</head>
247
<body onload="initialize()">
248
<script language="javascript">
249
	insertTemplateOpening("<%=CONTEXT_URL%>");
250
</script>
251

    
252
<div id="content_wrapper">
253

    
254
<h2>Annotation-based search</h2>
255

    
256
<div id="error">
257
	<!-- error messages here -->
258
</div>
259

    
260
<form method="POST" 
261
		action="<%=SERVLET_URL%>" 
262
		target="_top" 
263
		id="searchForm" 
264
		name="searchForm" 
265
		onSubmit="return doSearch(this)">
266
	<input name="query" type="hidden" />
267
	<input name="qformat" value="semtools" type="hidden" />
268
	<input name="includeHeader" value="false" type="hidden" />
269
	<input name="action" value="semquery" type="hidden" />
270

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

    
410
<div id="searchResults">
411
	Search Results
412
</div>
413

    
414
<!-- Included default search/login -->
415
<% if ( PropertyService.getProperty("spatial.runSpatialOption").equals("true") ) { %>
416
<script language="javascript">
417
	insertMap("<%=CONTEXT_URL%>");
418
</script>
419
<br/>
420
<% } %>
421
  
422
<script language="javascript">
423
	insertSearchBox("<%=CONTEXT_URL%>");
424
	insertLoginBox("<%=CONTEXT_URL%>");	
425
</script>
426

    
427
</div>
428

    
429
<script language="javascript">
430
	insertTemplateClosing("<%=CONTEXT_URL%>");
431
</script>
432

    
433
</body>
434
</html>
(5-5/14)