Project

General

Profile

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
        	"<namespace prefix='sms'>http://ecoinformatics.org/sms/annotation.0.9</namespace>" +
21
        	"<returnField>/@id</returnField>" +
22
        	"<returnField>/@emlPackage</returnField>" +
23
        	"<returnField>/@dataTable</returnField>" +
24
        	"<title>Semantic Search Example</title>" +
25
        	"<!-- Match all criteria, must be on same observation -->" +
26
        	"<" + operator + " strict='" + strict + "'>";
27
        	for (var i=0; i < submitFormObj.dynamicClass.length; i++) {
28
        		var searchClass = submitFormObj.dynamicClass[i].value;
29
        	    var searchValue = submitFormObj.dynamicValue[i].value;
30
        	    if (searchValue!="") {
31
	        	    submitFormObj.query.value +=
32
	        	    	"<condition " +
33
		        		"concept='" + searchClass + "' " +
34
						"operator='EQUALS'>" +
35
						searchValue +
36
					"</condition>";
37
        	    }
38
        	}
39
        	submitFormObj.query.value += "</" + operator + ">";
40
    	submitFormObj.query.value += "</sq:query>";
41
42 5586 leinfelder
    //alert("query: " + submitFormObj.query.value);
43 5509 leinfelder
44
    return true;
45
}