ref #7008 Migrate CSV export
authorPatrick Plitzner <p.plitzner@bgbm.org>
Fri, 6 Oct 2017 13:21:00 +0000 (15:21 +0200)
committerPatrick Plitzner <p.plitzner@bgbm.org>
Fri, 6 Oct 2017 14:29:03 +0000 (16:29 +0200)
eu.etaxonomy.taxeditor.store/fragment.e4xmi
eu.etaxonomy.taxeditor.store/plugin.xml
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/e4/out/AbstractExportWizardE4.java [new file with mode: 0644]
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/e4/out/AbstractOpenExportWizard.java [new file with mode: 0644]
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/e4/out/csv/CsvExportWizardE4.java [new file with mode: 0644]
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/e4/out/csv/OpenCsvExportWizard.java [new file with mode: 0644]

index bdb8dde3778fd962eaf71e0f2a25232e1df4e585..5f028b12851dcdd844fd2e161146a960f67da826 100644 (file)
     <elements xsi:type="commands:Command" xmi:id="_bLGTMKmuEeeTAPHmaMLwQQ" elementId="eu.etaxonomy.taxeditor.store.command.importSdd" commandName="%wizard.name.4"/>
     <elements xsi:type="commands:Command" xmi:id="_2JV9IKnAEeeTAPHmaMLwQQ" elementId="eu.etaxonomy.taxeditor.store.command.importExcelSpecimen" commandName="%wizard.name.5"/>
     <elements xsi:type="commands:Command" xmi:id="_OQ9n8KnCEeeTAPHmaMLwQQ" elementId="eu.etaxonomy.taxeditor.store.command.importTcs" commandName="%wizard.name"/>
+    <elements xsi:type="commands:Command" xmi:id="_L0xNEKqYEeeXcJGhyhlrKA" elementId="eu.etaxonomy.taxeditor.store.command.exportCsv" commandName="%wizard.name.18"/>
   </fragments>
   <fragments xsi:type="fragment:StringModelFragment" xmi:id="_swGH0GhvEee3K4uKJljEYg" featurename="handlers" parentElementId="org.eclipse.e4.legacy.ide.application">
     <elements xsi:type="commands:Handler" xmi:id="_rVEdIGcjEee0qLTtA2ZpVQ" elementId="eu.etaxonomy.taxeditor.featuretree.e4.handler.RemoveFeatureHandler" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.featuretree.e4.handler.RemoveFeatureHandler" command="_fNBtQGcjEee0qLTtA2ZpVQ"/>
     <elements xsi:type="commands:Handler" xmi:id="_do2IAKmuEeeTAPHmaMLwQQ" elementId="eu.etaxonomy.taxeditor.io.e4.sdd.OpenSddImportWizard" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.io.e4.in.sdd.OpenSddImportWizard" command="_bLGTMKmuEeeTAPHmaMLwQQ"/>
     <elements xsi:type="commands:Handler" xmi:id="_6BmBEKnAEeeTAPHmaMLwQQ" elementId="eu.etaxonomy.taxeditor.io.e4.excel.specimen.OpenExcelSpecimenImportWizard" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.io.e4.in.excel.specimen.OpenExcelSpecimenImportWizard" command="_2JV9IKnAEeeTAPHmaMLwQQ"/>
     <elements xsi:type="commands:Handler" xmi:id="_Q8Z6gKnCEeeTAPHmaMLwQQ" elementId="eu.etaxonomy.taxeditor.io.e4.tcs.TcsImportWizardE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.io.e4.in.tcs.TcsImportWizardE4" command="_OQ9n8KnCEeeTAPHmaMLwQQ"/>
+    <elements xsi:type="commands:Handler" xmi:id="_SciLQKqYEeeXcJGhyhlrKA" elementId="eu.etaxonomy.taxeditor.io.e4.out.csv.OpenCsvExportWizard" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.io.e4.out.csv.OpenCsvExportWizard" command="_L0xNEKqYEeeXcJGhyhlrKA"/>
   </fragments>
   <fragments xsi:type="fragment:StringModelFragment" xmi:id="_qT4hgIfTEeecZ4F2Y9Z0Og" featurename="children" parentElementId="eu.etaxonomy.taxeditor.workbench.menu.window" positionInList="before:eu.etaxonomy.taxeditor.application.windowMenu.last">
     <elements xsi:type="menu:Menu" xmi:id="_LT3P8IfcEeecZ4F2Y9Z0Og" elementId="eu.etaxonomy.taxeditor.store.menu.termeditor" label="Term Editor">
       <children xsi:type="menu:HandledMenuItem" xmi:id="_hXY2UKmuEeeTAPHmaMLwQQ" elementId="eu.etaxonomy.taxeditor.store.handledmenuitem.importSdd" label="%wizard.name.4" command="_bLGTMKmuEeeTAPHmaMLwQQ"/>
       <children xsi:type="menu:HandledMenuItem" xmi:id="_X2Xb8KnCEeeTAPHmaMLwQQ" elementId="eu.etaxonomy.taxeditor.store.handledmenuitem.importTcs" label="%wizard.name" command="_OQ9n8KnCEeeTAPHmaMLwQQ"/>
     </elements>
+    <elements xsi:type="menu:Menu" xmi:id="_z6EugKqXEeeXcJGhyhlrKA" elementId="eu.etaxonomy.taxeditor.store.menu.export" label="Export (E4)">
+      <visibleWhen xsi:type="ui:CoreExpression" xmi:id="_3eyLYKqXEeeXcJGhyhlrKA" coreExpressionId="isCdmStoreConnected"/>
+      <children xsi:type="menu:HandledMenuItem" xmi:id="_V3eBEKqYEeeXcJGhyhlrKA" elementId="eu.etaxonomy.taxeditor.store.handledmenuitem.wizardname18" label="%wizard.name.18" command="_L0xNEKqYEeeXcJGhyhlrKA"/>
+    </elements>
   </fragments>
 </fragment:ModelFragments>
index 3bb53262dfcaa227b20ab7f625cf765966d47a80..c0f7e9ac8d85edb8eda672759f49871a8108fd4d 100755 (executable)
             id="eu.etaxonomy.taxeditor.io.export.dwca"
             name="%wizard.name.9">
       </wizard>
-      <wizard
-            category="eu.etaxonomy.taxeditor.export.category.cdm"
-            class="eu.etaxonomy.taxeditor.io.wizard.CsvExportWizard"
-            id="eu.etaxonomy.taxeditor.io.export.csv"
-            name="%wizard.name.18">
-      </wizard>
       <wizard
             category="eu.etaxonomy.taxeditor.export.category.cdm"
             class="eu.etaxonomy.taxeditor.io.wizard.CsvNameExportWizard"
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/e4/out/AbstractExportWizardE4.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/e4/out/AbstractExportWizardE4.java
new file mode 100644 (file)
index 0000000..622ce1c
--- /dev/null
@@ -0,0 +1,42 @@
+/**
+* Copyright (C) 2007 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.io.e4.out;
+
+import org.eclipse.jface.wizard.Wizard;
+
+import eu.etaxonomy.cdm.io.common.IIoConfigurator;
+import eu.etaxonomy.taxeditor.io.wizard.GenericConfiguratorWizardPage;
+
+/**
+ *
+ * @author pplitzner
+ * @since Oct 6, 2017
+ *
+ * @param <CONFIG>
+ */
+public abstract class AbstractExportWizardE4<CONFIG extends IIoConfigurator> extends Wizard {
+
+       protected final String CONFIGURATION_PAGE = "CONFIGURATION_PAGE";
+
+       private GenericConfiguratorWizardPage pageConfiguration;
+
+       /** {@inheritDoc} */
+       @Override
+       public void addPages() {
+               super.addPages();
+
+               pageConfiguration = GenericConfiguratorWizardPage.Export(CONFIGURATION_PAGE, getConfigurator(), null);
+               this.addPage(pageConfiguration);
+       }
+
+       public abstract void init();
+
+       public abstract CONFIG getConfigurator();
+}
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/e4/out/AbstractOpenExportWizard.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/e4/out/AbstractOpenExportWizard.java
new file mode 100644 (file)
index 0000000..949db15
--- /dev/null
@@ -0,0 +1,34 @@
+/**
+* Copyright (C) 2017 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.io.e4.out;
+
+import org.eclipse.e4.core.contexts.ContextInjectionFactory;
+import org.eclipse.e4.core.contexts.IEclipseContext;
+import org.eclipse.e4.core.di.annotations.Execute;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * @author pplitzner
+ * @since Oct 5, 2017
+ *
+ */
+public abstract class AbstractOpenExportWizard {
+    @Execute
+    public void execute(IEclipseContext ctx, Shell s)
+    {
+        AbstractExportWizardE4 wizard = ContextInjectionFactory.make(getExportWizardClass(), ctx);
+        wizard.init();
+        WizardDialog dialog = new WizardDialog(s, wizard);
+        dialog.open();
+    }
+
+    protected abstract Class<? extends AbstractExportWizardE4> getExportWizardClass();
+
+}
\ No newline at end of file
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/e4/out/csv/CsvExportWizardE4.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/e4/out/csv/CsvExportWizardE4.java
new file mode 100644 (file)
index 0000000..c2ad2b2
--- /dev/null
@@ -0,0 +1,102 @@
+/**
+ * Copyright (C) 2007 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.io.e4.out.csv;
+
+import java.io.File;
+import java.util.HashSet;
+import java.util.List;
+import java.util.UUID;
+
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.ui.progress.IProgressConstants;
+
+import eu.etaxonomy.cdm.io.csv.redlist.demo.CsvDemoExportConfigurator;
+import eu.etaxonomy.cdm.model.taxon.Classification;
+import eu.etaxonomy.taxeditor.io.e4.out.AbstractExportWizardE4;
+import eu.etaxonomy.taxeditor.io.wizard.ExportToFileDestinationWizardPage;
+import eu.etaxonomy.taxeditor.store.CdmStore;
+
+/**
+ * @author a.oppermann
+ * @created Nov. 11, 2014
+ * @version 1.0
+ */
+public class CsvExportWizardE4 extends AbstractExportWizardE4<CsvDemoExportConfigurator> {
+
+       private CsvDemoExportConfigurator configurator;
+       private ExportToFileDestinationWizardPage page;
+
+       private final String description = "Export the contents of the currently selected database into Comma Separated Value format.";
+
+       @Override
+       public void init() {
+               configurator = CsvDemoExportConfigurator.NewInstance(null, null);
+       }
+
+       @Override
+       public CsvDemoExportConfigurator getConfigurator() {
+               return configurator;
+       }
+
+       @Override
+       public boolean performFinish() {
+               String urlString = page.getFolderText() + File.separator
+                               + page.getExportFileName();
+
+               final Combo combo = page.getCombo();
+               final List<Classification> listClassifications = CdmStore.getCurrentApplicationConfiguration().getClassificationService().listClassifications(null, null, null, null);
+               if(combo != null){
+                   int selectionIndex = combo.getSelectionIndex();
+                   HashSet<UUID> set = new HashSet<UUID>();
+                   if(selectionIndex == -1){
+                       for(Classification c:listClassifications){
+                           set.add(c.getUuid());
+                       }
+                   }else{
+                       for(Classification c:listClassifications){
+                           if(c.getTitleCache().equalsIgnoreCase(combo.getItem(selectionIndex))){
+                               set.add(c.getUuid());
+                           }
+                       }
+                       configurator.setClassificationUuids(set);
+                       configurator.setDoTaxa(true);
+                       configurator.setHasHeaderLines(true);
+                       configurator.setClassification(true);
+                       configurator.setTaxonName(true);
+                       configurator.setAuthor(true);
+                       configurator.setRank(true);
+                       configurator.setLastChange(true);
+                   }
+               }
+
+           // create job
+           Job job = CdmStore.getExportManager().createIOServiceJob(configurator, new File(urlString));
+           // configure the job
+           job.setProperty(IProgressConstants.KEEP_PROPERTY, true);
+           job.setUser(true);
+           // schedule job
+           job.schedule();
+
+               return true;
+       }
+
+       @Override
+       public void addPages() {
+           //TODO create page with drop down menu for export for single classification.
+//             super.addPages();
+
+
+               //standard page
+               page =  ExportToFileDestinationWizardPage.Csv(configurator);
+
+               addPage(page);
+       }
+}
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/e4/out/csv/OpenCsvExportWizard.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/e4/out/csv/OpenCsvExportWizard.java
new file mode 100644 (file)
index 0000000..8287f2b
--- /dev/null
@@ -0,0 +1,29 @@
+/**
+* Copyright (C) 2017 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.io.e4.out.csv;
+
+import eu.etaxonomy.taxeditor.io.e4.out.AbstractExportWizardE4;
+import eu.etaxonomy.taxeditor.io.e4.out.AbstractOpenExportWizard;
+
+/**
+ * @author pplitzner
+ * @since Oct 5, 2017
+ *
+ */
+public class OpenCsvExportWizard extends AbstractOpenExportWizard {
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    protected Class<? extends AbstractExportWizardE4> getExportWizardClass() {
+        return CsvExportWizardE4.class;
+    }
+
+}