Project

General

Profile

Download (2.32 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2014 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.taxeditor.view.dataimport;
10

    
11
import java.io.IOException;
12
import java.net.URISyntaxException;
13
import java.util.Collection;
14

    
15
import org.apache.http.client.ClientProtocolException;
16

    
17
import eu.etaxonomy.cdm.ext.occurrence.OccurenceQuery;
18
import eu.etaxonomy.cdm.ext.occurrence.gbif.GbifQueryServiceWrapper;
19
import eu.etaxonomy.cdm.ext.occurrence.gbif.GbifResponse;
20

    
21
/**
22
 * @author pplitzner
23
 * @date 27.05.2014
24
 *
25
 */
26
public class GbifImportEditorInput extends DataImportEditorInput<GbifResponse> {
27

    
28
    public GbifImportEditorInput(OccurenceQuery query) {
29
        super();
30
        this.query = query;
31
    }
32

    
33
    @Override
34
    public void query(){
35
        String errorMessage = "Could not execute query " + query;
36
        try{
37
            Collection<GbifResponse> results = new GbifQueryServiceWrapper().query(query);
38
            setResults(results);
39
        } catch (ClientProtocolException e) {
40
            logger.error(errorMessage, e);
41
        } catch (IOException e) {
42
            logger.error(errorMessage, e);
43
        } catch (URISyntaxException e) {
44
            logger.error(errorMessage, e);
45
        }
46
    }
47

    
48

    
49
    @Override
50
    public String getName() {
51
        return "[GBIF] " + query.toString();
52
    }
53

    
54
    @Override
55
    public String getToolTipText() {
56
        return "[GBIF] " + query.toString();
57
    }
58

    
59
    @Override
60
    public int hashCode() {
61
        final int prime = 31;
62
        int result = 1;
63
        result = prime * result + ((query == null) ? 0 : query.hashCode());
64
        return result;
65
    }
66

    
67
    @Override
68
    public boolean equals(Object obj) {
69
        if (this == obj) {
70
            return true;
71
        }
72
        if (obj == null) {
73
            return false;
74
        }
75
        if (getClass() != obj.getClass()) {
76
            return false;
77
        }
78
        DataImportEditorInput<GbifResponse> other = (DataImportEditorInput<GbifResponse>) obj;
79
        if (query == null) {
80
            if (other.query != null) {
81
                return false;
82
            }
83
        } else if (!query.equals(other.query)) {
84
            return false;
85
        }
86
        return true;
87
    }
88

    
89
}
(7-7/16)