1
|
/**
|
2
|
* Copyright (C) 2019 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 java.util.UUID;
|
12
|
|
13
|
import org.eclipse.jface.wizard.Wizard;
|
14
|
import org.eclipse.swt.widgets.Display;
|
15
|
|
16
|
import eu.etaxonomy.cdm.api.application.CdmApplicationState;
|
17
|
import eu.etaxonomy.cdm.api.service.config.CacheUpdaterConfigurator;
|
18
|
import eu.etaxonomy.cdm.api.service.longrunningService.ILongRunningTasksService;
|
19
|
import eu.etaxonomy.cdm.common.monitor.IRemotingProgressMonitor;
|
20
|
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
|
21
|
import eu.etaxonomy.cdm.model.name.TaxonName;
|
22
|
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
|
23
|
import eu.etaxonomy.cdm.model.reference.Reference;
|
24
|
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
|
25
|
import eu.etaxonomy.taxeditor.model.AbstractUtility;
|
26
|
import eu.etaxonomy.taxeditor.operation.IPostMoniteredOperationEnabled;
|
27
|
|
28
|
/**
|
29
|
* @author k.luther
|
30
|
* @since 05.03.2019
|
31
|
*
|
32
|
*/
|
33
|
public class DatabaseRepairUpdateCachesWizard extends Wizard implements IPostMoniteredOperationEnabled {
|
34
|
|
35
|
CacheUpdaterConfigurator cacheUpdaterConfig;
|
36
|
ILongRunningTasksService longRunningTaskService;
|
37
|
CacheUpdaterWizardPage page;
|
38
|
|
39
|
|
40
|
public DatabaseRepairUpdateCachesWizard() {
|
41
|
setWindowTitle("Update Caches");
|
42
|
cacheUpdaterConfig = CacheUpdaterConfigurator.NewInstance();
|
43
|
longRunningTaskService = CdmApplicationState.getLongRunningTasksService();
|
44
|
page = new CacheUpdaterWizardPage("Update Caches", cacheUpdaterConfig);
|
45
|
}
|
46
|
|
47
|
/**
|
48
|
* {@inheritDoc}
|
49
|
*/
|
50
|
@Override
|
51
|
public void postOperation(IRemotingProgressMonitor monitor) {
|
52
|
// TODO Auto-generated method stub
|
53
|
|
54
|
}
|
55
|
|
56
|
@Override
|
57
|
public void addPages() {
|
58
|
addPage(page);
|
59
|
}
|
60
|
|
61
|
/**
|
62
|
* {@inheritDoc}
|
63
|
*/
|
64
|
@Override
|
65
|
public boolean performFinish() {
|
66
|
if (page.updateAgentBase){
|
67
|
cacheUpdaterConfig.getClassList().add(TeamOrPersonBase.class);
|
68
|
}
|
69
|
if (page.updateReference){
|
70
|
cacheUpdaterConfig.getClassList().add(Reference.class);
|
71
|
}
|
72
|
if (page.updateName){
|
73
|
cacheUpdaterConfig.getClassList().add(TaxonName.class);
|
74
|
}
|
75
|
if (page.updateTaxonBase){
|
76
|
cacheUpdaterConfig.getClassList().add(TaxonBase.class);
|
77
|
}
|
78
|
if (page.updateSpecimen){
|
79
|
cacheUpdaterConfig.getClassList().add(SpecimenOrObservationBase.class);
|
80
|
}
|
81
|
if (!cacheUpdaterConfig.getClassList().isEmpty()){
|
82
|
|
83
|
|
84
|
final UUID uuid = longRunningTaskService.monitLongRunningTask(cacheUpdaterConfig);
|
85
|
Display.getDefault().asyncExec(new Runnable() {
|
86
|
@Override
|
87
|
public void run() {
|
88
|
AbstractUtility.executeMoniteredOperation("Update Caches",
|
89
|
uuid,
|
90
|
1000,
|
91
|
false,
|
92
|
DatabaseRepairUpdateCachesWizard.this,
|
93
|
null,
|
94
|
true);
|
95
|
|
96
|
}
|
97
|
|
98
|
});
|
99
|
}
|
100
|
|
101
|
|
102
|
|
103
|
return true;
|
104
|
}
|
105
|
|
106
|
}
|