Project

General

Profile

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

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

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

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

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

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

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

    
49

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

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

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

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

    
90
}
(7-7/15)