1
|
/**
|
2
|
* Copyright (C) 2017 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.cdm.vaadin.view.registration;
|
10
|
|
11
|
import java.util.ArrayList;
|
12
|
import java.util.EnumSet;
|
13
|
import java.util.List;
|
14
|
|
15
|
import org.springframework.beans.factory.annotation.Autowired;
|
16
|
import org.springframework.context.event.EventListener;
|
17
|
import org.springframework.security.core.Authentication;
|
18
|
import org.springframework.transaction.TransactionStatus;
|
19
|
|
20
|
import com.vaadin.spring.annotation.SpringComponent;
|
21
|
import com.vaadin.spring.annotation.ViewScope;
|
22
|
import com.vaadin.ui.Label;
|
23
|
import com.vaadin.ui.UI;
|
24
|
import com.vaadin.ui.VerticalLayout;
|
25
|
import com.vaadin.ui.Window;
|
26
|
|
27
|
import eu.etaxonomy.cdm.api.service.INameService;
|
28
|
import eu.etaxonomy.cdm.api.service.IRegistrationService;
|
29
|
import eu.etaxonomy.cdm.api.service.idminter.IdentifierMinter.Identifier;
|
30
|
import eu.etaxonomy.cdm.api.service.idminter.RegistrationIdentifierMinter;
|
31
|
import eu.etaxonomy.cdm.model.common.User;
|
32
|
import eu.etaxonomy.cdm.model.name.Rank;
|
33
|
import eu.etaxonomy.cdm.model.name.Registration;
|
34
|
import eu.etaxonomy.cdm.model.name.RegistrationStatus;
|
35
|
import eu.etaxonomy.cdm.model.name.TaxonName;
|
36
|
import eu.etaxonomy.cdm.model.name.TaxonNameFactory;
|
37
|
import eu.etaxonomy.cdm.model.name.TypeDesignationBase;
|
38
|
import eu.etaxonomy.cdm.model.reference.Reference;
|
39
|
import eu.etaxonomy.cdm.persistence.hibernate.permission.CRUD;
|
40
|
import eu.etaxonomy.cdm.persistence.hibernate.permission.Operation;
|
41
|
import eu.etaxonomy.cdm.service.CdmFilterablePagingProvider;
|
42
|
import eu.etaxonomy.cdm.service.CdmStore;
|
43
|
import eu.etaxonomy.cdm.service.IRegistrationWorkingSetService;
|
44
|
import eu.etaxonomy.cdm.vaadin.event.EntityChangeEvent;
|
45
|
import eu.etaxonomy.cdm.vaadin.event.ReferenceEditorAction;
|
46
|
import eu.etaxonomy.cdm.vaadin.event.RegistrationEditorAction;
|
47
|
import eu.etaxonomy.cdm.vaadin.event.ShowDetailsEvent;
|
48
|
import eu.etaxonomy.cdm.vaadin.event.TaxonNameEditorAction;
|
49
|
import eu.etaxonomy.cdm.vaadin.event.TypeDesignationWorkingsetEditorAction;
|
50
|
import eu.etaxonomy.cdm.vaadin.event.registration.RegistrationWorkingsetAction;
|
51
|
import eu.etaxonomy.cdm.vaadin.model.EntityReference;
|
52
|
import eu.etaxonomy.cdm.vaadin.model.registration.RegistrationWorkingSet;
|
53
|
import eu.etaxonomy.cdm.vaadin.security.UserHelper;
|
54
|
import eu.etaxonomy.cdm.vaadin.util.CdmTitleCacheCaptionGenerator;
|
55
|
import eu.etaxonomy.cdm.vaadin.util.converter.TypeDesignationSetManager.TypeDesignationWorkingSetType;
|
56
|
import eu.etaxonomy.cdm.vaadin.view.name.SpecimenTypeDesignationWorkingsetPopupEditor;
|
57
|
import eu.etaxonomy.cdm.vaadin.view.name.TaxonNamePopupEditor;
|
58
|
import eu.etaxonomy.cdm.vaadin.view.name.TaxonNamePopupEditorMode;
|
59
|
import eu.etaxonomy.cdm.vaadin.view.name.TypeDesignationWorkingsetEditorIdSet;
|
60
|
import eu.etaxonomy.cdm.vaadin.view.reference.ReferencePopupEditor;
|
61
|
import eu.etaxonomy.vaadin.mvp.AbstractPresenter;
|
62
|
import eu.etaxonomy.vaadin.ui.view.DoneWithPopupEvent;
|
63
|
import eu.etaxonomy.vaadin.ui.view.DoneWithPopupEvent.Reason;
|
64
|
|
65
|
/**
|
66
|
* @author a.kohlbecker
|
67
|
* @since Mar 3, 2017
|
68
|
*
|
69
|
*/
|
70
|
@SpringComponent
|
71
|
@ViewScope
|
72
|
public class RegistrationWorkingsetPresenter extends AbstractPresenter<RegistrationWorkingsetView> {
|
73
|
|
74
|
private static final long serialVersionUID = 1L;
|
75
|
|
76
|
@Autowired
|
77
|
private IRegistrationWorkingSetService workingSetService;
|
78
|
|
79
|
@Autowired
|
80
|
private RegistrationIdentifierMinter minter;
|
81
|
|
82
|
/**
|
83
|
* @return the workingSetService
|
84
|
*/
|
85
|
public IRegistrationWorkingSetService getWorkingSetService() {
|
86
|
return workingSetService;
|
87
|
}
|
88
|
|
89
|
private RegistrationWorkingSet workingset;
|
90
|
|
91
|
private TaxonName newTaxonNameForRegistration = null;
|
92
|
|
93
|
private RegistrationDTO newRegistrationDTOWithExistingName;
|
94
|
|
95
|
|
96
|
/**
|
97
|
*
|
98
|
*/
|
99
|
public RegistrationWorkingsetPresenter() {
|
100
|
}
|
101
|
|
102
|
|
103
|
/**
|
104
|
* Always create a new Store
|
105
|
*
|
106
|
* @return
|
107
|
*/
|
108
|
protected CdmStore<Registration, IRegistrationService> getRegistrationStore(){
|
109
|
return new CdmStore<Registration, IRegistrationService>(getRepo(), getRepo().getRegistrationService());
|
110
|
}
|
111
|
|
112
|
/**
|
113
|
* Always create a new Store
|
114
|
*
|
115
|
* @return
|
116
|
*/
|
117
|
protected CdmStore<TaxonName, INameService> getTaxonNameStore(){
|
118
|
return new CdmStore<TaxonName, INameService>(getRepo(), getRepo().getNameService());
|
119
|
}
|
120
|
|
121
|
|
122
|
/**
|
123
|
* @param taxonNameId
|
124
|
* @return
|
125
|
*/
|
126
|
protected Registration createNewRegistrationForName(Integer taxonNameId) {
|
127
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
128
|
// move into RegistrationWorkflowStateMachine
|
129
|
TransactionStatus txStatus = getRepo().startTransaction();
|
130
|
long identifier = System.currentTimeMillis();
|
131
|
|
132
|
Identifier<String> identifiers = minter.mint();
|
133
|
if(identifiers.getIdentifier() == null){
|
134
|
throw new RuntimeException("RegistrationIdentifierMinter configuration incomplete.");
|
135
|
}
|
136
|
Registration reg = Registration.NewInstance(
|
137
|
identifiers.getIdentifier(),
|
138
|
identifiers.getLocalId(),
|
139
|
taxonNameId != null ? getRepo().getNameService().find(taxonNameId) : null,
|
140
|
null);
|
141
|
Authentication authentication = currentSecurityContext().getAuthentication();
|
142
|
reg.setSubmitter((User)authentication.getPrincipal());
|
143
|
EntityChangeEvent event = getRegistrationStore().saveBean(reg);
|
144
|
UserHelper.fromSession().createAuthorityForCurrentUser(Registration.class, event.getEntityId(), Operation.UPDATE, RegistrationStatus.PREPARATION.name());
|
145
|
getRepo().commitTransaction(txStatus);
|
146
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
147
|
return getRepo().getRegistrationService().find(event.getEntityId());
|
148
|
}
|
149
|
|
150
|
|
151
|
/**
|
152
|
* @param doReload TODO
|
153
|
*
|
154
|
*/
|
155
|
protected void refreshView(boolean doReload) {
|
156
|
if(doReload){
|
157
|
loadWorkingSet(workingset.getCitationId());
|
158
|
}
|
159
|
getView().setWorkingset(workingset);
|
160
|
}
|
161
|
|
162
|
|
163
|
/**
|
164
|
* {@inheritDoc}
|
165
|
*/
|
166
|
@Override
|
167
|
public void handleViewEntered() {
|
168
|
|
169
|
super.handleViewEntered();
|
170
|
|
171
|
loadWorkingSet(getView().getCitationID());
|
172
|
getView().setWorkingset(workingset);
|
173
|
|
174
|
CdmFilterablePagingProvider<TaxonName, TaxonName> pagingProvider = new CdmFilterablePagingProvider<TaxonName, TaxonName>(
|
175
|
getRepo().getNameService());
|
176
|
CdmTitleCacheCaptionGenerator<TaxonName> titleCacheGenrator = new CdmTitleCacheCaptionGenerator<TaxonName>();
|
177
|
getView().getAddExistingNameCombobox().setCaptionGenerator(titleCacheGenrator);
|
178
|
getView().getAddExistingNameCombobox().loadFrom(pagingProvider, pagingProvider, pagingProvider.getPageSize());
|
179
|
}
|
180
|
|
181
|
|
182
|
/**
|
183
|
* @param referenceID
|
184
|
*/
|
185
|
protected void loadWorkingSet(Integer referenceID) {
|
186
|
try {
|
187
|
workingset = getWorkingSetService().loadWorkingSetByReferenceID(referenceID);
|
188
|
} catch (RegistrationValidationException error) {
|
189
|
logger.error(error);
|
190
|
Window errorDialog = new Window("Validation Error");
|
191
|
errorDialog.setModal(true);
|
192
|
VerticalLayout subContent = new VerticalLayout();
|
193
|
subContent.setMargin(true);
|
194
|
errorDialog.setContent(subContent);
|
195
|
subContent.addComponent(new Label(error.getMessage()));
|
196
|
UI.getCurrent().addWindow(errorDialog);
|
197
|
}
|
198
|
if(workingset == null || workingset.getCitationId() == null){
|
199
|
Reference citation = getRepo().getReferenceService().find(referenceID);
|
200
|
workingset = new RegistrationWorkingSet(citation);
|
201
|
}
|
202
|
}
|
203
|
|
204
|
@EventListener(condition = "#event.type == T(eu.etaxonomy.vaadin.event.EditorActionType).ADD")
|
205
|
public void onReferenceEditorActionAdd(ReferenceEditorAction event) {
|
206
|
|
207
|
if(!checkFromOwnView(event)){
|
208
|
return;
|
209
|
}
|
210
|
|
211
|
ReferencePopupEditor popup = getNavigationManager().showInPopup(ReferencePopupEditor.class);
|
212
|
popup.loadInEditor(null);
|
213
|
}
|
214
|
|
215
|
@EventListener(condition = "#event.type == T(eu.etaxonomy.vaadin.event.EditorActionType).EDIT")
|
216
|
public void onReferenceEditorActionEdit(ReferenceEditorAction event) {
|
217
|
|
218
|
if(!checkFromOwnView(event)){
|
219
|
return;
|
220
|
}
|
221
|
ReferencePopupEditor popup = getNavigationManager().showInPopup(ReferencePopupEditor.class);
|
222
|
popup.withDeleteButton(true);
|
223
|
popup.loadInEditor(event.getEntityId());
|
224
|
}
|
225
|
|
226
|
@EventListener(condition = "#event.type == T(eu.etaxonomy.vaadin.event.EditorActionType).EDIT")
|
227
|
public void onRegistrationEditorAction(RegistrationEditorAction event) {
|
228
|
|
229
|
if(!checkFromOwnView(event)){
|
230
|
return;
|
231
|
}
|
232
|
|
233
|
RegistrationPopupEditor popup = getNavigationManager().showInPopup(RegistrationPopupEditor.class);
|
234
|
popup.loadInEditor(event.getEntityId());
|
235
|
}
|
236
|
|
237
|
@EventListener(condition = "#event.type == T(eu.etaxonomy.vaadin.event.EditorActionType).EDIT")
|
238
|
public void onTaxonNameEditorActionEdit(TaxonNameEditorAction event) {
|
239
|
|
240
|
if(!checkFromOwnView(event)){
|
241
|
return;
|
242
|
}
|
243
|
|
244
|
TaxonNamePopupEditor popup = getNavigationManager().showInPopup(TaxonNamePopupEditor.class);
|
245
|
popup.withDeleteButton(true);
|
246
|
configureTaxonNameEditor(popup);
|
247
|
popup.loadInEditor(event.getEntityId());
|
248
|
if(event.getSourceComponent() != null){
|
249
|
popup.setReadOnly(event.getSourceComponent().isReadOnly());
|
250
|
}
|
251
|
|
252
|
}
|
253
|
|
254
|
|
255
|
@EventListener(condition = "#event.type == T(eu.etaxonomy.vaadin.event.EditorActionType).ADD")
|
256
|
public void onTaxonNameEditorActionAdd(TaxonNameEditorAction event) {
|
257
|
|
258
|
if(!checkFromOwnView(event)){
|
259
|
return;
|
260
|
}
|
261
|
|
262
|
newTaxonNameForRegistration = TaxonNameFactory.NewBotanicalInstance(Rank.SPECIES());
|
263
|
newTaxonNameForRegistration.setNomenclaturalReference(getRepo().getReferenceService().find(workingset.getCitationId()));
|
264
|
EntityChangeEvent nameSaveEvent = getTaxonNameStore().saveBean(newTaxonNameForRegistration);
|
265
|
newTaxonNameForRegistration = getRepo().getNameService().find(nameSaveEvent.getEntityId());
|
266
|
TaxonNamePopupEditor popup = getNavigationManager().showInPopup(TaxonNamePopupEditor.class);
|
267
|
popup.grantToCurrentUser(EnumSet.of(CRUD.UPDATE,CRUD.DELETE));
|
268
|
popup.withDeleteButton(true);
|
269
|
configureTaxonNameEditor(popup);
|
270
|
popup.loadInEditor(newTaxonNameForRegistration.getId());
|
271
|
}
|
272
|
|
273
|
/**
|
274
|
* TODO consider putting this into a Configurer Bean per UIScope.
|
275
|
* In the configurator bean this methods popup papamerter should be of the type
|
276
|
* AbstractPopupEditor
|
277
|
*
|
278
|
* @param popup
|
279
|
*/
|
280
|
protected void configureTaxonNameEditor(TaxonNamePopupEditor popup) {
|
281
|
popup.enableMode(TaxonNamePopupEditorMode.suppressReplacementAuthorshipData);
|
282
|
popup.enableMode(TaxonNamePopupEditorMode.nomenclaturalReferenceSectionEditingOnly);
|
283
|
}
|
284
|
|
285
|
/**
|
286
|
* Creates a new <code>Registration</code> for a new name that has just been edited
|
287
|
* using the <code>TaxonNamePopupEditor</code>. The new name was previously created
|
288
|
* in this presenter as <code>newTaxonNameForRegistration</code> (see {@link #onTaxonNameEditorActionAdd(TaxonNameEditorAction)})
|
289
|
* and is either filled with data (<code>Reason.SAVE</code>) or it is still empty
|
290
|
* (<code>Reason.CANCEL</code>).
|
291
|
*
|
292
|
*
|
293
|
* @param event
|
294
|
* @throws RegistrationValidationException
|
295
|
*/
|
296
|
@EventListener
|
297
|
public void onDoneWithTaxonnameEditor(DoneWithPopupEvent event) throws RegistrationValidationException{
|
298
|
if(event.getPopup() instanceof TaxonNamePopupEditor){
|
299
|
TransactionStatus txStatus = getRepo().startTransaction();
|
300
|
if(event.getReason().equals(Reason.SAVE)){
|
301
|
if(newTaxonNameForRegistration != null){
|
302
|
int taxonNameId = newTaxonNameForRegistration.getId();
|
303
|
getRepo().getSession().refresh(newTaxonNameForRegistration);
|
304
|
Registration reg = createNewRegistrationForName(taxonNameId);
|
305
|
// reload workingset into current session
|
306
|
loadWorkingSet(workingset.getCitationId());
|
307
|
workingset.add(reg);
|
308
|
}
|
309
|
refreshView(true);
|
310
|
} else if(event.getReason().equals(Reason.CANCEL)){
|
311
|
if(newTaxonNameForRegistration != null){
|
312
|
// clean up
|
313
|
getTaxonNameStore().deleteBean(newTaxonNameForRegistration);
|
314
|
}
|
315
|
}
|
316
|
getRepo().commitTransaction(txStatus);
|
317
|
newTaxonNameForRegistration = null;
|
318
|
}
|
319
|
}
|
320
|
|
321
|
|
322
|
/**
|
323
|
* Creates a new Registration for an exiting (previously published name).
|
324
|
*
|
325
|
* @param event
|
326
|
* @throws RegistrationValidationException
|
327
|
*/
|
328
|
@EventListener(condition = "#event.action == T(eu.etaxonomy.cdm.vaadin.event.registration.RegistrationWorkingsetAction.Action).start")
|
329
|
public void onRegistrationWorkflowEventActionStart(RegistrationWorkingsetAction event) throws RegistrationValidationException {
|
330
|
|
331
|
getView().getAddExistingNameCombobox().commit();
|
332
|
TaxonName typifiedName = getView().getAddExistingNameCombobox().getValue();
|
333
|
if(typifiedName != null){
|
334
|
Registration newRegistrationWithExistingName = createNewRegistrationForName(null);
|
335
|
Reference citation = getRepo().getReferenceService().find(workingset.getCitationId());
|
336
|
newRegistrationDTOWithExistingName = new RegistrationDTO(newRegistrationWithExistingName, typifiedName, citation);
|
337
|
workingset.add(newRegistrationDTOWithExistingName);
|
338
|
// tell the view to update the workingset
|
339
|
getView().setWorkingset(workingset);
|
340
|
getView().getAddExistingNameRegistrationButton().setEnabled(false);
|
341
|
getView().getAddExistingNameRegistrationButton().setDescription("You first need to add a type designation to the previously created registration.");
|
342
|
} else {
|
343
|
logger.error("Seletced name is NULL");
|
344
|
}
|
345
|
|
346
|
}
|
347
|
|
348
|
@EventListener(condition = "#event.type == T(eu.etaxonomy.vaadin.event.EditorActionType).EDIT")
|
349
|
public void onTypeDesignationsEditorActionEdit(TypeDesignationWorkingsetEditorAction event) {
|
350
|
|
351
|
if(!checkFromOwnView(event)){
|
352
|
return;
|
353
|
}
|
354
|
|
355
|
if(event.getWorkingSetType() == TypeDesignationWorkingSetType.SPECIMEN_TYPE_DESIGNATION_WORKINGSET ){
|
356
|
SpecimenTypeDesignationWorkingsetPopupEditor popup = getNavigationManager().showInPopup(SpecimenTypeDesignationWorkingsetPopupEditor.class);
|
357
|
popup.withDeleteButton(true);
|
358
|
popup.loadInEditor(new TypeDesignationWorkingsetEditorIdSet(event.getRegistrationId(), event.getEntityId()));
|
359
|
if(event.getSourceComponent() != null){
|
360
|
popup.setReadOnly(event.getSourceComponent().isReadOnly());
|
361
|
}
|
362
|
} else {
|
363
|
// TypeDesignationWorkingSetType.NAME_TYPE_DESIGNATION_WORKINGSET
|
364
|
// FIXME implement NameTypeDesignationWorkingsetPopupEditor
|
365
|
}
|
366
|
}
|
367
|
|
368
|
@EventListener(condition = "#event.type == T(eu.etaxonomy.vaadin.event.EditorActionType).ADD && #event.sourceComponent == null")
|
369
|
public void onAddNewTypeDesignationWorkingset(TypeDesignationWorkingsetEditorAction event) {
|
370
|
|
371
|
if(event.getWorkingSetType() == TypeDesignationWorkingSetType.SPECIMEN_TYPE_DESIGNATION_WORKINGSET){
|
372
|
SpecimenTypeDesignationWorkingsetPopupEditor popup = getNavigationManager().showInPopup(SpecimenTypeDesignationWorkingsetPopupEditor.class);
|
373
|
TypeDesignationWorkingsetEditorIdSet identifierSet;
|
374
|
Integer typifiedNameId;
|
375
|
if(newRegistrationDTOWithExistingName != null){
|
376
|
typifiedNameId = newRegistrationDTOWithExistingName.getTypifiedNameRef().getId();
|
377
|
} else {
|
378
|
RegistrationDTO registrationDTO = workingset.getRegistrationDTO(event.getRegistrationId()).get();
|
379
|
EntityReference typifiedNameRef = registrationDTO.getTypifiedNameRef();
|
380
|
if(typifiedNameRef != null){
|
381
|
// case for registrations without name, in which case the typifiedName is only defined via the typedesignations
|
382
|
typifiedNameId = typifiedNameRef.getId();
|
383
|
} else {
|
384
|
// case of registrations with a name in the nomenclatural act.
|
385
|
typifiedNameId = registrationDTO.getNameRef().getId();
|
386
|
}
|
387
|
}
|
388
|
identifierSet = new TypeDesignationWorkingsetEditorIdSet(
|
389
|
event.getRegistrationId(),
|
390
|
getView().getCitationID(),
|
391
|
typifiedNameId
|
392
|
);
|
393
|
popup.grantToCurrentUser(EnumSet.of(CRUD.UPDATE, CRUD.DELETE));
|
394
|
popup.loadInEditor(identifierSet);
|
395
|
popup.withDeleteButton(true);
|
396
|
} else {
|
397
|
// TypeDesignationWorkingSetType.NAME_TYPE_DESIGNATION_WORKINGSET
|
398
|
// FIXME implement NameTypeDesignationWorkingsetPopupEditor
|
399
|
}
|
400
|
}
|
401
|
|
402
|
/**
|
403
|
* Performs final actions after a TypeDesignationEditor which has been
|
404
|
* opened to add a TypeDesignation to a Registration object which was
|
405
|
* created for an previously published name. Prior adding a typedesignation,
|
406
|
* the according Registration object is dangling, that has no association to
|
407
|
* any entity denoting an nomenclatural act which has a reference to a
|
408
|
* publication. This means that the registration object is not in the
|
409
|
* working set.
|
410
|
*
|
411
|
*
|
412
|
* @param event
|
413
|
* @throws RegistrationValidationException
|
414
|
*/
|
415
|
@EventListener
|
416
|
public void onDoneWithTypeDesignationEditor(DoneWithPopupEvent event) throws RegistrationValidationException{
|
417
|
if(event.getPopup() instanceof SpecimenTypeDesignationWorkingsetPopupEditor){
|
418
|
if(event.getReason().equals(Reason.SAVE)){
|
419
|
refreshView(true);
|
420
|
} else if(event.getReason().equals(Reason.CANCEL)){
|
421
|
// clean up
|
422
|
if(newRegistrationDTOWithExistingName != null){
|
423
|
getRegistrationStore().deleteBean(newRegistrationDTOWithExistingName.registration());
|
424
|
}
|
425
|
}
|
426
|
// set newRegistrationDTOWithExistingName NULL in any case
|
427
|
newRegistrationDTOWithExistingName = null;
|
428
|
}
|
429
|
}
|
430
|
|
431
|
|
432
|
@EventListener(classes=ShowDetailsEvent.class, condition = "#event.type == T(eu.etaxonomy.cdm.vaadin.model.registration.RegistrationWorkingSet)")
|
433
|
public void onShowRegistrationWorkingSetMessages(ShowDetailsEvent<?,?> event) { // WARNING don't use more specific generic type arguments
|
434
|
List<String> messages = new ArrayList<>();
|
435
|
for(RegistrationDTO dto : workingset.getRegistrationDTOs()){
|
436
|
dto.getMessages().forEach(m -> messages.add(dto.getSummary() + ": " + m));
|
437
|
}
|
438
|
if(event.getProperty().equals("messages")){
|
439
|
getView().openDetailsPopup("Messages", messages);
|
440
|
}
|
441
|
}
|
442
|
|
443
|
@EventListener(classes=ShowDetailsEvent.class, condition = "#event.type == T(eu.etaxonomy.cdm.vaadin.view.registration.RegistrationDTO)")
|
444
|
public void onShowRegistrationMessages(ShowDetailsEvent<?,?> event) { // WARNING don't use more specific generic type arguments
|
445
|
RegistrationDTO regDto = workingSetService.loadDtoById((Integer)event.getIdentifier());
|
446
|
if(event.getProperty().equals("messages")){
|
447
|
if(getView() != null){
|
448
|
getView().openDetailsPopup("Messages", regDto.getMessages());
|
449
|
}
|
450
|
}
|
451
|
}
|
452
|
|
453
|
@EventListener
|
454
|
public void onEntityChangeEvent(EntityChangeEvent event){
|
455
|
if(workingset == null){
|
456
|
return;
|
457
|
}
|
458
|
if(Reference.class.isAssignableFrom(event.getEntityType())){
|
459
|
if(workingset.getCitationId().equals(event.getEntityId())){
|
460
|
refreshView(true);
|
461
|
}
|
462
|
} else
|
463
|
if(Registration.class.isAssignableFrom(event.getEntityType())){
|
464
|
if(workingset.getRegistrations().stream().anyMatch(reg -> reg.getId() == event.getEntityId())){
|
465
|
refreshView(true);
|
466
|
}
|
467
|
} else
|
468
|
if(TaxonName.class.isAssignableFrom(event.getEntityType())){
|
469
|
if(workingset.getRegistrationDTOs().stream().anyMatch(reg ->
|
470
|
reg.getTypifiedNameRef() != null
|
471
|
&& reg.getTypifiedNameRef().getId() == event.getEntityId())){
|
472
|
refreshView(true);
|
473
|
}
|
474
|
} else
|
475
|
if(TypeDesignationBase.class.isAssignableFrom(event.getEntityType())){
|
476
|
if(workingset.getRegistrationDTOs().stream().anyMatch(
|
477
|
reg -> reg.getTypeDesignations().stream().anyMatch(
|
478
|
td -> td.getId() == event.getEntityId()
|
479
|
)
|
480
|
)
|
481
|
){
|
482
|
refreshView(true);
|
483
|
}
|
484
|
}
|
485
|
|
486
|
}
|
487
|
|
488
|
}
|