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
.biocase
.BioCaseQuery
;
22 import eu
.etaxonomy
.cdm
.ext
.biocase
.BioCaseQueryServiceWrapper
;
23 import eu
.etaxonomy
.cdm
.io
.common
.CdmDefaultImport
;
24 import eu
.etaxonomy
.cdm
.io
.specimen
.abcd206
.in
.Abcd206ImportConfigurator
;
25 import eu
.etaxonomy
.cdm
.model
.occurrence
.SpecimenOrObservationBase
;
26 import eu
.etaxonomy
.taxeditor
.editor
.view
.dataimport
.transientServices
.TransientCdmRepository
;
27 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
34 public class SpecimenImportEditorInput
extends DataImportEditorInput
<SpecimenOrObservationBase
> {
36 private final BioCaseQuery query
;
41 public SpecimenImportEditorInput(BioCaseQuery query
) {
47 String errorMessage
= "Could not execute query " + SpecimenImportEditorInput
.this.query
;
49 Collection
<SpecimenOrObservationBase
> results
= new ArrayList
<SpecimenOrObservationBase
>();
51 InputStream resultStream
= new BioCaseQueryServiceWrapper().query(SpecimenImportEditorInput
.this.query
);
52 Abcd206ImportConfigurator configurator
= Abcd206ImportConfigurator
.NewInstance(resultStream
, null, false);
53 TransientCdmRepository repo
=
54 new TransientCdmRepository(CdmStore
.getCurrentApplicationConfiguration());
55 configurator
.setCdmAppController(repo
);
57 CdmDefaultImport
<Abcd206ImportConfigurator
> importer
= new CdmDefaultImport
<Abcd206ImportConfigurator
>();
58 importer
.invoke(configurator
);
59 results
= repo
.getUnits();
60 } catch (ClientProtocolException e
) {
61 logger
.error(errorMessage
, e
);
62 } catch (IOException e
) {
63 logger
.error(errorMessage
, e
);
64 } catch (URISyntaxException e
) {
65 logger
.error(errorMessage
, e
);
69 Display
.getDefault().asyncExec(new Runnable() {
73 CdmStore
.getContextManager().notifyContextRefresh();
79 * @see org.eclipse.ui.IEditorInput#getName()
82 public String
getName() {
83 return query
.toString();
87 * @see org.eclipse.ui.IEditorInput#getToolTipText()
90 public String
getToolTipText() {
91 return query
.toString();
95 * @see java.lang.Object#hashCode()
98 public int hashCode() {
101 result
= prime
* result
+ ((query
== null) ?
0 : query
.hashCode());
106 * @see java.lang.Object#equals(java.lang.Object)
109 public boolean equals(Object obj
) {
116 if (getClass() != obj
.getClass()) {
119 SpecimenImportEditorInput other
= (SpecimenImportEditorInput
) obj
;
121 if (other
.query
!= null) {
124 } else if (!query
.equals(other
.query
)) {