Project

General

Profile

1 3774 leinfelder
function generateQueryString(organizationScope, anyValue, searchFields) {
2 3462 leinfelder
	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 5710 leinfelder
	queryString += "<returndoctype>eml://ecoinformatics.org/eml-2.1.1</returndoctype>";
8 4505 daigle
	queryString += "<returndoctype>eml://ecoinformatics.org/eml-2.1.0</returndoctype>";
9 3462 leinfelder
	queryString += "<returndoctype>eml://ecoinformatics.org/eml-2.0.1</returndoctype>";
10
	queryString += "<returndoctype>eml://ecoinformatics.org/eml-2.0.0</returndoctype>";
11
	queryString += "<returndoctype>-//NCEAS//eml-dataset-2.0//EN</returndoctype>";
12
	queryString += "<returndoctype>-//NCEAS//resource//EN</returndoctype>";
13
	queryString += "<returnfield>originator/individualName/surName</returnfield>";
14
	queryString += "<returnfield>originator/individualName/givenName</returnfield>";
15
	queryString += "<returnfield>originator/organizationName</returnfield>";
16
	queryString += "<returnfield>creator/individualName/surName</returnfield>";
17
	queryString += "<returnfield>creator/organizationName</returnfield>";
18
	queryString += "<returnfield>dataset/title</returnfield>";
19
	queryString += "<returnfield>keyword</returnfield>";
20
	queryString += "<returnfield>creator/individualName/givenName</returnfield>";
21
	queryString += "<returnfield>idinfo/citation/citeinfo/title</returnfield>";
22
	queryString += "<returnfield>idinfo/citation/citeinfo/origin</returnfield>";
23
	queryString += "<returnfield>idinfo/keywords/theme/themekey</returnfield>";
24
25
	queryString += "<querygroup operator='INTERSECT'>";
26
27 3774 leinfelder
	//search particular fields, or all?
28
	if (searchFields.length > 0) {
29
		queryString += "<querygroup operator='UNION'>";
30
		for (var i = 0; i < searchFields.length; i++) {
31
			queryString += "<queryterm casesensitive='false' searchmode='contains'>";
32
			queryString += "<value>" + anyValue + "</value>";
33
			queryString += "<pathexpr>" + searchFields[i] +"</pathexpr>";
34
			queryString += "</queryterm>";
35
		}
36
		queryString += "</querygroup>";
37
	}
38
	else {
39
		queryString += "<queryterm casesensitive='false' searchmode='contains'>";
40
		queryString += "<value>" + anyValue + "</value>";
41
		queryString += "</queryterm>";
42
	}
43 3462 leinfelder
44 3774 leinfelder
	//now limit by the organization
45 3462 leinfelder
	queryString += "<querygroup operator='UNION'>";
46
47 3650 leinfelder
	for (var i = 0; i < organizationScope.length; i++) {
48
		queryString += "<queryterm casesensitive='false' searchmode='contains'>";
49
		queryString += "<value>" + organizationScope[i] + "</value>";
50
		queryString += "<pathexpr>placekey</pathexpr>";
51
		queryString += "</queryterm>";
52
53
		queryString += "<queryterm casesensitive='false' searchmode='contains'>";
54
		queryString += "<value>" + organizationScope[i] + "</value>";
55
		queryString += "<pathexpr>keyword</pathexpr>";
56
		queryString += "</queryterm>";
57
	}
58 3462 leinfelder
59
	queryString += "</querygroup>";
60
61
	queryString += "</querygroup>";
62
63
	queryString += "</pathquery>";
64
65
	//alert(queryString);
66
67
	return queryString;
68
}
69
70
function setQueryFormField() {
71 3477 leinfelder
	//alert('setQueryFormField');
72 3462 leinfelder
	var queryField = document.getElementById("query");
73
	//alert('queryField=' + queryField);
74
	var anyfieldField = document.getElementById("anyfield");
75
	//alert('anyfieldField=' + anyfieldField);
76
	var organizationScopeField = document.getElementById("organizationScope");
77 3650 leinfelder
	//alert('organizationScopeField=' + organizationScopeField.value);
78 3774 leinfelder
	var searchAll = document.getElementById("searchAll");
79
	//alert('searchAll=' + searchAll.checked);
80 3462 leinfelder
81 3774 leinfelder
	//make the array for organization
82 3650 leinfelder
	var orgArray = new Array();
83
	orgArray[0] = organizationScopeField.value;
84
	//if "All", include multiple entries
85
	if (organizationScopeField.value == '') {
86
		orgArray[0] = "SANParks, South Africa";
87
		orgArray[1] = "SAEON, South Africa";
88
	}
89
90 3774 leinfelder
	//make the array for paths to search
91
	var searchFieldArray = new Array();
92
	if (!searchAll.checked) {
93
		var counter = 0;
94
		//EML fields
95
		searchFieldArray[counter++] = "abstract/para";
96
		searchFieldArray[counter++] = "surName";
97
		searchFieldArray[counter++] = "givenName";
98
		searchFieldArray[counter++] = "organizationName";
99
		searchFieldArray[counter++] = "title";
100
		searchFieldArray[counter++] = "keyword";
101
		searchFieldArray[counter++] = "para";
102
		searchFieldArray[counter++] = "geographicDescription";
103
		searchFieldArray[counter++] = "literalLayout";
104
		searchFieldArray[counter++] = "@packageId";
105
106
		//FGDC fields
107
		searchFieldArray[counter++] = "abstract";
108
		searchFieldArray[counter++] = "idinfo/citation/citeinfo/title";
109
		searchFieldArray[counter++] = "idinfo/citation/citeinfo/origin";
110
		searchFieldArray[counter++] = "idinfo/keywords/theme/themekey";
111 3778 tao
		searchFieldArray[counter++] = "placekey";
112 3774 leinfelder
	}
113
114
	//generate the query
115 3462 leinfelder
	queryField.value =
116
		generateQueryString(
117 3650 leinfelder
			orgArray,
118 3774 leinfelder
			anyfieldField.value,
119
			searchFieldArray);
120 3462 leinfelder
121 3477 leinfelder
	//alert(queryField.value);
122 3462 leinfelder
}
123
124
function setBrowseAll() {
125
	//set the field to wildcard
126
	var anyfieldField = document.getElementById("anyfield");
127
	anyfieldField.value = "";
128
129
	//set the query
130
	setQueryFormField();
131
}