ref #7005 Migrate Tcs import
authorPatrick Plitzner <p.plitzner@bgbm.org>
Thu, 5 Oct 2017 11:56:21 +0000 (13:56 +0200)
committerPatrick Plitzner <p.plitzner@bgbm.org>
Thu, 5 Oct 2017 11:56:21 +0000 (13:56 +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/tcs/OpenTcsImportWizard.java [new file with mode: 0644]
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/e4/tcs/TcsImportWizardE4.java [new file with mode: 0644]

index f46b58063021390237f2da0abd582edf5e933e0e..1570dafb833f92358fd6514c02910ddf8411e3b7 100644 (file)
     <elements xsi:type="commands:Command" xmi:id="_tBCr8KmsEeeTAPHmaMLwQQ" elementId="eu.etaxonomy.taxeditor.store.command.importRisReference" commandName="%wizard.name.24"/>
     <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"/>
   </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="_96ANIKmsEeeTAPHmaMLwQQ" elementId="eu.etaxonomy.taxeditor.io.e4.ris.OpenRisImportWizard" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.io.e4.ris.OpenRisImportWizard" command="_tBCr8KmsEeeTAPHmaMLwQQ"/>
     <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.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.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.tcs.TcsImportWizardE4" command="_OQ9n8KnCEeeTAPHmaMLwQQ"/>
   </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="_0z1o8KmjEeeTAPHmaMLwQQ" elementId="eu.etaxonomy.taxeditor.store.handledmenuitem.importExcelSpecimen" label="%wizard.name.5" command="_2JV9IKnAEeeTAPHmaMLwQQ"/>
       <children xsi:type="menu:HandledMenuItem" xmi:id="_pQNeoKmsEeeTAPHmaMLwQQ" elementId="eu.etaxonomy.taxeditor.store.handledmenuitem.importRisReference" label="%wizard.name.24" command="_tBCr8KmsEeeTAPHmaMLwQQ"/>
       <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>
   </fragments>
 </fragment:ModelFragments>
index e5a66976c635e43bb5ca7d83ffccc7b2ace0211f..2c9479edc8edca9b7a8eb112d35503baaff11ce0 100755 (executable)
             type="java.util.List">
       </commandParameterType>
    </extension>
-   <extension
-         point="org.eclipse.ui.importWizards">
-      <wizard
-            category="eu.etaxonomy.taxeditor.import.category.cdm"
-            class="eu.etaxonomy.taxeditor.io.wizard.TcsImportWizard"
-            id="eu.etaxonomy.taxeditor.io.import.tcs"
-            name="%wizard.name">
-      </wizard>
-   
-   <!--   <wizard
-            category="eu.etaxonomy.taxeditor.import.category.cdm"
-            class="eu.etaxonomy.taxeditor.io.wizard.JaxbImportWizard"
-            id="eu.etaxonomy.taxeditor.io.import.jaxb"
-            name="JAXB">
-      </wizard> -->
-   <!--   <wizard
-            category="eu.etaxonomy.taxeditor.import.category.cdm"
-            class="eu.etaxonomy.taxeditor.io.wizard.BerlinModelImportWizard"
-            id="eu.etaxonomy.taxeditor.io.import.berlinModel"
-            name="%wizard.name.0">
-      </wizard>
-      <wizard
-            category="eu.etaxonomy.taxeditor.import.category.cdm"
-            class="eu.etaxonomy.taxeditor.io.wizard.EndnoteImportWizard"
-            id="eu.etaxonomy.taxeditor.io.import.endnote"
-            name="%wizard.name.1">
-      </wizard>-->
-   </extension>
    <extension
          point="org.eclipse.ui.exportWizards">
       <category
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/e4/tcs/OpenTcsImportWizard.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/e4/tcs/OpenTcsImportWizard.java
new file mode 100644 (file)
index 0000000..fe4b2f6
--- /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.tcs;
+
+import eu.etaxonomy.taxeditor.io.e4.AbstractImportWizardE4;
+import eu.etaxonomy.taxeditor.io.e4.AbstractOpenImportWizard;
+
+/**
+ * @author pplitzner
+ * @since Oct 5, 2017
+ *
+ */
+public class OpenTcsImportWizard extends AbstractOpenImportWizard {
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    protected Class<? extends AbstractImportWizardE4> getImportWizardClass() {
+        return TcsImportWizardE4.class;
+    }
+
+}
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/e4/tcs/TcsImportWizardE4.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/e4/tcs/TcsImportWizardE4.java
new file mode 100644 (file)
index 0000000..32221c8
--- /dev/null
@@ -0,0 +1,79 @@
+/**
+* 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.tcs;
+
+import java.io.File;
+import java.net.URI;
+
+import javax.inject.Inject;
+
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.e4.core.contexts.ContextInjectionFactory;
+import org.eclipse.e4.core.contexts.IEclipseContext;
+import org.eclipse.e4.ui.workbench.modeling.EPartService;
+
+import eu.etaxonomy.cdm.database.DbSchemaValidation;
+import eu.etaxonomy.cdm.io.common.IImportConfigurator.SOURCE_TYPE;
+import eu.etaxonomy.cdm.io.tcsxml.in.TcsXmlImportConfigurator;
+import eu.etaxonomy.taxeditor.io.e4.AbstractImportWizardE4;
+import eu.etaxonomy.taxeditor.io.e4.ImportFromFileDataSourceWizardPageE4;
+import eu.etaxonomy.taxeditor.store.CdmStore;
+
+/**
+ *
+ * @author pplitzner
+ * @since Oct 5, 2017
+ *
+ */
+public class TcsImportWizardE4 extends AbstractImportWizardE4<TcsXmlImportConfigurator> {
+
+
+    private TcsXmlImportConfigurator configurator;
+
+       private ImportFromFileDataSourceWizardPageE4 dataSourcePage;
+
+       @Inject
+       public TcsImportWizardE4(IEclipseContext context, EPartService partService) {
+           super(context, partService);
+       }
+
+       /** {@inheritDoc} */
+       @Override
+       public boolean performFinish() {
+           URI source = dataSourcePage.getUri();
+           configurator.setSource(source);
+           configurator.setDbSchemaValidation(DbSchemaValidation.CREATE);
+
+           Job job = CdmStore.getImportManager().createIOServiceJob(configurator, new File(source), SOURCE_TYPE.URI);
+           CdmStore.getImportManager().run(job);
+
+           return true;
+       }
+
+       /** {@inheritDoc} */
+       @Override
+    public void init() {
+               configurator = CdmStore.getImportManager().TcsConfigurator();
+       }
+
+       /** {@inheritDoc} */
+       @Override
+       public TcsXmlImportConfigurator getConfigurator() {
+               return configurator;
+       }
+
+       /** {@inheritDoc} */
+       @Override
+       public void addPages() {
+               super.addPages();
+               dataSourcePage = ContextInjectionFactory.make(ImportFromFileDataSourceWizardPageE4.class, context);
+               addPage(dataSourcePage);
+       }
+}