1
|
package eu.etaxonomy.taxeditor.navigation.navigator.operation;
|
2
|
|
3
|
import java.util.ArrayList;
|
4
|
import java.util.List;
|
5
|
import java.util.UUID;
|
6
|
|
7
|
import org.eclipse.e4.ui.model.application.MApplication;
|
8
|
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
|
9
|
import org.eclipse.e4.ui.workbench.modeling.EModelService;
|
10
|
import org.eclipse.e4.ui.workbench.modeling.EPartService;
|
11
|
|
12
|
import eu.etaxonomy.cdm.api.application.CdmApplicationState;
|
13
|
import eu.etaxonomy.cdm.api.application.CdmChangeEvent.Action;
|
14
|
import eu.etaxonomy.cdm.api.longrunningService.ILongRunningTasksService;
|
15
|
import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
|
16
|
import eu.etaxonomy.cdm.api.service.UpdateResult;
|
17
|
import eu.etaxonomy.cdm.api.service.config.ForSubtreeConfiguratorBase;
|
18
|
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
|
19
|
import eu.etaxonomy.cdm.model.common.CdmBase;
|
20
|
import eu.etaxonomy.cdm.model.taxon.Synonym;
|
21
|
import eu.etaxonomy.cdm.model.taxon.Taxon;
|
22
|
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
|
23
|
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
|
24
|
import eu.etaxonomy.taxeditor.event.EventUtility;
|
25
|
import eu.etaxonomy.taxeditor.event.WorkbenchEventConstants;
|
26
|
import eu.etaxonomy.taxeditor.operation.RemotingCdmUpdateOperation;
|
27
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
28
|
|
29
|
public abstract class UpdateSubtreeOperation extends RemotingCdmUpdateOperation {
|
30
|
|
31
|
ForSubtreeConfiguratorBase config;
|
32
|
|
33
|
UUID parentUuid;
|
34
|
|
35
|
TaxonNode subtreeNode;
|
36
|
ITaxonNodeService taxonNodeService;
|
37
|
ILongRunningTasksService longRunningTaskService;
|
38
|
|
39
|
protected EModelService modelService = null;
|
40
|
|
41
|
public UpdateSubtreeOperation(Object source,
|
42
|
boolean async,
|
43
|
UUID taxonNodeUuid,
|
44
|
EPartService partService,
|
45
|
MPart activePart,
|
46
|
MApplication application,
|
47
|
EModelService modelService,
|
48
|
ForSubtreeConfiguratorBase config,
|
49
|
String label) {
|
50
|
super(label, Action.Update, source, async, partService, activePart, application);
|
51
|
parentUuid = taxonNodeUuid;
|
52
|
this.config = config;
|
53
|
this.updateResult = new UpdateResult();
|
54
|
this.modelService = modelService;
|
55
|
longRunningTaskService = CdmApplicationState.getLongRunningTasksService();
|
56
|
subtreeNode = CdmStore.getService(ITaxonNodeService.class).load(config.getSubtreeUuid());
|
57
|
}
|
58
|
public void updateNameEditors(){
|
59
|
|
60
|
EventUtility.postEvent(WorkbenchEventConstants.REFRESH_NAME_EDITOR, true);
|
61
|
|
62
|
List<TaxonBase> taxaToUpdate = new ArrayList();
|
63
|
for (CdmBase object: updateResult.getUpdatedObjects()){
|
64
|
TaxonBase taxonBase = null;
|
65
|
TaxonNode node = null;
|
66
|
if (object instanceof Taxon){
|
67
|
taxonBase = HibernateProxyHelper.deproxy(object, Taxon.class);
|
68
|
|
69
|
}else {
|
70
|
taxonBase = HibernateProxyHelper.deproxy(object, Synonym.class);
|
71
|
|
72
|
}
|
73
|
taxaToUpdate.add(taxonBase);
|
74
|
|
75
|
}
|
76
|
|
77
|
//for (TaxonBase taxon: taxaToUpdate){
|
78
|
EventUtility.postEvent(WorkbenchEventConstants.REFRESH_NAME_EDITOR, taxaToUpdate);
|
79
|
//}
|
80
|
|
81
|
|
82
|
|
83
|
}
|
84
|
|
85
|
}
|