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 11:54:16 -0800 (Tue, 23 Nov 2010) $'
10
 * '$Revision: 5664 $'
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 other trees for active domain after this filtering action
218
	// TODO actually do the active domain filtering when selection is made
219
	//initialize($(parent).children("div"));
220
}
221
function donothing() {}
222
--></script>
223

    
224
</head>
225
<body onload="initialize()">
226
<script language="javascript">
227
	insertTemplateOpening("<%=CONTEXT_URL%>");
228
</script>
229

    
230
<div id="content_wrapper">
231

    
232
<h2>Annotation-based search</h2>
233

    
234
<div id="error">
235
	<!-- error messages here -->
236
</div>
237

    
238
<form method="POST" action="<%=SERVLET_URL%>" target="_top" id="searchForm" name="searchForm" onSubmit="return checkSearch(this)">
239
	<input name="query" type="hidden" />
240
	<input name="qformat" value="semtools" type="hidden" />
241
	<input name="action" value="semquery" type="hidden" />
242

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

    
382
<!-- Included default search/login -->
383
<% if ( PropertyService.getProperty("spatial.runSpatialOption").equals("true") ) { %>
384
<script language="javascript">
385
	insertMap("<%=CONTEXT_URL%>");
386
</script>
387
<br/>
388
<% } %>
389
  
390
<script language="javascript">
391
	insertSearchBox("<%=CONTEXT_URL%>");
392
	insertLoginBox("<%=CONTEXT_URL%>");	
393
</script>
394

    
395
</div>
396

    
397
<script language="javascript">
398
	insertTemplateClosing("<%=CONTEXT_URL%>");
399
</script>
400

    
401
</body>
402
</html>
(5-5/14)