Project

General

Profile

« Previous | Next » 

Revision 7095e8e3

Added by Andreas Kohlbecker almost 5 years ago

fix #8246 fixing handling of CANCEL events of TaxonNameEditors in the RegistrationWorkingsetPresenter

View differences:

src/main/java/eu/etaxonomy/cdm/vaadin/event/error/DelegatingErrorHandler.java
59 59
    @Override
60 60
    public void error(ErrorEvent event) {
61 61

  
62
        boolean handlerFound = true;
63 62
        Throwable throwable = event.getThrowable();
64 63
        while(throwable != null && (
65 64
                RpcInvocationException.class.isAssignableFrom(throwable.getClass()) ||
......
77 76
            }
78 77
            throwable = throwable.getCause();
79 78
        }
80
        if(!handlerFound){
79
        if(event.getThrowable() != null){
81 80
            Notification.show(event.getThrowable().getMessage());
82 81
          }
83 82
    }
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationWorkingsetPresenter.java
417 417
        }
418 418

  
419 419
        if(event.getPopup() instanceof TaxonNamePopupEditor){
420
            Registration registration = null;
421
            if(newNameForRegistrationPopupEditor != null && event.getPopup().equals(newNameForRegistrationPopupEditor)){
422
                if(event.getReason().equals(Reason.SAVE)){
423
                    try {
424
                        TaxonName taxonName = newNameForRegistrationPopupEditor.getBean().cdmEntity();
425
                        registration = registrationWorkflowService.createRegistration(taxonName, newNameBlockingRegistrations);
426
                        loadWorkingSet(workingset.getCitationUuid());
427
                    } finally {
428
                        clearSession();
429
                        getView().getAddNewNameRegistrationButton().setEnabled(true);
420

  
421
                Registration registration = null;
422
                if(newNameForRegistrationPopupEditor != null && event.getPopup().equals(newNameForRegistrationPopupEditor)){
423
                    if(event.getReason().equals(Reason.SAVE)){
424
                        try {
425
                            TaxonName taxonName = newNameForRegistrationPopupEditor.getBean().cdmEntity();
426
                            registration = registrationWorkflowService.createRegistration(taxonName, newNameBlockingRegistrations);
427
                            loadWorkingSet(workingset.getCitationUuid());
428
                        } finally {
429
                            clearSession();
430
                            getView().getAddNewNameRegistrationButton().setEnabled(true);
431
                        }
430 432
                    }
433
                    // nullify and clear the memory on this popup editor in any case (SAVE, DELETE, CANCEL)
434
                    newNameForRegistrationPopupEditor = null;
435
                    newNameBlockingRegistrations.clear();
436
                    getView().getAddNewNameRegistrationButton().setEnabled(true);
431 437
                }
432
                // nullify and clear the memory on this popup editor in any case (SAVE, CANCEL, DELETE)
433
                newNameForRegistrationPopupEditor = null;
434
                newNameBlockingRegistrations.clear();
435
                getView().getAddNewNameRegistrationButton().setEnabled(true);
436
            }
437 438

  
438
            if(registration == null){
439
                // no new registration has been created above, so there must be an existing one.
440
                registration = findRegistrationInContext(event.getPopup());
441
            }
439
                if(event.getReason().equals(Reason.SAVE)){
440
                    if(registration == null){
441
                        // no new registration has been created above, so there must be an existing one.
442
                        registration = findRegistrationInContext(event.getPopup());
443
                    }
442 444

  
443
            // Check if the other names used in the context of the name are registered yet.
444
            TaxonNamePopupEditor nameEditor = (TaxonNamePopupEditor)event.getPopup();
445
            Set<TaxonName> namesToCheck = new HashSet<>();
445
                    // Check if the other names used in the context of the name are registered yet.
446
                    TaxonNamePopupEditor nameEditor = (TaxonNamePopupEditor)event.getPopup();
447
                    Set<TaxonName> namesToCheck = new HashSet<>();
446 448

  
447
            namesToCheck.addAll(nameEditor.getBasionymComboboxSelect().getValue());
448
            namesToCheck.addAll(nameEditor.getReplacedSynonymsComboboxSelect().getValue());
449
            namesToCheck.add(nameEditor.getValidationField().getRelatedNameComboBox().getValue());
450
            namesToCheck.add(nameEditor.getOrthographicVariantField().getRelatedNameComboBox().getValue());
449
                    namesToCheck.addAll(nameEditor.getBasionymComboboxSelect().getValue());
450
                    namesToCheck.addAll(nameEditor.getReplacedSynonymsComboboxSelect().getValue());
451
                    namesToCheck.add(nameEditor.getValidationField().getRelatedNameComboBox().getValue());
452
                    namesToCheck.add(nameEditor.getOrthographicVariantField().getRelatedNameComboBox().getValue());
451 453

  
452
            for(TaxonName name : namesToCheck){
453
                if(name != null){
454
                    clearSession();
455
                    registrationWorkflowService.addBlockingRegistration(name.getUuid(), registration);
454
                    for(TaxonName name : namesToCheck){
455
                        if(name != null){
456
                            clearSession();
457
                            registrationWorkflowService.addBlockingRegistration(name.getUuid(), registration);
458
                        }
459
                    }
460
                } else if (event.getReason().equals(Reason.DELETE)){
461
                    //FIXME handle delete: need to remove blocking registrations?
456 462
                }
457
            }
458

  
459
            // always reload if the first editor is closed as the data might have been changed through any other sub-popupeditor
460
            refreshView(isAtContextRoot(event.getPopup()));
463
                // always reload if the first editor is closed as the data might have been changed through any other sub-popupeditor
464
                refreshView(isAtContextRoot(event.getPopup()));
461 465
        }
462 466
    }
463 467

  

Also available in: Unified diff