- updated SpecimenImportWizard
authorPatric Plitzner <p.plitzner@bgbm.org>
Tue, 18 Feb 2014 07:42:22 +0000 (07:42 +0000)
committerPatric Plitzner <p.plitzner@bgbm.org>
Tue, 18 Feb 2014 07:42:22 +0000 (07:42 +0000)
 - refactored BioCase querying to be a separate job

eu.etaxonomy.taxeditor.bulkeditor/plugin.xml
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/dataimport/DerivedUnitEditorInput.java
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/dataimport/wizard/SpecimenSearchWizard.java
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/dataimport/wizard/SpecimenSearchWizardPage.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/specimenSearch/SpecimenSearchComposite.java

index 8df35d12b1963c3ca040cb6c05ff8b56c99aabcf..835b0248545fdc49d6d852e0904333defb835a4d 100644 (file)
             class="eu.etaxonomy.taxeditor.dataimport.wizard.SpecimenSearchWizard"\r
             id="eu.etaxonomy.taxeditor.dataimport.wizard.SpecimenSearchWizard"\r
             name="Query BioCASE">\r
             class="eu.etaxonomy.taxeditor.dataimport.wizard.SpecimenSearchWizard"\r
             id="eu.etaxonomy.taxeditor.dataimport.wizard.SpecimenSearchWizard"\r
             name="Query BioCASE">\r
+         <description>\r
+            Query BioCaseProvider\r
+         </description>\r
       </wizard>\r
    </extension>
 <!-- start set marker -->\r
       </wizard>\r
    </extension>
 <!-- start set marker -->\r
index f1f05d07dd3f3f246752166633e97af87f001a9f..06b0bb710b97bd19fa6321d9dd961e662554cedb 100644 (file)
@@ -12,16 +12,19 @@ package eu.etaxonomy.taxeditor.dataimport;
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.URISyntaxException;
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.URISyntaxException;
-import java.util.Collections;
 import java.util.List;
 
 import org.apache.http.client.ClientProtocolException;
 import org.apache.log4j.Logger;
 import java.util.List;
 
 import org.apache.http.client.ClientProtocolException;
 import org.apache.log4j.Logger;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
 import org.eclipse.jface.resource.ImageDescriptor;
 import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.widgets.Display;
 import org.eclipse.ui.IEditorInput;
 import org.eclipse.ui.IPersistableElement;
 
 import org.eclipse.ui.IEditorInput;
 import org.eclipse.ui.IPersistableElement;
 
-import eu.etaxonomy.cdm.api.application.ICdmApplicationConfiguration;
 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.ext.biocase.BioCaseQuery;
 import eu.etaxonomy.cdm.ext.biocase.BioCaseQueryServiceWrapper;
 import eu.etaxonomy.cdm.io.common.CdmDefaultImport;
@@ -41,11 +44,83 @@ public class DerivedUnitEditorInput implements IEditorInput {
 
     private final BioCaseQuery query;
 
 
     private final BioCaseQuery query;
 
+    private List<SpecimenOrObservationBase> results;
+
     /**
      * @param results
      */
     public DerivedUnitEditorInput(BioCaseQuery query) {
         this.query = query;
     /**
      * @param results
      */
     public DerivedUnitEditorInput(BioCaseQuery query) {
         this.query = query;
+        Display.getCurrent().asyncExec(new Runnable() {
+
+            @Override
+            public void run() {
+                String errorMessage = "Could not execute query " + DerivedUnitEditorInput.this.query;
+                try {
+                    InputStream resultStream = new BioCaseQueryServiceWrapper().query(DerivedUnitEditorInput.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();
+//            Abcd206Import abcd206Import = new Abcd206Import();
+//            Abcd206ImportState state = new Abcd206ImportState(configurator);
+//            abcd206Import.invoke(state);
+//            state.countTrees();
+                } catch (ClientProtocolException e) {
+                    logger.error(errorMessage, e);
+                } catch (IOException e) {
+                    logger.error(errorMessage, e);
+                } catch (URISyntaxException e) {
+                    logger.error(errorMessage, e);
+                }
+//        return new BioCaseQueryServiceWrapper().dummyData();
+            }
+        });
+    }
+
+    public void query(){
+        Job queryJob = new Job("Query Biocase") {
+
+            @Override
+            protected IStatus run(IProgressMonitor monitor) {
+                String errorMessage = "Could not execute query " + DerivedUnitEditorInput.this.query;
+                try {
+                    InputStream resultStream = new BioCaseQueryServiceWrapper().query(DerivedUnitEditorInput.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();
+//            Abcd206Import abcd206Import = new Abcd206Import();
+//            Abcd206ImportState state = new Abcd206ImportState(configurator);
+//            abcd206Import.invoke(state);
+//            state.countTrees();
+                } 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();
+                    }
+                });
+
+                return Status.OK_STATUS;
+            }
+        };
     }
 
     /* (non-Javadoc)
     }
 
     /* (non-Javadoc)
@@ -102,30 +177,6 @@ public class DerivedUnitEditorInput implements IEditorInput {
      * @return the results
      */
     public List<SpecimenOrObservationBase> getResults() {
      * @return the results
      */
     public List<SpecimenOrObservationBase> getResults() {
-        String errorMessage = "Could not execute query " + query;
-        List<SpecimenOrObservationBase> results = Collections.EMPTY_LIST;
-        try {
-            InputStream resultStream = new BioCaseQueryServiceWrapper().query(query);
-            Abcd206ImportConfigurator configurator = Abcd206ImportConfigurator.NewInstance(resultStream, null, false);
-            TransientCdmRepository repo = 
-                       new TransientCdmRepository((ICdmApplicationConfiguration)CdmStore.getCurrentApplicationConfiguration());
-            configurator.setCdmAppController(repo);
-
-            CdmDefaultImport<Abcd206ImportConfigurator> importer = new CdmDefaultImport<Abcd206ImportConfigurator>();
-            importer.invoke(configurator);
-            results = repo.getUnits();
-//            Abcd206Import abcd206Import = new Abcd206Import();
-//            Abcd206ImportState state = new Abcd206ImportState(configurator);
-//            abcd206Import.invoke(state);
-//            state.countTrees();
-        } catch (ClientProtocolException e) {
-            logger.error(errorMessage, e);
-        } catch (IOException e) {
-            logger.error(errorMessage, e);
-        } catch (URISyntaxException e) {
-            logger.error(errorMessage, e);
-        }
-//        return new BioCaseQueryServiceWrapper().dummyData();
         return results;
     }
 
         return results;
     }
 
index 62642019ae0b0269fdbf23ed155e91759180e0de..f25f4226834f7a06b789f98ff59c3916d66a4c9b 100644 (file)
@@ -44,6 +44,7 @@ public class SpecimenSearchWizard extends Wizard implements IImportWizard {
 
         //check if connected to a data source. If not this will open an error dialog
         CdmStore.getCurrentApplicationConfiguration();
 
         //check if connected to a data source. If not this will open an error dialog
         CdmStore.getCurrentApplicationConfiguration();
+        this.setWindowTitle("Search Specimens");
     }
 
 
     }
 
 
@@ -57,6 +58,7 @@ public class SpecimenSearchWizard extends Wizard implements IImportWizard {
         try {
             query = searchPage.getQuery();
             DerivedUnitEditorInput input = new DerivedUnitEditorInput(query);
         try {
             query = searchPage.getQuery();
             DerivedUnitEditorInput input = new DerivedUnitEditorInput(query);
+            input.query();
             page.openEditor(input, DataImportEditor.ID, true);
         } catch ( PartInitException e ) {
             //Put your exception handler here if you wish to
             page.openEditor(input, DataImportEditor.ID, true);
         } catch ( PartInitException e ) {
             //Put your exception handler here if you wish to
index 4f75dbd39a54ad1c1dcbdc2ff6ef7c67c0993c6c..cc534bf5bcd9d34dd4279aefecece9eec3e09445 100644 (file)
@@ -28,6 +28,8 @@ public class SpecimenSearchWizardPage extends WizardPage{
 
     protected SpecimenSearchWizardPage(String pageName) {
         super(pageName);
 
     protected SpecimenSearchWizardPage(String pageName) {
         super(pageName);
+        setDescription("Specify search parameters for external search query.");
+        setTitle("Search Specimens");
     }
 
     /* (non-Javadoc)
     }
 
     /* (non-Javadoc)
index 2b8911c8fe46ba82cfefbff3ddf4e91eaabfd496..0fbaebd2124d014f679b63885298fba4a172ee16 100644 (file)
@@ -25,82 +25,75 @@ import org.eclipse.ui.forms.widgets.TableWrapLayout;
  */
 public class SpecimenSearchComposite extends Composite {
     private final FormToolkit formToolkit = new FormToolkit(Display.getDefault());
  */
 public class SpecimenSearchComposite extends Composite {
     private final FormToolkit formToolkit = new FormToolkit(Display.getDefault());
-    private Text textTaxonName;
-    private Text textCollector;
-    private Text textCollectorNumber;
-    private Text textAccessionNumber;
-    private Text textLocality;
-    private Text textHerbarium;
-    private Text textCountry;
+    private final Text textTaxonName;
+    private final Text textCollector;
+    private final Text textCollectorNumber;
+    private final Text textAccessionNumber;
+    private final Text textLocality;
+    private final Text textHerbarium;
+    private final Text textCountry;
 
     /**
      * Create the composite.
      * @param parent
 
     /**
      * Create the composite.
      * @param parent
-     * @param style
+     * @setBackgroundMode(SWT.INHERIT_DEFAULT);
+        param style
      */
     public SpecimenSearchComposite(Composite parent, int style) {
         super(parent, style);
      */
     public SpecimenSearchComposite(Composite parent, int style) {
         super(parent, style);
-        setBackgroundMode(SWT.INHERIT_DEFAULT);
         {
             TableWrapLayout tableWrapLayout = new TableWrapLayout();
             tableWrapLayout.numColumns = 2;
             setLayout(tableWrapLayout);
         }
 
         {
             TableWrapLayout tableWrapLayout = new TableWrapLayout();
             tableWrapLayout.numColumns = 2;
             setLayout(tableWrapLayout);
         }
 
-        Label lblTaxonName = formToolkit.createLabel(this, "Taxon Name", SWT.NONE);
+        Label lblTaxonName = new Label(this, SWT.NONE);
+        lblTaxonName.setText("Taxon Name");
 
 
-        textTaxonName = new Text(this, SWT.BORDER);
+        textTaxonName = new Text(this, SWT.NONE);
         textTaxonName.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.TOP, 1, 1));
         textTaxonName.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.TOP, 1, 1));
-        formToolkit.adapt(textTaxonName, true, true);
 
         Label lblCollectors = new Label(this, SWT.NONE);
 
         Label lblCollectors = new Label(this, SWT.NONE);
-        formToolkit.adapt(lblCollectors, true, true);
         lblCollectors.setText("Collector(s)");
 
         lblCollectors.setText("Collector(s)");
 
-        textCollector = new Text(this, SWT.BORDER);
+        textCollector = new Text(this, SWT.NONE);
         textCollector.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.TOP, 1, 1));
         formToolkit.adapt(textCollector, true, true);
 
         Label lblCollectorsNumber = new Label(this, SWT.NONE);
         textCollector.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.TOP, 1, 1));
         formToolkit.adapt(textCollector, true, true);
 
         Label lblCollectorsNumber = new Label(this, SWT.NONE);
-        formToolkit.adapt(lblCollectorsNumber, true, true);
         lblCollectorsNumber.setText("Collector(s) Number");
 
         lblCollectorsNumber.setText("Collector(s) Number");
 
-        textCollectorNumber = new Text(this, SWT.BORDER);
+        textCollectorNumber = new Text(this, SWT.NONE);
         textCollectorNumber.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.TOP, 1, 1));
         formToolkit.adapt(textCollectorNumber, true, true);
 
         Label lblAccessionNumber = new Label(this, SWT.NONE);
         textCollectorNumber.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.TOP, 1, 1));
         formToolkit.adapt(textCollectorNumber, true, true);
 
         Label lblAccessionNumber = new Label(this, SWT.NONE);
-        formToolkit.adapt(lblAccessionNumber, true, true);
         lblAccessionNumber.setText("Accession Number");
 
         lblAccessionNumber.setText("Accession Number");
 
-        textAccessionNumber = new Text(this, SWT.BORDER);
+        textAccessionNumber = new Text(this, SWT.NONE);
         textAccessionNumber.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.TOP, 1, 1));
         formToolkit.adapt(textAccessionNumber, true, true);
 
         Label lblHerbarium = new Label(this, SWT.NONE);
         textAccessionNumber.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.TOP, 1, 1));
         formToolkit.adapt(textAccessionNumber, true, true);
 
         Label lblHerbarium = new Label(this, SWT.NONE);
-        formToolkit.adapt(lblHerbarium, true, true);
         lblHerbarium.setText("Herbarium");
 
         textHerbarium = new Text(this, SWT.NONE);
         textHerbarium.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.TOP, 1, 1));
 
         Label lblCountry = new Label(this, SWT.NONE);
         lblHerbarium.setText("Herbarium");
 
         textHerbarium = new Text(this, SWT.NONE);
         textHerbarium.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.TOP, 1, 1));
 
         Label lblCountry = new Label(this, SWT.NONE);
-        formToolkit.adapt(lblCountry, true, true);
         lblCountry.setText("Country");
 
         textCountry = new Text(this, SWT.NONE);
         textCountry.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.TOP, 1, 1));
 
         Label lblLocality = new Label(this, SWT.NONE);
         lblCountry.setText("Country");
 
         textCountry = new Text(this, SWT.NONE);
         textCountry.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.TOP, 1, 1));
 
         Label lblLocality = new Label(this, SWT.NONE);
-        formToolkit.adapt(lblLocality, true, true);
         lblLocality.setText("Locality");
 
         lblLocality.setText("Locality");
 
-        textLocality = new Text(this, SWT.BORDER);
+        textLocality = new Text(this, SWT.NONE);
         textLocality.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.TOP, 1, 1));
         formToolkit.adapt(textLocality, true, true);
 
         Label lblCollectionDate = new Label(this, SWT.NONE);
         textLocality.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.TOP, 1, 1));
         formToolkit.adapt(textLocality, true, true);
 
         Label lblCollectionDate = new Label(this, SWT.NONE);
-        formToolkit.adapt(lblCollectionDate, true, true);
         lblCollectionDate.setText("Collection Date");
         new Label(this, SWT.NONE);
 
         lblCollectionDate.setText("Collection Date");
         new Label(this, SWT.NONE);