1 |
5509
|
leinfelder
|
function trim(stringToTrim) {
|
2 |
|
|
return stringToTrim.replace(/^\s*/, '').replace(/\s*$/,'');
|
3 |
|
|
}
|
4 |
|
|
|
5 |
|
|
function checkSearch(submitFormObj) {
|
6 |
|
|
|
7 |
5533
|
leinfelder
|
var operator = "OR";
|
8 |
|
|
if (submitFormObj.matchAll.checked) {
|
9 |
|
|
operator = "AND";
|
10 |
|
|
}
|
11 |
|
|
var strict = "false";
|
12 |
|
|
if (submitFormObj.strict.checked) {
|
13 |
|
|
strict = "true";
|
14 |
|
|
}
|
15 |
|
|
submitFormObj.query.value =
|
16 |
|
|
"<sq:query queryId='query.1' system='semtools' " +
|
17 |
|
|
"xmlns:sq='http://ecoinformatics.org/semQuery-1.0.0' " +
|
18 |
|
|
"xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' " +
|
19 |
|
|
"xsi:schemaLocation='http://ecoinformatics.org/semQuery-1.0.0 semQuery.xsd '>" +
|
20 |
5951
|
leinfelder
|
"<namespace prefix='sms'>http://ecoinformatics.org/sms/annotation.1.0beta1</namespace>" +
|
21 |
5533
|
leinfelder
|
"<returnField>/@id</returnField>" +
|
22 |
5951
|
leinfelder
|
"<returnField>/@dataPackage</returnField>" +
|
23 |
5533
|
leinfelder
|
"<title>Semantic Search Example</title>" +
|
24 |
|
|
"<!-- Match all criteria, must be on same observation -->" +
|
25 |
|
|
"<" + operator + " strict='" + strict + "'>";
|
26 |
5661
|
leinfelder
|
|
27 |
5633
|
leinfelder
|
// handle specific classes
|
28 |
|
|
// Entity
|
29 |
5774
|
leinfelder
|
if (submitFormObj.activeEntitiesClass.value) {
|
30 |
|
|
var searchClass = submitFormObj.activeEntitiesClass.value;
|
31 |
5656
|
leinfelder
|
var searchValue = submitFormObj.activeEntitiesValue.value;
|
32 |
5633
|
leinfelder
|
if (searchValue!="") {
|
33 |
|
|
submitFormObj.query.value +=
|
34 |
|
|
"<condition " +
|
35 |
|
|
"concept='" + searchClass + "' " +
|
36 |
|
|
"operator='EQUALS'>" +
|
37 |
|
|
searchValue +
|
38 |
|
|
"</condition>";
|
39 |
|
|
}
|
40 |
5774
|
leinfelder
|
} else {
|
41 |
|
|
for (var i=0; i < submitFormObj.activeEntitiesValue.length; i++) {
|
42 |
|
|
var searchClass = submitFormObj.activeEntitiesClass[i].value;
|
43 |
|
|
var searchValue = submitFormObj.activeEntitiesValue[i].value;
|
44 |
|
|
if (searchValue!="") {
|
45 |
|
|
submitFormObj.query.value +=
|
46 |
|
|
"<condition " +
|
47 |
|
|
"concept='" + searchClass + "' " +
|
48 |
|
|
"operator='EQUALS'>" +
|
49 |
|
|
searchValue +
|
50 |
|
|
"</condition>";
|
51 |
|
|
}
|
52 |
|
|
}
|
53 |
|
|
}
|
54 |
5633
|
leinfelder
|
// Characteristic
|
55 |
5774
|
leinfelder
|
if (submitFormObj.activeCharacteristicsClass.value) {
|
56 |
|
|
var searchClass = submitFormObj.activeCharacteristicsClass.value;
|
57 |
5656
|
leinfelder
|
var searchValue = submitFormObj.activeCharacteristicsValue.value;
|
58 |
5633
|
leinfelder
|
if (searchValue!="") {
|
59 |
|
|
submitFormObj.query.value +=
|
60 |
|
|
"<condition " +
|
61 |
|
|
"concept='" + searchClass + "' " +
|
62 |
|
|
"operator='EQUALS'>" +
|
63 |
|
|
searchValue +
|
64 |
|
|
"</condition>";
|
65 |
|
|
}
|
66 |
5774
|
leinfelder
|
} else {
|
67 |
|
|
for (var i=0; i < submitFormObj.activeCharacteristicsValue.length; i++) {
|
68 |
|
|
var searchClass = submitFormObj.activeCharacteristicsClass[i].value;
|
69 |
|
|
var searchValue = submitFormObj.activeCharacteristicsValue[i].value;
|
70 |
|
|
if (searchValue!="") {
|
71 |
|
|
submitFormObj.query.value +=
|
72 |
|
|
"<condition " +
|
73 |
|
|
"concept='" + searchClass + "' " +
|
74 |
|
|
"operator='EQUALS'>" +
|
75 |
|
|
searchValue +
|
76 |
|
|
"</condition>";
|
77 |
|
|
}
|
78 |
|
|
}
|
79 |
|
|
}
|
80 |
5633
|
leinfelder
|
// Protocol
|
81 |
5774
|
leinfelder
|
if (submitFormObj.activeProtocolsValue.value) {
|
82 |
5954
|
leinfelder
|
var searchClass = submitFormObj.activeProtocolsClass.value;
|
83 |
5656
|
leinfelder
|
var searchValue = submitFormObj.activeProtocolsValue.value;
|
84 |
5633
|
leinfelder
|
if (searchValue!="") {
|
85 |
|
|
submitFormObj.query.value +=
|
86 |
|
|
"<condition " +
|
87 |
|
|
"concept='" + searchClass + "' " +
|
88 |
|
|
"operator='EQUALS'>" +
|
89 |
|
|
searchValue +
|
90 |
|
|
"</condition>";
|
91 |
|
|
}
|
92 |
5774
|
leinfelder
|
} else {
|
93 |
|
|
for (var i=0; i < submitFormObj.activeProtocolsValue.length; i++) {
|
94 |
|
|
var searchClass = submitFormObj.activeProtocolsClass[i].value;
|
95 |
|
|
var searchValue = submitFormObj.activeProtocolsValue[i].value;
|
96 |
|
|
if (searchValue!="") {
|
97 |
|
|
submitFormObj.query.value +=
|
98 |
|
|
"<condition " +
|
99 |
|
|
"concept='" + searchClass + "' " +
|
100 |
|
|
"operator='EQUALS'>" +
|
101 |
|
|
searchValue +
|
102 |
|
|
"</condition>";
|
103 |
|
|
}
|
104 |
|
|
}
|
105 |
|
|
}
|
106 |
5633
|
leinfelder
|
// Measurement
|
107 |
5774
|
leinfelder
|
if (submitFormObj.activeMeasurementsValue.value) {
|
108 |
5954
|
leinfelder
|
var searchClass = submitFormObj.activeMeasurementsClass.value;
|
109 |
5656
|
leinfelder
|
var searchValue = submitFormObj.activeMeasurementsValue.value;
|
110 |
5633
|
leinfelder
|
if (searchValue!="") {
|
111 |
|
|
submitFormObj.query.value +=
|
112 |
|
|
"<condition " +
|
113 |
|
|
"concept='" + searchClass + "' " +
|
114 |
|
|
"operator='EQUALS'>" +
|
115 |
|
|
searchValue +
|
116 |
|
|
"</condition>";
|
117 |
|
|
}
|
118 |
5774
|
leinfelder
|
} else {
|
119 |
|
|
for (var i=0; i < submitFormObj.activeMeasurementsValue.length; i++) {
|
120 |
|
|
var searchClass = submitFormObj.activeMeasurementsClass[i].value;
|
121 |
|
|
var searchValue = submitFormObj.activeMeasurementsValue[i].value;
|
122 |
|
|
if (searchValue!="") {
|
123 |
|
|
submitFormObj.query.value +=
|
124 |
|
|
"<condition " +
|
125 |
|
|
"concept='" + searchClass + "' " +
|
126 |
|
|
"operator='EQUALS'>" +
|
127 |
|
|
searchValue +
|
128 |
|
|
"</condition>";
|
129 |
|
|
}
|
130 |
|
|
}
|
131 |
|
|
}
|
132 |
5533
|
leinfelder
|
submitFormObj.query.value += "</" + operator + ">";
|
133 |
|
|
submitFormObj.query.value += "</sq:query>";
|
134 |
|
|
|
135 |
5635
|
leinfelder
|
//alert("query: " + submitFormObj.query.value);
|
136 |
5509
|
leinfelder
|
|
137 |
|
|
return true;
|
138 |
5704
|
leinfelder
|
}
|