Revision c320e0fa
Added by Andreas Kohlbecker over 5 years ago
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationWorkingsetPresenter.java | ||
---|---|---|
759 | 759 |
EditorActionContext rootContext = context.get(0); |
760 | 760 |
if(rootContext.getParentView().equals(getView()) && event.getSourceView() != newNameForRegistrationPopupEditor){ |
761 | 761 |
|
762 |
// create a blocking registration, the new Registration will be persisted |
|
763 |
UUID taxonNameUUID = event.getEntityUuid(); |
|
764 |
Registration blockingRegistration = getRepo().getRegistrationService().createRegistrationForName(taxonNameUUID); |
|
765 |
|
|
766 |
if(context.get(1).getParentView() instanceof TaxonNamePopupEditor && !((TaxonNamePopupEditor)context.get(1).getParentView()).getBean().cdmEntity().isPersited()){ |
|
767 |
// Oha!! The event came from a popup editor and the |
|
768 |
// first popup in the context is a TaxonNameEditor with un-persisted name |
|
769 |
// This is a name for a new registration which has not yet been created. |
|
770 |
// It is necessary to store blocking registrations in the newNameBlockingRegistrations |
|
771 |
newNameBlockingRegistrations.add(blockingRegistration); |
|
772 |
logger.debug("Blocking registration created and memorized"); |
|
773 |
} else { |
|
774 |
// some new name related somehow to an existing registration |
|
775 |
TypedEntityReference<Registration> regReference = (TypedEntityReference<Registration>)rootContext.getParentEntity(); |
|
776 |
RegistrationDTO registrationDTO = workingset.getRegistrationDTO(regReference.getUuid()).get(); |
|
777 |
Registration registration = registrationDTO.registration(); |
|
778 |
if(registration == null){ |
|
779 |
throw new NullPointerException("Registration not found for " + regReference + " which has been hold in the rootContext"); |
|
762 |
try { |
|
763 |
getRepo().getSession().clear(); |
|
764 |
TransactionStatus txStatus = getRepo().startTransaction(); |
|
765 |
// create a blocking registration, the new Registration will be persisted |
|
766 |
UUID taxonNameUUID = event.getEntityUuid(); |
|
767 |
Registration blockingRegistration = getRepo().getRegistrationService().createRegistrationForName(taxonNameUUID); |
|
768 |
|
|
769 |
if(context.get(1).getParentView() instanceof TaxonNamePopupEditor && !((TaxonNamePopupEditor)context.get(1).getParentView()).getBean().cdmEntity().isPersited()){ |
|
770 |
// Oha!! The event came from a popup editor and the |
|
771 |
// first popup in the context is a TaxonNameEditor with un-persisted name |
|
772 |
// This is a name for a new registration which has not yet been created. |
|
773 |
// It is necessary to store blocking registrations in the newNameBlockingRegistrations |
|
774 |
newNameBlockingRegistrations.add(blockingRegistration); |
|
775 |
logger.debug("Blocking registration created and memorized"); |
|
776 |
} else { |
|
777 |
// some new name related somehow to an existing registration |
|
778 |
TypedEntityReference<Registration> regReference = (TypedEntityReference<Registration>)rootContext.getParentEntity(); |
|
779 |
RegistrationDTO registrationDTO = workingset.getRegistrationDTO(regReference.getUuid()).get(); |
|
780 |
Registration registration = registrationDTO.registration(); |
|
781 |
|
|
782 |
registration = getRepo().getRegistrationService().load(registration.getUuid()); |
|
783 |
if(registration == null){ |
|
784 |
throw new NullPointerException("Registration not found for " + regReference + " which has been hold in the rootContext"); |
|
785 |
} |
|
786 |
registration.getBlockedBy().add(blockingRegistration); |
|
787 |
getRepo().getRegistrationService().saveOrUpdate(registration); |
|
788 |
getRepo().commitTransaction(txStatus); |
|
789 |
logger.debug("Blocking registration created and added to registion"); |
|
780 | 790 |
} |
781 |
registration.getBlockedBy().add(blockingRegistration); |
|
782 |
getRepo().getRegistrationService().saveOrUpdate(registration); |
|
783 |
logger.debug("Blocking registration created and added to registion"); |
|
791 |
} finally { |
|
792 |
getRepo().getSession().clear(); |
|
784 | 793 |
} |
785 | 794 |
} else { |
786 | 795 |
// in case of creating a new name for a registration the parent view is the TaxonNamePopupEditor |
Also available in: Unified diff
fix #7842 reloading registration before adding blocking registrations