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
.view
.dataimport
;
12 import java
.io
.IOException
;
13 import java
.io
.InputStream
;
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
.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
.store
.CdmStore
;
33 public class BioCaseEditorInput
extends DataImportEditorInput
<SpecimenOrObservationBase
<?
>> {
35 private final URI endPoint
;
38 * Constructs a new BioCaseEditorInput.
39 * @param query The {@link OccurenceQuery} object holding all necessary parameters.
40 * @param endPoint If the endPoint {@link URI} is <code>null</code> then the default endPoint is used
41 * (<i>http://ww3.bgbm.org/biocase/pywrapper.cgi?dsa=Herbar</i>)
43 public BioCaseEditorInput(OccurenceQuery query
, URI endPoint
) {
46 this.endPoint
= endPoint
;
51 String errorMessage
= "Could not execute query " + query
;
53 Collection
<SpecimenOrObservationBase
<?
>> results
= new ArrayList
<SpecimenOrObservationBase
<?
>>();
55 //FIXME move ABCD import to cdmlib -> this will also get rid of the transient services
56 InputStream resultStream
;
57 resultStream
= new BioCaseQueryServiceWrapper().query(query
, endPoint
);
58 Abcd206ImportConfigurator configurator
= Abcd206ImportConfigurator
.NewInstance(endPoint
, null, false);
59 /* TransientCdmRepository repo =
60 new TransientCdmRepository(CdmStore.getCurrentApplicationConfiguration());
61 configurator.setCdmAppController(repo);
63 CdmDefaultImport
<Abcd206ImportConfigurator
> importer
= new CdmDefaultImport
<Abcd206ImportConfigurator
>();
64 importer
.invoke(configurator
);
65 // results = repo.getUnits();
67 } catch (ClientProtocolException e
) {
68 logger
.error(errorMessage
, e
);
69 } catch (IOException e
) {
70 logger
.error(errorMessage
, e
);
75 Display
.getDefault().asyncExec(new Runnable() {
79 CdmStore
.getContextManager().notifyContextRefresh();
85 * @see org.eclipse.ui.IEditorInput#getName()
88 public String
getName() {
89 return "[BioCASE] " + query
.toString();
93 * @see org.eclipse.ui.IEditorInput#getToolTipText()
96 public String
getToolTipText() {
97 return "[BioCASE] " + query
.toString();
101 * @see java.lang.Object#hashCode()
104 public int hashCode() {
105 final int prime
= 31;
107 result
= prime
* result
+ ((query
== null) ?
0 : query
.hashCode());
112 * @see java.lang.Object#equals(java.lang.Object)
115 public boolean equals(Object obj
) {
122 if (getClass() != obj
.getClass()) {
125 BioCaseEditorInput other
= (BioCaseEditorInput
) obj
;
127 if (other
.query
!= null) {
130 } else if (!query
.equals(other
.query
)) {