--- /dev/null
+// $Id$
+/**
+* Copyright (C) 2014 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+package eu.etaxonomy.taxeditor.editor.view.dataimport;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.eclipse.swt.widgets.Display;
+
+import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
+import eu.etaxonomy.cdm.ext.biocase.BioCaseQuery;
+import eu.etaxonomy.cdm.model.location.NamedArea;
+import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
+import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType;
+import eu.etaxonomy.taxeditor.store.CdmStore;
+
+/**
+ * @author pplitzner
+ * @date 25.02.2014
+ *
+ */
+public class SpecimenImportEditorInput extends DataImportEditorInput<SpecimenOrObservationBase> {
+
+ private final BioCaseQuery query;
+
+ /**
+ * @param results
+ */
+ public SpecimenImportEditorInput(BioCaseQuery query) {
+ super();
+ this.query = query;
+ }
+
+ public void query(){
+ String errorMessage = "Could not execute query " + SpecimenImportEditorInput.this.query;
+
+ Collection<SpecimenOrObservationBase> results = new ArrayList<SpecimenOrObservationBase>();
+ DerivedUnitFacade unit1 = DerivedUnitFacade.NewInstance(SpecimenOrObservationType.PreservedSpecimen);
+// newInstance.setTitleCache("Test Specimen", true);
+ unit1.setCollectingMethod("Collected from the ground");
+ unit1.setAccessionNumber("ACC-12345");
+ unit1.setLocality("locality");
+ unit1.setCountry(NamedArea.EUROPE());
+
+ DerivedUnitFacade unit2 = DerivedUnitFacade.NewInstance(SpecimenOrObservationType.PreservedSpecimen);
+ unit2.setTitleCache("Test Specimen 2", false);
+ unit2.setCollectingMethod("Collected from the ground");
+ unit2.setAccessionNumber("ACC-67890");
+ unit2.setLocality("solid ground close to car park");
+ unit2.setCountry(NamedArea.ASIA_TEMPERATE());
+
+ DerivedUnitFacade unit3 = DerivedUnitFacade.NewInstance(SpecimenOrObservationType.PreservedSpecimen);
+ unit3.setTitleCache("Test Specimen 3", false);
+ unit3.setCollectingMethod("Collected from the air");
+ unit3.setAccessionNumber("ACC-999");
+ unit3.setLocality("thin air");
+ unit3.setCountry(NamedArea.SOUTHERNOCEAN());
+
+ results.add(unit1.innerDerivedUnit());
+ results.add(unit2.innerDerivedUnit());
+ results.add(unit3.innerDerivedUnit());
+ results.add(unit1.innerDerivedUnit());
+ setResults(results);
+// try {
+// InputStream resultStream = new BioCaseQueryServiceWrapper().query(DataImportEditorInput.this.query);
+// Abcd206ImportConfigurator configurator = Abcd206ImportConfigurator.NewInstance(resultStream, null, false);
+// TransientCdmRepository repo =
+// new TransientCdmRepository(CdmStore.getCurrentApplicationConfiguration());
+// configurator.setCdmAppController(repo);
+//
+// CdmDefaultImport<Abcd206ImportConfigurator> importer = new CdmDefaultImport<Abcd206ImportConfigurator>();
+// importer.invoke(configurator);
+// results = repo.getUnits();
+// } catch (ClientProtocolException e) {
+// logger.error(errorMessage, e);
+// } catch (IOException e) {
+// logger.error(errorMessage, e);
+// } catch (URISyntaxException e) {
+// logger.error(errorMessage, e);
+// }
+
+ Display.getDefault().asyncExec(new Runnable() {
+
+ @Override
+ public void run() {
+ CdmStore.getContextManager().notifyContextRefresh();
+ }
+ });
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IEditorInput#getName()
+ */
+ @Override
+ public String getName() {
+ return query.toString();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IEditorInput#getToolTipText()
+ */
+ @Override
+ public String getToolTipText() {
+ return query.toString();
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((query == null) ? 0 : query.hashCode());
+ return result;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ SpecimenImportEditorInput other = (SpecimenImportEditorInput) obj;
+ if (query == null) {
+ if (other.query != null) {
+ return false;
+ }
+ } else if (!query.equals(other.query)) {
+ return false;
+ }
+ return true;
+ }
+}