Project

General

Profile

1 5509 leinfelder
<%@ 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$'
9
 *      '$Date$'
10
 * '$Revision$'
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 5385 leinfelder
%>
27 5632 leinfelder
28 5509 leinfelder
<%@ include file="../../common/common-settings.jsp"%>
29
<%@ include file="../../common/configure-check.jsp"%>
30 5604 leinfelder
31 5385 leinfelder
<html>
32
<head>
33 5509 leinfelder
<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 5656 leinfelder
<!--
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 5509 leinfelder
<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 5656 leinfelder
<script language="Javascript" type="text/JavaScript"><!--
54 5633 leinfelder
function populateActiveDomain(divId, class) {
55 5656 leinfelder
	// 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 5633 leinfelder
62 5656 leinfelder
	// 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 5633 leinfelder
	$("#" + divId).load(
69 5656 leinfelder
		"<%=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 5660 leinfelder
					//bind calls here
91 5656 leinfelder
					.jstree({
92
						"ui" : {
93
							"select_limit" : 1,
94
							"select_multiple_modifier" : "alt",
95
							"selected_parent_close" : "select_parent"//,
96
							//"initially_select" : [ selectedNodeId ]
97 5659 leinfelder
						},
98
						"themes" : {
99
							"theme" : "default",
100
							"dots" : true,
101
							"icons" : false
102
						},
103 5656 leinfelder
						//"core" : { "initially_open" : [ selectedNodeId ] },
104 5658 leinfelder
						"search" : { "case_insensitive" : true },
105
						"plugins" : [ "themes", "html_data", "ui", "cookies", "search" ]
106 5656 leinfelder
					});
107
			});
108
109 5658 leinfelder
			// 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 5663 leinfelder
						// now prune
115
						prune(divId);
116 5658 leinfelder
					}
117
				});
118
119 5656 leinfelder
			// TODO: try to select the original node after refresh with active domain
120
			//$("#" + divId).jstree("open_node", $(selectedNode));
121
			//$("#" + divId).jstree("select_node", $(selectedNode));
122
		});
123 5633 leinfelder
}
124 5663 leinfelder
function prune(divId) {
125
126
	// show all nodes (reset)
127
	$("#" + divId).find("li").show();
128
129
	// get all non-matched anchor tags
130
	var nonmatches = $("#" + divId).find("a").not(".jstree-search");
131
132
	// get their parent nodes
133
	nonmatches = $(nonmatches).parents("li");
134
135
	// are there any matches under each parent node?
136
	$(nonmatches).each(
137
		function(index) {
138
			// do any chidren match?
139
			var childMatches = $(this).find("a.jstree-search");
140
			if (childMatches && childMatches.length > 0) {
141
				return true;
142
			}
143
			// parent matches?
144
			var parentMatches = $(this).parents("li").children("a.jstree-search");
145
			if (parentMatches && parentMatches.length > 0) {
146
				return true;
147
			}
148
			// hide this node if no matches under it
149
			$(this).hide();
150
		});
151
}
152 5633 leinfelder
function initialize(source) {
153 5656 leinfelder
	// we don't want to reload the source of the filtering request
154
	// but we do want to reload the other trees for active domains
155
	// we reload all of them if no source is given - first time the page loads
156 5633 leinfelder
	if (source) {
157 5656 leinfelder
		source = $(source).attr("id");
158 5633 leinfelder
	}
159
	if (!source) {
160
		source = "";
161
	}
162
	if (source != 'activeEntities') {
163
		populateActiveDomain('activeEntities', 'org.ecoinformatics.sms.annotation.Entity');
164
	}
165
	if (source != 'activeCharacteristics') {
166
		populateActiveDomain('activeCharacteristics', 'org.ecoinformatics.sms.annotation.Characteristic');
167
	}
168
	if (source != 'activeProtocols') {
169
		populateActiveDomain('activeProtocols', 'org.ecoinformatics.sms.annotation.Protocol');
170
	}
171
	if (source != 'activeMeasurements') {
172
		populateActiveDomain('activeMeasurements', 'org.ecoinformatics.sms.annotation.Measurement');
173
	}
174
}
175 5656 leinfelder
function select(item) {
176 5633 leinfelder
177 5656 leinfelder
	// get the selected value, stored in the title attribute of the item <a> tag
178
	var value = $(item).attr("title");
179
	//alert("value: " + value);
180
181
	// get the parent div so we know what kind of class it is meant to filter
182
	// this is "the first parent of the class 'select'"
183
	var parent = $(item).parents("div.select:first");
184
	//alert("parent: " + parent);
185
186
	// set the value for the hidden input value
187
	// the input field of class "value" will hold it, this way we don't need to know the id
188
	var input = $(parent).children("input.value");
189
	$(input).val(value);
190
	//alert("input: " + input);
191 5662 leinfelder
192
	// set it in the search field
193
	var treeInstance = $(item).parents("div.jstree:first");
194
	var shortName = $(item).parent().attr("id");
195
	$("#" + $(treeInstance).attr("id") + "Search").val(shortName)
196 5656 leinfelder
197
	// refresh the other trees for active domain after this filtering action
198
	// TODO actually do the active domain filtering when selection is made
199
	//initialize($(parent).children("div"));
200
}
201
function donothing() {}
202
--></script>
203
204 5385 leinfelder
</head>
205 5633 leinfelder
<body onload="initialize()">
206 5509 leinfelder
<script language="javascript">
207
	insertTemplateOpening("<%=CONTEXT_URL%>");
208
</script>
209 5385 leinfelder
210 5574 leinfelder
<div id="content_wrapper">
211
212 5533 leinfelder
<h2>Annotation-based search</h2>
213 5385 leinfelder
214 5633 leinfelder
<div id="error">
215
	<!-- error messages here -->
216
</div>
217
218 5509 leinfelder
<form method="POST" action="<%=SERVLET_URL%>" target="_top" id="searchForm" name="searchForm" onSubmit="return checkSearch(this)">
219
	<input name="query" type="hidden" />
220
	<input name="qformat" value="semtools" type="hidden" />
221 5533 leinfelder
	<input name="action" value="semquery" type="hidden" />
222 5509 leinfelder
223 5602 leinfelder
	<table class="group group_border">
224 5509 leinfelder
		<tr>
225 5632 leinfelder
			<th colspan="3">
226 5602 leinfelder
				<p>
227
					Locate <b>data packages</b> that have been semantically annotated within the observation model by
228
					selecting concepts from
229
					<br/>
230
					(a) existing semantic annotations
231
					<br/>
232
					(b) registered OBOE extension ontologies
233
				</p>
234
			</th>
235 5533 leinfelder
		</tr>
236 5632 leinfelder
		<!--  measurement -->
237 5533 leinfelder
		<tr>
238 5632 leinfelder
			<td colspan="3">
239
				<table class="subGroup subGroup_border onehundred_percent">
240
					<tr>
241
						<th colspan="2">
242
							Measurement
243
						</th>
244
					</tr>
245
					<tr>
246
						<td>a template that defines Entity, Characteristic, Standard, and/or Protocol</td>
247
					</tr>
248
					<tr>
249
						<td>
250 5658 leinfelder
							<input type="text" id="activeMeasurementsSearch" />
251 5656 leinfelder
							<div class="select">
252 5660 leinfelder
								<div id="activeMeasurements" style="width: 100%; height: 100px; overflow: auto">
253 5656 leinfelder
									<p>loading...</p>
254
								</div>
255
								<input type="hidden" class="value" name="activeMeasurementsValue" id="activeMeasurementsValue"/>
256
								<input type="hidden" name="activeMeasurementsClass" id="activeMeasurementsClass" value="http://ecoinformatics.org/oboe/oboe.1.0/oboe-core.owl#Measurement"/>
257
							</div>
258 5632 leinfelder
						</td>
259
					</tr>
260
				</table>
261
			</td>
262
		</tr>
263
		<tr>
264 5533 leinfelder
			<td>
265 5602 leinfelder
				<table class="subGroup subGroup_border">
266
					<tr>
267
						<th colspan="1">
268
							Entity
269
						</th>
270
					</tr>
271
					<tr>
272
						<td>Find observations of</td>
273
					</tr>
274
					<tr>
275
						<td>
276 5658 leinfelder
							<input type="text" id="activeEntitiesSearch" />
277 5656 leinfelder
							<div class="select">
278 5660 leinfelder
								<div id="activeEntities" style="width: 216px; height: 100px; overflow: auto">
279 5656 leinfelder
									<p>loading...</p>
280
								</div>
281
								<input type="hidden" class="value" name="activeEntitiesValue" id="activeEntitiesValue"/>
282
								<input type="hidden" name="activeEntitiesClass" id="activeEntitiesClass" value="http://ecoinformatics.org/oboe/oboe.1.0/oboe-core.owl#Entity"/>
283
							</div>
284 5602 leinfelder
						</td>
285
					</tr>
286
				</table>
287 5533 leinfelder
			</td>
288
			<td>
289 5602 leinfelder
				<table class="subGroup subGroup_border">
290
					<tr>
291
						<th colspan="1">
292
							Characteristic
293
						</th>
294
					</tr>
295
					<tr>
296 5632 leinfelder
						<td>with measurements of</td>
297 5602 leinfelder
					</tr>
298
					<tr>
299
						<td>
300 5658 leinfelder
							<input type="text" id="activeCharacteristicsSearch" />
301 5656 leinfelder
							<div class="select">
302 5660 leinfelder
								<div id="activeCharacteristics" style="width: 216px; height: 100px; overflow: auto">
303 5656 leinfelder
									<p>loading...</p>
304
								</div>
305
								<input type="hidden" class="value" name="activeCharacteristicsValue" id="activeCharacteristicsValue"/>
306
								<input type="hidden" name="activeCharacteristicsClass" id="activeCharacteristicsClass" value="http://ecoinformatics.org/oboe/oboe.1.0/oboe-core.owl#Characteristic"/>
307
							</div>
308 5602 leinfelder
						</td>
309
					</tr>
310
				</table>
311 5533 leinfelder
			</td>
312
			<td>
313 5602 leinfelder
				<table class="subGroup subGroup_border">
314
					<tr>
315
						<th colspan="1">
316
							Protocol
317
						</th>
318
					</tr>
319
					<tr>
320 5632 leinfelder
						<td>using procedures outlined by</td>
321 5602 leinfelder
					</tr>
322
					<tr>
323
						<td>
324 5658 leinfelder
							<input type="text" id="activeProtocolsSearch" />
325 5656 leinfelder
							<div class="select">
326 5660 leinfelder
								<div id="activeProtocols" style="width: 216px; height: 100px; overflow: auto">
327 5656 leinfelder
									<p>loading...</p>
328
								</div>
329
								<input type="hidden" class="value" name="activeProtocolsValue" id="activeProtocolsValue" />
330
								<input type="hidden" name="activeProtocolsClass" id="activeProtocolsClass" value="http://ecoinformatics.org/oboe/oboe.1.0/oboe-core.owl#Protocol"/>
331
							</div>
332 5602 leinfelder
						</td>
333
					</tr>
334
				</table>
335 5533 leinfelder
			</td>
336
		</tr>
337
		<tr>
338 5632 leinfelder
			<td colspan="3">Match All? <input type="checkbox" name="matchAll" checked="checked"/></td>
339 5509 leinfelder
		</tr>
340
		<tr>
341 5632 leinfelder
			<td colspan="3">From same Observation? <input type="checkbox" name="strict"/></td>
342 5509 leinfelder
		</tr>
343
		<tr>
344 5633 leinfelder
			<td colspan="3">
345
				<input type="submit" value="Search"/>
346
				<input type="reset" value="Clear" onclick="$('#searchForm').get(0).reset(); initialize()"/>
347
			</td>
348 5509 leinfelder
		</tr>
349 5602 leinfelder
	</table>
350
		<!--
351 5509 leinfelder
		<tr>
352 5602 leinfelder
			<td>Entity: (SBC only)</td>
353
			<td><input type="text" name="entity" class="bp_form_complete-1523-uri" size="100" /></td>
354 5509 leinfelder
		</tr>
355 5602 leinfelder
		 -->
356 5509 leinfelder
</form>
357
358
<!-- Included default search/login -->
359
<% if ( PropertyService.getProperty("spatial.runSpatialOption").equals("true") ) { %>
360
<script language="javascript">
361
	insertMap("<%=CONTEXT_URL%>");
362
</script>
363
<br/>
364
<% } %>
365
366
<script language="javascript">
367
	insertSearchBox("<%=CONTEXT_URL%>");
368
	insertLoginBox("<%=CONTEXT_URL%>");
369
</script>
370
371 5574 leinfelder
</div>
372
373 5509 leinfelder
<script language="javascript">
374
	insertTemplateClosing("<%=CONTEXT_URL%>");
375
</script>
376
377 5385 leinfelder
</body>
378
</html>