add abcd import configuration to preferences
authorKatja Luther <k.luther@bgbm.org>
Tue, 2 May 2017 09:08:16 +0000 (11:08 +0200)
committerKatja Luther <k.luther@bgbm.org>
Tue, 2 May 2017 09:15:45 +0000 (11:15 +0200)
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databaseAdmin/wizard/AbstractPreferenceWizard.java [new file with mode: 0755]
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databaseAdmin/wizard/DatabasePreferencesPage.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databaseAdmin/wizard/DatabasePreferencesWizard.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databaseAdmin/wizard/ImportPreferencesWizard.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/ExportManager.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/AbcdImportConfiguratorWizardPage.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/AbcdImportWizard.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/PreferencesUtil.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/store/CdmStore.java

diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databaseAdmin/wizard/AbstractPreferenceWizard.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databaseAdmin/wizard/AbstractPreferenceWizard.java
new file mode 100755 (executable)
index 0000000..ff1efca
--- /dev/null
@@ -0,0 +1,62 @@
+/**
+* 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.databaseAdmin.wizard;
+
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.TabFolder;
+import org.eclipse.swt.widgets.TabItem;
+
+/**
+ * @author k.luther
+ * @date 26.04.2017
+ *
+ */
+public abstract class AbstractPreferenceWizard extends WizardPage {
+    /**
+     * @param pageName
+     */
+    protected AbstractPreferenceWizard(String pageName) {
+        super(pageName);
+
+    }
+    protected TabFolder tabFolder;
+    protected Composite composite;
+    /***
+     * Adds a tab to the page.
+     * @param text the tab label
+     */
+     public Composite addTab(String text)    {
+         if (tabFolder == null){
+             // initialize tab folder
+             if (composite == null) {
+                 composite = new Composite(getShell(), SWT.NONE);
+             }
+             tabFolder = new TabFolder(composite, SWT.NONE);
+             tabFolder.setLayoutData(new GridData(GridData.FILL_BOTH));
+         }
+
+         TabItem item = new TabItem(tabFolder, SWT.NONE);
+         item.setText(text);
+
+         Composite currentTab = new Composite(tabFolder, SWT.NULL);
+         GridLayout layout = new GridLayout();
+         currentTab.setLayout(layout);
+         currentTab.setFont(composite.getFont());
+        // currentTab.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+         item.setControl(currentTab);
+         return currentTab;
+
+     }
+
+}
index 235c7b23ab5dcf620dd6c0ef6462476fc6fba3d2..24dc0d250393fbe53cd48f56fe43a3c287bc9faf 100755 (executable)
@@ -13,18 +13,14 @@ import java.util.List;
 import org.eclipse.jface.preference.IPreferenceStore;
 import org.eclipse.jface.wizard.IWizard;
 import org.eclipse.jface.wizard.IWizardPage;
-import org.eclipse.jface.wizard.WizardPage;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.SelectionAdapter;
 import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Combo;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.TabFolder;
-import org.eclipse.swt.widgets.TabItem;
 
 import eu.etaxonomy.cdm.io.specimen.abcd206.in.Abcd206ImportConfigurator;
 import eu.etaxonomy.cdm.model.metadata.CdmPreference;
@@ -40,7 +36,7 @@ import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
  * @date 01.11.2016
  *
  */
-public class DatabasePreferencesPage extends WizardPage implements IWizardPage{
+public class DatabasePreferencesPage extends AbstractPreferenceWizard implements IWizardPage{
 
     CdmPreference preferedNomenclaturalCode;
     NameDetailsConfigurator config ;
@@ -49,11 +45,6 @@ public class DatabasePreferencesPage extends WizardPage implements IWizardPage{
     CdmPreference showCollectingAreaInGeneralSectionPreference;
     CdmPreference showTaxonAssociationsPreference;
 
-
-    TabFolder tabFolder;
-
-    IPreferenceStore preferenceStore;
-    Composite composite;
     boolean isSimpleDetailsViewActivated;
 
     Composite child ;
@@ -67,10 +58,6 @@ public class DatabasePreferencesPage extends WizardPage implements IWizardPage{
     ListComponent biocaseProviderList;
     Abcd206ImportConfigurator abcdImportConfigurator;
 
-
-//    private UriWithLabelElement nomenclaturalCodeCombo;
-//    private Label nomenclaturalCodeLabel;
-
     String[][] labelAndValues;
 
     /*
@@ -83,48 +70,11 @@ public class DatabasePreferencesPage extends WizardPage implements IWizardPage{
         if (config == null){
             config = new NameDetailsConfigurator(false);
         }
-        setPreferenceStore(PreferencesUtil.getPreferenceStore());
 
-    }
 
-    protected void setPreferenceStore(IPreferenceStore store){
-        this.preferenceStore = store;
     }
 
 
-
-
-    /***
-    * Adds a tab to the page.
-    * @param text the tab label
-    */
-    public Composite addTab(String text)    {
-        if (tabFolder == null){
-            // initialize tab folder
-            if (composite == null) {
-                composite = new Composite(getShell(), SWT.NONE);
-            }
-            tabFolder = new TabFolder(composite, SWT.NONE);
-            tabFolder.setLayoutData(new GridData(GridData.FILL_BOTH));
-        }
-
-        TabItem item = new TabItem(tabFolder, SWT.NONE);
-        item.setText(text);
-
-        Composite currentTab = new Composite(tabFolder, SWT.NULL);
-        GridLayout layout = new GridLayout();
-        currentTab.setLayout(layout);
-        currentTab.setFont(composite.getFont());
-       // currentTab.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
-        item.setControl(currentTab);
-        return currentTab;
-
-    }
-
-
-
-
     protected IPreferenceStore doGetPreferenceStore() {
         return PreferencesUtil.getPreferenceStore();
     }
index 2f062e4d0ae2915e48492b7b682223070f31021c..43b9701c2716c4e4f6f6734b0be1e0592decc7dd 100644 (file)
@@ -13,10 +13,8 @@ import org.eclipse.jface.wizard.Wizard;
 
 import eu.etaxonomy.cdm.api.application.ICdmRepository;
 import eu.etaxonomy.cdm.api.service.IPreferenceService;
-import eu.etaxonomy.cdm.io.specimen.abcd206.in.Abcd206ImportConfigurator;
 import eu.etaxonomy.cdm.model.metadata.CdmPreference;
 import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
-import eu.etaxonomy.taxeditor.io.wizard.AbcdImportConfiguratorWizardPage;
 import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
 import eu.etaxonomy.taxeditor.store.CdmStore;
 
@@ -29,14 +27,14 @@ public class DatabasePreferencesWizard extends Wizard {
 
 
     public DatabasePreferencesPage preferencePage;
-    public AbcdImportConfiguratorWizardPage configAbcdImport;
+
 
 
     public DatabasePreferencesWizard() {
         setWindowTitle("Database Preferences Wizard");
 
         preferencePage = new DatabasePreferencesPage("Database Preferences");
-        configAbcdImport = AbcdImportConfiguratorWizardPage.createPage(Abcd206ImportConfigurator.NewInstance(null, null));
+
 
     }
 
@@ -115,14 +113,12 @@ public class DatabasePreferencesWizard extends Wizard {
     @Override
     public void addPages() {
         addPage(preferencePage);
-        addPage(configAbcdImport);
+
     }
 
     @Override
     public IWizardPage getNextPage(IWizardPage currentPage) {
-       if (currentPage.equals(preferencePage)){
-           return configAbcdImport;
-       }
+
        return null;
     }
 
index 4adb396c221cb1f262a5334cf92347ef5ef22386..8d5c61fb174efbbd2c7fbab48bc11178b835c2ac 100755 (executable)
@@ -10,8 +10,13 @@ package eu.etaxonomy.taxeditor.databaseAdmin.wizard;
 
 import org.eclipse.jface.wizard.Wizard;
 
-import eu.etaxonomy.cdm.io.specimen.abcd206.in.Abcd206ImportConfigurator;
+import eu.etaxonomy.cdm.api.application.ICdmRepository;
+import eu.etaxonomy.cdm.api.service.IPreferenceService;
+import eu.etaxonomy.cdm.model.metadata.CdmPreference;
+import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
 import eu.etaxonomy.taxeditor.io.wizard.AbcdImportConfiguratorWizardPage;
+import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
+import eu.etaxonomy.taxeditor.store.CdmStore;
 
 /**
  * @author k.luther
@@ -24,16 +29,37 @@ public class ImportPreferencesWizard extends Wizard {
 
     public ImportPreferencesWizard() {
         setWindowTitle("Abcd Import Configuration Wizard");
-        configPage = AbcdImportConfiguratorWizardPage.createPreferencePage(Abcd206ImportConfigurator.NewInstance(null, null));
 
-    }
+        configPage = AbcdImportConfiguratorWizardPage.createPreferencePage(PreferencesUtil.getAbcdImportConfigurationPreference(false));
 
+    }
+    @Override
+    public void addPages() {
+        addPage(configPage);
+    }
     /**
      * {@inheritDoc}
      */
     @Override
     public boolean performFinish() {
+        String configString = "";
+        this.configPage.saveConfigToPrefernceStore();
+        configString = this.configPage.createConfigString();
+
+        CdmPreference pref = CdmPreference.NewDatabaseInstance( PreferencePredicate.AbcdImportConfig, configString);
+        pref.setAllowOverride(true);
 
-        return false;
+        ICdmRepository controller = CdmStore.getCurrentApplicationConfiguration();
+        if (controller == null){
+            return false;
+        }
+        IPreferenceService service = controller.getPreferenceService();
+        service.set(pref);
+
+
+       return true;
     }
+
+
+
 }
index bd2144d51f437ef970f657de0e9334ec25efe1d3..485b11c42ce09c00a9b2c0a71240e2eef57e5cf8 100644 (file)
@@ -11,6 +11,7 @@ package eu.etaxonomy.taxeditor.io;
 
 import java.io.File;
 import java.io.FileOutputStream;
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
@@ -22,6 +23,7 @@ import org.eclipse.core.runtime.Status;
 import org.eclipse.core.runtime.jobs.Job;
 import org.eclipse.swt.widgets.Display;
 import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.PlatformUI;
 
 import eu.etaxonomy.cdm.api.application.CdmApplicationState;
 import eu.etaxonomy.cdm.api.application.ICdmRepository;
@@ -38,8 +40,10 @@ import eu.etaxonomy.cdm.io.sdd.out.SDDExportConfigurator;
 import eu.etaxonomy.cdm.io.service.IIOService;
 import eu.etaxonomy.taxeditor.model.CdmProgressMonitorAdapter;
 import eu.etaxonomy.taxeditor.model.MessagingUtils;
+import eu.etaxonomy.taxeditor.store.CdmStore;
 import eu.etaxonomy.taxeditor.store.StoreUtil;
 import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin;
+import eu.etaxonomy.taxeditor.ui.dialog.ReportTextDialog;
 
 /**
  * <p>
@@ -317,8 +321,40 @@ public class ExportManager extends AbstractIOManager<IExportConfigurator> {
                      } catch(Exception e){
                          logger.error(e.getStackTrace());
                      }
+                     final StringBuilder reportText = new StringBuilder();
+                     if(result!=null){
+                         List<byte[]> reports = result.getErrors();
+                         reportText.append("Errors:\\r");
+                         for (byte[] bs : reports) {
+                             reportText.append(new String(bs));
+                         }
+                         List<byte[]> warnings = result.getWarnings();
+                         reportText.append("Warnings:\\r");
+                         for (byte[] bs : warnings) {
+                             reportText.append(new String(bs));
+                         }
+                         List<Exception> exceptions = result.getExceptions();
+                         reportText.append("Exceptions:\\r");
+                         for (Exception ex : exceptions) {
+                             reportText.append(ex.getStackTrace());
+                         }
 
 
+                     }
+                     final Display display = Display.getDefault();
+                     display.asyncExec(new Runnable() {
+
+                         @Override
+                         public void run() {
+                             // display reports with possibility to save
+                             ReportTextDialog dialog = new ReportTextDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
+                             dialog.setTitle(configurator.getClass().getSimpleName()+" Report");
+                             dialog.setReportText(reportText.toString());
+                             dialog.open();
+                             CdmStore.getContextManager().notifyContextRefresh();
+                         }
+                     });
+
 
 
                  } catch (Exception e) {
@@ -329,6 +365,7 @@ public class ExportManager extends AbstractIOManager<IExportConfigurator> {
                              e,
                              true);
                  }
+
                  return Status.OK_STATUS;
              }
          };
index b791d303500aedd2b22016ebfe8f447aa8147b7f..49edb5b70aacf24ef6204af97e9ec55bc4201b5e 100644 (file)
@@ -13,7 +13,7 @@ import java.net.URI;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.jface.preference.IPreferenceStore;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.SelectionAdapter;
 import org.eclipse.swt.events.SelectionEvent;
@@ -22,14 +22,16 @@ import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Composite;
 
 import eu.etaxonomy.cdm.io.specimen.abcd206.in.Abcd206ImportConfigurator;
-import eu.etaxonomy.taxeditor.databaseAdmin.wizard.ListComponent;
+import eu.etaxonomy.taxeditor.databaseAdmin.wizard.AbstractPreferenceWizard;
+import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
+import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
 
 /**
  *
  * @author pplitzner
  *
  */
-public class AbcdImportConfiguratorWizardPage extends WizardPage {
+public class AbcdImportConfiguratorWizardPage extends AbstractPreferenceWizard {
 
        public static final String PAGE_NAME = "AbcdImportConfiguratorWizardPage";
 
@@ -70,12 +72,12 @@ public class AbcdImportConfiguratorWizardPage extends WizardPage {
        @Override
     public void createControl(Composite parent) {
                final Composite composite = new Composite(parent, SWT.NULL);
-
+               //composite = addTab(Messages.DatabasePreferencesPage_Define_Default_NomenclaturalCode);
                GridLayout gridLayout = new GridLayout();
                composite.setLayout(gridLayout);
-        if (isPreferencePage){
-            ListComponent list = new ListComponent(composite, composite.getStyle());
-        }
+//        if (isPreferencePage){
+//            ListComponent list = new ListComponent(composite, composite.getStyle());
+//        }
 
                Button checkBoxMediaSpecimen = new Button(composite, SWT.CHECK);
                checkBoxMediaSpecimen.setSelection(configurator.isAddMediaAsMediaSpecimen());
@@ -126,7 +128,7 @@ public class AbcdImportConfiguratorWizardPage extends WizardPage {
                                configurator.setMapUnitIdToCatalogNumber(!configurator.isMapUnitIdToCatalogNumber());
                        }
                });
-
+//TODO: only one of the mappings can be checked!
                Button checkBoxMapUnitIdToAccessionNumber = new Button(composite, SWT.CHECK);
                checkBoxMapUnitIdToAccessionNumber.setSelection(configurator.isMapUnitIdToAccessionNumber());
                checkBoxMapUnitIdToAccessionNumber.setText("Map UnitID to accession number");
@@ -176,11 +178,104 @@ public class AbcdImportConfiguratorWizardPage extends WizardPage {
                checkBoxMoveToDefaultClassification.addSelectionListener(new SelectionAdapter() {
                        @Override
                        public void widgetSelected(SelectionEvent e) {
-                               configurator.setRemoveCountryFromLocalityText(!configurator.isRemoveCountryFromLocalityText());
+                               configurator.setMoveNewTaxaToDefaultClassification(!configurator.isMoveNewTaxaToDefaultClassification());
                        }
                });
 
+               Button checkBoxImportSiblings = new Button(composite, SWT.CHECK);
+               checkBoxImportSiblings.setSelection(configurator.isGetSiblings());
+               checkBoxImportSiblings.setText("Import all children of cultures or tissue samples");
+               checkBoxImportSiblings
+        .setToolTipText("for a tissue sample or culture all children will be searched and imported");
+               checkBoxImportSiblings.addSelectionListener(new SelectionAdapter() {
+            @Override
+            public void widgetSelected(SelectionEvent e) {
+                configurator.setGetSiblings(!configurator.isGetSiblings());
+            }
+        });
+
+        Button checkBoxAddIndividualsAssociations = new Button(composite, SWT.CHECK);
+        checkBoxAddIndividualsAssociations.setSelection(configurator.isAddIndividualsAssociationsSuchAsSpecimenAndObservations());
+        checkBoxAddIndividualsAssociations.setText("Create an Individual Association for each Specimen");
+        checkBoxAddIndividualsAssociations
+        .setToolTipText("for each specimen associated to a taxon an indiviadual association to this taxon is created");
+        checkBoxAddIndividualsAssociations.addSelectionListener(new SelectionAdapter() {
+            @Override
+            public void widgetSelected(SelectionEvent e) {
+                configurator.setAddIndividualsAssociationsSuchAsSpecimenAndObservations(!configurator.isAddIndividualsAssociationsSuchAsSpecimenAndObservations());
+            }
+        });
+
+        Button checkBoxReuseDescriptiveGroups = new Button(composite, SWT.CHECK);
+        checkBoxReuseDescriptiveGroups.setSelection(configurator.isReuseExistingDescriptiveGroups());
+        checkBoxReuseDescriptiveGroups.setText("Reuse existing descriptive group");
+        checkBoxReuseDescriptiveGroups
+        .setToolTipText("reuse one of the existing descriptive groups or create a new one for every import");
+        checkBoxReuseDescriptiveGroups.addSelectionListener(new SelectionAdapter() {
+            @Override
+            public void widgetSelected(SelectionEvent e) {
+                configurator.setReuseExistingDescriptiveGroups(!configurator.isReuseExistingDescriptiveGroups());
+            }
+        });
+
+        Button checkBoxReuseExistingTaxa = new Button(composite, SWT.CHECK);
+        checkBoxReuseExistingTaxa.setSelection(configurator.isReuseExistingTaxaWhenPossible());
+        checkBoxReuseExistingTaxa.setText("Reuse existing taxa when possible");
+        checkBoxReuseExistingTaxa
+        .setToolTipText("reuse existing taxa when the name matches the identified name of the specimen");
+        checkBoxReuseExistingTaxa.addSelectionListener(new SelectionAdapter() {
+            @Override
+            public void widgetSelected(SelectionEvent e) {
+                configurator.setReuseExistingDescriptiveGroups(!configurator.isReuseExistingDescriptiveGroups());
+            }
+        });
+
+
                setControl(composite);
        }
 
+        public void saveConfigToPrefernceStore() {
+               PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_ADD_INDIVIDUALS_ASSOCIATIONS_SUCH_AS_SPECIMEN_AND_OBSERVATIONS,
+                       configurator.isAddIndividualsAssociationsSuchAsSpecimenAndObservations());
+               PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_ADD_MEDIA_AS_MEDIASPECIMEN,
+                    configurator.isAddMediaAsMediaSpecimen());
+               PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_ALLOW_REUSE_OTHER_CLASSIFICATIONS,
+                    configurator.isAllowReuseOtherClassifications());
+               PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_DEDUPLICATE_CLASSIFICATIONS,
+                    configurator.isDeduplicateClassifications());
+               PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_DEDUPLICATE_REFERENCES,
+                    configurator.isDeduplicateReferences());
+               PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_DO_SIBLINGS,
+                    configurator.isGetSiblings());
+               PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_IGNORE_AUTHORSHIP,
+                    configurator.isIgnoreAuthorship());
+               PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_IGNORE_IMPORT_OF_EXISTING_SPECIMEN,
+                    configurator.isIgnoreImportOfExistingSpecimen());
+               PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TO_ACCESSION_NUMBER,
+                    configurator.isMapUnitIdToAccessionNumber());
+               PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TO_BARCODE,
+                    configurator.isMapUnitIdToBarcode());
+               PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TOCATALOG_NUMBER,
+                    configurator.isMapUnitIdToCatalogNumber());
+               PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_MOVE_NEW_TAXA_TO_DEFAULT_CLASSIFICATION,
+                    configurator.isMoveNewTaxaToDefaultClassification());
+               PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_OVERWRITE_EXISTING_SPECIMEN,
+                    configurator.isOverwriteExistingSpecimens());
+               PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_DESCRIPTIVE_GROUPS,
+                    configurator.isReuseExistingDescriptiveGroups());
+               PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_META_DATA,
+                    configurator.isReuseExistingMetaData());
+               PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_TAXA_WHEN_POSSIBLE,
+                    configurator.isReuseExistingTaxaWhenPossible());
+
+           }
+
+        public String createConfigString(){
+           return configurator.toString();
+
+        }
+
+        protected IPreferenceStore doGetPreferenceStore() {
+               return PreferencesUtil.getPreferenceStore();
+           }
 }
index 5acde9322d3d3638f5cfa2d17b89f97205aea5e1..d1a488cad49c829bdbb0d9d54f68275f62f53240 100644 (file)
@@ -19,6 +19,7 @@ import org.eclipse.ui.IWorkbench;
 import eu.etaxonomy.cdm.database.DbSchemaValidation;
 import eu.etaxonomy.cdm.io.common.IImportConfigurator.SOURCE_TYPE;
 import eu.etaxonomy.cdm.io.specimen.abcd206.in.Abcd206ImportConfigurator;
+import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
 import eu.etaxonomy.taxeditor.store.CdmStore;
 
 /**
@@ -52,7 +53,7 @@ public class AbcdImportWizard extends AbstractImportWizard<Abcd206ImportConfigur
            }
 
            CdmStore.getImportManager().runMoniteredOperation(configurator, new File(source), SOURCE_TYPE.INPUTSTREAM);
-           
+
            return true;
 
        }
@@ -61,9 +62,9 @@ public class AbcdImportWizard extends AbstractImportWizard<Abcd206ImportConfigur
        @Override
     public void init(IWorkbench workbench, IStructuredSelection selection) {
                super.init(workbench, selection);
-               configurator =  CdmStore.getImportManager().AbcdConfigurator();
+               configurator =  PreferencesUtil.getAbcdImportConfigurationPreference(true);
        }
-       
+
        @Override
        protected void addConfiguratorPage() {
                AbcdImportConfiguratorWizardPage configuratorWizardPage = AbcdImportConfiguratorWizardPage.createPage(configurator);
index 6a445da2a234765b6757dde702ea1552ac7372dd..24beb44d4c279bbd46ea3a8b902ec645dc57bd6f 100644 (file)
@@ -26,6 +26,7 @@ import java.util.StringTokenizer;
 import java.util.UUID;
 
 import org.apache.commons.lang.StringUtils;
+import org.apache.log4j.Logger;
 import org.eclipse.equinox.internal.p2.ui.model.MetadataRepositoryElement;
 import org.eclipse.jface.preference.IPreferenceStore;
 import org.eclipse.jface.window.Window;
@@ -42,6 +43,7 @@ import eu.etaxonomy.cdm.api.service.config.FindTaxaAndNamesConfiguratorImpl;
 import eu.etaxonomy.cdm.api.service.config.IFindTaxaAndNamesConfigurator;
 import eu.etaxonomy.cdm.common.CdmUtils;
 import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
+import eu.etaxonomy.cdm.io.specimen.abcd206.in.Abcd206ImportConfigurator;
 import eu.etaxonomy.cdm.model.common.ICdmBase;
 import eu.etaxonomy.cdm.model.common.IDefinedTerm;
 import eu.etaxonomy.cdm.model.common.ISimpleTerm;
@@ -85,7 +87,7 @@ public class PreferencesUtil implements IPreferenceKeys {
        public static final String P2_REPOSITORIES_DELIM = ",";
        public static final String P2_REPOSITORY_FIELDS_DELIM = ";";
 
-
+       private final static Logger logger = Logger.getLogger(PreferencesUtil.class);
 
        /**
         * <p>
@@ -1104,67 +1106,92 @@ public class PreferencesUtil implements IPreferenceKeys {
      *            a {@link eu.etaxonomy.cdm.io.specimen.abcd206.in.Abcd206ImportConfigurator}
      *            object.
      */
-//    public static CdmPreference setAbcdImportConfigurationPreference(
-//            Abcd206ImportConfigurator preferredConfiguration, boolean local) {
-//        if (local){
-//            /*
-//             *
-//    public static final String ABCD_IMPORT_CONFIGURATOR_DO_SIBLINGS = "eu.etaxonomy.taxeditor.abcd_import_configurator.doSiblings";
-//    public static final String ABCD_IMPORT_CONFIGURATOR_IGNORE_IMPORT_OF_EXISTING_SPECIMEN= "eu.etaxonomy.taxeditor.abcd_import_configurator.ignoreImportOfExistingSpecimen";
-//    public static final String ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_TAXA_WHEN_POSSIBLE= "eu.etaxonomy.taxeditor.abcd_import_configurator.reuseExistingTaxaWhenPossible";
-//    public static final String ABCD_IMPORT_CONFIGURATOR_IGNORE_AUTHORSHIP= "eu.etaxonomy.taxeditor.abcd_import_configurator.ignoreAuthorship";
-//    public static final String ABCD_IMPORT_CONFIGURATOR_REMOVE_COUNTRY_FROM_LOCALITY_TEXT= "eu.etaxonomy.taxeditor.abcd_import_configurator.removeCountryFromLocalityText";
-//    public static final String ABCD_IMPORT_CONFIGURATOR_ADD_MEDIA_AS_MEDIASPECIMEN= "eu.etaxonomy.taxeditor.abcd_import_configurator.addMediaAsMediaSpecimen";
-//    public static final String ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_META_DATA= "eu.etaxonomy.taxeditor.abcd_import_configurator.reuseExistingMetaData";
-//    public static final String ABCD_IMPORT_CONFIGURATOR_ADD_INDIVIDUALS_ASSOCIATIONS_SUCH_AS_SPECIMEN_AND_OBSERVATIONS= "eu.etaxonomy.taxeditor.abcd_import_configurator.addIndividualsAssociationsSuchAsSpecimenAndObservations";
-//    public static final String ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_DESCRIPTIVE_GROUPS= "eu.etaxonomy.taxeditor.abcd_import_configurator.reuseExistingDescriptiveGroups";
-//    public static final String ABCD_IMPORT_CONFIGURATOR_ALLOW_REUSE_OTHER_CLASSIFICATIONS= "eu.etaxonomy.taxeditor.abcd_import_configurator.allowReuseOtherClassifications";
-//    public static final String ABCD_IMPORT_CONFIGURATOR_DEDUPLICATE_REFERENCES= "eu.etaxonomy.taxeditor.abcd_import_configurator.deduplicateReferences";
-//    public static final String ABCD_IMPORT_CONFIGURATOR_DEDUPLICATE_CLASSIFICATIONS= "eu.etaxonomy.taxeditor.abcd_import_configurator.deduplicateClassifications";
-//    public static final String ABCD_IMPORT_CONFIGURATOR_MOVE_NEW_TAXA_TO_DEFAULT_CLASSIFICATION= "eu.etaxonomy.taxeditor.abcd_import_configurator.moveNewTaxaToDefaultClassification";
-//    public static final String ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TOCATALOG_NUMBER= "eu.etaxonomy.taxeditor.abcd_import_configurator.mapUnitIdToCatalogNumber";
-//    public static final String ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TO_ACCESSION_NUMBER= "eu.etaxonomy.taxeditor.abcd_import_configurator.mapUnitIdToAccessionNumber";
-//    public static final String ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TO_BARCODE= "eu.etaxonomy.taxeditor.abcd_import_configurator.mapUnitIdToBarcode";
-//    public static final String ABCD_IMPORT_CONFIGURATOR_OVERWRITE_EXISTING_SPECIMEN= "eu.etaxonomy.taxeditor.abcd_import_configurator.overwriteExistingSpecimens";
-//
-//             */
-//
-//            getPreferenceStore().setValue(ABCD_IMPORT_CONFIGURATOR_SOURCE_URI,
-//                    getPreferenceKey(preferredConfiguration.getSourceUri()));
-//        }
-//        else{
-//            ICdmRepository controller;
-//            controller = CdmStore.getCurrentApplicationConfiguration();
-//            PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.NomenclaturalCode);
-//            CdmPreference preference = null;
-//            if (controller == null){
-//                return null;
-//            }
-//            if (preferredCode == null){
-//                preference = controller.getPreferenceService().find(key);
-//                if (preference == null){
-//                    return null;
-//                } else{
-//                    int index = StringUtils.lastIndexOf(preference.getValue(), ".");
-//                    UUID uuid = UUID.fromString(preference.getValue().substring(index +1, preference.getValue().length()));
-//                    preferredCode = NomenclaturalCode.getByUuid(uuid);
-//
-//                    getPreferenceStore().setValue(CDM_NOMENCLATURAL_CODE_KEY,
-//                            getPreferenceKey(preferredCode));
-//                    getPreferenceStore().setValue(ALLOW_OVERRIDE_NOMENCLATURAL_CODE_KEY,preference.isAllowOverride());
-//                    return preference;
-//                }
-//            } else{
-//                preference = CdmPreference.NewInstance(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.NomenclaturalCode, preferredCode.getKey());
-//                controller.getPreferenceService().set(preference);
-//
-//            }
-//        }
-//        return null;
-//
-//
-//
-//    }
+    public static Abcd206ImportConfigurator getAbcdImportConfigurationPreference(boolean useLocal) {
+
+        Abcd206ImportConfigurator config = Abcd206ImportConfigurator.NewInstance(null,null);
+
+        if (useLocal){
+            config.setAddIndividualsAssociationsSuchAsSpecimenAndObservations(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_ADD_INDIVIDUALS_ASSOCIATIONS_SUCH_AS_SPECIMEN_AND_OBSERVATIONS));
+
+            config.setAddMediaAsMediaSpecimen(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_ADD_MEDIA_AS_MEDIASPECIMEN));
+
+            config.setAllowReuseOtherClassifications(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_ALLOW_REUSE_OTHER_CLASSIFICATIONS));
+            config.setDeduplicateClassifications(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_DEDUPLICATE_CLASSIFICATIONS));
+            config.setDeduplicateReferences(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_DEDUPLICATE_REFERENCES));
+
+            config.setGetSiblings(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_DO_SIBLINGS));
+            config.setIgnoreAuthorship(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_IGNORE_AUTHORSHIP));
+            config.setIgnoreImportOfExistingSpecimen(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_IGNORE_IMPORT_OF_EXISTING_SPECIMEN));
+            config.setMapUnitIdToAccessionNumber(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TO_ACCESSION_NUMBER));
+            config.setMapUnitIdToBarcode(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TO_BARCODE));
+            config.setMapUnitIdToCatalogNumber(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TOCATALOG_NUMBER));
+            config.setMoveNewTaxaToDefaultClassification(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_MOVE_NEW_TAXA_TO_DEFAULT_CLASSIFICATION));
+            config.setOverwriteExistingSpecimens(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_OVERWRITE_EXISTING_SPECIMEN));
+            config.setReuseExistingDescriptiveGroups(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_DESCRIPTIVE_GROUPS));
+            config.setReuseExistingMetaData(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_META_DATA));
+            config.setReuseExistingTaxaWhenPossible(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_TAXA_WHEN_POSSIBLE));
+            return config;
+
+        }
+            ICdmRepository controller;
+            controller = CdmStore.getCurrentApplicationConfiguration();
+            PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.AbcdImportConfig);
+            CdmPreference preference = null;
+            if (controller == null){
+                return null;
+            }
+            preference = controller.getPreferenceService().find(key);
+            if (preference == null){
+                return config;
+             } else{
+             String configString = preference.getValue();
+             String[] configArray = configString.split(";");
+
+             for (String configItem: configArray){
+                 String[] keyValue = configItem.split(":");
+                 String keyString = keyValue[0];
+                 String valueString = keyValue[1];
+                 if (keyString.equals("ignoreImportOfExistingSpecimen")){
+                     config.setIgnoreImportOfExistingSpecimen(Boolean.valueOf(valueString));
+                 }else if (keyString.equals("addIndividualsAssociationsSuchAsSpecimenAndObservations")){
+                     config.setAddIndividualsAssociationsSuchAsSpecimenAndObservations(Boolean.valueOf(valueString));
+                 }else if (keyString.equals("reuseExistingTaxaWhenPossible")){
+                     config.setReuseExistingTaxaWhenPossible(Boolean.valueOf(valueString));
+                 }else if (keyString.equals("ignoreAuthorship")){
+                     config.setIgnoreAuthorship(Boolean.valueOf(valueString));
+                 }else if (keyString.equals("addMediaAsMediaSpecimen")){
+                     config.setAddMediaAsMediaSpecimen(Boolean.valueOf(valueString));
+                 }else if (keyString.equals("reuseExistingMetaData")){
+                     config.setReuseExistingMetaData(Boolean.valueOf(valueString));
+                 }else if (keyString.equals("reuseExistingDescriptiveGroups")){
+                     config.setReuseExistingDescriptiveGroups(Boolean.valueOf(valueString));
+                 }else if (keyString.equals("allowReuseOtherClassifications")){
+                     config.setAllowReuseOtherClassifications(Boolean.valueOf(valueString));
+                 }else if (keyString.equals("deduplicateReferences")){
+                     config.setDeduplicateReferences(Boolean.valueOf(valueString));
+                 }else if (keyString.equals("deduplicateClassifications")){
+                     config.setDeduplicateClassifications(Boolean.valueOf(valueString));
+                 }else if (keyString.equals("moveNewTaxaToDefaultClassification")){
+                     config.setMoveNewTaxaToDefaultClassification(Boolean.valueOf(valueString));
+                 }else if (keyString.equals("mapUnitIdToCatalogNumber")){
+                     config.setMapUnitIdToCatalogNumber(Boolean.valueOf(valueString));
+                 }else if (keyString.equals("mapUnitIdToAccessionNumber")){
+                     config.setMapUnitIdToAccessionNumber(Boolean.valueOf(valueString));
+                 }else if (keyString.equals("mapUnitIdToBarcode")){
+                     config.setMapUnitIdToBarcode(Boolean.valueOf(valueString));
+                 }else if (keyString.equals("overwriteExistingSpecimens")){
+                     config.setOverwriteExistingSpecimens(Boolean.valueOf(valueString));
+                 }else{
+                     logger.debug("This key of the abcd configurator needs to be added to the transformer: " + keyString);
+                 }
+
+            }
+        }
+        return config;
+
+
+
+    }
 
 
 
index b84f9c9155d9b2aab794120659ca711eb94b4d09..60a9018c3040580e38152dac827ff5f1fd0c7858 100644 (file)
@@ -280,9 +280,9 @@ public class CdmStore {
 
     }
 
-    private CdmStore(ICdmRepository applicationController,
+    private CdmStore(ICdmRepository repository,
             ICdmSource cdmSource) {
-        CdmApplicationState.setCurrentAppConfig(applicationController);
+        CdmApplicationState.setCurrentAppConfig(repository);
         CdmApplicationState.setCurrentDataChangeService(new CdmUIDataChangeService());
         this.cdmSource = cdmSource;
         isConnected = true;