Revision 4e29c10f
Added by Andreas Kohlbecker about 5 years ago
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationWorkingsetPresenter.java | ||
---|---|---|
95 | 95 |
import eu.etaxonomy.vaadin.ui.navigation.NavigationEvent; |
96 | 96 |
import eu.etaxonomy.vaadin.ui.view.DoneWithPopupEvent; |
97 | 97 |
import eu.etaxonomy.vaadin.ui.view.DoneWithPopupEvent.Reason; |
98 |
import eu.etaxonomy.vaadin.ui.view.PopupView; |
|
98 | 99 |
|
99 | 100 |
/** |
100 | 101 |
* @author a.kohlbecker |
... | ... | |
356 | 357 |
} |
357 | 358 |
} |
358 | 359 |
|
359 |
@EventBusListenerMethod |
|
360 |
public void onDoneWithSpecimenTypeDesignationWorkingsetPopupEditor(DoneWithPopupEvent event) throws RegistrationValidationException{ |
|
361 |
if(event.getPopup() instanceof SpecimenTypeDesignationWorkingsetPopupEditor){ |
|
362 |
if(event.getReason().equals(Reason.SAVE)){ |
|
363 |
refreshView(true); |
|
364 |
} |
|
365 |
} |
|
366 |
} |
|
367 |
|
|
368 | 360 |
@EventBusListenerMethod(filter = EditorActionTypeFilter.Edit.class) |
369 | 361 |
public void onRegistrationEditorAction(RegistrationEditorAction event) { |
370 | 362 |
|
... | ... | |
439 | 431 |
* @throws RegistrationValidationException |
440 | 432 |
*/ |
441 | 433 |
@EventBusListenerMethod |
442 |
public void onDoneWithTaxonnameEditor(DoneWithPopupEvent event) throws RegistrationValidationException{
|
|
434 |
public void onDoneWithTaxonnameEditor(DoneWithPopupEvent event) { |
|
443 | 435 |
if(event.getPopup() instanceof TaxonNamePopupEditor){ |
436 |
Registration registration = null; |
|
437 |
boolean doRefreshView = false; |
|
444 | 438 |
if(newNameForRegistrationPopupEditor != null && event.getPopup().equals(newNameForRegistrationPopupEditor)){ |
445 | 439 |
if(event.getReason().equals(Reason.SAVE)){ |
446 | 440 |
try { |
447 | 441 |
TaxonName taxonName = newNameForRegistrationPopupEditor.getBean().cdmEntity(); |
448 |
registrationWorkflowService.createRegistration(taxonName, newNameBlockingRegistrations); |
|
442 |
registration = registrationWorkflowService.createRegistration(taxonName, newNameBlockingRegistrations);
|
|
449 | 443 |
loadWorkingSet(workingset.getCitationUuid()); |
450 |
refreshView(true); |
|
451 |
getView().getAddNewNameRegistrationButton().setEnabled(true); |
|
452 | 444 |
} finally { |
453 | 445 |
getRepo().getSession().clear(); // #7702 |
454 |
refreshView(true);
|
|
446 |
doRefreshView = true;
|
|
455 | 447 |
getView().getAddNewNameRegistrationButton().setEnabled(true); |
456 | 448 |
} |
457 | 449 |
} |
... | ... | |
459 | 451 |
newNameForRegistrationPopupEditor = null; |
460 | 452 |
newNameBlockingRegistrations.clear(); |
461 | 453 |
getView().getAddNewNameRegistrationButton().setEnabled(true); |
462 |
} else { |
|
463 |
refreshView(true); |
|
464 | 454 |
} |
455 |
|
|
456 |
if(registration == null){ |
|
457 |
// no new registration has been created above, so there must be an existing one. |
|
458 |
registration = findRegistrationInContext(event.getPopup()); |
|
459 |
} |
|
460 |
|
|
461 |
// Check if the other names used in the context of the name are registered yet. |
|
462 |
TaxonNamePopupEditor nameEditor = (TaxonNamePopupEditor)event.getPopup(); |
|
463 |
Set<TaxonName> namesToCheck = new HashSet<>(); |
|
464 |
|
|
465 |
namesToCheck.addAll(nameEditor.getBasionymComboboxSelect().getValue()); |
|
466 |
namesToCheck.addAll(nameEditor.getReplacedSynonymsComboboxSelect().getValue()); |
|
467 |
namesToCheck.add(nameEditor.getValidationField().getRelatedNameComboBox().getValue()); |
|
468 |
namesToCheck.add(nameEditor.getOrthographicVariantField().getRelatedNameComboBox().getValue()); |
|
469 |
|
|
470 |
for(TaxonName name : namesToCheck){ |
|
471 |
if(name != null){ |
|
472 |
doRefreshView |= registrationWorkflowService.addBlockingRegistration(name.getUuid(), registration) != null; |
|
473 |
} |
|
474 |
} |
|
475 |
|
|
476 |
refreshView(doRefreshView); |
|
465 | 477 |
} |
466 | 478 |
} |
467 | 479 |
|
... | ... | |
621 | 633 |
} |
622 | 634 |
} else if(event.getPopup() instanceof NameTypeDesignationPopupEditor){ |
623 | 635 |
if(event.getReason().equals(Reason.SAVE)){ |
636 |
|
|
637 |
Registration registration = null; |
|
638 |
boolean doRefreshView = false; |
|
639 |
|
|
624 | 640 |
UUID typeDesignationUuid = ((NameTypeDesignationPopupEditor)event.getPopup()).getBean().getUuid(); |
625 | 641 |
|
626 | 642 |
try { |
627 |
Stack<EditorActionContext>context = ((AbstractPopupEditor)event.getPopup()).getEditorActionContext(); |
|
628 |
Registration registration = findRegistrationInContext(context); |
|
643 |
registration = findRegistrationInContext(event.getPopup()); |
|
629 | 644 |
getRepo().getSession().clear(); |
630 | 645 |
registrationWorkflowService.addTypeDesignation(typeDesignationUuid, registration); |
631 | 646 |
nameTypeDesignationPopupEditorRegistrationUUIDMap.remove(event.getPopup()); |
632 | 647 |
} finally { |
633 | 648 |
getRepo().getSession().clear(); |
634 |
refreshView(true); |
|
649 |
doRefreshView = true; |
|
650 |
} |
|
651 |
|
|
652 |
if(registration == null){ |
|
653 |
// no new registration has been created above, so there must be an existing one. |
|
654 |
registration = findRegistrationInContext(event.getPopup()); |
|
655 |
} |
|
656 |
|
|
657 |
// Check if the other names used in the context of the name are registered yet. |
|
658 |
NameTypeDesignationPopupEditor nameEditor = (NameTypeDesignationPopupEditor)event.getPopup(); |
|
659 |
Set<TaxonName> namesToCheck = new HashSet<>(); |
|
660 |
|
|
661 |
namesToCheck.add(nameEditor.getTypeNameField().getValue()); |
|
662 |
|
|
663 |
for(TaxonName name : namesToCheck){ |
|
664 |
if(name != null){ |
|
665 |
doRefreshView |= registrationWorkflowService.addBlockingRegistration(name.getUuid(), registration) != null; |
|
666 |
} |
|
667 |
|
|
635 | 668 |
} |
669 |
|
|
670 |
refreshView(doRefreshView); |
|
671 |
|
|
636 | 672 |
} else if(event.getReason().equals(Reason.CANCEL)){ |
637 | 673 |
// noting to do |
638 | 674 |
} |
... | ... | |
727 | 763 |
} |
728 | 764 |
} |
729 | 765 |
|
766 |
public Registration findRegistrationInContext(PopupView popupView) { |
|
767 |
Stack<EditorActionContext>context = ((AbstractPopupEditor)popupView).getEditorActionContext(); |
|
768 |
return findRegistrationInContext(context); |
|
769 |
} |
|
730 | 770 |
/** |
731 | 771 |
* Finds the Registration in the EditorContext stack |
732 | 772 |
* |
Also available in: Unified diff
ref #8050 creating blocking registrations for exising names which are used in the context of another registration