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 5661 leinfelder
28 5633 leinfelder
        	// handle specific classes
29
        	// Entity
30 5774 leinfelder
    		if (submitFormObj.activeEntitiesClass.value) {
31
    			var searchClass = submitFormObj.activeEntitiesClass.value;
32 5656 leinfelder
        	    var searchValue = submitFormObj.activeEntitiesValue.value;
33 5633 leinfelder
        	    if (searchValue!="") {
34
	        	    submitFormObj.query.value +=
35
	        	    	"<condition " +
36
		        		"concept='" + searchClass + "' " +
37
						"operator='EQUALS'>" +
38
						searchValue +
39
					"</condition>";
40
        	    }
41 5774 leinfelder
    		} else {
42
	        	for (var i=0; i < submitFormObj.activeEntitiesValue.length; i++) {
43
	        		var searchClass = submitFormObj.activeEntitiesClass[i].value;
44
	        	    var searchValue = submitFormObj.activeEntitiesValue[i].value;
45
	        	    if (searchValue!="") {
46
		        	    submitFormObj.query.value +=
47
		        	    	"<condition " +
48
			        		"concept='" + searchClass + "' " +
49
							"operator='EQUALS'>" +
50
							searchValue +
51
						"</condition>";
52
	        	    }
53
	        	}
54
    		}
55 5633 leinfelder
        	// Characteristic
56 5774 leinfelder
    		if (submitFormObj.activeCharacteristicsClass.value) {
57
    			var searchClass = submitFormObj.activeCharacteristicsClass.value;
58 5656 leinfelder
        	    var searchValue = submitFormObj.activeCharacteristicsValue.value;
59 5633 leinfelder
        	    if (searchValue!="") {
60
	        	    submitFormObj.query.value +=
61
	        	    	"<condition " +
62
		        		"concept='" + searchClass + "' " +
63
						"operator='EQUALS'>" +
64
						searchValue +
65
					"</condition>";
66
        	    }
67 5774 leinfelder
    		} else {
68
	        	for (var i=0; i < submitFormObj.activeCharacteristicsValue.length; i++) {
69
	        		var searchClass = submitFormObj.activeCharacteristicsClass[i].value;
70
	        	    var searchValue = submitFormObj.activeCharacteristicsValue[i].value;
71
	        	    if (searchValue!="") {
72
		        	    submitFormObj.query.value +=
73
		        	    	"<condition " +
74
			        		"concept='" + searchClass + "' " +
75
							"operator='EQUALS'>" +
76
							searchValue +
77
						"</condition>";
78
	        	    }
79
	        	}
80
    		}
81 5633 leinfelder
        	// Protocol
82 5774 leinfelder
    		if (submitFormObj.activeProtocolsValue.value) {
83
    			var searchClass = submitFormObj.activeProtocolsValue.value;
84 5656 leinfelder
        	    var searchValue = submitFormObj.activeProtocolsValue.value;
85 5633 leinfelder
        	    if (searchValue!="") {
86
	        	    submitFormObj.query.value +=
87
	        	    	"<condition " +
88
		        		"concept='" + searchClass + "' " +
89
						"operator='EQUALS'>" +
90
						searchValue +
91
					"</condition>";
92
        	    }
93 5774 leinfelder
    		} else {
94
	        	for (var i=0; i < submitFormObj.activeProtocolsValue.length; i++) {
95
	        		var searchClass = submitFormObj.activeProtocolsClass[i].value;
96
	        	    var searchValue = submitFormObj.activeProtocolsValue[i].value;
97
	        	    if (searchValue!="") {
98
		        	    submitFormObj.query.value +=
99
		        	    	"<condition " +
100
			        		"concept='" + searchClass + "' " +
101
							"operator='EQUALS'>" +
102
							searchValue +
103
						"</condition>";
104
	        	    }
105
	        	}
106
    		}
107 5633 leinfelder
        	// Measurement
108 5774 leinfelder
    		if (submitFormObj.activeMeasurementsValue.value) {
109
    			var searchClass = submitFormObj.activeMeasurementsValue.value;
110 5656 leinfelder
        	    var searchValue = submitFormObj.activeMeasurementsValue.value;
111 5633 leinfelder
        	    if (searchValue!="") {
112
	        	    submitFormObj.query.value +=
113
	        	    	"<condition " +
114
		        		"concept='" + searchClass + "' " +
115
						"operator='EQUALS'>" +
116
						searchValue +
117
					"</condition>";
118
        	    }
119 5774 leinfelder
    		} else {
120
	        	for (var i=0; i < submitFormObj.activeMeasurementsValue.length; i++) {
121
	        		var searchClass = submitFormObj.activeMeasurementsClass[i].value;
122
	        	    var searchValue = submitFormObj.activeMeasurementsValue[i].value;
123
	        	    if (searchValue!="") {
124
		        	    submitFormObj.query.value +=
125
		        	    	"<condition " +
126
			        		"concept='" + searchClass + "' " +
127
							"operator='EQUALS'>" +
128
							searchValue +
129
						"</condition>";
130
	        	    }
131
	        	}
132
    		}
133 5533 leinfelder
        	submitFormObj.query.value += "</" + operator + ">";
134
    	submitFormObj.query.value += "</sq:query>";
135
136 5635 leinfelder
    //alert("query: " + submitFormObj.query.value);
137 5509 leinfelder
138
    return true;
139 5704 leinfelder
}