line endings
authorPatrick Plitzner <p.plitzner@bgbm.org>
Tue, 26 Jul 2016 13:44:19 +0000 (15:44 +0200)
committerPatrick Plitzner <p.plitzner@bgbm.org>
Tue, 26 Jul 2016 13:53:06 +0000 (15:53 +0200)
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/dataimport/SpecimenSearchWizard.java

index 03aa92c07d6a66c848099e1be6a4df69c87630a0..9ba538987ccf9548ed598ffd3df2ad8a61390024 100644 (file)
-// $Id$\r
-/**\r
-* Copyright (C) 2013 EDIT\r
-* European Distributed Institute of Taxonomy\r
-* http://www.e-taxonomy.eu\r
-*\r
-* The contents of this file are subject to the Mozilla Public License Version 1.1\r
-* See LICENSE.TXT at the top of this package for the full license terms.\r
-*/\r
-package eu.etaxonomy.taxeditor.view.dataimport;\r
-\r
-import java.io.IOException;\r
-import java.io.InputStream;\r
-import java.net.URI;\r
-\r
-import org.apache.log4j.Logger;\r
-import org.eclipse.core.runtime.IProgressMonitor;\r
-import org.eclipse.core.runtime.IStatus;\r
-import org.eclipse.core.runtime.Status;\r
-import org.eclipse.core.runtime.jobs.Job;\r
-import org.eclipse.jface.viewers.IStructuredSelection;\r
-import org.eclipse.jface.wizard.Wizard;\r
-import org.eclipse.swt.widgets.Display;\r
-import org.eclipse.ui.IImportWizard;\r
-import org.eclipse.ui.IWorkbench;\r
-import org.eclipse.ui.IWorkbenchPage;\r
-import org.eclipse.ui.IWorkbenchWindow;\r
-import org.eclipse.ui.PartInitException;\r
-import org.eclipse.ui.PlatformUI;\r
-import org.w3c.dom.NodeList;\r
-\r
-import eu.etaxonomy.cdm.database.DbSchemaValidation;\r
-import eu.etaxonomy.cdm.ext.common.ServiceWrapperBase;\r
-import eu.etaxonomy.cdm.ext.occurrence.OccurenceQuery;\r
-import eu.etaxonomy.cdm.ext.occurrence.bioCase.BioCaseQueryServiceWrapper;\r
-import eu.etaxonomy.cdm.io.specimen.abcd206.in.Abcd206ImportConfigurator;\r
-\r
-import eu.etaxonomy.cdm.io.specimen.abcd206.in.AbcdParseUtility;\r
-import eu.etaxonomy.cdm.io.specimen.abcd206.in.SpecimenImportReport;\r
-import eu.etaxonomy.cdm.io.specimen.abcd206.in.UnitAssociationWrapper;\r
-import eu.etaxonomy.taxeditor.store.CdmStore;\r
-\r
-/**\r
- * Wizard for querying specimen provider.\r
- * @author pplitzner\r
- * @date 11.09.2013\r
- *\r
- */\r
-public class SpecimenSearchWizard extends Wizard implements IImportWizard {\r
-    private static final Logger logger = Logger.getLogger(SpecimenSearchWizard.class);\r
-\r
-    private OccurenceQuery query = null;\r
-    private SpecimenProviderSelectionWizardPage providerSelectionPage;\r
-    private SpecimenSearchWizardPage searchPage;\r
-\r
-    /**\r
-     * Creates a new SpecimenSearchWizard\r
-     */\r
-    public SpecimenSearchWizard() {\r
-        //default constructor needed for RCP extension points\r
-\r
-        //check if connected to a data source. If not this will open an error dialog\r
-        CdmStore.getCurrentApplicationConfiguration();\r
-        this.setWindowTitle("Search Specimens");\r
-    }\r
-\r
-\r
-    /* (non-Javadoc)\r
-     * @see org.eclipse.jface.wizard.Wizard#performFinish()\r
-     */\r
-    @Override\r
-    public boolean performFinish() {\r
-        searchPage.getController().saveLastSate();\r
-        providerSelectionPage.getController().saveLastState();\r
-        ServiceWrapperBase serviceWrapper;\r
-        DataImportView<?> dataImportView = null;\r
-        query = searchPage.getQuery();\r
-        Abcd206ImportConfigurator configurator =  CdmStore.getImportManager().AbcdConfigurator();\r
-        configurator.setOccurenceQuery(query);\r
-        configurator.setSourceUri(providerSelectionPage.getEndPoint());\r
-        configurator.setDbSchemaValidation(DbSchemaValidation.CREATE);\r
-        if(CdmStore.getCurrentSessionManager().isRemoting() ) {\r
-            //Job job = CdmStore.getImportManager().createIOServiceJob(configurator, new File(source), SOURCE_TYPE.INPUTSTREAM);\r
-            //CdmStore.getImportManager().run(job);\r
-            try {\r
-                serviceWrapper = providerSelectionPage.getQueryServiceWrapper();\r
-                InputStream stream = null;\r
-\r
-                final IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();\r
-                IWorkbenchPage activePart = window.getActivePage();\r
-                if (providerSelectionPage.getQueryType().equals(QueryType.BIOCASE)){\r
-                    stream =((BioCaseQueryServiceWrapper) serviceWrapper).query(query, configurator.getSourceUri());\r
-                    SpecimenImportReport report = new SpecimenImportReport();\r
-                    UnitAssociationWrapper unitNodesList = AbcdParseUtility.parseUnitsNodeList(stream, report);\r
-                    NodeList nodeList = unitNodesList.getAssociatedUnits();\r
-                    String prefix = unitNodesList.getPrefix();\r
-                    String associationType = unitNodesList.getAssociationType();\r
-                    URI uri =AbcdParseUtility.parseFirstUri(nodeList, report);\r
-                    String content = AbcdParseUtility.parseFirstTextContent(nodeList);\r
-                    System.out.println(content);\r
-\r
-\r
-                    SpecimenImportView specimenImportView = new SpecimenImportView();\r
-                    try {\r
-                        specimenImportView = (SpecimenImportView) activePart.showView(SpecimenImportView.ID);\r
-                        specimenImportView.setEndpoint(providerSelectionPage.getEndPoint());\r
-                        specimenImportView.setQuery(query);\r
-                        dataImportView = specimenImportView;\r
-                    } catch (PartInitException e) {\r
-                        // TODO Auto-generated catch block\r
-                        e.printStackTrace();\r
-\r
-                    }\r
-\r
-                } else{\r
-                    try {\r
-                       \r
-                        dataImportView = (GbifResponseImportView) activePart.showView(GbifResponseImportView.ID, "query_"+query.toString().replaceAll(",", ""), IWorkbenchPage.VIEW_ACTIVATE);\r
-                        dataImportView.setQuery(query);                \r
-                               //      (GbifResponseImportView) activePart.showView(GbifResponseImportView.ID);getWorkbench().getActiveWorkbenchWindow().getActivePage()\r
-                             // .showView(GbifResponseImportView.ID, "query_"+query.toString().replaceAll(",", ""),IWorkbenchPage.VIEW_ACTIVATE);\r
-\r
-                    } catch (PartInitException e) {\r
-                        // TODO Auto-generated catch block\r
-                        e.printStackTrace();\r
-                    }\r
-\r
-                }\r
-\r
-\r
-            } catch (IOException e) {\r
-                // TODO Auto-generated catch block\r
-                e.printStackTrace();\r
-            }\r
-           // CdmStore.getImportManager().run(configurator);\r
-        }\r
-//        try {\r
-//            switch (providerSelectionPage.getQueryType()) {\r
-//            case BIOCASE:\r
-//                SpecimenImportView specimenImportView = (SpecimenImportView) TaxeditorEditorPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage()\r
-//                        .showView(SpecimenImportView.ID, "query_"+query.toString().replaceAll(",", ""),IWorkbenchPage.VIEW_ACTIVATE);\r
-//                specimenImportView.setEndpoint(providerSelectionPage.getEndPoint());\r
-//                dataImportView = specimenImportView;\r
-//                break;\r
-//            case GBIF:\r
-//                dataImportView = (GbifResponseImportView) TaxeditorEditorPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage()\r
-//                .showView(GbifResponseImportView.ID, "query_"+query.toString().replaceAll(",", ""),IWorkbenchPage.VIEW_ACTIVATE);\r
-//                break;\r
-//            }\r
-//        } catch ( PartInitException e ) {\r
-//            logger.error("Could not open import view for query: " + query.toString(), e);\r
-//        }\r
-//        if(dataImportView!=null){\r
-//            dataImportView.setQuery(query);\r
-////            dataImportView.query();\r
-////            Display.getDefault().asyncExec(new Runnable() {\r
-////\r
-////                @Override\r
-////                public void run() {\r
-////                    CdmStore.getContextManager().notifyContextRefresh();\r
-////                }\r
-////            });\r
-            Job queryJob = new QueryJob("Query specimen provider", dataImportView);\r
-            queryJob.schedule();\r
-\r
-        return true;\r
-    }\r
-\r
-    /* (non-Javadoc)\r
-     * @see org.eclipse.jface.wizard.Wizard#addPages()\r
-     */\r
-    @Override\r
-    public void addPages() {\r
-        addPage(providerSelectionPage);\r
-        addPage(searchPage);\r
-    }\r
-\r
-    /* (non-Javadoc)\r
-     * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)\r
-     */\r
-    @Override\r
-    public void init(IWorkbench workbench, IStructuredSelection selection) {\r
-        providerSelectionPage = new SpecimenProviderSelectionWizardPage("Select specimen provider");\r
-        searchPage = new SpecimenSearchWizardPage("Specimen Search");\r
-    }\r
-\r
-    private class QueryJob extends Job{\r
-\r
-        private final DataImportView<?> view;\r
-\r
-        /**\r
-         * @param name\r
-         */\r
-        public QueryJob(String name, DataImportView<?> view) {\r
-            super(name);\r
-            this.view = view;\r
-        }\r
-\r
-        /* (non-Javadoc)\r
-         * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)\r
-         */\r
-        @Override\r
-        protected IStatus run(IProgressMonitor monitor) {\r
-            view.getConversationHolder().bind();\r
-            view.query();\r
-            Display.getDefault().asyncExec(new Runnable() {\r
-\r
-                @Override\r
-                public void run() {\r
-                    CdmStore.getContextManager().notifyContextRefresh();\r
-                }\r
-            });\r
-            return Status.OK_STATUS;\r
-        }\r
-\r
-    }\r
-}\r
+// $Id$
+/**
+* Copyright (C) 2013 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.view.dataimport;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+
+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.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IImportWizard;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.w3c.dom.NodeList;
+
+import eu.etaxonomy.cdm.database.DbSchemaValidation;
+import eu.etaxonomy.cdm.ext.common.ServiceWrapperBase;
+import eu.etaxonomy.cdm.ext.occurrence.OccurenceQuery;
+import eu.etaxonomy.cdm.ext.occurrence.bioCase.BioCaseQueryServiceWrapper;
+import eu.etaxonomy.cdm.io.specimen.abcd206.in.Abcd206ImportConfigurator;
+
+import eu.etaxonomy.cdm.io.specimen.abcd206.in.AbcdParseUtility;
+import eu.etaxonomy.cdm.io.specimen.abcd206.in.SpecimenImportReport;
+import eu.etaxonomy.cdm.io.specimen.abcd206.in.UnitAssociationWrapper;
+import eu.etaxonomy.taxeditor.store.CdmStore;
+
+/**
+ * Wizard for querying specimen provider.
+ * @author pplitzner
+ * @date 11.09.2013
+ *
+ */
+public class SpecimenSearchWizard extends Wizard implements IImportWizard {
+    private static final Logger logger = Logger.getLogger(SpecimenSearchWizard.class);
+
+    private OccurenceQuery query = null;
+    private SpecimenProviderSelectionWizardPage providerSelectionPage;
+    private SpecimenSearchWizardPage searchPage;
+
+    /**
+     * Creates a new SpecimenSearchWizard
+     */
+    public SpecimenSearchWizard() {
+        //default constructor needed for RCP extension points
+
+        //check if connected to a data source. If not this will open an error dialog
+        CdmStore.getCurrentApplicationConfiguration();
+        this.setWindowTitle("Search Specimens");
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.wizard.Wizard#performFinish()
+     */
+    @Override
+    public boolean performFinish() {
+        searchPage.getController().saveLastSate();
+        providerSelectionPage.getController().saveLastState();
+        ServiceWrapperBase serviceWrapper;
+        DataImportView<?> dataImportView = null;
+        query = searchPage.getQuery();
+        Abcd206ImportConfigurator configurator =  CdmStore.getImportManager().AbcdConfigurator();
+        configurator.setOccurenceQuery(query);
+        configurator.setSourceUri(providerSelectionPage.getEndPoint());
+        configurator.setDbSchemaValidation(DbSchemaValidation.CREATE);
+        if(CdmStore.getCurrentSessionManager().isRemoting() ) {
+            //Job job = CdmStore.getImportManager().createIOServiceJob(configurator, new File(source), SOURCE_TYPE.INPUTSTREAM);
+            //CdmStore.getImportManager().run(job);
+            try {
+                serviceWrapper = providerSelectionPage.getQueryServiceWrapper();
+                InputStream stream = null;
+
+                final IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+                IWorkbenchPage activePart = window.getActivePage();
+                if (providerSelectionPage.getQueryType().equals(QueryType.BIOCASE)){
+                    stream =((BioCaseQueryServiceWrapper) serviceWrapper).query(query, configurator.getSourceUri());
+                    SpecimenImportReport report = new SpecimenImportReport();
+                    UnitAssociationWrapper unitNodesList = AbcdParseUtility.parseUnitsNodeList(stream, report);
+                    NodeList nodeList = unitNodesList.getAssociatedUnits();
+                    String prefix = unitNodesList.getPrefix();
+                    String associationType = unitNodesList.getAssociationType();
+                    URI uri =AbcdParseUtility.parseFirstUri(nodeList, report);
+                    String content = AbcdParseUtility.parseFirstTextContent(nodeList);
+                    System.out.println(content);
+
+
+                    SpecimenImportView specimenImportView = new SpecimenImportView();
+                    try {
+                        specimenImportView = (SpecimenImportView) activePart.showView(SpecimenImportView.ID);
+                        specimenImportView.setEndpoint(providerSelectionPage.getEndPoint());
+                        specimenImportView.setQuery(query);
+                        dataImportView = specimenImportView;
+                    } catch (PartInitException e) {
+                        // TODO Auto-generated catch block
+                        e.printStackTrace();
+
+                    }
+
+                } else{
+                    try {
+                       
+                        dataImportView = (GbifResponseImportView) activePart.showView(GbifResponseImportView.ID, "query_"+query.toString().replaceAll(",", ""), IWorkbenchPage.VIEW_ACTIVATE);
+                        dataImportView.setQuery(query);                
+                               //      (GbifResponseImportView) activePart.showView(GbifResponseImportView.ID);getWorkbench().getActiveWorkbenchWindow().getActivePage()
+                             // .showView(GbifResponseImportView.ID, "query_"+query.toString().replaceAll(",", ""),IWorkbenchPage.VIEW_ACTIVATE);
+
+                    } catch (PartInitException e) {
+                        // TODO Auto-generated catch block
+                        e.printStackTrace();
+                    }
+
+                }
+
+
+            } catch (IOException e) {
+                // TODO Auto-generated catch block
+                e.printStackTrace();
+            }
+           // CdmStore.getImportManager().run(configurator);
+        }
+//        try {
+//            switch (providerSelectionPage.getQueryType()) {
+//            case BIOCASE:
+//                SpecimenImportView specimenImportView = (SpecimenImportView) TaxeditorEditorPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage()
+//                        .showView(SpecimenImportView.ID, "query_"+query.toString().replaceAll(",", ""),IWorkbenchPage.VIEW_ACTIVATE);
+//                specimenImportView.setEndpoint(providerSelectionPage.getEndPoint());
+//                dataImportView = specimenImportView;
+//                break;
+//            case GBIF:
+//                dataImportView = (GbifResponseImportView) TaxeditorEditorPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage()
+//                .showView(GbifResponseImportView.ID, "query_"+query.toString().replaceAll(",", ""),IWorkbenchPage.VIEW_ACTIVATE);
+//                break;
+//            }
+//        } catch ( PartInitException e ) {
+//            logger.error("Could not open import view for query: " + query.toString(), e);
+//        }
+//        if(dataImportView!=null){
+//            dataImportView.setQuery(query);
+////            dataImportView.query();
+////            Display.getDefault().asyncExec(new Runnable() {
+////
+////                @Override
+////                public void run() {
+////                    CdmStore.getContextManager().notifyContextRefresh();
+////                }
+////            });
+            Job queryJob = new QueryJob("Query specimen provider", dataImportView);
+            queryJob.schedule();
+
+        return true;
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.wizard.Wizard#addPages()
+     */
+    @Override
+    public void addPages() {
+        addPage(providerSelectionPage);
+        addPage(searchPage);
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
+     */
+    @Override
+    public void init(IWorkbench workbench, IStructuredSelection selection) {
+        providerSelectionPage = new SpecimenProviderSelectionWizardPage("Select specimen provider");
+        searchPage = new SpecimenSearchWizardPage("Specimen Search");
+    }
+
+    private class QueryJob extends Job{
+
+        private final DataImportView<?> view;
+
+        /**
+         * @param name
+         */
+        public QueryJob(String name, DataImportView<?> view) {
+            super(name);
+            this.view = view;
+        }
+
+        /* (non-Javadoc)
+         * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
+         */
+        @Override
+        protected IStatus run(IProgressMonitor monitor) {
+            view.getConversationHolder().bind();
+            view.query();
+            Display.getDefault().asyncExec(new Runnable() {
+
+                @Override
+                public void run() {
+                    CdmStore.getContextManager().notifyContextRefresh();
+                }
+            });
+            return Status.OK_STATUS;
+        }
+
+    }
+}