- added BioCaseQuery to the API
authorPatric Plitzner <p.plitzner@bgbm.org>
Wed, 18 Sep 2013 08:29:09 +0000 (08:29 +0000)
committerPatric Plitzner <p.plitzner@bgbm.org>
Wed, 18 Sep 2013 08:29:09 +0000 (08:29 +0000)
   - adapted taxeditor

 - this is EXPERIMENTAL

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/specimenSearch/SpecimenSearchResultWizardPage.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/specimenSearch/SpecimenSearchWizard.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/specimenSearch/SpecimenSearchWizardPage.java

index 2832fcca67128f0110b121d441b59713a0aa8b0e..c1cf37f27eb8482c8f328927ec54f706a79a611c 100644 (file)
@@ -9,9 +9,14 @@
 */
 package eu.etaxonomy.taxeditor.io.wizard.specimenSearch;
 
+import java.util.List;
+
+import org.eclipse.jface.dialogs.IPageChangedListener;
+import org.eclipse.jface.dialogs.PageChangedEvent;
 import org.eclipse.jface.wizard.WizardPage;
 import org.eclipse.swt.widgets.Composite;
 
+import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
 import eu.etaxonomy.taxeditor.ui.campanula.specimenSearch.SpecimenSearchResultsController;
 
 /**
@@ -19,13 +24,17 @@ import eu.etaxonomy.taxeditor.ui.campanula.specimenSearch.SpecimenSearchResultsC
  * @date 12.09.2013
  *
  */
-public class SpecimenSearchResultWizardPage extends WizardPage {
+public class SpecimenSearchResultWizardPage extends WizardPage implements IPageChangedListener {
+
+    private SpecimenSearchResultsController specimenSearchResultsController;
+    private List<SpecimenOrObservationBase> results;
 
     /**
      * @param pageName
      */
-    protected SpecimenSearchResultWizardPage(String pageName) {
+    protected SpecimenSearchResultWizardPage(String pageName, List<SpecimenOrObservationBase> results) {
         super(pageName);
+        this.results = results;
     }
 
     /* (non-Javadoc)
@@ -33,7 +42,24 @@ public class SpecimenSearchResultWizardPage extends WizardPage {
      */
     @Override
     public void createControl(Composite parent) {
-        setControl(new SpecimenSearchResultsController(parent).getComposite());
+        specimenSearchResultsController = new SpecimenSearchResultsController(parent);
+        setControl(specimenSearchResultsController.getComposite());
+    }
+
+    @Override
+    public void setVisible(boolean visible) {
+        super.setVisible(visible);
     }
 
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.dialogs.IPageChangedListener#pageChanged(org.eclipse.jface.dialogs.PageChangedEvent)
+     */
+    @Override
+    public void pageChanged(PageChangedEvent event) {
+        if(isCurrentPage()){
+            if(results!=null && !results.isEmpty()){
+                specimenSearchResultsController.setText(results.get(0).getTitleCache());
+            }
+        }
+    };
 }
index 712362a5970c15d7c38982ffb85162a4041a2d66..2b0e0d2e58e0ecc5a6dc26cbeff119f57c6aa63b 100644 (file)
@@ -9,11 +9,21 @@
 */
 package eu.etaxonomy.taxeditor.io.wizard.specimenSearch;
 
+import java.io.IOException;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.http.client.ClientProtocolException;
 import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.jface.wizard.Wizard;
 import org.eclipse.ui.IImportWizard;
 import org.eclipse.ui.IWorkbench;
 
+import eu.etaxonomy.cdm.ext.biocase.BioCaseQuery;
+import eu.etaxonomy.cdm.ext.biocase.BioCaseQueryServiceWrapper;
+import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
+
 /**
  * @author pplitzner
  * @date 11.09.2013
@@ -21,6 +31,20 @@ import org.eclipse.ui.IWorkbench;
  */
 public class SpecimenSearchWizard extends Wizard implements IImportWizard {
 
+    private BioCaseQueryServiceWrapper bioCaseQueryServiceWrapper;
+    private BioCaseQuery query;
+    private List<SpecimenOrObservationBase> results;
+
+    /**
+     *
+     */
+    public SpecimenSearchWizard() {
+        query = new BioCaseQuery();
+        bioCaseQueryServiceWrapper = new BioCaseQueryServiceWrapper();
+        this.results = new ArrayList<SpecimenOrObservationBase>();
+    }
+
+
     /* (non-Javadoc)
      * @see org.eclipse.jface.wizard.Wizard#performFinish()
      */
@@ -34,10 +58,25 @@ public class SpecimenSearchWizard extends Wizard implements IImportWizard {
      */
     @Override
     public void addPages() {
-        addPage(new SpecimenSearchWizardPage("Specimen Search"));
-        addPage(new SpecimenSearchResultWizardPage("Search Results"));
+        addPage(new SpecimenSearchWizardPage("Specimen Search", results));
+        addPage(new SpecimenSearchResultWizardPage("Search Results", results));
     }
 
+    public List<SpecimenOrObservationBase> getResults(){
+        try {
+            return bioCaseQueryServiceWrapper.query(query);
+        } catch (ClientProtocolException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        } catch (IOException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        } catch (URISyntaxException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+        return null;
+    }
 
     /* (non-Javadoc)
      * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
@@ -46,4 +85,11 @@ public class SpecimenSearchWizard extends Wizard implements IImportWizard {
     public void init(IWorkbench workbench, IStructuredSelection selection) {
     }
 
+    /**
+     * @return the query
+     */
+    public BioCaseQuery getQuery() {
+        return query;
+    }
+
 }
index 1269c70e1ed4652a3893681070ff5de08414a50f..e9c3f0b69fc4ea5a9693e305081698fd6551f44c 100644 (file)
@@ -9,9 +9,12 @@
 */
 package eu.etaxonomy.taxeditor.io.wizard.specimenSearch;
 
+import java.util.List;
+
 import org.eclipse.jface.wizard.WizardPage;
 import org.eclipse.swt.widgets.Composite;
 
+import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
 import eu.etaxonomy.taxeditor.ui.campanula.specimenSearch.SpecimenSearchController;
 
 /**
@@ -21,11 +24,14 @@ import eu.etaxonomy.taxeditor.ui.campanula.specimenSearch.SpecimenSearchControll
  */
 public class SpecimenSearchWizardPage extends WizardPage{
 
+    private List<SpecimenOrObservationBase> results;
+
     /**
      * @param pageName
      */
-    protected SpecimenSearchWizardPage(String pageName) {
+    protected SpecimenSearchWizardPage(String pageName, List<SpecimenOrObservationBase> results) {
         super(pageName);
+        this.results = results;
     }
 
     /* (non-Javadoc)
@@ -36,6 +42,14 @@ public class SpecimenSearchWizardPage extends WizardPage{
         setControl(new SpecimenSearchController(parent).getComposite());
     }
 
-
-
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.dialogs.DialogPage#setVisible(boolean)
+     */
+    @Override
+    public void setVisible(boolean visible) {
+        super.setVisible(visible);
+        if(visible==false){
+            ((SpecimenSearchWizard) getWizard()).getResults();
+        }
+    }
 }