From bce192f441ec607cc1e4a3461b1b416d5b6eefe2 Mon Sep 17 00:00:00 2001
From: Patric Plitzner
Date: Wed, 21 May 2014 07:43:39 +0000
Subject: [PATCH] - refactored BioCaseQuery to more generic OccurrenceQuery
- for import wizard - for DataImportEditor - exported new cdmlib package
structure for gbif and biocase querying in taxeditor.cdmlib
---
.../META-INF/MANIFEST.MF | 4 ++-
eu.etaxonomy.taxeditor.editor/plugin.xml | 4 +--
.../view/dataimport/DataImportEditor.java | 2 +-
.../view/dataimport/SaveSpecimenCommand.java | 4 +--
.../view/dataimport/SpecimenImportEditor.java | 2 +-
.../dataimport/SpecimenImportEditorInput.java | 29 +++++++------------
.../view/dataimport/SpecimenSearchWizard.java | 13 ++++-----
.../dataimport/SpecimenSearchWizardPage.java | 25 ++++++++--------
8 files changed, 37 insertions(+), 46 deletions(-)
diff --git a/eu.etaxonomy.taxeditor.cdmlib/META-INF/MANIFEST.MF b/eu.etaxonomy.taxeditor.cdmlib/META-INF/MANIFEST.MF
index 7f3b00fb3..6410a6033 100644
--- a/eu.etaxonomy.taxeditor.cdmlib/META-INF/MANIFEST.MF
+++ b/eu.etaxonomy.taxeditor.cdmlib/META-INF/MANIFEST.MF
@@ -37,7 +37,9 @@ Export-Package: com.google.api,
eu.etaxonomy.cdm.database.update.v25_30,
eu.etaxonomy.cdm.database.update.v30_31,
eu.etaxonomy.cdm.ext.bci,
- eu.etaxonomy.cdm.ext.biocase,
+ eu.etaxonomy.cdm.ext.occurrence,
+ eu.etaxonomy.cdm.ext.occurrence.bioCase,
+ eu.etaxonomy.cdm.ext.occurrence.gbif,
eu.etaxonomy.cdm.ext.common,
eu.etaxonomy.cdm.ext.dc,
eu.etaxonomy.cdm.ext.geo,
diff --git a/eu.etaxonomy.taxeditor.editor/plugin.xml b/eu.etaxonomy.taxeditor.editor/plugin.xml
index 0e2465a74..ca2c7502f 100644
--- a/eu.etaxonomy.taxeditor.editor/plugin.xml
+++ b/eu.etaxonomy.taxeditor.editor/plugin.xml
@@ -1276,9 +1276,9 @@
category="eu.etaxonomy.taxeditor.import.category.cdm"
class="eu.etaxonomy.taxeditor.editor.view.dataimport.SpecimenSearchWizard"
id="eu.etaxonomy.taxeditor.editor.view.dataimport.SpecimenSearchWizard"
- name="Query BioCASE">
+ name="Specimen Search/Import">
- Query BioCaseProvider
+ Queries data provider (currently only GBIF) for specimens with specified parameters.
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/DataImportEditor.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/DataImportEditor.java
index 303312518..c92e1df1b 100644
--- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/DataImportEditor.java
+++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/DataImportEditor.java
@@ -100,7 +100,7 @@ IConversationEnabled, IPartContentHasDetails, IPartContentHasSupplementalData, I
setInput(input);
setPartName(input.getName());
setTitleToolTip(input.getName());
- conversation = ((DataImportEditorInput)input).getConversationHolder();
+ conversation = ((DataImportEditorInput)input).getConversationHolder();
}
/* (non-Javadoc)
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/SaveSpecimenCommand.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/SaveSpecimenCommand.java
index 89c353488..cc0fca225 100644
--- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/SaveSpecimenCommand.java
+++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/SaveSpecimenCommand.java
@@ -28,14 +28,14 @@ public class SaveSpecimenCommand extends AbstractHandler {
final ISelection selection = window.getActivePage().getSelection();
if(selection instanceof StructuredSelection){
StructuredSelection structuredSelection = (StructuredSelection)selection;
- Iterator iterator = structuredSelection.iterator();
+ Iterator> iterator = structuredSelection.iterator();
while(iterator.hasNext()){
Object next = iterator.next();
if(next instanceof SpecimenOrObservationBase){
IWorkbenchPart activePart = AbstractUtility.getActivePart();
if(activePart instanceof DataImportEditor){
SpecimenImportEditor dataImportEditor = (SpecimenImportEditor)activePart;
- CdmStore.getService(IOccurrenceService.class).saveOrUpdate((SpecimenOrObservationBase) next);
+ CdmStore.getService(IOccurrenceService.class).saveOrUpdate((SpecimenOrObservationBase>) next);
dataImportEditor.getConversationHolder().commit(true);
}
}
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/SpecimenImportEditor.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/SpecimenImportEditor.java
index 92cf857ac..742fe4128 100644
--- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/SpecimenImportEditor.java
+++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/SpecimenImportEditor.java
@@ -17,7 +17,7 @@ import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
* @date 20.09.2013
*
*/
-public class SpecimenImportEditor extends DataImportEditor {
+public class SpecimenImportEditor extends DataImportEditor> {
public static final String ID = "eu.etaxonomy.taxeditor.editor.view.dataimport.SpecimenImportEditor";
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/SpecimenImportEditorInput.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/SpecimenImportEditorInput.java
index e559665a2..3a6784b1e 100644
--- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/SpecimenImportEditorInput.java
+++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/SpecimenImportEditorInput.java
@@ -18,12 +18,9 @@ import java.util.Collection;
import org.apache.http.client.ClientProtocolException;
import org.eclipse.swt.widgets.Display;
-import eu.etaxonomy.cdm.ext.biocase.BioCaseQuery;
-import eu.etaxonomy.cdm.ext.biocase.BioCaseQueryServiceWrapper;
-import eu.etaxonomy.cdm.io.common.CdmDefaultImport;
-import eu.etaxonomy.cdm.io.specimen.abcd206.in.Abcd206ImportConfigurator;
+import eu.etaxonomy.cdm.ext.occurrence.OccurenceQuery;
+import eu.etaxonomy.cdm.ext.occurrence.gbif.GbifQueryServiceWrapper;
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
-import eu.etaxonomy.taxeditor.editor.view.dataimport.transientServices.TransientCdmRepository;
import eu.etaxonomy.taxeditor.store.CdmStore;
/**
@@ -31,32 +28,26 @@ import eu.etaxonomy.taxeditor.store.CdmStore;
* @date 25.02.2014
*
*/
-public class SpecimenImportEditorInput extends DataImportEditorInput {
+public class SpecimenImportEditorInput extends DataImportEditorInput> {
- private final BioCaseQuery query;
+ private final OccurenceQuery query;
/**
* @param results
*/
- public SpecimenImportEditorInput(BioCaseQuery query) {
+ public SpecimenImportEditorInput(OccurenceQuery query) {
super();
this.query = query;
}
public void query(){
- String errorMessage = "Could not execute query " + SpecimenImportEditorInput.this.query;
+ String errorMessage = "Could not execute query " + query;
- Collection results = new ArrayList();
+ Collection> results = new ArrayList>();
try {
- InputStream resultStream = new BioCaseQueryServiceWrapper().query(SpecimenImportEditorInput.this.query);
- Abcd206ImportConfigurator configurator = Abcd206ImportConfigurator.NewInstance(resultStream, null, false);
- TransientCdmRepository repo =
- new TransientCdmRepository(CdmStore.getCurrentApplicationConfiguration());
- configurator.setCdmAppController(repo);
-
- CdmDefaultImport importer = new CdmDefaultImport();
- importer.invoke(configurator);
- results = repo.getUnits();
+ InputStream resultStream = new GbifQueryServiceWrapper().query(query);
+// JSONObject jsonObject = JSONObject.fromObject(dummyJson);
+// Object java = JSONSerializer.toJava(jsonObject);
} catch (ClientProtocolException e) {
logger.error(errorMessage, e);
} catch (IOException e) {
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/SpecimenSearchWizard.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/SpecimenSearchWizard.java
index 47e802d4f..5182c307c 100644
--- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/SpecimenSearchWizard.java
+++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/SpecimenSearchWizard.java
@@ -22,11 +22,11 @@ import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
-import eu.etaxonomy.cdm.ext.biocase.BioCaseQuery;
+import eu.etaxonomy.cdm.ext.occurrence.OccurenceQuery;
import eu.etaxonomy.taxeditor.store.CdmStore;
/**
- * Wizard for querying BioCASe provider.
+ * Wizard for querying specimen provider.
* @author pplitzner
* @date 11.09.2013
*
@@ -35,7 +35,7 @@ public class SpecimenSearchWizard extends Wizard implements IImportWizard {
@SuppressWarnings("unused")
private static final Logger logger = Logger.getLogger(SpecimenSearchWizard.class);
- private BioCaseQuery query;
+ private OccurenceQuery query = null;
private SpecimenSearchWizardPage searchPage;
/**
@@ -59,7 +59,7 @@ public class SpecimenSearchWizard extends Wizard implements IImportWizard {
query = searchPage.getQuery();
final SpecimenImportEditorInput input = new SpecimenImportEditorInput(query);
- Job queryJob = new Job("Query Biocase") {
+ Job queryJob = new Job("Query specimen provider") {
@Override
protected IStatus run(IProgressMonitor monitor) {
@@ -89,15 +89,14 @@ public class SpecimenSearchWizard extends Wizard implements IImportWizard {
*/
@Override
public void init(IWorkbench workbench, IStructuredSelection selection) {
- query = new BioCaseQuery();
searchPage = new SpecimenSearchWizardPage("Specimen Search");
}
/**
- * Return a {@link BioCaseQuery} with the parameters entered in the wizard
+ * Return a {@link OccurenceQuery} with the parameters entered in the wizard
* @return the query
*/
- public BioCaseQuery getQuery() {
+ public OccurenceQuery getQuery() {
return query;
}
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/SpecimenSearchWizardPage.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/SpecimenSearchWizardPage.java
index 73ffb24ea..21e0b7bbd 100644
--- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/SpecimenSearchWizardPage.java
+++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/SpecimenSearchWizardPage.java
@@ -12,7 +12,7 @@ package eu.etaxonomy.taxeditor.editor.view.dataimport;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.widgets.Composite;
-import eu.etaxonomy.cdm.ext.biocase.BioCaseQuery;
+import eu.etaxonomy.cdm.ext.occurrence.OccurenceQuery;
import eu.etaxonomy.taxeditor.view.specimenSearch.SpecimenSearchController;
@@ -42,20 +42,19 @@ public class SpecimenSearchWizardPage extends WizardPage{
}
/**
- * Returns a {@link BioCaseQuery} filled with the parameters defined in this wizard page
+ * Returns an {@link OccurenceQuery} filled with the parameters defined in this wizard page
* @return
*/
- public BioCaseQuery getQuery() {
- BioCaseQuery query = new BioCaseQuery();
- query.accessionNumber = specimenSearchController.getAccessionNumber();
- query.collector = specimenSearchController.getCollector();
- query.collectorsNumber = specimenSearchController.getCollectorNumber();
- query.country = specimenSearchController.getCountry();
-// query.date = specimenSearchController.getDate();
- query.herbarium = specimenSearchController.getHerbarium();
- query.locality = specimenSearchController.getLocality();
- query.taxonName = specimenSearchController.getTaxonName();
- return query;
+ public OccurenceQuery getQuery() {
+ String accessionNumber = specimenSearchController.getAccessionNumber();
+ String collector = specimenSearchController.getCollector();
+ String collectorsNumber = specimenSearchController.getCollectorNumber();
+ String country = specimenSearchController.getCountry();
+// date = specimenSearchController.getDate();
+ String herbarium = specimenSearchController.getHerbarium();
+ String locality = specimenSearchController.getLocality();
+ String taxonName = specimenSearchController.getTaxonName();
+ return new OccurenceQuery(taxonName, collector, collectorsNumber, accessionNumber, herbarium, country, locality, null);
}
}
--
2.34.1