Revision 0844524a
Added by Andreas Kohlbecker almost 6 years ago
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationWorkingsetPresenter.java | ||
---|---|---|
150 | 150 |
* @param taxonNameId |
151 | 151 |
* @return |
152 | 152 |
*/ |
153 |
protected Registration createNewRegistrationForName(Integer taxonNameId) {
|
|
153 |
protected Registration createNewRegistrationForName(UUID taxonNameUuid) {
|
|
154 | 154 |
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
155 | 155 |
// move into RegistrationWorkflowStateMachine |
156 | 156 |
TransactionStatus txStatus = getRepo().startTransaction(); |
... | ... | |
162 | 162 |
Registration reg = Registration.NewInstance( |
163 | 163 |
identifiers.getIdentifier(), |
164 | 164 |
identifiers.getLocalId(), |
165 |
taxonNameId != null ? getRepo().getNameService().find(taxonNameId) : null,
|
|
165 |
taxonNameUuid != null ? getRepo().getNameService().find(taxonNameUuid) : null,
|
|
166 | 166 |
null); |
167 | 167 |
Authentication authentication = currentSecurityContext().getAuthentication(); |
168 | 168 |
reg.setSubmitter((User)authentication.getPrincipal()); |
169 | 169 |
EntityChangeEvent event = getRegistrationStore().saveBean(reg, (AbstractView) getView()); |
170 |
UserHelper.fromSession().createAuthorityForCurrentUser(Registration.class, event.getEntityId(), Operation.UPDATE, RegistrationStatus.PREPARATION.name());
|
|
170 |
UserHelper.fromSession().createAuthorityForCurrentUser(Registration.class, event.getEntityUuid(), Operation.UPDATE, RegistrationStatus.PREPARATION.name());
|
|
171 | 171 |
getRepo().commitTransaction(txStatus); |
172 | 172 |
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
173 |
return getRepo().getRegistrationService().load(event.getEntityId(), Arrays.asList(new String []{"blockedBy"}));
|
|
173 |
return getRepo().getRegistrationService().load(event.getEntityUuid(), Arrays.asList(new String []{"blockedBy"}));
|
|
174 | 174 |
} |
175 | 175 |
|
176 | 176 |
|
... | ... | |
183 | 183 |
return; // nothing to do |
184 | 184 |
} |
185 | 185 |
if(doReload){ |
186 |
loadWorkingSet(workingset.getCitationId());
|
|
186 |
loadWorkingSet(workingset.getCitationUuid());
|
|
187 | 187 |
} |
188 | 188 |
getView().setWorkingset(workingset); |
189 | 189 |
} |
... | ... | |
197 | 197 |
|
198 | 198 |
super.handleViewEntered(); |
199 | 199 |
|
200 |
loadWorkingSet(getView().getCitationID());
|
|
200 |
loadWorkingSet(getView().getCitationUuid());
|
|
201 | 201 |
getView().setWorkingset(workingset); |
202 | 202 |
|
203 | 203 |
// PagingProviders and CacheGenerator for the existingNameCombobox |
... | ... | |
209 | 209 |
|
210 | 210 |
// update the messages |
211 | 211 |
User user = UserHelper.fromSession().user(); |
212 |
for (Integer registrationId : getView().getRegistrationItemMap().keySet()) {
|
|
213 |
Button messageButton = getView().getRegistrationItemMap().get(registrationId).regItemButtons.getMessagesButton();
|
|
212 |
for (UUID registrationUuid : getView().getRegistrationItemMap().keySet()) {
|
|
213 |
Button messageButton = getView().getRegistrationItemMap().get(registrationUuid).regItemButtons.getMessagesButton();
|
|
214 | 214 |
|
215 |
RegistrationDTO regDto = workingset.getRegistrationDTO(registrationId).get();
|
|
215 |
RegistrationDTO regDto = workingset.getRegistrationDTO(registrationUuid).get();
|
|
216 | 216 |
try { |
217 | 217 |
int messageCount = messageService.countActiveMessagesFor(regDto.registration(), user); |
218 | 218 |
|
... | ... | |
248 | 248 |
/** |
249 | 249 |
* @param referenceID |
250 | 250 |
*/ |
251 |
protected void loadWorkingSet(Integer referenceID) {
|
|
251 |
protected void loadWorkingSet(UUID referenceUuid) {
|
|
252 | 252 |
try { |
253 |
workingset = getWorkingSetService().loadWorkingSetByReferenceID(referenceID);
|
|
253 |
workingset = getWorkingSetService().loadWorkingSetByReferenceUuid(referenceUuid);
|
|
254 | 254 |
} catch (RegistrationValidationException error) { |
255 | 255 |
logger.error(error); |
256 | 256 |
Window errorDialog = new Window("Validation Error"); |
... | ... | |
261 | 261 |
subContent.addComponent(new Label(error.getMessage())); |
262 | 262 |
UI.getCurrent().addWindow(errorDialog); |
263 | 263 |
} |
264 |
if(workingset == null || workingset.getCitationId() == null){
|
|
265 |
Reference citation = getRepo().getReferenceService().find(referenceID);
|
|
264 |
if(workingset == null || workingset.getCitationUuid() == null){
|
|
265 |
Reference citation = getRepo().getReferenceService().find(referenceUuid);
|
|
266 | 266 |
workingset = new RegistrationWorkingSet(citation); |
267 | 267 |
} |
268 | 268 |
} |
... | ... | |
289 | 289 |
ReferencePopupEditor popup = getNavigationManager().showInPopup(ReferencePopupEditor.class, getView()); |
290 | 290 |
popup.withReferenceTypes(RegistrationUIDefaults.PRINTPUB_REFERENCE_TYPES); |
291 | 291 |
popup.withDeleteButton(true); |
292 |
popup.loadInEditor(event.getEntityId());
|
|
292 |
popup.loadInEditor(event.getEntityUuid());
|
|
293 | 293 |
} |
294 | 294 |
|
295 | 295 |
@EventBusListenerMethod |
... | ... | |
318 | 318 |
} |
319 | 319 |
|
320 | 320 |
RegistrationPopupEditor popup = getNavigationManager().showInPopup(RegistrationPopupEditor.class, getView()); |
321 |
popup.loadInEditor(event.getEntityId());
|
|
321 |
popup.loadInEditor(event.getEntityUuid());
|
|
322 | 322 |
} |
323 | 323 |
|
324 | 324 |
@EventBusListenerMethod(filter = EditorActionTypeFilter.Edit.class) |
... | ... | |
332 | 332 |
popup.setParentEditorActionContext(event.getContext()); |
333 | 333 |
popup.withDeleteButton(true); |
334 | 334 |
configureTaxonNameEditor(popup); |
335 |
popup.loadInEditor(event.getEntityId());
|
|
335 |
popup.loadInEditor(event.getEntityUuid());
|
|
336 | 336 |
if(event.getSourceComponent() != null){ |
337 | 337 |
popup.setReadOnly(event.getSourceComponent().isReadOnly()); |
338 | 338 |
} |
... | ... | |
348 | 348 |
} |
349 | 349 |
|
350 | 350 |
newTaxonNameForRegistration = TaxonNameFactory.NewNameInstance(RegistrationUIDefaults.NOMENCLATURAL_CODE, Rank.SPECIES()); |
351 |
newTaxonNameForRegistration.setNomenclaturalReference(getRepo().getReferenceService().find(workingset.getCitationId()));
|
|
351 |
newTaxonNameForRegistration.setNomenclaturalReference(getRepo().getReferenceService().find(workingset.getCitationUuid()));
|
|
352 | 352 |
EntityChangeEvent nameSaveEvent = getTaxonNameStore().saveBean(newTaxonNameForRegistration, (AbstractView) getView()); |
353 |
newTaxonNameForRegistration = getRepo().getNameService().find(nameSaveEvent.getEntityId());
|
|
353 |
newTaxonNameForRegistration = getRepo().getNameService().find(nameSaveEvent.getEntityUuid());
|
|
354 | 354 |
TaxonNamePopupEditor popup = getNavigationManager().showInPopup(TaxonNamePopupEditor.class, getView()); |
355 | 355 |
popup.setParentEditorActionContext(event.getContext()); |
356 | 356 |
popup.grantToCurrentUser(EnumSet.of(CRUD.UPDATE,CRUD.DELETE)); |
357 | 357 |
popup.withDeleteButton(true); |
358 | 358 |
configureTaxonNameEditor(popup); |
359 |
popup.loadInEditor(newTaxonNameForRegistration.getId());
|
|
359 |
popup.loadInEditor(newTaxonNameForRegistration.getUuid());
|
|
360 | 360 |
} |
361 | 361 |
|
362 | 362 |
/** |
... | ... | |
389 | 389 |
TransactionStatus txStatus = getRepo().startTransaction(); |
390 | 390 |
if(event.getReason().equals(Reason.SAVE)){ |
391 | 391 |
if(newTaxonNameForRegistration != null){ |
392 |
int taxonNameId = newTaxonNameForRegistration.getId();
|
|
392 |
UUID taxonNameUuid = newTaxonNameForRegistration.getUuid();
|
|
393 | 393 |
getRepo().getSession().refresh(newTaxonNameForRegistration); |
394 |
Registration reg = createNewRegistrationForName(taxonNameId);
|
|
394 |
Registration reg = createNewRegistrationForName(taxonNameUuid);
|
|
395 | 395 |
// reload workingset into current session |
396 |
loadWorkingSet(workingset.getCitationId());
|
|
396 |
loadWorkingSet(workingset.getCitationUuid());
|
|
397 | 397 |
workingset.add(reg); |
398 | 398 |
} |
399 | 399 |
refreshView(true); |
... | ... | |
426 | 426 |
TaxonName typifiedName = getView().getAddExistingNameCombobox().getValue(); |
427 | 427 |
if(typifiedName != null){ |
428 | 428 |
Registration newRegistrationWithExistingName = createNewRegistrationForName(null); |
429 |
Reference citation = getRepo().getReferenceService().find(workingset.getCitationId());
|
|
429 |
Reference citation = getRepo().getReferenceService().find(workingset.getCitationUuid());
|
|
430 | 430 |
newRegistrationDTOWithExistingName = new RegistrationDTO(newRegistrationWithExistingName, typifiedName, citation); |
431 | 431 |
workingset.add(newRegistrationDTOWithExistingName); |
432 | 432 |
// tell the view to update the workingset |
... | ... | |
451 | 451 |
SpecimenTypeDesignationWorkingsetPopupEditor popup = getNavigationManager().showInPopup(SpecimenTypeDesignationWorkingsetPopupEditor.class, getView()); |
452 | 452 |
popup.setParentEditorActionContext(event.getContext()); |
453 | 453 |
popup.withDeleteButton(true); |
454 |
popup.loadInEditor(new TypeDesignationWorkingsetEditorIdSet(event.getRegistrationId(), event.getBaseEntityRef()));
|
|
454 |
popup.loadInEditor(new TypeDesignationWorkingsetEditorIdSet(event.getRegistrationUuid(), event.getBaseEntityRef()));
|
|
455 | 455 |
if(event.getSourceComponent() != null){ |
456 | 456 |
// propagate readonly state from source component to popup |
457 | 457 |
popup.setReadOnly(event.getSourceComponent().isReadOnly()); |
... | ... | |
460 | 460 |
NameTypeDesignationPopupEditor popup = getNavigationManager().showInPopup(NameTypeDesignationPopupEditor.class, getView()); |
461 | 461 |
popup.setParentEditorActionContext(event.getContext()); |
462 | 462 |
popup.withDeleteButton(true); |
463 |
popup.loadInEditor(new TypeDesignationWorkingsetEditorIdSet(event.getRegistrationId(), event.getBaseEntityRef()));
|
|
463 |
popup.loadInEditor(new TypeDesignationWorkingsetEditorIdSet(event.getRegistrationUuid(), event.getBaseEntityRef()));
|
|
464 | 464 |
|
465 | 465 |
popup.getCitationCombobox().setEnabled(false); |
466 | 466 |
popup.getTypifiedNamesComboboxSelect().setEnabled(false); |
... | ... | |
469 | 469 |
// propagate readonly state from source component to popup |
470 | 470 |
popup.setReadOnly(event.getSourceComponent().isReadOnly()); |
471 | 471 |
} |
472 |
newNameTypeDesignationTarget = workingset.getRegistrationDTO(event.getRegistrationId()).get();
|
|
472 |
newNameTypeDesignationTarget = workingset.getRegistrationDTO(event.getRegistrationUuid()).get();
|
|
473 | 473 |
} |
474 | 474 |
} |
475 | 475 |
|
... | ... | |
484 | 484 |
SpecimenTypeDesignationWorkingsetPopupEditor popup = getNavigationManager().showInPopup(SpecimenTypeDesignationWorkingsetPopupEditor.class, getView()); |
485 | 485 |
popup.setParentEditorActionContext(event.getContext()); |
486 | 486 |
TypeDesignationWorkingsetEditorIdSet identifierSet; |
487 |
Integer typifiedNameId;
|
|
487 |
UUID typifiedNameUuid;
|
|
488 | 488 |
if(newRegistrationDTOWithExistingName != null){ |
489 |
typifiedNameId = newRegistrationDTOWithExistingName.getTypifiedNameRef().getId();
|
|
489 |
typifiedNameUuid = newRegistrationDTOWithExistingName.getTypifiedNameRef().getUuid();
|
|
490 | 490 |
} else { |
491 |
RegistrationDTO registrationDTO = workingset.getRegistrationDTO(event.getRegistrationId()).get();
|
|
491 |
RegistrationDTO registrationDTO = workingset.getRegistrationDTO(event.getRegistrationUuid()).get();
|
|
492 | 492 |
EntityReference typifiedNameRef = registrationDTO.getTypifiedNameRef(); |
493 | 493 |
if(typifiedNameRef != null){ |
494 | 494 |
// case for registrations without name, in which case the typifiedName is only defined via the typedesignations |
495 |
typifiedNameId = typifiedNameRef.getId();
|
|
495 |
typifiedNameUuid = typifiedNameRef.getUuid();
|
|
496 | 496 |
} else { |
497 | 497 |
// case of registrations with a name in the nomenclatural act. |
498 |
typifiedNameId = registrationDTO.getNameRef().getId();
|
|
498 |
typifiedNameUuid = registrationDTO.getNameRef().getUuid();
|
|
499 | 499 |
} |
500 | 500 |
} |
501 | 501 |
identifierSet = new TypeDesignationWorkingsetEditorIdSet( |
502 |
event.getRegistrationId(),
|
|
503 |
getView().getCitationID(),
|
|
504 |
typifiedNameId
|
|
502 |
event.getRegistrationUuid(),
|
|
503 |
getView().getCitationUuid(),
|
|
504 |
typifiedNameUuid
|
|
505 | 505 |
); |
506 | 506 |
popup.grantToCurrentUser(EnumSet.of(CRUD.UPDATE, CRUD.DELETE)); |
507 | 507 |
popup.loadInEditor(identifierSet); |
... | ... | |
515 | 515 |
popup.setParentEditorActionContext(event.getContext()); |
516 | 516 |
popup.withDeleteButton(true); |
517 | 517 |
popup.grantToCurrentUser(EnumSet.of(CRUD.UPDATE, CRUD.DELETE)); |
518 |
newNameTypeDesignationTarget = workingset.getRegistrationDTO(event.getRegistrationId()).get();
|
|
518 |
newNameTypeDesignationTarget = workingset.getRegistrationDTO(event.getRegistrationUuid()).get();
|
|
519 | 519 |
popup.setBeanInstantiator(new BeanInstantiator<NameTypeDesignation>() { |
520 | 520 |
|
521 | 521 |
@Override |
522 | 522 |
public NameTypeDesignation createNewBean() { |
523 | 523 |
|
524 |
TaxonName typifiedName = getRepo().getNameService().load(event.getTypifiedNameId(), Arrays.asList(new String[]{"typeDesignations", "homotypicalGroup"}));
|
|
524 |
TaxonName typifiedName = getRepo().getNameService().load(event.getTypifiedNameUuid(), Arrays.asList(new String[]{"typeDesignations", "homotypicalGroup"}));
|
|
525 | 525 |
NameTypeDesignation nameTypeDesignation = NameTypeDesignation.NewInstance(); |
526 | 526 |
nameTypeDesignation.setCitation(newNameTypeDesignationTarget.getCitation()); |
527 | 527 |
nameTypeDesignation.getTypifiedNames().add(typifiedName); |
... | ... | |
603 | 603 |
return; |
604 | 604 |
} |
605 | 605 |
if(Reference.class.isAssignableFrom(event.getEntityType())){ |
606 |
if(workingset.getCitationId().equals(event.getEntityId())){
|
|
606 |
if(workingset.getCitationUuid().equals(event.getEntityUuid())){
|
|
607 | 607 |
refreshView(true); |
608 | 608 |
} |
609 | 609 |
} else |
610 | 610 |
if(Registration.class.isAssignableFrom(event.getEntityType())){ |
611 |
if(workingset.getRegistrations().stream().anyMatch(reg -> reg.getId() == event.getEntityId())){
|
|
611 |
if(workingset.getRegistrations().stream().anyMatch(reg -> reg.getUuid() == event.getEntityUuid())){
|
|
612 | 612 |
refreshView(true); |
613 | 613 |
} |
614 | 614 |
} else |
... | ... | |
618 | 618 |
Stack<EditorActionContext>context = ((AbstractPopupEditor)event.getSourceView()).getEditorActionContext(); |
619 | 619 |
EditorActionContext rootContext = context.get(0); |
620 | 620 |
if(rootContext.getParentView().equals(getView())){ |
621 |
Registration blockingRegistration = createNewRegistrationForName(event.getEntityId());
|
|
621 |
Registration blockingRegistration = createNewRegistrationForName(event.getEntityUuid());
|
|
622 | 622 |
TypedEntityReference<Registration> regReference = (TypedEntityReference<Registration>)rootContext.getParentEntity(); |
623 |
Registration registration = getRepo().getRegistrationService().load(regReference.getId(), Arrays.asList("$", "blockedBy"));
|
|
623 |
Registration registration = getRepo().getRegistrationService().load(regReference.getUuid(), Arrays.asList("$", "blockedBy"));
|
|
624 | 624 |
registration.getBlockedBy().add(blockingRegistration); |
625 | 625 |
getRepo().getRegistrationService().saveOrUpdate(registration); |
626 | 626 |
logger.debug("Blocking registration created"); |
... | ... | |
630 | 630 |
} |
631 | 631 |
if(workingset.getRegistrationDTOs().stream().anyMatch(reg -> |
632 | 632 |
reg.getTypifiedNameRef() != null |
633 |
&& reg.getTypifiedNameRef().getId() == event.getEntityId())){
|
|
633 |
&& reg.getTypifiedNameRef().getUuid().equals(event.getEntityUuid()))){
|
|
634 | 634 |
refreshView(true); |
635 | 635 |
} |
636 | 636 |
} else |
637 | 637 |
if(TypeDesignationBase.class.isAssignableFrom(event.getEntityType())){ |
638 | 638 |
if(workingset.getRegistrationDTOs().stream().anyMatch( |
639 | 639 |
reg -> reg.getTypeDesignations() != null && reg.getTypeDesignations().stream().anyMatch( |
640 |
td -> td.getId() == event.getEntityId()
|
|
640 |
td -> td.getUuid() == event.getEntityUuid()
|
|
641 | 641 |
) |
642 | 642 |
) |
643 | 643 |
){ |
... | ... | |
648 | 648 |
|
649 | 649 |
|
650 | 650 |
@EventBusListenerMethod(filter = ShowDetailsEventEntityTypeFilter.RegistrationDTO.class) |
651 |
public void onShowDetailsEventForRegistrationDTO(ShowDetailsEvent<RegistrationDTO, Integer> event) {
|
|
651 |
public void onShowDetailsEventForRegistrationDTO(ShowDetailsEvent<RegistrationDTO, UUID> event) {
|
|
652 | 652 |
|
653 | 653 |
// FIXME check from own view!!! |
654 | 654 |
if(getView() == null){ |
655 | 655 |
return; |
656 | 656 |
} |
657 | 657 |
|
658 |
Integer registrationId = event.getIdentifier();
|
|
658 |
UUID registrationUuid = event.getIdentifier();
|
|
659 | 659 |
|
660 |
RegistrationDTO regDto = getWorkingSetService().loadDtoById(registrationId);
|
|
660 |
RegistrationDTO regDto = getWorkingSetService().loadDtoByUuid(registrationUuid);
|
|
661 | 661 |
if(event.getProperty().equals(RegistrationItem.BLOCKED_BY)){ |
662 | 662 |
|
663 |
Set<RegistrationDTO> blockingRegs = getWorkingSetService().loadBlockingRegistrations(registrationId);
|
|
664 |
getView().setBlockingRegistrations(registrationId, blockingRegs);
|
|
663 |
Set<RegistrationDTO> blockingRegs = getWorkingSetService().loadBlockingRegistrations(registrationUuid);
|
|
664 |
getView().setBlockingRegistrations(registrationUuid, blockingRegs);
|
|
665 | 665 |
} else if(event.getProperty().equals(RegistrationItem.MESSAGES)){ |
666 | 666 |
|
667 | 667 |
RegistrationMessagesPopup popup = getNavigationManager().showInPopup(RegistrationMessagesPopup.class, getView()); |
668 |
popup.loadMessagesFor(regDto.getId());
|
|
668 |
popup.loadMessagesFor(regDto.getUuid());
|
|
669 | 669 |
|
670 | 670 |
} else if(event.getProperty().equals(RegistrationItem.VALIDATION_PROBLEMS)){ |
671 | 671 |
getView().openDetailsPopup("Validation Problems", regDto.getValidationProblems()); |
Also available in: Unified diff
switching vom id based to uuid based ui navigation and entity references