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.databaseAdmin.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.operation.config.CacheUpdaterConfigurator;
|
16
|
import eu.etaxonomy.cdm.io.common.IImportConfigurator.CHECK;
|
17
|
import eu.etaxonomy.cdm.io.operation.config.SortIndexUpdaterConfigurator;
|
18
|
import eu.etaxonomy.cdm.model.agent.AgentBase;
|
19
|
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
|
20
|
import eu.etaxonomy.cdm.model.name.TaxonName;
|
21
|
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
|
22
|
import eu.etaxonomy.cdm.model.reference.Reference;
|
23
|
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
|
24
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
25
|
|
26
|
/**
|
27
|
* @author k.luther
|
28
|
* @date 06.12.2016
|
29
|
*
|
30
|
*/
|
31
|
public class DatabaseRepairWizard extends Wizard {
|
32
|
// private final DatabaseRepairSortIndexPage repairSortIndexPage;
|
33
|
private final Test test;
|
34
|
SortIndexUpdaterConfigurator config;
|
35
|
CacheUpdaterConfigurator cacheUpdaterConfig;
|
36
|
|
37
|
|
38
|
|
39
|
public DatabaseRepairWizard() {
|
40
|
setWindowTitle("Database Repair Wizard");
|
41
|
config = SortIndexUpdaterConfigurator.NewInstance(null);
|
42
|
// repairSortIndexPage = new DatabaseRepairSortIndexPage("SortIndex Repair",config);
|
43
|
cacheUpdaterConfig = CacheUpdaterConfigurator.NewInstance(null);
|
44
|
test = new Test("Test", cacheUpdaterConfig, config);
|
45
|
|
46
|
}
|
47
|
|
48
|
/**
|
49
|
* {@inheritDoc}
|
50
|
*/
|
51
|
@Override
|
52
|
public boolean performFinish() {
|
53
|
|
54
|
if (config == null){
|
55
|
ICdmSource source= CdmStore.getActiveCdmSource();
|
56
|
config = SortIndexUpdaterConfigurator.NewInstance(null);
|
57
|
config.setDoFeatureNode(false);
|
58
|
config.setDoPolytomousKeyNode(false);
|
59
|
|
60
|
|
61
|
}
|
62
|
if (config.isDoFeatureNode() || config.isDoPolytomousKeyNode() || config.isDoTaxonNode()){
|
63
|
config.setCheck(CHECK.IMPORT_WITHOUT_CHECK);
|
64
|
Job updateJob = CdmStore.getImportManager().createIOServiceJob(config);
|
65
|
CdmStore.getImportManager().run(updateJob);
|
66
|
}
|
67
|
if (test.updateAgentBase){
|
68
|
cacheUpdaterConfig.getClassList().add(TeamOrPersonBase.class);
|
69
|
}
|
70
|
if (test.updateReference){
|
71
|
cacheUpdaterConfig.getClassList().add(Reference.class);
|
72
|
}
|
73
|
if (test.updateName){
|
74
|
cacheUpdaterConfig.getClassList().add(TaxonName.class);
|
75
|
}
|
76
|
if (test.updateTaxonBase){
|
77
|
cacheUpdaterConfig.getClassList().add(TaxonBase.class);
|
78
|
}
|
79
|
if (test.updateSpecimen){
|
80
|
cacheUpdaterConfig.getClassList().add(SpecimenOrObservationBase.class);
|
81
|
}
|
82
|
if (!cacheUpdaterConfig.getClassList().isEmpty()){
|
83
|
cacheUpdaterConfig.setCheck(CHECK.IMPORT_WITHOUT_CHECK);
|
84
|
Job updateJob2 = CdmStore.getImportManager().createIOServiceJob(cacheUpdaterConfig);
|
85
|
CdmStore.getImportManager().run(updateJob2);
|
86
|
}
|
87
|
|
88
|
|
89
|
|
90
|
return true;
|
91
|
}
|
92
|
|
93
|
@Override
|
94
|
public void addPages() {
|
95
|
//addPage(repairSortIndexPage);
|
96
|
addPage(test);
|
97
|
}
|
98
|
|
99
|
|
100
|
}
|