Revision a1ab28ed
Added by Katja Luther over 6 years ago
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/operation/SetSecundumForSubtreeOperation.java | ||
---|---|---|
33 | 33 |
import eu.etaxonomy.cdm.api.application.CdmChangeEvent.Action; |
34 | 34 |
import eu.etaxonomy.cdm.api.service.ITaxonNodeService; |
35 | 35 |
import eu.etaxonomy.cdm.api.service.UpdateResult; |
36 |
import eu.etaxonomy.cdm.api.service.config.PublishForSubtreeConfigurator; |
|
36 | 37 |
import eu.etaxonomy.cdm.api.service.config.SecundumForSubtreeConfigurator; |
37 | 38 |
import eu.etaxonomy.cdm.common.monitor.IRemotingProgressMonitor; |
38 | 39 |
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper; |
... | ... | |
47 | 48 |
import eu.etaxonomy.taxeditor.navigation.l10n.Messages; |
48 | 49 |
import eu.etaxonomy.taxeditor.operation.IPostMoniteredOperationEnabled; |
49 | 50 |
import eu.etaxonomy.taxeditor.operation.RemotingCdmUpdateOperation; |
51 |
import eu.etaxonomy.taxeditor.ui.dialog.configurator.SetSecundumForSubtreeConfigurationWizard; |
|
50 | 52 |
|
51 | 53 |
/** |
52 | 54 |
* @author k.luther |
53 | 55 |
* @date 10.02.2017 |
54 | 56 |
* |
55 | 57 |
*/ |
56 |
public class SetSecundumForSubtreeOperation extends RemotingCdmUpdateOperation implements IPostMoniteredOperationEnabled{
|
|
57 |
|
|
58 |
private final static String LABEL = Messages.SetSecundumForSubtreeOperation_CHANGE_SEC_OP;
|
|
58 |
public class SetSecundumForSubtreeOperation extends UpdateSubtreeOperation implements IPostMoniteredOperationEnabled{
|
|
59 |
|
|
60 |
private final static String LABEL = Messages.SetSecundumForSubtreeOperation_CHANGE_SEC_OP;
|
|
59 | 61 |
private static final Logger logger = Logger |
60 | 62 |
.getLogger(SetSecundumForSubtreeOperation.class); |
61 |
UUID parentUuid; |
|
62 |
SecundumForSubtreeConfigurator config; |
|
63 |
EPartService partService; |
|
64 |
MPart activePart; |
|
65 |
MApplication application; |
|
66 |
|
|
63 |
|
|
67 | 64 |
@Inject |
68 | 65 |
UISynchronize sync; |
69 | 66 |
|
70 |
/** |
|
71 |
* @param label |
|
72 |
* @param action |
|
73 |
* @param source |
|
74 |
* @param async |
|
75 |
*/ |
|
76 |
public SetSecundumForSubtreeOperation(Object source, |
|
77 |
boolean async, |
|
78 |
UUID taxonNodeUuid, |
|
79 |
EPartService partService, |
|
80 |
MPart activePart, |
|
81 |
MApplication application, |
|
82 |
SecundumForSubtreeConfigurator config) { |
|
83 |
super(LABEL, Action.Update, source, async); |
|
84 |
parentUuid = taxonNodeUuid; |
|
85 |
this.config = config; |
|
86 |
this.updateResult = new UpdateResult(); |
|
87 |
this.partService= partService; |
|
88 |
this.activePart = activePart; |
|
89 |
this.application = application; |
|
90 |
} |
|
91 |
|
|
67 |
|
|
68 |
public SetSecundumForSubtreeOperation(Object source, boolean async, UUID taxonNodeUuid, EPartService partService, |
|
69 |
MPart activePart, MApplication application, SecundumForSubtreeConfigurator config) { |
|
70 |
super(source, async, taxonNodeUuid, partService, activePart, application, config, LABEL); |
|
71 |
|
|
72 |
} |
|
73 |
|
|
92 | 74 |
/** |
93 | 75 |
* {@inheritDoc} |
94 | 76 |
*/ |
... | ... | |
117 | 99 |
Job job = new Job(Messages.SetSecundumForSubtreeOperation_SET_SEC_TASK) { |
118 | 100 |
@Override |
119 | 101 |
protected IStatus run(IProgressMonitor monitor) { |
120 |
|
|
121 |
try { |
|
122 |
ITaxonNodeService taxonNodeService = CdmApplicationState.getService(ITaxonNodeService.class); |
|
123 |
TaxonNode subtreeNode = taxonNodeService.load(config.getSubtreeUuid()); |
|
124 |
updateResult = taxonNodeService.setSecundumForSubtree(config); |
|
125 |
|
|
126 |
for (CdmBase object: updateResult.getUpdatedObjects()){ |
|
127 |
Taxon taxon = null; |
|
128 |
TaxonNode node = null; |
|
129 |
if (object instanceof Taxon){ |
|
130 |
taxon = HibernateProxyHelper.deproxy(object, Taxon.class); |
|
131 |
node = taxon.getTaxonNode(subtreeNode.getClassification()); |
|
132 |
|
|
133 |
}else if (object instanceof Synonym){ |
|
134 |
Synonym syn = HibernateProxyHelper.deproxy(object, Synonym.class); |
|
135 |
taxon = syn.getAcceptedTaxon(); |
|
136 |
node = taxon.getTaxonNode(subtreeNode.getClassification()); |
|
137 |
} |
|
138 |
|
|
139 |
Display.getDefault().asyncExec(new Runnable() { |
|
140 |
public void run() { |
|
141 |
for (MPart part : partService.getParts()){ |
|
142 |
Object object = part.getObject(); |
|
143 |
if (object instanceof TaxonNameEditorE4){ |
|
144 |
Set<TaxonNode> nodes = ((TaxonNameEditorE4)object).getTaxon().getTaxonNodes(); |
|
145 |
for (TaxonNode node: nodes){ |
|
146 |
if (node.treeIndex().startsWith(subtreeNode.treeIndex())){ |
|
147 |
EditorUtil.updateEditor(node, partService, application); |
|
148 |
} |
|
149 |
|
|
150 |
} |
|
151 |
} |
|
152 |
} |
|
153 |
} |
|
154 |
}); |
|
155 |
} |
|
156 |
} catch (CdmApplicationException e) { |
|
157 |
// TODO Auto-generated catch block |
|
158 |
e.printStackTrace(); |
|
102 |
if (config instanceof SecundumForSubtreeConfigurator){ |
|
103 |
updateResult = taxonNodeService.setSecundumForSubtree((SecundumForSubtreeConfigurator)config); |
|
104 |
}else{ |
|
105 |
return Status.CANCEL_STATUS; |
|
159 | 106 |
} |
160 |
return Status.OK_STATUS; |
|
107 |
updateNameEditors(); |
|
108 |
return Status.OK_STATUS; |
|
161 | 109 |
|
162 | 110 |
} |
163 | 111 |
}; |
... | ... | |
170 | 118 |
try { |
171 | 119 |
nodeService = CdmApplicationState.getService(ITaxonNodeService.class); |
172 | 120 |
|
173 |
final UUID uuid = nodeService.monitSetSecundum(config); |
|
121 |
final UUID uuid = nodeService.monitSetSecundum((SecundumForSubtreeConfigurator)config);
|
|
174 | 122 |
Display.getDefault().asyncExec(new Runnable() { |
175 | 123 |
@Override |
176 | 124 |
public void run() { |
Also available in: Unified diff
fix #7065: update the nameEditors also after update publish flag