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 int hashCode() {
|
51
|
final int prime = 31;
|
52
|
int result = 1;
|
53
|
result = prime * result + ((query == null) ? 0 : query.hashCode());
|
54
|
return result;
|
55
|
}
|
56
|
|
57
|
@Override
|
58
|
public boolean equals(Object obj) {
|
59
|
if (this == obj) {
|
60
|
return true;
|
61
|
}
|
62
|
if (obj == null) {
|
63
|
return false;
|
64
|
}
|
65
|
if (getClass() != obj.getClass()) {
|
66
|
return false;
|
67
|
}
|
68
|
DataImportEditorInput<GbifResponse> other = (DataImportEditorInput<GbifResponse>) obj;
|
69
|
if (query == null) {
|
70
|
if (other.query != null) {
|
71
|
return false;
|
72
|
}
|
73
|
} else if (!query.equals(other.query)) {
|
74
|
return false;
|
75
|
}
|
76
|
return true;
|
77
|
}
|
78
|
|
79
|
}
|