Project

General

Profile

1
function generateQueryString(organizationScope, anyValue) {
2
	var queryString = ""; 
3
	queryString += "<pathquery version='1.2'>";
4
	queryString += "<returndoctype>metadata</returndoctype>";
5
	queryString += "<returndoctype>-//ecoinformatics.org//eml-dataset-2.0.0beta6//EN</returndoctype>";
6
	queryString += "<returndoctype>-//ecoinformatics.org//eml-dataset-2.0.0beta4//EN</returndoctype>";
7
	queryString += "<returndoctype>eml://ecoinformatics.org/eml-2.0.1</returndoctype>";
8
	queryString += "<returndoctype>eml://ecoinformatics.org/eml-2.0.0</returndoctype>";
9
	queryString += "<returndoctype>-//NCEAS//eml-dataset-2.0//EN</returndoctype>";
10
	queryString += "<returndoctype>-//NCEAS//resource//EN</returndoctype>";
11
	queryString += "<returnfield>originator/individualName/surName</returnfield>";
12
	queryString += "<returnfield>originator/individualName/givenName</returnfield>";
13
	queryString += "<returnfield>originator/organizationName</returnfield>";
14
	queryString += "<returnfield>creator/individualName/surName</returnfield>";
15
	queryString += "<returnfield>creator/organizationName</returnfield>";
16
	queryString += "<returnfield>dataset/title</returnfield>";
17
	queryString += "<returnfield>keyword</returnfield>";
18
	queryString += "<returnfield>creator/individualName/givenName</returnfield>";
19
	queryString += "<returnfield>idinfo/citation/citeinfo/title</returnfield>";
20
	queryString += "<returnfield>idinfo/citation/citeinfo/origin</returnfield>";
21
	queryString += "<returnfield>idinfo/keywords/theme/themekey</returnfield>";
22
	
23
	queryString += "<querygroup operator='INTERSECT'>";
24
	queryString += "<queryterm casesensitive='false' searchmode='contains'>";
25
	
26
	queryString += "<value>" + anyValue + "</value>";
27
			
28
	queryString += "</queryterm>";
29
	
30
	queryString += "<querygroup operator='UNION'>";
31
	
32
	for (var i = 0; i < organizationScope.length; i++) {
33
		queryString += "<queryterm casesensitive='false' searchmode='contains'>";
34
		queryString += "<value>" + organizationScope[i] + "</value>";
35
		queryString += "<pathexpr>placekey</pathexpr>";
36
		queryString += "</queryterm>";
37
		
38
		queryString += "<queryterm casesensitive='false' searchmode='contains'>";
39
		queryString += "<value>" + organizationScope[i] + "</value>";
40
		queryString += "<pathexpr>keyword</pathexpr>";
41
		queryString += "</queryterm>";
42
	}
43
	
44
	queryString += "</querygroup>";
45
	
46
	queryString += "</querygroup>";
47
	
48
	queryString += "</pathquery>";
49
	
50
	//alert(queryString);
51
	
52
	return queryString;
53
}
54

    
55
function setQueryFormField() {
56
	//alert('setQueryFormField');
57
	var queryField = document.getElementById("query");
58
	//alert('queryField=' + queryField);
59
	var anyfieldField = document.getElementById("anyfield");
60
	//alert('anyfieldField=' + anyfieldField);
61
	var organizationScopeField = document.getElementById("organizationScope");
62
	//alert('organizationScopeField=' + organizationScopeField.value);
63
	
64
	//make the array
65
	var orgArray = new Array();
66
	orgArray[0] = organizationScopeField.value;
67
	//if "All", include multiple entries
68
	if (organizationScopeField.value == '') {
69
		orgArray[0] = "SANParks, South Africa";
70
		orgArray[1] = "SAEON, South Africa";
71
	}
72
	
73
	queryField.value = 
74
		generateQueryString(
75
			orgArray,
76
			anyfieldField.value);
77
	
78
	//alert(queryField.value);
79
}
80

    
81
function setBrowseAll() {
82
	//set the field to wildcard
83
	var anyfieldField = document.getElementById("anyfield");
84
	anyfieldField.value = "";
85
	
86
	//set the query
87
	setQueryFormField();
88
}
(16-16/18)