Project

General

Profile

« Previous | Next » 

Revision 1183a87f

Added by Katja Luther over 6 years ago

ref #4766: sortindex updater integration in admin menu

View differences:

eu.etaxonomy.taxeditor.application/OSGI-INF/l10n/plugin.properties
46 46
command.label.21 = New
47 47
command.label.22 = Save
48 48
command.label.23 = Database Preferences
49
command.label.24 = Database Repair Functionality
49 50
product.name = EDIT Taxonomic Editor
50 51
command.name = Parser Help
51 52
command.name.0 = About the EDIT Platform
eu.etaxonomy.taxeditor.application/OSGI-INF/l10n/plugin_de.properties
46 46
command.label.21 = Neu
47 47
command.label.22 = Speichern
48 48
command.label.23 = Datenbank Pr?ferenzen
49
command.label.24 = Datenbank Reparatur Funktionalit?t
49 50
product.name = EDIT Taxonomischer Editor
50 51
command.name = Parser Hilfe
51 52
command.name.0 = \u00dcber die EDIT Platform
eu.etaxonomy.taxeditor.application/plugin.xml
228 228
               </and>
229 229
            </visibleWhen>
230 230
         </command>
231
         <command
232
               commandId="eu.etaxonomy.taxeditor.application.DatabaseRepairFunctionality"
233
               label="%command.label.24"
234
               style="push">
235
                <visibleWhen
236
                  checkEnabled="true">
237
               <and>
238
                  <reference
239
                        definitionId="hasROLE_PROJECT_MANAGER">
240
                  </reference>
241
                  <reference
242
                        definitionId="isCdmStoreConnected">
243
                  </reference>
244
               </and>
245
            </visibleWhen>
246
         </command>
231 247
      </menuContribution>
232 248
      <menuContribution
233 249
            locationURI="menu:org.eclipse.ui.main.menu.help">
eu.etaxonomy.taxeditor.store/OSGI-INF/l10n/messages.properties
15 15
LanguageEditorPreferencePage_RestartRequired=After changing the default language, a restart is required,\nin order for the new settings to take effect.
16 16
OrderPreferencePage_NewNavigatorWindowRequired=After changing the order of the taxon nodes, closing and reopen of the taxon navigator is required.
17 17
OrderPreferencePage_PleaseReopenNavigator=Please close and reopen the taxon navigator.
18
DatabaseRepairPage_chooseParameter=Please choose the trees where the sortIndex should be recalculated.
19
DatabaseRepairPage_updateTaxonNodes=Taxonomic Tree
20
DatabaseRepairPage_toolTip_taxonNode=The sort indexes of the taxonomic tree will be recalculated.
21
DatabaseRepairPage_PolytomousKeyNode=Polytomous Key
22
DatabaseRepairPage_toolTip_polytomousKeyNode=The sort indexes of all polytomous keys are recalculated.
23
DatabaseRepairPage_featureNodes=Feature Tree
24
DatabaseRepairPage_toolTipFeatureNodes=The sort indexes of the feature tree will be recalculated.
18 25
UriWithLabelElement_URL_NOT_SAVED=URI won't be saved\! 
19 26
UriWithLabelElement_COULD_NOT_OPEN_BROWSER=Could not open external browser. URI is invalid.
20 27
UriWithLabelElement_INVALID_URL=Invalid URI
eu.etaxonomy.taxeditor.store/OSGI-INF/l10n/messages_de.properties
14 14
LanguageEditorPreferencePage_PleaseRestart=Bitte neu starten
15 15
LanguageEditorPreferencePage_RestartRequired=Nach dem Wechsel der Standardsprache ist ein Neustart erforderlich.
16 16
OrderPreferencePage_NewNavigatorWindowRequired=Nach dem ?ndern der Taxon Sortierung, ist das Schlie?en und erneute ?ffnen des Taxonnavigators erforderlich.
17
OrderPreferencePage_PleaseReopenNavigator=Bitte schlie?en sie den Taxonnavigator und ?ffnen ihn erneut.
17
OrderPreferencePage_PleaseReopenNavigator=Bitte schlie?en Sie den Taxonnavigator und ?ffnen ihn erneut.
18
DatabaseRepairPage_chooseParameter=Bitte w?hlen Sie, f?r welche B?ume der SortIndex neu berechnet werden soll.
19
DatabaseRepairPage_updateTaxonNodes=Taxonomischer Baum
20
DatabaseRepairPage_toolTip_taxonNode=Die Sortier Indizes des Taxonomischen Baums werden aktualisiert.
21
DatabaseRepairPage_PolytomousKeyNode=Polytome Schl?ssel
22
DatabaseRepairPage_toolTip_polytomousKeyNode=Die Sortier Indizes aller Polytomen Schl?ssel werden aktualisiert.
23
DatabaseRepairPage_featureNodes=Merkmalsbaum
24
DatabaseRepairPage_toolTipFeatureNodes=Die Sortier Indizes des Merkmalsbaumes werden aktualisiert. 
25

  
18 26
UriWithLabelElement_URL_NOT_SAVED=URI wird nicht gespeichert\! 
19 27
UriWithLabelElement_COULD_NOT_OPEN_BROWSER=Externer Browser konnte nicht ge?ffnet werden. URI ist ung\u00FCtlig.
20 28
UriWithLabelElement_INVALID_URL=Ung\u00FCltige URI
eu.etaxonomy.taxeditor.store/plugin.xml
822 822
            id="eu.etaxonomy.taxeditor.application.DatabaseSettings"
823 823
            name="%command.label.23">
824 824
      </command>
825
      <command
826
            defaultHandler="eu.etaxonomy.taxeditor.handler.OpenDatabaseRepairWizardHandler"
827
            id="eu.etaxonomy.taxeditor.application.DatabaseRepairFunctionality"
828
            name="%command.label.24">
829
      </command>
825 830
   </extension>
826 831
   <extension
827 832
         point="org.eclipse.ui.commands">
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/Messages.java
18 18
 */
19 19
public class Messages extends NLS {
20 20
    private static final String BUNDLE_NAME = "OSGI-INF/l10n/messages"; //$NON-NLS-1$
21

  
21 22
    public static String AuthenticatedUserBar_LOGGED_IN_AS;
22 23
    public static String AuthenticatedUserBar_NOT_LOGGED_IN;
23 24
    public static String LanguageEditorPreferencePage_ChooseDefaultLanguage;
24 25
    public static String LanguageEditorPreferencePage_EditorHasToRestart;
25 26
    public static String LanguageEditorPreferencePage_PleaseRestart;
26 27
    public static String LanguageEditorPreferencePage_RestartRequired;
28
    public static String DatabaseRepairPage_chooseParameter;
29
    public static String DatabaseRepairPage_updateTaxonNodes;
30
    public static String DatabaseRepairPage_toolTip_taxonNode;
31
    public static String DatabaseRepairPage_PolytomousKeyNode;
32
    public static String DatabaseRepairPage_toolTip_polytomousKeyNode;
33
    public static String DatabaseRepairPage_featureNodes;
34
    public static String DatabaseRepairPage_toolTipFeatureNodes;
27 35
    public static String LoginDialog_CANCEL_MESSAGE;
28 36
    public static String LoginDialog_LOGIN;
29 37
    public static String LoginDialog_PASSWORD;
......
118 126
	public static String RemotingLoginDialog_STATUS_REMOTING_NOT_ACTIVATED;
119 127
	public static String RemotingLoginDialog_STATUS_RETRIEVING;
120 128
	public static String RemotingLoginDialog_STATUS_STARTED;
121
	public static String RemotingLoginDialog_UPDATE_EDITOR;	
129
	public static String RemotingLoginDialog_UPDATE_EDITOR;
122 130
	public static String RemotingLoginDialog_COULD_NOT_STOP_SERVER;
123 131
	public static String RemotingLoginDialog_ERROR_GENERATING_CONFIG_FILE;
124 132
	public static String RemotingLoginDialog_ERROR_STARTING_SERVER;
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databasePreferences/wizard/DatabaseRepairPage.java
1
/**
2
* Copyright (C) 2016 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.taxeditor.databasePreferences.wizard;
10

  
11
import org.eclipse.jface.wizard.WizardPage;
12
import org.eclipse.swt.SWT;
13
import org.eclipse.swt.events.SelectionAdapter;
14
import org.eclipse.swt.events.SelectionEvent;
15
import org.eclipse.swt.layout.GridLayout;
16
import org.eclipse.swt.widgets.Button;
17
import org.eclipse.swt.widgets.Composite;
18

  
19
import eu.etaxonomy.cdm.io.common.SortIndexUpdaterConfigurator;
20
import eu.etaxonomy.taxeditor.Messages;
21

  
22
/**
23
 * @author k.luther
24
 * @date 06.12.2016
25
 *
26
 */
27
public class DatabaseRepairPage extends WizardPage {
28

  
29
    SortIndexUpdaterConfigurator config = null;
30
    /**
31
     * @param pageName
32
     */
33
    protected DatabaseRepairPage(String pageName, SortIndexUpdaterConfigurator config){
34
        super(pageName);
35
        this.config = config;
36
        setMessage(Messages.DatabaseRepairPage_chooseParameter);
37
    }
38

  
39

  
40

  
41

  
42

  
43

  
44

  
45

  
46
    /**
47
     * {@inheritDoc}
48
     */
49
    @Override
50
    public void createControl(Composite parent) {
51
        final Composite composite = new Composite(parent, SWT.NULL);
52

  
53
        GridLayout gridLayout = new GridLayout();
54
        composite.setLayout(gridLayout);
55

  
56
        Button checkBoxTaxonNode = new Button(composite, SWT.CHECK);
57
        checkBoxTaxonNode.setSelection(config.isDoTaxonNode());
58
        checkBoxTaxonNode.setText(Messages.DatabaseRepairPage_updateTaxonNodes);
59
        checkBoxTaxonNode
60
                .setToolTipText(Messages.DatabaseRepairPage_toolTip_taxonNode);
61
        checkBoxTaxonNode.addSelectionListener(new SelectionAdapter() {
62
            @Override
63
            public void widgetSelected(SelectionEvent e) {
64
                config.setDoTaxonNode(!config.isDoTaxonNode());
65
            }
66
        });
67

  
68
        Button checkBoxPolytomousKeyNode = new Button(composite, SWT.CHECK);
69
        checkBoxPolytomousKeyNode.setSelection(config.isDoPolytomousKeyNode());
70
        checkBoxPolytomousKeyNode.setText(Messages.DatabaseRepairPage_PolytomousKeyNode);
71
        checkBoxPolytomousKeyNode
72
        .setToolTipText(Messages.DatabaseRepairPage_toolTip_polytomousKeyNode);
73
        checkBoxPolytomousKeyNode.addSelectionListener(new SelectionAdapter() {
74
            @Override
75
            public void widgetSelected(SelectionEvent e) {
76
                config.setDoPolytomousKeyNode(!config.isDoPolytomousKeyNode());
77
            }
78
        });
79

  
80
        Button checkBoxFeatureNode = new Button(composite, SWT.CHECK);
81
        checkBoxFeatureNode.setSelection(config.isDoFeatureNode());
82
        checkBoxFeatureNode.setText(Messages.DatabaseRepairPage_featureNodes);
83
        checkBoxFeatureNode
84
        .setToolTipText(Messages.DatabaseRepairPage_toolTipFeatureNodes);
85
        checkBoxFeatureNode.addSelectionListener(new SelectionAdapter() {
86
            @Override
87
            public void widgetSelected(SelectionEvent e) {
88
                config.setDoFeatureNode(!config.isDoFeatureNode());
89
            }
90
        });
91

  
92

  
93

  
94
        setControl(composite);
95

  
96
    }
97

  
98

  
99

  
100
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databasePreferences/wizard/DatabaseRepairWizard.java
1
/**
2
* Copyright (C) 2016 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.taxeditor.databasePreferences.wizard;
10

  
11
import org.eclipse.core.runtime.jobs.Job;
12
import org.eclipse.jface.wizard.Wizard;
13

  
14
import eu.etaxonomy.cdm.config.ICdmSource;
15
import eu.etaxonomy.cdm.io.common.SortIndexUpdaterConfigurator;
16
import eu.etaxonomy.taxeditor.store.CdmStore;
17

  
18
/**
19
 * @author k.luther
20
 * @date 06.12.2016
21
 *
22
 */
23
public class DatabaseRepairWizard extends Wizard {
24
    private final DatabaseRepairPage repairPage;
25
    SortIndexUpdaterConfigurator config;
26

  
27
    public DatabaseRepairWizard() {
28
        setWindowTitle("Database Repair Wizard");
29
        config = SortIndexUpdaterConfigurator.NewInstance(null);
30
        repairPage = new DatabaseRepairPage("Database Repair",config);
31

  
32
    }
33

  
34
    /**
35
     * {@inheritDoc}
36
     */
37
    @Override
38
    public boolean performFinish() {
39
        if (repairPage.isPageComplete()){
40
            if (config == null){
41
                ICdmSource source= CdmStore.getActiveCdmSource();
42
                config = SortIndexUpdaterConfigurator.NewInstance(null);
43
                config.setDoFeatureNode(false);
44
                config.setDoPolytomousKeyNode(false);
45

  
46
             }
47
             Job updateJob = CdmStore.getImportManager().createIOServiceJob(config);
48

  
49
             CdmStore.getImportManager().run(updateJob);
50
        }
51
        return true;
52
    }
53

  
54
    @Override
55
    public void addPages() {
56
        addPage(repairPage);
57
    }
58

  
59

  
60
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/handler/OpenDatabaseRepairWizardHandler.java
1
/**
2
* Copyright (C) 2016 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.taxeditor.handler;
10

  
11
import org.eclipse.core.commands.AbstractHandler;
12
import org.eclipse.core.commands.ExecutionEvent;
13
import org.eclipse.core.commands.ExecutionException;
14
import org.eclipse.jface.wizard.WizardDialog;
15

  
16
import eu.etaxonomy.taxeditor.databasePreferences.wizard.DatabaseRepairWizard;
17
import eu.etaxonomy.taxeditor.store.StoreUtil;
18

  
19

  
20

  
21
/**
22
 * @author k.luther
23
 * @date 06.12.2016
24
 *
25
 */
26
public class OpenDatabaseRepairWizardHandler extends AbstractHandler {
27

  
28
    /**
29
     * {@inheritDoc}
30
     */
31
    @Override
32
    public Object execute(ExecutionEvent event) throws ExecutionException {
33
        DatabaseRepairWizard databaseRepairWizard = new DatabaseRepairWizard();
34
        WizardDialog dialog = new WizardDialog(StoreUtil.getShell(),
35
                databaseRepairWizard);
36

  
37
        dialog.open();
38

  
39
        return null;
40
    }
41

  
42

  
43

  
44
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/ImportManager.java
12 12

  
13 13
import java.io.File;
14 14
import java.io.InputStream;
15
import java.net.URI;
16 15
import java.nio.file.Files;
17 16
import java.nio.file.Path;
18 17
import java.nio.file.Paths;
19 18
import java.util.List;
20
import java.util.Set;
21 19
import java.util.UUID;
22 20

  
23 21
import org.apache.commons.io.IOUtils;
......
36 34
import eu.etaxonomy.cdm.io.common.IImportConfigurator;
37 35
import eu.etaxonomy.cdm.io.common.IImportConfigurator.SOURCE_TYPE;
38 36
import eu.etaxonomy.cdm.io.common.ImportResult;
37
import eu.etaxonomy.cdm.io.common.SortIndexUpdaterConfigurator;
39 38
import eu.etaxonomy.cdm.io.dwca.in.DwcaImportConfigurator;
40 39
import eu.etaxonomy.cdm.io.excel.taxa.NormalExplicitImportConfigurator;
41 40
import eu.etaxonomy.cdm.io.jaxb.JaxbImportConfigurator;
42 41
import eu.etaxonomy.cdm.io.reference.endnote.in.EndnoteImportConfigurator;
43 42
import eu.etaxonomy.cdm.io.sdd.in.SDDImportConfigurator;
44 43
import eu.etaxonomy.cdm.io.service.IIOService;
45
import eu.etaxonomy.cdm.io.specimen.SpecimenImportConfiguratorBase;
46 44
import eu.etaxonomy.cdm.io.specimen.abcd206.in.Abcd206ImportConfigurator;
47 45
import eu.etaxonomy.cdm.io.specimen.abcd206.in.Abcd206ImportState;
48 46
import eu.etaxonomy.cdm.io.specimen.excel.in.SpecimenCdmExcelImportConfigurator;
......
395 393
	public SpecimenCdmExcelImportConfigurator SpecimenCdmExcelImportConfigurator() {
396 394
		return (SpecimenCdmExcelImportConfigurator) getConfigurator(TYPE.SpecimenCdmExcel);
397 395
	}
398
	
396

  
399 397
	public DwcaImportConfigurator DwcaImportConfigurator() {
400 398
		return (DwcaImportConfigurator) getConfigurator(TYPE.Gbif);
401 399
	}
......
444 442
	        return job;
445 443

  
446 444
	}
447
	
445

  
448 446
	public Job createIOServiceJob(final Abcd206ImportConfigurator<Abcd206ImportState, InputStream> configurator) {
449 447
		 Assert.isNotNull(configurator, "Configuration may not be null");
450 448
	        final Display display = Display.getDefault();
......
503 501
	        return job;
504 502
	}
505 503

  
506
	
504
    public Job createIOServiceJob(final SortIndexUpdaterConfigurator configurator) {
505
        Assert.isNotNull(configurator, "Configuration may not be null");
506
        final Display display = Display.getDefault();
507
        Job job = new Job("Update: " + configurator.getClass().getSimpleName()) {
508

  
509
            @Override
510
            protected IStatus run(IProgressMonitor monitor) {
511
                monitor.beginTask("Updating data", IProgressMonitor.UNKNOWN);
512
                IIOService ioService = CdmApplicationState.getIOService();
513

  
514
                ioService.updateSortIndex(configurator);
515

  
516
                monitor.done();
517

  
518
                display.asyncExec(new Runnable() {
519

  
520
                    @Override
521
                    public void run() {
522
                        CdmStore.getContextManager().notifyContextRefresh();
523
                    }
524
                });
525

  
526
                return Status.OK_STATUS;
527
            }
528
        };
529

  
530
        return job;
531

  
532
    }
533

  
534

  
535

  
507 536

  
508 537

  
509 538
}

Also available in: Unified diff