endnote and excel import added. fixes #779
authorn.hoffmann <n.hoffmann@localhost>
Wed, 23 Sep 2009 09:16:34 +0000 (09:16 +0000)
committern.hoffmann <n.hoffmann@localhost>
Wed, 23 Sep 2009 09:16:34 +0000 (09:16 +0000)
17 files changed:
.gitattributes
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/AbstractExcelExportWizard.java [new file with mode: 0644]
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/AbstractExcelImportWizard.java [new file with mode: 0644]
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/AbstractExportWizard.java [new file with mode: 0644]
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/AbstractImportWizard.java [new file with mode: 0644]
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/BerlinModelExportWizard.java [new file with mode: 0644]
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/BerlinModelImportWizard.java [new file with mode: 0644]
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/EndnoteImportWizard.java [new file with mode: 0644]
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/ExcelNormalExplicitTaxaImportWizard.java [new file with mode: 0644]
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/ExportToFileDestinationWizardPage.java [new file with mode: 0644]
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/GenericConfiguratorWizardPage.java [new file with mode: 0644]
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/ImportFromFileDataSourceWizardPage.java [new file with mode: 0644]
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/JaxbExportWizard.java [new file with mode: 0644]
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/JaxbImportSourceWizardPage.java [new file with mode: 0644]
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/JaxbImportWizard.java [new file with mode: 0644]
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/TcsExportWizard.java [new file with mode: 0644]
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/TcsImportWizard.java [new file with mode: 0644]

index 8015bf1c8bc23295150b3bea794dfc88ae5e4e91..082637398f2300fa5b36ea954951c1d56ff79c80 100644 (file)
@@ -1072,6 +1072,22 @@ taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/JaxbImportWizard.java -t
 taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/NomenclaturalCodeWizardPage.java -text
 taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/TcsExportWizard.java -text
 taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/TcsImportWizard.java -text
+taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/AbstractExcelExportWizard.java -text
+taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/AbstractExcelImportWizard.java -text
+taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/AbstractExportWizard.java -text
+taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/AbstractImportWizard.java -text
+taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/BerlinModelExportWizard.java -text
+taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/BerlinModelImportWizard.java -text
+taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/EndnoteImportWizard.java -text
+taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/ExcelNormalExplicitTaxaImportWizard.java -text
+taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/ExportToFileDestinationWizardPage.java -text
+taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/GenericConfiguratorWizardPage.java -text
+taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/ImportFromFileDataSourceWizardPage.java -text
+taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/JaxbExportWizard.java -text
+taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/JaxbImportSourceWizardPage.java -text
+taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/JaxbImportWizard.java -text
+taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/TcsExportWizard.java -text
+taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/TcsImportWizard.java -text
 taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/labels/DefaultLabelStrategy.java -text
 taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/labels/ILabelImageStrategy.java -text
 taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/labels/LabelImageProvider.java -text
diff --git a/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/AbstractExcelExportWizard.java b/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/AbstractExcelExportWizard.java
new file mode 100644 (file)
index 0000000..acd0f9b
--- /dev/null
@@ -0,0 +1,44 @@
+// $Id$
+/**
+* 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.wizard;
+
+import org.apache.log4j.Logger;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.IExportWizard;
+import org.eclipse.ui.IWorkbench;
+
+/**
+ * @author n.hoffmann
+ * @created 15.06.2009
+ * @version 1.0
+ */
+public class AbstractExcelExportWizard extends Wizard implements IExportWizard {
+       private static final Logger logger = Logger
+                       .getLogger(AbstractExcelExportWizard.class);
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.wizard.Wizard#performFinish()
+        */
+       @Override
+       public boolean performFinish() {
+               // TODO Auto-generated method stub
+               return false;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
+        */
+       public void init(IWorkbench workbench, IStructuredSelection selection) {
+               // TODO Auto-generated method stub
+
+       }
+}
diff --git a/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/AbstractExcelImportWizard.java b/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/AbstractExcelImportWizard.java
new file mode 100644 (file)
index 0000000..1cc95c6
--- /dev/null
@@ -0,0 +1,44 @@
+// $Id$
+/**
+* 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.wizard;
+
+import org.apache.log4j.Logger;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.IImportWizard;
+import org.eclipse.ui.IWorkbench;
+
+/**
+ * @author n.hoffmann
+ * @created 15.06.2009
+ * @version 1.0
+ */
+public class AbstractExcelImportWizard extends Wizard implements IImportWizard {
+       private static final Logger logger = Logger
+                       .getLogger(AbstractExcelImportWizard.class);
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.wizard.Wizard#performFinish()
+        */
+       @Override
+       public boolean performFinish() {
+               // TODO Auto-generated method stub
+               return false;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
+        */
+       public void init(IWorkbench workbench, IStructuredSelection selection) {
+               // TODO Auto-generated method stub
+
+       }
+}
diff --git a/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/AbstractExportWizard.java b/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/AbstractExportWizard.java
new file mode 100644 (file)
index 0000000..cd7e567
--- /dev/null
@@ -0,0 +1,67 @@
+// $Id$
+/**
+* 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.wizard;
+
+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.wizard.Wizard;
+import org.eclipse.ui.IExportWizard;
+
+import eu.etaxonomy.cdm.io.common.CdmDefaultExport;
+import eu.etaxonomy.cdm.io.common.IExportConfigurator;
+import eu.etaxonomy.cdm.io.common.IIoConfigurator;
+
+/**
+ * @author n.hoffmann
+ * @created 24.06.2009
+ * @version 1.0
+ */
+public abstract class AbstractExportWizard<CONFIG extends IIoConfigurator> extends Wizard implements IExportWizard{
+       private static final Logger logger = Logger
+                       .getLogger(AbstractExportWizard.class);
+       
+       protected final String CONFIGURATION_PAGE = "CONFIGURATION_PAGE"; 
+       
+       private GenericConfiguratorWizardPage pageConfiguration;
+       
+       private CdmDefaultExport export;
+       
+       public boolean doExport(final IExportConfigurator configurator){
+               export = new CdmDefaultExport();
+               
+               Job exportJob = new Job("Export"){
+                       @Override
+                       protected IStatus run(IProgressMonitor monitor) {
+                               return export.invoke(configurator) ? Status.OK_STATUS : Status.CANCEL_STATUS;
+                       }
+               };              
+               
+               exportJob.schedule();
+               
+               return true;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.wizard.Wizard#addPages()
+        */
+       @Override
+       public void addPages() {
+               super.addPages();
+               
+               pageConfiguration = GenericConfiguratorWizardPage.Export(CONFIGURATION_PAGE, getConfigurator());
+               this.addPage(pageConfiguration);
+       }
+       
+       public abstract CONFIG getConfigurator();
+}
diff --git a/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/AbstractImportWizard.java b/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/AbstractImportWizard.java
new file mode 100644 (file)
index 0000000..8a4b67b
--- /dev/null
@@ -0,0 +1,176 @@
+// $Id$
+/**
+* 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.wizard;
+
+import org.apache.log4j.Logger;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.IImportWizard;
+
+import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
+import eu.etaxonomy.cdm.io.common.CdmDefaultImport;
+import eu.etaxonomy.cdm.io.common.IImportConfigurator;
+import eu.etaxonomy.cdm.io.common.IIoConfigurator;
+import eu.etaxonomy.taxeditor.datasource.wizard.NomenclaturalCodeWizardPage;
+import eu.etaxonomy.taxeditor.store.StoreUtil;
+
+/**
+ * @author n.hoffmann
+ * @created 24.06.2009
+ * @version 1.0
+ */
+public abstract class AbstractImportWizard<CONFIG extends IIoConfigurator> extends Wizard implements IImportWizard {
+       private static final Logger logger = Logger
+                       .getLogger(AbstractImportWizard.class);
+       
+       protected final String CONFIGURATION_PAGE = "CONFIGURATION_PAGE"; 
+       
+       private GenericConfiguratorWizardPage pageConfiguration;
+       private NomenclaturalCodeWizardPage pageNomenclaturalCode;
+       
+       private CdmDefaultImport<IImportConfigurator> importer;
+       
+       /**
+        * Performs an import into a new database. The application context has to be changed
+        * @param configurator
+        * @return
+        */
+       public boolean doImportExternal(IImportConfigurator configurator){
+               
+               
+//             try {
+//                     ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
+//                     ILaunchConfigurationType type = manager.getLaunchConfigurationType(ID_JAVA_APPLICATION);
+//                     ILaunchConfiguration[] configurations = manager.getLaunchConfigurations(type);
+//                     
+//                     // delete possible prior launch configurations
+//                     for (ILaunchConfiguration configuration : configurations) {
+//                             if (configuration.getName().equals("NewInstance")) {
+//                                     configuration.delete();
+//                                     break;
+//                             }
+//                     }
+//                     
+//                     ILaunchConfigurationWorkingCopy workingCopy = type.newInstance(null, "NewInstance");
+//                     
+//                     workingCopy.setAttribute(ATTR_MAIN_TYPE_NAME, "eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin");
+//                     
+//             
+//                     workingCopy.setAttribute(ATTR_VM_INSTALL_NAME, JavaRuntime.getDefaultVMInstall().getName());
+//                     workingCopy.setAttribute(ATTR_VM_INSTALL_TYPE, JavaRuntime.getDefaultVMInstall().getVMInstallType().getId());                   
+//                     
+//                     
+//                     workingCopy.launch(ILaunchManager.RUN_MODE, null);
+                       
+                       
+//                   IVMInstall vm = JavaRuntime.getDefaultVMInstall();//VMInstall(proj);
+//                   if (vm == null) vm = JavaRuntime.getDefaultVMInstall();
+//                   IVMRunner vmr = vm.getVMRunner(ILaunchManager.RUN_MODE);
+//                   String[] cp = JavaRuntime.computeDefaultRuntimeClassPath(proj);
+//                   VMRunnerConfiguration config = new VMRunnerConfiguration(main, cp);
+//                   ILaunch launch = new Launch(null, 
+//                      ILaunchManager.RUN_MODE, null);
+//                   vmr.run(config, launch, null);
+                     
+//                     IVMInstallType[] types = JavaRuntime.getVMInstallTypes();
+//                     
+//                     IVMInstall install = null;
+//                     for(IVMInstallType type : types){
+//                             install = type.createVMInstall(type.getId());
+//                             break;
+//                     }
+//                     
+//                     
+//                     IPath path = JavaRuntime.newJREContainerPath(install);
+//                     String jrePath = path.toPortableString();
+
+                       
+//                     
+//                        ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
+//                        ILaunchConfigurationType type = manager.getLaunchConfigurationType(ID_JAVA_APPLICATION);
+//                        ILaunchConfigurationWorkingCopy wc = type.newInstance(null, "NewInstance");
+//                        wc.setAttribute(ATTR_JRE_CONTAINER_PATH, jrePath);
+//                        wc.setAttribute(ATTR_MAIN_TYPE_NAME, "eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin");
+//                        ILaunchConfiguration config = wc.doSave();   
+//                        config.launch(ILaunchManager.RUN_MODE, null);
+//
+//                     
+//                        Process p = Runtime.getRuntime().exec(cmdarray);
+//                        
+//                     
+//             } catch (CoreException e) {
+//                     logger.error("Error launching import", e);
+//             }
+               
+               StoreUtil.notImplementedMessage();
+               
+               return true;
+       }
+       
+       /**
+        * Use when importing data into the current application context
+        * 
+        * @param configurator
+        * @return
+        */
+       public boolean doImportInternal(final IImportConfigurator configurator){
+               
+               if(configurator == null){
+                       throw new IllegalArgumentException("Configuration may not be null");
+               }
+               
+               // terminate any open transactions
+               IConversationEnabled activePart = (IConversationEnabled) StoreUtil.getActivePage().getActivePart();
+               activePart.getConversationHolder().commit(false);
+               
+               
+               
+//             ConversationHolder conversation = CdmStore.NewTransactionalConversation();
+               
+               importer = new CdmDefaultImport();
+//             
+//             Job importJob = new Job("Import"){
+//                     @Override
+//                     protected IStatus run(IProgressMonitor monitor) {
+//                             return importer.invoke(configurator) ? Status.OK_STATUS : Status.CANCEL_STATUS;
+//                     }
+//             };              
+//             
+//             importJob.schedule();
+               
+               importer.setCdmAppController(configurator.getCdmAppController());
+               
+               boolean result = importer.invoke(configurator);
+
+               // restarting transaction and committing it to trigger change listener
+               // TODO verify correct behaviour
+               activePart.getConversationHolder().startTransaction();
+               activePart.getConversationHolder().commit();
+
+               
+               return result; 
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.wizard.Wizard#addPages()
+        */
+       @Override
+       public void addPages() {
+               super.addPages();
+               
+               pageConfiguration = GenericConfiguratorWizardPage.Import(CONFIGURATION_PAGE, getConfigurator());
+               this.addPage(pageConfiguration);
+               
+               pageNomenclaturalCode = new NomenclaturalCodeWizardPage((IImportConfigurator)getConfigurator());
+               this.addPage(pageNomenclaturalCode);
+       }
+       
+       public abstract CONFIG getConfigurator();
+}
diff --git a/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/BerlinModelExportWizard.java b/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/BerlinModelExportWizard.java
new file mode 100644 (file)
index 0000000..0a2faa9
--- /dev/null
@@ -0,0 +1,89 @@
+// $Id$
+/**
+* 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.wizard;
+
+import org.apache.log4j.Logger;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IWorkbench;
+
+import eu.etaxonomy.cdm.database.ICdmDataSource;
+import eu.etaxonomy.cdm.io.berlinModel.out.BerlinModelExportConfigurator;
+import eu.etaxonomy.cdm.io.common.Source;
+import eu.etaxonomy.taxeditor.datasource.wizard.CdmDataSourceSQLServerWizardPage;
+import eu.etaxonomy.taxeditor.store.CdmStore;
+
+/**
+ * @author n.hoffmann
+ * @created 23.06.2009
+ * @version 1.0
+ */
+public class BerlinModelExportWizard extends AbstractExportWizard<BerlinModelExportConfigurator> {
+       private static final Logger logger = Logger
+                       .getLogger(BerlinModelExportWizard.class);
+       
+       private CdmDataSourceSQLServerWizardPage pageDataSource;
+
+
+       private BerlinModelExportConfigurator configurator;
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
+        */
+       public void init(IWorkbench workbench, IStructuredSelection selection) {
+               this.setWindowTitle("Berlin Model Export");
+               configurator = BerlinModelExportConfigurator.NewInstance(null, null);
+       }
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.wizard.Wizard#addPages()
+        */
+       @Override
+       public void addPages() {
+               super.addPages();
+               
+               pageDataSource = new CdmDataSourceSQLServerWizardPage(null);
+               this.addPage(pageDataSource);
+               
+
+               
+       }
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.wizard.Wizard#performFinish()
+        */
+       @Override
+       public boolean performFinish() {
+               
+               ICdmDataSource dataSource = pageDataSource.getDataSource();
+               
+               // FIXME use new constructor Source(ICdmDataSource)
+               Source destination = new Source(Source.SQL_SERVER_2005, 
+                                                               dataSource.getServer(),
+                                                               dataSource.getDatabase(),
+                                                               dataSource.getPort());
+               destination.setUserAndPwd(dataSource.getUsername(), dataSource.getPassword());
+               
+               configurator.setDestination(destination);               
+               configurator.setCdmAppController(CdmStore.getApplicationControllerWillBeObsolete());
+               
+               
+               return doExport(configurator);
+       }
+
+       /* (non-Javadoc)
+        * @see eu.etaxonomy.taxeditor.io.AbstractExportWizard#getConfigurator()
+        */
+       @Override
+       public BerlinModelExportConfigurator getConfigurator() {
+               return configurator;
+       }
+
+}
diff --git a/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/BerlinModelImportWizard.java b/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/BerlinModelImportWizard.java
new file mode 100644 (file)
index 0000000..866c58a
--- /dev/null
@@ -0,0 +1,91 @@
+// $Id$
+/**
+* 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.wizard;
+
+import org.apache.log4j.Logger;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IWorkbench;
+
+import eu.etaxonomy.cdm.database.ICdmDataSource;
+import eu.etaxonomy.cdm.io.berlinModel.in.BerlinModelImportConfigurator;
+import eu.etaxonomy.cdm.io.common.Source;
+import eu.etaxonomy.taxeditor.datasource.CdmDataSourceRepository;
+import eu.etaxonomy.taxeditor.datasource.wizard.CdmDataSourceSQLServerWizardPage;
+import eu.etaxonomy.taxeditor.store.CdmStore;
+
+/**
+ * @author n.hoffmann
+ * @created 24.06.2009
+ * @version 1.0
+ */
+public class BerlinModelImportWizard extends AbstractImportWizard<BerlinModelImportConfigurator> {
+       private static final Logger logger = Logger
+                       .getLogger(BerlinModelImportWizard.class);
+
+       CdmDataSourceSQLServerWizardPage dataSourcePage;
+       
+       BerlinModelImportConfigurator configurator;
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
+        */
+       public void init(IWorkbench workbench, IStructuredSelection selection) {
+               configurator =  CdmStore.getImportHandler().BerlinModelConfigurator();
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.wizard.Wizard#performFinish()
+        */
+       @Override
+       public boolean performFinish() {
+
+               ICdmDataSource dataSource =null;
+               if(dataSourcePage != null){
+                       dataSource = dataSourcePage.getDataSource();
+               }else{
+                       throw new IllegalStateException("Expected a datasource credentials page to exist");
+               }
+               
+               Source source = new Source(Source.SQL_SERVER_2005, 
+                               dataSource.getServer(),
+                               dataSource.getDatabase(),
+                               dataSource.getPort());
+               source.setUserAndPwd(dataSource.getUsername(), dataSource.getPassword());
+               
+               configurator.setSource(source);
+               // TODO should be obsolete because we want to pass application context but is not at the moment (throws NPE when not given)
+//             configurator.setDestination(CdmDataSourceRepository.getDefault().getCurrentDataSource());
+               
+               CdmStore.getImportHandler().doImport(configurator);
+               
+               return true;
+       }
+
+
+       /* (non-Javadoc)
+        * @see eu.etaxonomy.taxeditor.io.AbstractImportWizard#addPages()
+        */
+       @Override
+       public void addPages() {
+               super.addPages();
+               
+               dataSourcePage = new CdmDataSourceSQLServerWizardPage(null);
+               addPage(dataSourcePage);
+       }
+
+       /* (non-Javadoc)
+        * @see eu.etaxonomy.taxeditor.io.AbstractImportWizard#getConfigurator()
+        */
+       @Override
+       public BerlinModelImportConfigurator getConfigurator() {
+               return configurator;
+       }
+}
diff --git a/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/EndnoteImportWizard.java b/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/EndnoteImportWizard.java
new file mode 100644 (file)
index 0000000..7bc33c8
--- /dev/null
@@ -0,0 +1,80 @@
+// $Id$
+/**
+* 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.wizard;
+
+import org.apache.log4j.Logger;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IImportWizard;
+import org.eclipse.ui.IWorkbench;
+
+import eu.etaxonomy.cdm.io.reference.endnote.in.EndnoteImportConfigurator;
+import eu.etaxonomy.taxeditor.store.CdmStore;
+
+/**
+ * @author n.hoffmann
+ * @created Sep 18, 2009
+ * @version 1.0
+ */
+public class EndnoteImportWizard extends AbstractImportWizard<EndnoteImportConfigurator> implements IImportWizard {
+       private static final Logger logger = Logger
+                       .getLogger(EndnoteImportWizard.class);
+
+       private EndnoteImportConfigurator configurator;
+
+       private ImportFromFileDataSourceWizardPage dataSourcePage;
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.wizard.Wizard#performFinish()
+        */
+       @Override
+       public boolean performFinish() {
+               
+               String file = dataSourcePage.getFile();
+               
+               // TcsXmlImport expects a string that can be used to instantiate a URL instance
+               // TODO consolidate import and exports regarding what may be passed in as source
+               // will construct a url string for now
+               
+               file = "file://" + file;
+               
+               configurator.setSource(file);
+               
+               CdmStore.getImportHandler().doImport(configurator);
+               
+               return false;
+       }
+       
+       /* (non-Javadoc)
+        * @see eu.etaxonomy.taxeditor.io.AbstractImportWizard#addPages()
+        */
+       @Override
+       public void addPages() {
+               super.addPages();
+               
+               dataSourcePage = ImportFromFileDataSourceWizardPage.XML();
+               addPage(dataSourcePage);
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
+        */
+       public void init(IWorkbench workbench, IStructuredSelection selection) {
+               configurator =  CdmStore.getImportHandler().EndnoteImportConfigurator();
+       }
+
+       /* (non-Javadoc)
+        * @see eu.etaxonomy.taxeditor.io.AbstractImportWizard#getConfigurator()
+        */
+       @Override
+       public EndnoteImportConfigurator getConfigurator() {
+               return configurator;
+       }
+}
diff --git a/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/ExcelNormalExplicitTaxaImportWizard.java b/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/ExcelNormalExplicitTaxaImportWizard.java
new file mode 100644 (file)
index 0000000..feac06c
--- /dev/null
@@ -0,0 +1,82 @@
+// $Id$
+/**
+* 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.wizard;
+
+import org.apache.log4j.Logger;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IWorkbench;
+
+import eu.etaxonomy.cdm.database.DbSchemaValidation;
+import eu.etaxonomy.cdm.io.excel.taxa.NormalExplicitImportConfigurator;
+import eu.etaxonomy.taxeditor.store.CdmStore;
+
+
+/**
+ * @author n.hoffmann
+ * @created Sep 22, 2009
+ * @version 1.0
+ */
+public class ExcelNormalExplicitTaxaImportWizard extends AbstractImportWizard<NormalExplicitImportConfigurator>{
+       private static final Logger logger = Logger
+                       .getLogger(ExcelNormalExplicitTaxaImportWizard.class);
+
+       private NormalExplicitImportConfigurator configurator;
+
+       private ImportFromFileDataSourceWizardPage dataSourcePage;
+       
+       /* (non-Javadoc)
+        * @see eu.etaxonomy.taxeditor.io.wizard.AbstractImportWizard#getConfigurator()
+        */
+       @Override
+       public NormalExplicitImportConfigurator getConfigurator() {
+               return configurator;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.wizard.Wizard#performFinish()
+        */
+       @Override
+       public boolean performFinish() {
+               String file = dataSourcePage.getFile();
+               
+               // Imports are expecting a string that can be used to instantiate a URL instance
+               // TODO consolidate import and exports regarding what may be passed in as source
+               // will construct a url string for now
+               
+               file = "file://" + file;
+               
+               configurator.setSource(file);
+               configurator.setDbSchemaValidation(DbSchemaValidation.CREATE);
+               
+               CdmStore.getImportHandler().doImport(configurator);
+               
+               return true;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
+        */
+       public void init(IWorkbench workbench, IStructuredSelection selection) {
+               configurator =  CdmStore.getImportHandler().NormalExplicitImportConfigurator();
+       }
+
+       /* (non-Javadoc)
+        * @see eu.etaxonomy.taxeditor.io.wizard.AbstractImportWizard#addPages()
+        */
+       @Override
+       public void addPages() {
+               super.addPages();
+               
+               dataSourcePage = new ImportFromFileDataSourceWizardPage("Choose NormalExplicit", 
+                               "Please choose an xls file in the NormalExplicit format.", new String[]{"*.xls"});
+               addPage(dataSourcePage);
+       }
+}
diff --git a/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/ExportToFileDestinationWizardPage.java b/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/ExportToFileDestinationWizardPage.java
new file mode 100644 (file)
index 0000000..fc74015
--- /dev/null
@@ -0,0 +1,159 @@
+// $Id$
+/**
+* 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.wizard;
+
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+
+import org.apache.log4j.Logger;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.MouseAdapter;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.DirectoryDialog;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+import eu.etaxonomy.taxeditor.datasource.CdmDataSourceRepository;
+
+/**
+ * @author n.hoffmann
+ * @created 15.06.2009
+ * @version 1.0
+ */
+public class ExportToFileDestinationWizardPage extends WizardPage{
+
+       public static final String DATE_FORMAT_NOW = "yyyyMMddHHmm";
+       
+       public static final String JAXB_EXPORT = "JAXB_EXPORT";
+       
+       public static final String TCS_EXPORT = "TCS_EXPORT";
+       
+       private static final Logger logger = Logger
+                       .getLogger(ExportToFileDestinationWizardPage.class);
+       private DirectoryDialog folderDialog;
+       private Text text_exportFileName;
+
+       private Text text_folder;
+
+       private String type;
+       
+       
+       /**
+        * @param pageName
+        * @param selection
+        */
+       private ExportToFileDestinationWizardPage(String pageName, String type, String title, String description) {
+               super(pageName);
+               
+               this.type = type;
+               
+               this.setTitle(title);
+               this.setDescription("Exports the contents of the currently selected database into the cdm jaxb format.");
+       }
+       
+       public static ExportToFileDestinationWizardPage Jaxb(){
+               return new ExportToFileDestinationWizardPage(JAXB_EXPORT, "jaxb",  "JAXB Export", "Exports the contents of the currently selected database into the cdm jaxb format.");
+       }
+       
+       public static ExportToFileDestinationWizardPage Tcs(){
+               return new ExportToFileDestinationWizardPage(TCS_EXPORT, "tcs", "Tcs Export", "Export the contents of the currently selected database into TCS format.");
+       }
+
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+        */
+       public void createControl(Composite parent) {
+               
+               setPageComplete(false);
+               
+               Composite composite = new Composite(parent, SWT.NONE);
+               GridLayout gridLayout = new GridLayout();
+               gridLayout.numColumns = 3;
+               composite.setLayout(gridLayout);
+               
+               Label fileLabel = new Label(composite, SWT.NONE);
+               fileLabel.setText("File");
+               
+               text_exportFileName = new Text(composite, SWT.BORDER);
+               text_exportFileName.setText(generateFilename());
+               text_exportFileName.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1));
+               
+               
+               Label folderLabel = new Label(composite, SWT.NONE);
+               folderLabel.setText("Folder");
+               
+               folderDialog = new DirectoryDialog(parent.getShell());
+               
+               text_folder = new Text(composite, SWT.BORDER);
+               text_folder.setEditable(false);
+               text_folder.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+
+               
+               Button button = new Button(composite, SWT.PUSH);
+               button.setText("Browse...");
+               
+               button.addMouseListener(new MouseAdapter(){
+
+                       /* (non-Javadoc)
+                        * @see org.eclipse.swt.events.MouseAdapter#mouseUp(org.eclipse.swt.events.MouseEvent)
+                        */
+                       @Override
+                       public void mouseUp(MouseEvent e) {
+                               String path = folderDialog.open();
+                               text_folder.setText(path);
+                               setPageComplete(true);
+                       }
+                       
+               });
+               
+               // make the composite the wizard pages control
+               setControl(composite);
+       }
+       
+       private String generateFilename(){
+               StringBuffer buffer = new StringBuffer();
+               
+               Calendar cal = Calendar.getInstance();
+           SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_NOW);
+               buffer.append(sdf.format(cal.getTime()));
+               
+               buffer.append("-");
+               
+               buffer.append(type + "_export-");
+               buffer.append(CdmDataSourceRepository.getDefault().getCurrentDataSource());
+                               
+               buffer.append(".xml");
+               
+               return buffer.toString();
+       }
+
+
+       /**
+        * @return the exportFileName
+        */
+       public String getExportFileName() {
+               return text_exportFileName.getText();
+       }
+
+
+       /**
+        * @return the folderText
+        */
+       public String getFolderText() {
+               return text_folder.getText();
+       }
+}
diff --git a/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/GenericConfiguratorWizardPage.java b/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/GenericConfiguratorWizardPage.java
new file mode 100644 (file)
index 0000000..f749c4d
--- /dev/null
@@ -0,0 +1,184 @@
+// $Id$
+/**
+* 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.wizard;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CLabel;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+
+import eu.etaxonomy.cdm.io.common.IIoConfigurator;
+
+/**
+ * @author n.hoffmann
+ * @created 23.06.2009
+ * @version 1.0
+ */
+public class GenericConfiguratorWizardPage extends WizardPage {
+
+
+       private static final Logger logger = Logger
+                       .getLogger(GenericConfiguratorWizardPage.class);
+       
+       private IIoConfigurator configurator;
+
+       /**
+        * @param pageName
+        * @param configurator 
+        */
+       private GenericConfiguratorWizardPage(String pageName, IIoConfigurator configurator, String title, String description) {
+               super(pageName);
+               this.setTitle(title);
+               
+               this.setDescription(description);
+               
+               this.configurator = configurator;
+       }
+       
+       public static GenericConfiguratorWizardPage Import(String pageName, IIoConfigurator configurator){
+               return new GenericConfiguratorWizardPage(pageName, configurator, "Import Configuration", "Configure the import mechanism.");
+       }
+       
+       public static GenericConfiguratorWizardPage Export(String pageName, IIoConfigurator configurator){
+               return new GenericConfiguratorWizardPage(pageName, configurator, "Export Configuration", "Configure the export mechanism.");
+       }
+       
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+        */
+       public void createControl(Composite parent) {
+               
+               Composite composite = new Composite(parent, SWT.NULL);
+               GridLayout gridLayout = new GridLayout();
+               gridLayout.numColumns = 2;
+               composite.setLayout(gridLayout);
+                               
+               List<Method> methods = getConfiguratorsBooleanSetMethods(configurator);
+               
+               for(Method method : methods){
+                       createCheckbox(composite, method, configurator);
+               }
+               
+               setControl(composite);
+       }
+       
+       private void createCheckbox(Composite parent, Method method, final IIoConfigurator configurator){
+       
+               String methodName = method.getName();
+               
+               final String methodNameValue = methodName.substring(3);
+       
+               CLabel label = new CLabel(parent, SWT.NULL);
+               label.setText(methodNameValue);
+               
+               final Button checkBox = new Button(parent, SWT.CHECK);
+               checkBox.setSelection(executeBooleanGetMethod(configurator,"is" + methodNameValue));
+               checkBox.addSelectionListener(new SelectionAdapter(){
+
+                       /* (non-Javadoc)
+                        * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+                        */
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               executeBooleanSetMethod(configurator, "set" + methodNameValue, checkBox.getSelection());
+                       }
+                       
+               });
+               
+       }
+       
+       
+       private boolean executeBooleanGetMethod(IIoConfigurator configurator, String methodName){
+               
+               Class<? extends IIoConfigurator> configuratorClass = configurator.getClass();
+               
+               boolean result = false;
+               
+               Method[] methods = configuratorClass.getMethods();
+               
+               for(Method method : methods){
+                       if(!method.getName().equals(methodName)){
+                               continue;
+                       }
+                       
+                       try {
+                               Object returnType = method.invoke(configurator, null);
+                               if(returnType.getClass().equals(Boolean.class)){
+                                       result = ((Boolean) returnType).booleanValue();
+                               }
+                                       
+                               break;
+                       } catch (Exception e) {
+                               logger.warn("Could not invoke method");
+                       } 
+               }
+               
+               
+               return result;
+       }
+       
+       private void executeBooleanSetMethod(IIoConfigurator configurator, String methodName, boolean selected){
+               
+               Class<? extends IIoConfigurator> configuratorClass = configurator.getClass();
+               
+               
+               Method[] methods = configuratorClass.getMethods();
+               
+               for(Method method : methods){
+                       if(!method.getName().equals(methodName)){
+                               continue;
+                       }
+                       
+                       try {
+                               method.invoke(configurator, selected);
+                                       
+                               break;
+                       } catch (Exception e) {
+                               logger.warn("Could not invoke method");
+                       } 
+               }
+       }
+       
+       private List<Method> getConfiguratorsBooleanSetMethods(IIoConfigurator configurator){
+               List<Method> booleanMethods = new ArrayList<Method>();
+               
+               Class<? extends IIoConfigurator> configuratorClass = configurator.getClass();
+               
+               Method[] allMethods = configuratorClass.getMethods();
+               
+               for(Method method : allMethods){
+                       if(method.getName().startsWith("set")){
+                               
+                               Class<?>[] typeList = method.getParameterTypes();
+                               
+                               if(typeList.length > 1){
+                                       new IllegalStateException("Found a setter with parameter count > 1");
+                               }
+                               
+                               if(typeList[0].getName().equals("boolean")){
+                                       booleanMethods.add(method);
+                               }
+                       }
+               }
+               
+               return booleanMethods;
+       }
+}
diff --git a/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/ImportFromFileDataSourceWizardPage.java b/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/ImportFromFileDataSourceWizardPage.java
new file mode 100644 (file)
index 0000000..b832068
--- /dev/null
@@ -0,0 +1,113 @@
+// $Id$
+/**
+* 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.wizard;
+
+import org.apache.log4j.Logger;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.MouseAdapter;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * @author n.hoffmann
+ * @created 04.08.2009
+ * @version 1.0
+ */
+public class ImportFromFileDataSourceWizardPage extends WizardPage {
+       private static final Logger logger = Logger
+               .getLogger(ImportFromFileDataSourceWizardPage.class);
+       
+       public static final String PAGE_NAME = "CdmXmlDataSourceWizardPage";
+
+       private String[] extensions = {"*.xml"};
+
+       private FileDialog fileDialog;
+
+       private Text text_file;
+       
+       
+       /**
+        * @param pageName
+        */
+       protected ImportFromFileDataSourceWizardPage(String title, String description, String[] extensions) {
+               super(PAGE_NAME);
+               
+               setTitle(title);
+               
+               setDescription(description);
+               
+               this.extensions = extensions;
+       }
+       
+       protected static ImportFromFileDataSourceWizardPage XML(){
+               return new ImportFromFileDataSourceWizardPage("Xml File", "Select XML file.", new String[]{"*.xml"});
+       }
+
+
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+        */
+       public void createControl(Composite parent) {
+               final Composite composite = new Composite(parent, SWT.NULL);
+               
+               setPageComplete(false);
+               
+               GridLayout gridLayout = new GridLayout();
+               gridLayout.numColumns = 3;
+               composite.setLayout(gridLayout);
+               
+               Label folderLabel = new Label(composite, SWT.NONE);
+               folderLabel.setText("File");
+               
+               fileDialog = new FileDialog(parent.getShell());
+               
+               fileDialog.setFilterExtensions(extensions);
+               
+               text_file = new Text(composite, SWT.BORDER);
+               text_file.setEditable(false);
+               text_file.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+
+               
+               Button button = new Button(composite, SWT.PUSH);
+               button.setText("Browse...");
+               
+               button.addMouseListener(new MouseAdapter(){
+
+                       /* (non-Javadoc)
+                        * @see org.eclipse.swt.events.MouseAdapter#mouseUp(org.eclipse.swt.events.MouseEvent)
+                        */
+                       @Override
+                       public void mouseUp(MouseEvent e) {
+                               String path = fileDialog.open();
+                               text_file.setText(path);
+                               setPageComplete(true);
+                       }
+                       
+               });
+               
+               setControl(composite);
+       }
+
+       /**
+        * @return
+        */
+       public String getFile() {
+               return text_file.getText();
+       }
+}
diff --git a/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/JaxbExportWizard.java b/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/JaxbExportWizard.java
new file mode 100644 (file)
index 0000000..2b358bc
--- /dev/null
@@ -0,0 +1,77 @@
+// $Id$
+/**
+* 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.wizard;
+
+import java.io.File;
+
+import org.apache.log4j.Logger;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IWorkbench;
+
+import eu.etaxonomy.cdm.io.jaxb.JaxbExportConfigurator;
+import eu.etaxonomy.taxeditor.store.CdmStore;
+
+/**
+ * @author n.hoffmann
+ * @created 15.06.2009
+ * @version 1.0
+ */
+public class JaxbExportWizard extends AbstractExportWizard<JaxbExportConfigurator> {
+       private static final Logger logger = Logger
+                       .getLogger(JaxbExportWizard.class);
+
+       private ExportToFileDestinationWizardPage page;
+
+       private JaxbExportConfigurator configurator;
+
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
+        */
+       public void init(IWorkbench workbench, IStructuredSelection selection) {
+               this.setWindowTitle("JAXB Export");
+               this.configurator = JaxbExportConfigurator.NewInstance(null, null);
+       }
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.wizard.Wizard#performFinish()
+        */
+       @Override
+       public boolean performFinish() {
+               
+               String urlString = page.getFolderText() + File.pathSeparator + page.getExportFileName();
+               
+               configurator.setDestination(urlString);
+               configurator.setCdmAppController(CdmStore.getApplicationControllerWillBeObsolete());
+               
+               return doExport(configurator);
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.wizard.Wizard#addPages()
+        */
+       @Override
+       public void addPages() {
+               super.addPages();
+                               
+               page = ExportToFileDestinationWizardPage.Jaxb();
+               addPage(page);
+       }
+
+       /* (non-Javadoc)
+        * @see eu.etaxonomy.taxeditor.io.AbstractExportWizard#getConfigurator()
+        */
+       @Override
+       public JaxbExportConfigurator getConfigurator() {
+               return configurator;
+       }
+       
+
+}
diff --git a/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/JaxbImportSourceWizardPage.java b/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/JaxbImportSourceWizardPage.java
new file mode 100644 (file)
index 0000000..fa2d9e6
--- /dev/null
@@ -0,0 +1,41 @@
+// $Id$
+/**
+* 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.wizard;
+
+import org.apache.log4j.Logger;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * @author n.hoffmann
+ * @created 24.06.2009
+ * @version 1.0
+ */
+public class JaxbImportSourceWizardPage extends WizardPage {
+       /**
+        * @param pageName
+        */
+       protected JaxbImportSourceWizardPage(String pageName) {
+               super(pageName);
+               // TODO Auto-generated constructor stub
+       }
+
+       private static final Logger logger = Logger
+                       .getLogger(JaxbImportSourceWizardPage.class);
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+        */
+       public void createControl(Composite parent) {
+               // TODO Auto-generated method stub
+
+       }
+}
diff --git a/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/JaxbImportWizard.java b/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/JaxbImportWizard.java
new file mode 100644 (file)
index 0000000..f4c758c
--- /dev/null
@@ -0,0 +1,44 @@
+// $Id$
+/**
+* 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.wizard;
+
+import org.apache.log4j.Logger;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.IImportWizard;
+import org.eclipse.ui.IWorkbench;
+
+/**
+ * @author n.hoffmann
+ * @created 15.06.2009
+ * @version 1.0
+ */
+public class JaxbImportWizard extends Wizard implements IImportWizard {
+       private static final Logger logger = Logger
+                       .getLogger(JaxbImportWizard.class);
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.wizard.Wizard#performFinish()
+        */
+       @Override
+       public boolean performFinish() {
+               // TODO Auto-generated method stub
+               return false;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
+        */
+       public void init(IWorkbench workbench, IStructuredSelection selection) {
+               // TODO Auto-generated method stub
+
+       }
+}
diff --git a/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/TcsExportWizard.java b/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/TcsExportWizard.java
new file mode 100644 (file)
index 0000000..02127cb
--- /dev/null
@@ -0,0 +1,74 @@
+// $Id$
+/**
+* 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.wizard;
+
+import java.io.File;
+
+import org.apache.log4j.Logger;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IWorkbench;
+
+import eu.etaxonomy.cdm.io.tcsxml.out.TcsXmlExportConfigurator;
+import eu.etaxonomy.taxeditor.store.CdmStore;
+
+/**
+ * @author n.hoffmann
+ * @created 15.06.2009
+ * @version 1.0
+ */
+public class TcsExportWizard extends AbstractExportWizard<TcsXmlExportConfigurator> {
+       private static final Logger logger = Logger
+                       .getLogger(TcsExportWizard.class);
+       private static final String TCS_EXPORT = "TCS_EXPORT";
+       private TcsXmlExportConfigurator configurator;
+       private ExportToFileDestinationWizardPage page;
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.wizard.Wizard#performFinish()
+        */
+       @Override
+       public boolean performFinish() {
+               String urlString = page.getFolderText() + File.separator + page.getExportFileName();
+               
+               configurator.setDestination(new File(urlString));
+               configurator.setCdmAppController(CdmStore.getApplicationControllerWillBeObsolete());
+               
+               return doExport(configurator);
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
+        */
+       public void init(IWorkbench workbench, IStructuredSelection selection) {
+               configurator = TcsXmlExportConfigurator.NewInstance(null, null);
+       }
+
+       /* (non-Javadoc)
+        * @see eu.etaxonomy.taxeditor.io.AbstractExportWizard#getConfigurator()
+        */
+       @Override
+       public TcsXmlExportConfigurator getConfigurator() {
+               return configurator;
+       }
+
+       /* (non-Javadoc)
+        * @see eu.etaxonomy.taxeditor.io.AbstractExportWizard#addPages()
+        */
+       @Override
+       public void addPages() {
+               super.addPages();
+               
+               page = ExportToFileDestinationWizardPage.Tcs();
+               addPage(page);
+       }
+       
+       
+}
diff --git a/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/TcsImportWizard.java b/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/TcsImportWizard.java
new file mode 100644 (file)
index 0000000..66503a0
--- /dev/null
@@ -0,0 +1,80 @@
+// $Id$
+/**
+* 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.wizard;
+
+import org.apache.log4j.Logger;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IWorkbench;
+
+import eu.etaxonomy.cdm.database.DbSchemaValidation;
+import eu.etaxonomy.cdm.io.tcsxml.in.TcsXmlImportConfigurator;
+import eu.etaxonomy.taxeditor.store.CdmStore;
+
+/**
+ * @author n.hoffmann
+ * @created 15.06.2009
+ * @version 1.0
+ */
+public class TcsImportWizard extends AbstractImportWizard<TcsXmlImportConfigurator>{
+       private static final Logger logger = Logger.getLogger(TcsImportWizard.class);
+       
+       private TcsXmlImportConfigurator configurator;
+
+       private ImportFromFileDataSourceWizardPage dataSourcePage;
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.wizard.Wizard#performFinish()
+        */
+       @Override
+       public boolean performFinish() {
+               
+               String file = dataSourcePage.getFile();
+               
+               // TcsXmlImport expects a string that can be used to instantiate a URL instance
+               // TODO consolidate import and exports regarding what may be passed in as source
+               // will construct a url string for now
+               
+               file = "file://" + file;
+               
+               configurator.setSource(file);
+               configurator.setDbSchemaValidation(DbSchemaValidation.CREATE);
+               
+               CdmStore.getImportHandler().doImport(configurator);
+               
+               return true;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
+        */
+       public void init(IWorkbench workbench, IStructuredSelection selection) {
+               configurator = CdmStore.getImportHandler().TcsConfigurator();
+       }
+
+       /* (non-Javadoc)
+        * @see eu.etaxonomy.taxeditor.io.AbstractImportWizard#getConfigurator()
+        */
+       @Override
+       public TcsXmlImportConfigurator getConfigurator() {
+               return configurator;
+       }
+
+       /* (non-Javadoc)
+        * @see eu.etaxonomy.taxeditor.io.AbstractImportWizard#addPages()
+        */
+       @Override
+       public void addPages() {
+               super.addPages();
+               
+               dataSourcePage = ImportFromFileDataSourceWizardPage.XML();
+               addPage(dataSourcePage);
+       }
+}