Project

General

Profile

1
function trim(stringToTrim) {
2
    return stringToTrim.replace(/^\s*/, '').replace(/\s*$/,'');
3
}
4

    
5
function checkSearch(submitFormObj) {
6

    
7
	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
        	// handle specific classes
40
        	// Entity
41
        	//for (var i=0; i < submitFormObj.activeEntities.length; i++) {
42
        		var searchClass = submitFormObj.activeEntitiesClass.value;
43
        	    var searchValue = submitFormObj.activeEntities.value;
44
        	    if (searchValue!="") {
45
	        	    submitFormObj.query.value += 
46
	        	    	"<condition " +
47
		        		"concept='" + searchClass + "' " +
48
						"operator='EQUALS'>" +
49
						searchValue +
50
					"</condition>";
51
        	    }
52
        	//}
53
        	// Characteristic
54
        	//for (var i=0; i < submitFormObj.activeCharacteristics.length; i++) {
55
        		var searchClass = submitFormObj.activeCharacteristicsClass.value;
56
        	    var searchValue = submitFormObj.activeCharacteristics.value;
57
        	    if (searchValue!="") {
58
	        	    submitFormObj.query.value += 
59
	        	    	"<condition " +
60
		        		"concept='" + searchClass + "' " +
61
						"operator='EQUALS'>" +
62
						searchValue +
63
					"</condition>";
64
        	    }
65
        	//}
66
        	// Protocol
67
        	//for (var i=0; i < submitFormObj.activeProtocols.length; i++) {
68
        		var searchClass = submitFormObj.activeProtocolsClass.value;
69
        	    var searchValue = submitFormObj.activeProtocols.value;
70
        	    if (searchValue!="") {
71
	        	    submitFormObj.query.value += 
72
	        	    	"<condition " +
73
		        		"concept='" + searchClass + "' " +
74
						"operator='EQUALS'>" +
75
						searchValue +
76
					"</condition>";
77
        	    }
78
        	//}
79
        	// Measurement
80
        	//for (var i=0; i < submitFormObj.activeMeasurements.length; i++) {
81
        		var searchClass = submitFormObj.activeMeasurementsClass.value;
82
        	    var searchValue = submitFormObj.activeMeasurements.value;
83
        	    if (searchValue!="") {
84
	        	    submitFormObj.query.value += 
85
	        	    	"<condition " +
86
		        		"concept='" + searchClass + "' " +
87
						"operator='EQUALS'>" +
88
						searchValue +
89
					"</condition>";
90
        	    }
91
        	//}
92
        	
93
        	submitFormObj.query.value += "</" + operator + ">";
94
    	submitFormObj.query.value += "</sq:query>";
95
		
96
    //alert("query: " + submitFormObj.query.value);
97

    
98
    return true;
99
}
(8-8/14)