Project

General

Profile

« Previous | Next » 

Revision 8af7fcc2

Added by Andreas Kohlbecker about 5 years ago

ref #8050 creating blocking registrations for exising names which are used in the context of another registration

View differences:

src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationWorkingsetPresenter.java
94 94
import eu.etaxonomy.vaadin.ui.navigation.NavigationEvent;
95 95
import eu.etaxonomy.vaadin.ui.view.DoneWithPopupEvent;
96 96
import eu.etaxonomy.vaadin.ui.view.DoneWithPopupEvent.Reason;
97
import eu.etaxonomy.vaadin.ui.view.PopupView;
97 98

  
98 99
/**
99 100
 * @author a.kohlbecker
......
340 341
        }
341 342
    }
342 343

  
343
    @EventBusListenerMethod
344
    public void onDoneWithSpecimenTypeDesignationWorkingsetPopupEditor(DoneWithPopupEvent event) throws RegistrationValidationException{
345
        if(event.getPopup() instanceof SpecimenTypeDesignationWorkingsetPopupEditor){
346
            if(event.getReason().equals(Reason.SAVE)){
347
                refreshView(true);
348
            }
349
        }
350
    }
351

  
352 344
    @EventBusListenerMethod(filter = EditorActionTypeFilter.Edit.class)
353 345
    public void onRegistrationEditorAction(RegistrationEditorAction event) {
354 346

  
......
423 415
     * @throws RegistrationValidationException
424 416
     */
425 417
    @EventBusListenerMethod
426
    public void onDoneWithTaxonnameEditor(DoneWithPopupEvent event) throws RegistrationValidationException{
418
    public void onDoneWithTaxonnameEditor(DoneWithPopupEvent event) {
427 419
        if(event.getPopup() instanceof TaxonNamePopupEditor){
420
            Registration registration = null;
421
            boolean doRefreshView = false;
428 422
            if(newNameForRegistrationPopupEditor != null && event.getPopup().equals(newNameForRegistrationPopupEditor)){
429 423
                if(event.getReason().equals(Reason.SAVE)){
430 424
                    try {
431 425
                        TaxonName taxonName = newNameForRegistrationPopupEditor.getBean().cdmEntity();
432
                        registrationWorkflowService.createRegistration(taxonName, newNameBlockingRegistrations);
426
                        registration = registrationWorkflowService.createRegistration(taxonName, newNameBlockingRegistrations);
433 427
                        loadWorkingSet(workingset.getCitationUuid());
434
                        refreshView(true);
435
                        getView().getAddNewNameRegistrationButton().setEnabled(true);
436 428
                    } finally {
437 429
                        clearSession();
438
                        refreshView(true);
430
                        doRefreshView = true;
439 431
                        getView().getAddNewNameRegistrationButton().setEnabled(true);
440 432
                    }
441 433
                }
......
443 435
                newNameForRegistrationPopupEditor = null;
444 436
                newNameBlockingRegistrations.clear();
445 437
                getView().getAddNewNameRegistrationButton().setEnabled(true);
446
            } else {
447
                refreshView(true);
448 438
            }
439

  
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
            }
444

  
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<>();
448

  
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());
453

  
454
            for(TaxonName name : namesToCheck){
455
                if(name != null){
456
                    doRefreshView |= registrationWorkflowService.addBlockingRegistration(name.getUuid(), registration) != null;
457
                }
458
            }
459

  
460
            refreshView(doRefreshView);
449 461
        }
450 462
    }
451 463

  
......
605 617
            }
606 618
        } else if(event.getPopup() instanceof NameTypeDesignationPopupEditor){
607 619
            if(event.getReason().equals(Reason.SAVE)){
620

  
621
                Registration registration = null;
622
                boolean doRefreshView = false;
623

  
608 624
                UUID typeDesignationUuid = ((NameTypeDesignationPopupEditor)event.getPopup()).getBean().getUuid();
609 625

  
610 626
                try {
611 627
                    clearSession();
612
                    Stack<EditorActionContext>context = ((AbstractPopupEditor)event.getPopup()).getEditorActionContext();
613
                    Registration registration = findRegistrationInContext(context);
614 628
                    getRepo().getSession().clear();
615 629
                    registrationWorkflowService.addTypeDesignation(typeDesignationUuid, registration);
616 630
                    nameTypeDesignationPopupEditorRegistrationUUIDMap.remove(event.getPopup());
617 631
                } finally {
618 632
                    clearSession();
619
                    refreshView(true);
633
                    doRefreshView = true;
634
                }
635

  
636
                if(registration == null){
637
                    // no new registration has been created above, so there must be an existing one.
638
                    registration = findRegistrationInContext(event.getPopup());
639
                }
640

  
641
                // Check if the other names used in the context of the name are registered yet.
642
                NameTypeDesignationPopupEditor nameEditor = (NameTypeDesignationPopupEditor)event.getPopup();
643
                Set<TaxonName> namesToCheck = new HashSet<>();
644

  
645
                namesToCheck.add(nameEditor.getTypeNameField().getValue());
646

  
647
                for(TaxonName name : namesToCheck){
648
                    if(name != null){
649
                        doRefreshView |= registrationWorkflowService.addBlockingRegistration(name.getUuid(), registration) != null;
650
                    }
651

  
620 652
                }
653

  
654
                refreshView(doRefreshView);
655

  
621 656
            } else if(event.getReason().equals(Reason.CANCEL)){
622 657
                // noting to do
623 658
            }
......
719 754
        }
720 755
    }
721 756

  
757
    public Registration findRegistrationInContext(PopupView popupView) {
758
        Stack<EditorActionContext>context = ((AbstractPopupEditor)popupView).getEditorActionContext();
759
        return findRegistrationInContext(context);
760
    }
722 761
    /**
723 762
     * Finds the Registration in the EditorContext stack
724 763
     *

Also available in: Unified diff