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
        	
28
        	// handle specific classes
29
        	// Entity
30
        	//for (var i=0; i < submitFormObj.activeEntities.length; i++) {
31
        		var searchClass = submitFormObj.activeEntitiesClass.value;
32
        	    var searchValue = submitFormObj.activeEntitiesValue.value;
33
        	    if (searchValue!="") {
34
	        	    submitFormObj.query.value += 
35
	        	    	"<condition " +
36
		        		"concept='" + searchClass + "' " +
37
						"operator='EQUALS'>" +
38
						searchValue +
39
					"</condition>";
40
        	    }
41
        	//}
42
        	// Characteristic
43
        	//for (var i=0; i < submitFormObj.activeCharacteristics.length; i++) {
44
        		var searchClass = submitFormObj.activeCharacteristicsClass.value;
45
        	    var searchValue = submitFormObj.activeCharacteristicsValue.value;
46
        	    if (searchValue!="") {
47
	        	    submitFormObj.query.value += 
48
	        	    	"<condition " +
49
		        		"concept='" + searchClass + "' " +
50
						"operator='EQUALS'>" +
51
						searchValue +
52
					"</condition>";
53
        	    }
54
        	//}
55
        	// Protocol
56
        	//for (var i=0; i < submitFormObj.activeProtocols.length; i++) {
57
        		var searchClass = submitFormObj.activeProtocolsClass.value;
58
        	    var searchValue = submitFormObj.activeProtocolsValue.value;
59
        	    if (searchValue!="") {
60
	        	    submitFormObj.query.value += 
61
	        	    	"<condition " +
62
		        		"concept='" + searchClass + "' " +
63
						"operator='EQUALS'>" +
64
						searchValue +
65
					"</condition>";
66
        	    }
67
        	//}
68
        	// Measurement
69
        	//for (var i=0; i < submitFormObj.activeMeasurements.length; i++) {
70
        		var searchClass = submitFormObj.activeMeasurementsClass.value;
71
        	    var searchValue = submitFormObj.activeMeasurementsValue.value;
72
        	    if (searchValue!="") {
73
	        	    submitFormObj.query.value += 
74
	        	    	"<condition " +
75
		        		"concept='" + searchClass + "' " +
76
						"operator='EQUALS'>" +
77
						searchValue +
78
					"</condition>";
79
        	    }
80
        	//}
81
        	
82
        	submitFormObj.query.value += "</" + operator + ">";
83
    	submitFormObj.query.value += "</sq:query>";
84
		
85
    //alert("query: " + submitFormObj.query.value);
86

    
87
    return true;
88
}
(8-8/14)