2 * Copyright (C) 2014 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
9 package eu
.etaxonomy
.taxeditor
.view
.dataimport
;
11 import java
.io
.IOException
;
12 import java
.io
.InputStream
;
13 import java
.util
.ArrayList
;
14 import java
.util
.Collection
;
16 import org
.apache
.http
.client
.ClientProtocolException
;
17 import org
.eclipse
.swt
.widgets
.Display
;
19 import eu
.etaxonomy
.cdm
.common
.URI
;
20 import eu
.etaxonomy
.cdm
.ext
.occurrence
.OccurenceQuery
;
21 import eu
.etaxonomy
.cdm
.ext
.occurrence
.bioCase
.BioCaseQueryServiceWrapper
;
22 import eu
.etaxonomy
.cdm
.io
.common
.CdmDefaultImport
;
23 import eu
.etaxonomy
.cdm
.io
.specimen
.abcd206
.in
.Abcd206ImportConfigurator
;
24 import eu
.etaxonomy
.cdm
.model
.occurrence
.SpecimenOrObservationBase
;
25 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
31 public class BioCaseEditorInput
extends DataImportEditorInput
<SpecimenOrObservationBase
<?
>> {
33 private final URI endPoint
;
36 * Constructs a new BioCaseEditorInput.
37 * @param query The {@link OccurenceQuery} object holding all necessary parameters.
38 * @param endPoint If the endPoint {@link URI} is <code>null</code> then the default endPoint is used
39 * (<i>http://ww3.bgbm.org/biocase/pywrapper.cgi?dsa=Herbar</i>)
41 public BioCaseEditorInput(OccurenceQuery query
, URI endPoint
) {
44 this.endPoint
= endPoint
;
49 String errorMessage
= "Could not execute query " + query
;
51 Collection
<SpecimenOrObservationBase
<?
>> results
= new ArrayList
<SpecimenOrObservationBase
<?
>>();
53 //FIXME move ABCD import to cdmlib -> this will also get rid of the transient services
54 InputStream resultStream
;
55 resultStream
= new BioCaseQueryServiceWrapper().query(query
, endPoint
);
56 Abcd206ImportConfigurator configurator
= Abcd206ImportConfigurator
.NewInstance(endPoint
, null, false);
57 /* TransientCdmRepository repo =
58 new TransientCdmRepository(CdmStore.getCurrentApplicationConfiguration());
59 configurator.setCdmAppController(repo);
61 CdmDefaultImport
<Abcd206ImportConfigurator
> importer
= new CdmDefaultImport
<Abcd206ImportConfigurator
>();
62 importer
.invoke(configurator
);
63 // results = repo.getUnits();
65 } catch (ClientProtocolException e
) {
66 logger
.error(errorMessage
, e
);
67 } catch (IOException e
) {
68 logger
.error(errorMessage
, e
);
73 Display
.getDefault().asyncExec(new Runnable() {
77 CdmStore
.getContextManager().notifyContextRefresh();
83 public int hashCode() {
86 result
= prime
* result
+ ((query
== null) ?
0 : query
.hashCode());
91 public boolean equals(Object obj
) {
98 if (getClass() != obj
.getClass()) {
101 BioCaseEditorInput other
= (BioCaseEditorInput
) obj
;
103 if (other
.query
!= null) {
106 } else if (!query
.equals(other
.query
)) {