Project

General

Profile

1
/**
2
 * Performs the search 
3
 */
4
function doSearch(serviceURL, searchFormId, browseAll) {
5
	var solrQuery = getSolrQuery(searchFormId);
6
	//alert(solrQuery);
7
	var url = serviceURL + "/" + solrQuery;
8
	// go directly there!
9
	document.location = url;
10
}
11

    
12
/**
13
 * Constructs the SOLR query to use
14
 */
15
function getSolrQuery(searchFormId, browseAll) {
16
	var submitFormObj = document.getElementById(searchFormId);
17
    var searchString = trim(submitFormObj.searchstring.value);
18
    if (browseAll) {
19
    	searchString = "";
20
    }
21
    var qformat = submitFormObj.qformat.value;
22

    
23
    if (searchString=="") {
24
        if (confirm("Show *all* data?")) {
25
            searchString = "*";
26
        } else {
27
            return false;
28
        }
29
    }
30

    
31
    var formats = 
32
    	"("
33
        +"formatId: \"eml\\://ecoinformatics.org/eml-2.1.1\""
34
        +" OR "
35
        +"formatId: \"eml\\://ecoinformatics.org/eml-2.1.0\""
36
        +" OR "
37
        +"formatId: \"eml\\://ecoinformatics.org/eml-2.0.1\""
38
        +" OR "
39
        +"formatId: \"eml\\://ecoinformatics.org/eml-2.0.0\""
40
        +" OR "
41
        +"formatId: \"-//ecoinformatics.org//eml-dataset-2.0.0beta6//EN\""
42
        +" OR "
43
        +"formatId: \"-//ecoinformatics.org//eml-dataset-2.0.0beta4//EN\""
44
        +" OR "
45
        +"formatId: \"-//NCEAS//resource//EN\""
46
        +" OR "
47
        +"formatId: \"-//NCEAS//eml-dataset//EN\""
48
        +" OR "
49
        +"formatId: \"metadata\""
50
    	+")";
51
    
52
	var solrQuery = "q="
53
		+ searchString
54
		+" AND "
55
    	+ formats
56
    	+" AND "         
57
    	+"("
58
            +"contactOrganization: \"National Center for Ecological Analysis and Synthesis\""	                    
59
        +")"
60
        +"&wt=" + qformat;
61
    	
62
    	solrQuery = encodeURIComponent(solrQuery);
63
    
64
    return solrQuery;
65
}
66

    
67
function trim(stringToTrim) {
68
    return stringToTrim.replace(/^\s*/, '').replace(/\s*$/,'');
69
}
(14-14/15)