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