ref #4766: sortindex updater integration in admin menu
authorKatja Luther <k.luther@bgbm.org>
Thu, 8 Dec 2016 10:31:19 +0000 (11:31 +0100)
committerKatja Luther <k.luther@bgbm.org>
Thu, 8 Dec 2016 10:31:19 +0000 (11:31 +0100)
eu.etaxonomy.taxeditor.application/OSGI-INF/l10n/plugin.properties
eu.etaxonomy.taxeditor.application/OSGI-INF/l10n/plugin_de.properties
eu.etaxonomy.taxeditor.application/plugin.xml
eu.etaxonomy.taxeditor.store/OSGI-INF/l10n/messages.properties
eu.etaxonomy.taxeditor.store/OSGI-INF/l10n/messages_de.properties
eu.etaxonomy.taxeditor.store/plugin.xml
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/Messages.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databasePreferences/wizard/DatabaseRepairPage.java [new file with mode: 0755]
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databasePreferences/wizard/DatabaseRepairWizard.java [new file with mode: 0755]
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/handler/OpenDatabaseRepairWizardHandler.java [new file with mode: 0755]
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/ImportManager.java

index 8110d546dba719d86bddafce7f48365e2b9b07bc..d1ad81663b39e91938d0efb84f19c7746011e3d6 100644 (file)
@@ -46,6 +46,7 @@ command.label.20 = About the EDIT Platform
 command.label.21 = New\r
 command.label.22 = Save\r
 command.label.23 = Database Preferences\r
+command.label.24 = Database Repair Functionality\r
 product.name = EDIT Taxonomic Editor\r
 command.name = Parser Help\r
 command.name.0 = About the EDIT Platform\r
index 0d736515a14ffc0ebc4e32a91534497d6fb1f665..ba37a6c3fda66be14395c2eea313e3a123eb7b5d 100644 (file)
@@ -46,6 +46,7 @@ command.label.20 = \u00dcber die EDIT Platform
 command.label.21 = Neu
 command.label.22 = Speichern
 command.label.23 = Datenbank Präferenzen
+command.label.24 = Datenbank Reparatur Funktionalität
 product.name = EDIT Taxonomischer Editor
 command.name = Parser Hilfe
 command.name.0 = \u00dcber die EDIT Platform
index a2ca946d76e1500dba5e0325d912e064375ffd78..d5ced8dd85f74d955af8dd6b0464896d8c73bfc4 100644 (file)
                </and>
             </visibleWhen>
          </command>
+         <command
+               commandId="eu.etaxonomy.taxeditor.application.DatabaseRepairFunctionality"
+               label="%command.label.24"
+               style="push">
+                <visibleWhen
+                  checkEnabled="true">
+               <and>
+                  <reference
+                        definitionId="hasROLE_PROJECT_MANAGER">
+                  </reference>
+                  <reference
+                        definitionId="isCdmStoreConnected">
+                  </reference>
+               </and>
+            </visibleWhen>
+         </command>
       </menuContribution>
       <menuContribution
             locationURI="menu:org.eclipse.ui.main.menu.help">
index 93bb1a95fd2538781bb03c1f29a420735977dedd..36180a8d273b73d7f866aa7f35f431fbce8dd6c5 100644 (file)
@@ -15,6 +15,13 @@ LanguageEditorPreferencePage_PleaseRestart=Please Restart
 LanguageEditorPreferencePage_RestartRequired=After changing the default language, a restart is required,\nin order for the new settings to take effect.
 OrderPreferencePage_NewNavigatorWindowRequired=After changing the order of the taxon nodes, closing and reopen of the taxon navigator is required.
 OrderPreferencePage_PleaseReopenNavigator=Please close and reopen the taxon navigator.
+DatabaseRepairPage_chooseParameter=Please choose the trees where the sortIndex should be recalculated.
+DatabaseRepairPage_updateTaxonNodes=Taxonomic Tree
+DatabaseRepairPage_toolTip_taxonNode=The sort indexes of the taxonomic tree will be recalculated.
+DatabaseRepairPage_PolytomousKeyNode=Polytomous Key
+DatabaseRepairPage_toolTip_polytomousKeyNode=The sort indexes of all polytomous keys are recalculated.
+DatabaseRepairPage_featureNodes=Feature Tree
+DatabaseRepairPage_toolTipFeatureNodes=The sort indexes of the feature tree will be recalculated.
 UriWithLabelElement_URL_NOT_SAVED=URI won't be saved\! 
 UriWithLabelElement_COULD_NOT_OPEN_BROWSER=Could not open external browser. URI is invalid.
 UriWithLabelElement_INVALID_URL=Invalid URI
index 88ae30acd523366944a6b108012fc2e29e17dc0c..b37f84878a4ab1b1ea911768139d47002ef9d2ae 100644 (file)
@@ -14,7 +14,15 @@ LanguageEditorPreferencePage_EditorHasToRestart=Der Anwendung muss neu gestartet
 LanguageEditorPreferencePage_PleaseRestart=Bitte neu starten
 LanguageEditorPreferencePage_RestartRequired=Nach dem Wechsel der Standardsprache ist ein Neustart erforderlich.
 OrderPreferencePage_NewNavigatorWindowRequired=Nach dem Ändern der Taxon Sortierung, ist das Schließen und erneute Öffnen des Taxonnavigators erforderlich.
-OrderPreferencePage_PleaseReopenNavigator=Bitte schließen sie den Taxonnavigator und öffnen ihn erneut.
+OrderPreferencePage_PleaseReopenNavigator=Bitte schließen Sie den Taxonnavigator und öffnen ihn erneut.
+DatabaseRepairPage_chooseParameter=Bitte wählen Sie, für welche Bäume der SortIndex neu berechnet werden soll.
+DatabaseRepairPage_updateTaxonNodes=Taxonomischer Baum
+DatabaseRepairPage_toolTip_taxonNode=Die Sortier Indizes des Taxonomischen Baums werden aktualisiert.
+DatabaseRepairPage_PolytomousKeyNode=Polytome Schlüssel
+DatabaseRepairPage_toolTip_polytomousKeyNode=Die Sortier Indizes aller Polytomen Schlüssel werden aktualisiert.
+DatabaseRepairPage_featureNodes=Merkmalsbaum
+DatabaseRepairPage_toolTipFeatureNodes=Die Sortier Indizes des Merkmalsbaumes werden aktualisiert. 
+
 UriWithLabelElement_URL_NOT_SAVED=URI wird nicht gespeichert\! 
 UriWithLabelElement_COULD_NOT_OPEN_BROWSER=Externer Browser konnte nicht geöffnet werden. URI ist ung\u00FCtlig.
 UriWithLabelElement_INVALID_URL=Ung\u00FCltige URI
index 9e449ab2a2e45f876aaf9e9634b34df4d70d4dfb..125c8ddfedf9462564195a9eba3ee98c5260a18f 100755 (executable)
             id="eu.etaxonomy.taxeditor.application.DatabaseSettings"
             name="%command.label.23">
       </command>
+      <command
+            defaultHandler="eu.etaxonomy.taxeditor.handler.OpenDatabaseRepairWizardHandler"
+            id="eu.etaxonomy.taxeditor.application.DatabaseRepairFunctionality"
+            name="%command.label.24">
+      </command>
    </extension>
    <extension
          point="org.eclipse.ui.commands">
index 3756992783d5fb4be9366dff6a7fbc44ffb4b09f..0e499cc2b838acfe224dad829b7af59647b15f46 100644 (file)
@@ -18,12 +18,20 @@ import org.eclipse.osgi.util.NLS;
  */
 public class Messages extends NLS {
     private static final String BUNDLE_NAME = "OSGI-INF/l10n/messages"; //$NON-NLS-1$
+
     public static String AuthenticatedUserBar_LOGGED_IN_AS;
     public static String AuthenticatedUserBar_NOT_LOGGED_IN;
     public static String LanguageEditorPreferencePage_ChooseDefaultLanguage;
     public static String LanguageEditorPreferencePage_EditorHasToRestart;
     public static String LanguageEditorPreferencePage_PleaseRestart;
     public static String LanguageEditorPreferencePage_RestartRequired;
+    public static String DatabaseRepairPage_chooseParameter;
+    public static String DatabaseRepairPage_updateTaxonNodes;
+    public static String DatabaseRepairPage_toolTip_taxonNode;
+    public static String DatabaseRepairPage_PolytomousKeyNode;
+    public static String DatabaseRepairPage_toolTip_polytomousKeyNode;
+    public static String DatabaseRepairPage_featureNodes;
+    public static String DatabaseRepairPage_toolTipFeatureNodes;
     public static String LoginDialog_CANCEL_MESSAGE;
     public static String LoginDialog_LOGIN;
     public static String LoginDialog_PASSWORD;
@@ -118,7 +126,7 @@ public class Messages extends NLS {
        public static String RemotingLoginDialog_STATUS_REMOTING_NOT_ACTIVATED;
        public static String RemotingLoginDialog_STATUS_RETRIEVING;
        public static String RemotingLoginDialog_STATUS_STARTED;
-       public static String RemotingLoginDialog_UPDATE_EDITOR; 
+       public static String RemotingLoginDialog_UPDATE_EDITOR;
        public static String RemotingLoginDialog_COULD_NOT_STOP_SERVER;
        public static String RemotingLoginDialog_ERROR_GENERATING_CONFIG_FILE;
        public static String RemotingLoginDialog_ERROR_STARTING_SERVER;
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databasePreferences/wizard/DatabaseRepairPage.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databasePreferences/wizard/DatabaseRepairPage.java
new file mode 100755 (executable)
index 0000000..99e7316
--- /dev/null
@@ -0,0 +1,100 @@
+/**
+* Copyright (C) 2016 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.databasePreferences.wizard;
+
+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.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+
+import eu.etaxonomy.cdm.io.common.SortIndexUpdaterConfigurator;
+import eu.etaxonomy.taxeditor.Messages;
+
+/**
+ * @author k.luther
+ * @date 06.12.2016
+ *
+ */
+public class DatabaseRepairPage extends WizardPage {
+
+    SortIndexUpdaterConfigurator config = null;
+    /**
+     * @param pageName
+     */
+    protected DatabaseRepairPage(String pageName, SortIndexUpdaterConfigurator config){
+        super(pageName);
+        this.config = config;
+        setMessage(Messages.DatabaseRepairPage_chooseParameter);
+    }
+
+
+
+
+
+
+
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void createControl(Composite parent) {
+        final Composite composite = new Composite(parent, SWT.NULL);
+
+        GridLayout gridLayout = new GridLayout();
+        composite.setLayout(gridLayout);
+
+        Button checkBoxTaxonNode = new Button(composite, SWT.CHECK);
+        checkBoxTaxonNode.setSelection(config.isDoTaxonNode());
+        checkBoxTaxonNode.setText(Messages.DatabaseRepairPage_updateTaxonNodes);
+        checkBoxTaxonNode
+                .setToolTipText(Messages.DatabaseRepairPage_toolTip_taxonNode);
+        checkBoxTaxonNode.addSelectionListener(new SelectionAdapter() {
+            @Override
+            public void widgetSelected(SelectionEvent e) {
+                config.setDoTaxonNode(!config.isDoTaxonNode());
+            }
+        });
+
+        Button checkBoxPolytomousKeyNode = new Button(composite, SWT.CHECK);
+        checkBoxPolytomousKeyNode.setSelection(config.isDoPolytomousKeyNode());
+        checkBoxPolytomousKeyNode.setText(Messages.DatabaseRepairPage_PolytomousKeyNode);
+        checkBoxPolytomousKeyNode
+        .setToolTipText(Messages.DatabaseRepairPage_toolTip_polytomousKeyNode);
+        checkBoxPolytomousKeyNode.addSelectionListener(new SelectionAdapter() {
+            @Override
+            public void widgetSelected(SelectionEvent e) {
+                config.setDoPolytomousKeyNode(!config.isDoPolytomousKeyNode());
+            }
+        });
+
+        Button checkBoxFeatureNode = new Button(composite, SWT.CHECK);
+        checkBoxFeatureNode.setSelection(config.isDoFeatureNode());
+        checkBoxFeatureNode.setText(Messages.DatabaseRepairPage_featureNodes);
+        checkBoxFeatureNode
+        .setToolTipText(Messages.DatabaseRepairPage_toolTipFeatureNodes);
+        checkBoxFeatureNode.addSelectionListener(new SelectionAdapter() {
+            @Override
+            public void widgetSelected(SelectionEvent e) {
+                config.setDoFeatureNode(!config.isDoFeatureNode());
+            }
+        });
+
+
+
+        setControl(composite);
+
+    }
+
+
+
+}
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databasePreferences/wizard/DatabaseRepairWizard.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databasePreferences/wizard/DatabaseRepairWizard.java
new file mode 100755 (executable)
index 0000000..cd9c39e
--- /dev/null
@@ -0,0 +1,60 @@
+/**
+* Copyright (C) 2016 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.databasePreferences.wizard;
+
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.wizard.Wizard;
+
+import eu.etaxonomy.cdm.config.ICdmSource;
+import eu.etaxonomy.cdm.io.common.SortIndexUpdaterConfigurator;
+import eu.etaxonomy.taxeditor.store.CdmStore;
+
+/**
+ * @author k.luther
+ * @date 06.12.2016
+ *
+ */
+public class DatabaseRepairWizard extends Wizard {
+    private final DatabaseRepairPage repairPage;
+    SortIndexUpdaterConfigurator config;
+
+    public DatabaseRepairWizard() {
+        setWindowTitle("Database Repair Wizard");
+        config = SortIndexUpdaterConfigurator.NewInstance(null);
+        repairPage = new DatabaseRepairPage("Database Repair",config);
+
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public boolean performFinish() {
+        if (repairPage.isPageComplete()){
+            if (config == null){
+                ICdmSource source= CdmStore.getActiveCdmSource();
+                config = SortIndexUpdaterConfigurator.NewInstance(null);
+                config.setDoFeatureNode(false);
+                config.setDoPolytomousKeyNode(false);
+
+             }
+             Job updateJob = CdmStore.getImportManager().createIOServiceJob(config);
+
+             CdmStore.getImportManager().run(updateJob);
+        }
+        return true;
+    }
+
+    @Override
+    public void addPages() {
+        addPage(repairPage);
+    }
+
+
+}
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/handler/OpenDatabaseRepairWizardHandler.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/handler/OpenDatabaseRepairWizardHandler.java
new file mode 100755 (executable)
index 0000000..7c619b5
--- /dev/null
@@ -0,0 +1,44 @@
+/**
+* Copyright (C) 2016 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.handler;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.wizard.WizardDialog;
+
+import eu.etaxonomy.taxeditor.databasePreferences.wizard.DatabaseRepairWizard;
+import eu.etaxonomy.taxeditor.store.StoreUtil;
+
+
+
+/**
+ * @author k.luther
+ * @date 06.12.2016
+ *
+ */
+public class OpenDatabaseRepairWizardHandler extends AbstractHandler {
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public Object execute(ExecutionEvent event) throws ExecutionException {
+        DatabaseRepairWizard databaseRepairWizard = new DatabaseRepairWizard();
+        WizardDialog dialog = new WizardDialog(StoreUtil.getShell(),
+                databaseRepairWizard);
+
+        dialog.open();
+
+        return null;
+    }
+
+
+
+}
index 539db22f7962b7dd3fe70ef4ff3da98d8cf12a78..6e6b00bb337b1540bac17bab4ea137d30e4216cf 100644 (file)
@@ -12,12 +12,10 @@ package eu.etaxonomy.taxeditor.io;
 
 import java.io.File;
 import java.io.InputStream;
-import java.net.URI;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.util.List;
-import java.util.Set;
 import java.util.UUID;
 
 import org.apache.commons.io.IOUtils;
@@ -36,13 +34,13 @@ import eu.etaxonomy.cdm.io.common.CdmDefaultImport;
 import eu.etaxonomy.cdm.io.common.IImportConfigurator;
 import eu.etaxonomy.cdm.io.common.IImportConfigurator.SOURCE_TYPE;
 import eu.etaxonomy.cdm.io.common.ImportResult;
+import eu.etaxonomy.cdm.io.common.SortIndexUpdaterConfigurator;
 import eu.etaxonomy.cdm.io.dwca.in.DwcaImportConfigurator;
 import eu.etaxonomy.cdm.io.excel.taxa.NormalExplicitImportConfigurator;
 import eu.etaxonomy.cdm.io.jaxb.JaxbImportConfigurator;
 import eu.etaxonomy.cdm.io.reference.endnote.in.EndnoteImportConfigurator;
 import eu.etaxonomy.cdm.io.sdd.in.SDDImportConfigurator;
 import eu.etaxonomy.cdm.io.service.IIOService;
-import eu.etaxonomy.cdm.io.specimen.SpecimenImportConfiguratorBase;
 import eu.etaxonomy.cdm.io.specimen.abcd206.in.Abcd206ImportConfigurator;
 import eu.etaxonomy.cdm.io.specimen.abcd206.in.Abcd206ImportState;
 import eu.etaxonomy.cdm.io.specimen.excel.in.SpecimenCdmExcelImportConfigurator;
@@ -395,7 +393,7 @@ public class ImportManager extends AbstractIOManager<IImportConfigurator> implem
        public SpecimenCdmExcelImportConfigurator SpecimenCdmExcelImportConfigurator() {
                return (SpecimenCdmExcelImportConfigurator) getConfigurator(TYPE.SpecimenCdmExcel);
        }
-       
+
        public DwcaImportConfigurator DwcaImportConfigurator() {
                return (DwcaImportConfigurator) getConfigurator(TYPE.Gbif);
        }
@@ -444,7 +442,7 @@ public class ImportManager extends AbstractIOManager<IImportConfigurator> implem
                return job;
 
        }
-       
+
        public Job createIOServiceJob(final Abcd206ImportConfigurator<Abcd206ImportState, InputStream> configurator) {
                 Assert.isNotNull(configurator, "Configuration may not be null");
                final Display display = Display.getDefault();
@@ -503,7 +501,38 @@ public class ImportManager extends AbstractIOManager<IImportConfigurator> implem
                return job;
        }
 
-       
+    public Job createIOServiceJob(final SortIndexUpdaterConfigurator configurator) {
+        Assert.isNotNull(configurator, "Configuration may not be null");
+        final Display display = Display.getDefault();
+        Job job = new Job("Update: " + configurator.getClass().getSimpleName()) {
+
+            @Override
+            protected IStatus run(IProgressMonitor monitor) {
+                monitor.beginTask("Updating data", IProgressMonitor.UNKNOWN);
+                IIOService ioService = CdmApplicationState.getIOService();
+
+                ioService.updateSortIndex(configurator);
+
+                monitor.done();
+
+                display.asyncExec(new Runnable() {
+
+                    @Override
+                    public void run() {
+                        CdmStore.getContextManager().notifyContextRefresh();
+                    }
+                });
+
+                return Status.OK_STATUS;
+            }
+        };
+
+        return job;
+
+    }
+
+
+
 
 
 }