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