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 |
5816
|
leinfelder
|
queryString += "<returnfield>dataset/title/value</returnfield>";
|
20 |
3462
|
leinfelder
|
queryString += "<returnfield>keyword</returnfield>";
|
21 |
5816
|
leinfelder
|
queryString += "<returnfield>keyword/value</returnfield>";
|
22 |
3462
|
leinfelder
|
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 |
3774
|
leinfelder
|
//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 |
3462
|
leinfelder
|
|
46 |
3774
|
leinfelder
|
//now limit by the organization
|
47 |
3462
|
leinfelder
|
queryString += "<querygroup operator='UNION'>";
|
48 |
|
|
|
49 |
3650
|
leinfelder
|
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 |
3462
|
leinfelder
|
|
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 |
3477
|
leinfelder
|
//alert('setQueryFormField');
|
74 |
3462
|
leinfelder
|
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 |
3650
|
leinfelder
|
//alert('organizationScopeField=' + organizationScopeField.value);
|
80 |
3774
|
leinfelder
|
var searchAll = document.getElementById("searchAll");
|
81 |
|
|
//alert('searchAll=' + searchAll.checked);
|
82 |
3462
|
leinfelder
|
|
83 |
3774
|
leinfelder
|
//make the array for organization
|
84 |
3650
|
leinfelder
|
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 |
3774
|
leinfelder
|
//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 |
5816
|
leinfelder
|
searchFieldArray[counter++] = "abstract/para/value";
|
99 |
3774
|
leinfelder
|
searchFieldArray[counter++] = "surName";
|
100 |
|
|
searchFieldArray[counter++] = "givenName";
|
101 |
|
|
searchFieldArray[counter++] = "organizationName";
|
102 |
|
|
searchFieldArray[counter++] = "title";
|
103 |
5816
|
leinfelder
|
searchFieldArray[counter++] = "title/value";
|
104 |
3774
|
leinfelder
|
searchFieldArray[counter++] = "keyword";
|
105 |
5816
|
leinfelder
|
searchFieldArray[counter++] = "keyword/value";
|
106 |
3774
|
leinfelder
|
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 |
3778
|
tao
|
searchFieldArray[counter++] = "placekey";
|
117 |
3774
|
leinfelder
|
}
|
118 |
|
|
|
119 |
|
|
//generate the query
|
120 |
3462
|
leinfelder
|
queryField.value =
|
121 |
|
|
generateQueryString(
|
122 |
3650
|
leinfelder
|
orgArray,
|
123 |
3774
|
leinfelder
|
anyfieldField.value,
|
124 |
|
|
searchFieldArray);
|
125 |
3462
|
leinfelder
|
|
126 |
3477
|
leinfelder
|
//alert(queryField.value);
|
127 |
3462
|
leinfelder
|
}
|
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 |
|
|
}
|