3 * Copyright (C) 2014 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.taxeditor
.editor
.view
.dataimport
;
12 import java
.io
.IOException
;
13 import java
.io
.InputStream
;
14 import java
.net
.URISyntaxException
;
15 import java
.util
.ArrayList
;
16 import java
.util
.Collection
;
18 import org
.apache
.http
.client
.ClientProtocolException
;
19 import org
.eclipse
.swt
.widgets
.Display
;
21 import eu
.etaxonomy
.cdm
.ext
.occurrence
.OccurenceQuery
;
22 import eu
.etaxonomy
.cdm
.ext
.occurrence
.gbif
.GbifQueryServiceWrapper
;
23 import eu
.etaxonomy
.cdm
.model
.occurrence
.SpecimenOrObservationBase
;
24 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
31 public class SpecimenImportEditorInput
extends DataImportEditorInput
<SpecimenOrObservationBase
<?
>> {
33 private final OccurenceQuery query
;
38 public SpecimenImportEditorInput(OccurenceQuery query
) {
44 String errorMessage
= "Could not execute query " + query
;
46 Collection
<SpecimenOrObservationBase
<?
>> results
= new ArrayList
<SpecimenOrObservationBase
<?
>>();
48 InputStream resultStream
= new GbifQueryServiceWrapper().query(query
);
49 // JSONObject jsonObject = JSONObject.fromObject(dummyJson);
50 // Object java = JSONSerializer.toJava(jsonObject);
51 } catch (ClientProtocolException e
) {
52 logger
.error(errorMessage
, e
);
53 } catch (IOException e
) {
54 logger
.error(errorMessage
, e
);
55 } catch (URISyntaxException e
) {
56 logger
.error(errorMessage
, e
);
60 Display
.getDefault().asyncExec(new Runnable() {
64 CdmStore
.getContextManager().notifyContextRefresh();
70 * @see org.eclipse.ui.IEditorInput#getName()
73 public String
getName() {
74 return query
.toString();
78 * @see org.eclipse.ui.IEditorInput#getToolTipText()
81 public String
getToolTipText() {
82 return query
.toString();
86 * @see java.lang.Object#hashCode()
89 public int hashCode() {
92 result
= prime
* result
+ ((query
== null) ?
0 : query
.hashCode());
97 * @see java.lang.Object#equals(java.lang.Object)
100 public boolean equals(Object obj
) {
107 if (getClass() != obj
.getClass()) {
110 SpecimenImportEditorInput other
= (SpecimenImportEditorInput
) obj
;
112 if (other
.query
!= null) {
115 } else if (!query
.equals(other
.query
)) {