Project

General

Profile

Revision 510ac6e7

ID510ac6e7a4c8ebf46906c5d7b2fe5047942b0d58
Parent 5055127f
Child c8dd76ae

Added by Andreas Kohlbecker about 2 years ago

ref #7630 fixing creation of blocking relations (part 2) and assuring registrations have an identifier when saved

View differences:

src/main/java/eu/etaxonomy/cdm/vaadin/ui/config/TaxonNamePopupEditorConfig.java
1
/**
2
* Copyright (C) 2018 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.cdm.vaadin.ui.config;
10

  
11
import eu.etaxonomy.cdm.vaadin.view.name.TaxonNamePopupEditorMode;
12
import eu.etaxonomy.cdm.vaadin.view.name.TaxonNamePopupEditorView;
13

  
14
/**
15
 * @author a.kohlbecker
16
 * @since Sep 25, 2018
17
 *
18
 */
19
public class TaxonNamePopupEditorConfig {
20

  
21
    /**
22
     * Configures the TaxonNamePopupEditorView for nomenclatural act editing.
23
     *
24
     * TODO consider putting this into a Configurer Bean per UIScope.
25
     * In the configurator bean this methods popup parameter should be of the type
26
     * AbstractPopupEditor
27
     *
28
     * @param popup
29
     */
30
    public static void configureForNomenclaturalAct(TaxonNamePopupEditorView popup) {
31
        popup.enableMode(TaxonNamePopupEditorMode.AUTOFILL_AUTHORSHIP_DATA);
32
        popup.enableMode(TaxonNamePopupEditorMode.NOMENCLATURALREFERENCE_SECTION_EDITING_ONLY);
33
        popup.enableMode(TaxonNamePopupEditorMode.VALIDATE_AGAINST_HIGHER_NAME_PART);
34
        // popup.enableMode(TaxonNamePopupEditorMode.REQUIRE_NOMENCLATURALREFERENCE);
35
    }
36

  
37
    /**
38
     * Configures the TaxonNamePopupEditorView for general purpose editing.
39
     *
40
     * @param popup
41
     */
42
    public static void configure(TaxonNamePopupEditorView popup) {
43
        popup.enableMode(TaxonNamePopupEditorMode.AUTOFILL_AUTHORSHIP_DATA);
44
        popup.enableMode(TaxonNamePopupEditorMode.VALIDATE_AGAINST_HIGHER_NAME_PART);
45
        // popup.enableMode(TaxonNamePopupEditorMode.REQUIRE_NOMENCLATURALREFERENCE);
46
    }
47

  
48
}
src/main/java/eu/etaxonomy/cdm/vaadin/view/name/NameTypeDesignationPresenter.java
42 42
import eu.etaxonomy.cdm.vaadin.event.TaxonNameEditorAction;
43 43
import eu.etaxonomy.cdm.vaadin.event.ToOneRelatedEntityButtonUpdater;
44 44
import eu.etaxonomy.cdm.vaadin.event.ToOneRelatedEntityReloader;
45
import eu.etaxonomy.cdm.vaadin.ui.config.TaxonNamePopupEditorConfig;
45 46
import eu.etaxonomy.cdm.vaadin.util.CdmTitleCacheCaptionGenerator;
46 47
import eu.etaxonomy.vaadin.mvp.AbstractCdmEditorPresenter;
47 48
import eu.etaxonomy.vaadin.mvp.AbstractView;
......
256 257
        TaxonNamePopupEditor typeNamePopup = openPopupEditor(TaxonNamePopupEditor.class, action);
257 258
        typeNamePopup.grantToCurrentUser(EnumSet.of(CRUD.UPDATE, CRUD.DELETE));
258 259
        typeNamePopup.withDeleteButton(true);
259
        // TODO configure Modes???
260
        TaxonNamePopupEditorConfig.configure(typeNamePopup);
260 261
        typeNamePopup.loadInEditor(null);
261 262

  
262 263
    }
......
272 273
        TaxonNamePopupEditor typeNamePopup = openPopupEditor(TaxonNamePopupEditor.class, action);
273 274
        typeNamePopup.grantToCurrentUser(EnumSet.of(CRUD.UPDATE, CRUD.DELETE));
274 275
        typeNamePopup.withDeleteButton(true);
275
        // TODO configure Modes???
276
        TaxonNamePopupEditorConfig.configure(typeNamePopup);
276 277
        typeNamePopup.loadInEditor(action.getEntityUuid());
277 278

  
278 279
    }
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationWorkingsetPresenter.java
81 81
import eu.etaxonomy.cdm.vaadin.permission.RolesAndPermissions;
82 82
import eu.etaxonomy.cdm.vaadin.theme.EditValoTheme;
83 83
import eu.etaxonomy.cdm.vaadin.ui.RegistrationUIDefaults;
84
import eu.etaxonomy.cdm.vaadin.ui.config.TaxonNamePopupEditorConfig;
84 85
import eu.etaxonomy.cdm.vaadin.util.CdmTitleCacheCaptionGenerator;
86
import eu.etaxonomy.cdm.vaadin.view.name.NameTypeDesignationEditorView;
85 87
import eu.etaxonomy.cdm.vaadin.view.name.NameTypeDesignationPopupEditor;
86 88
import eu.etaxonomy.cdm.vaadin.view.name.SpecimenTypeDesignationWorkingsetPopupEditor;
87 89
import eu.etaxonomy.cdm.vaadin.view.name.TaxonNamePopupEditor;
88
import eu.etaxonomy.cdm.vaadin.view.name.TaxonNamePopupEditorMode;
89
import eu.etaxonomy.cdm.vaadin.view.name.TaxonNamePopupEditorView;
90 90
import eu.etaxonomy.cdm.vaadin.view.name.TypeDesignationWorkingsetEditorIdSet;
91 91
import eu.etaxonomy.cdm.vaadin.view.reference.ReferencePopupEditor;
92 92
import eu.etaxonomy.vaadin.mvp.AbstractPopupEditor;
......
418 418
        TaxonNamePopupEditor popup = openPopupEditor(TaxonNamePopupEditor.class, event);
419 419
        popup.setParentEditorActionContext(event.getContext());
420 420
        popup.withDeleteButton(true);
421
        configureTaxonNameEditor(popup);
421
        TaxonNamePopupEditorConfig.configureForNomenclaturalAct(popup);
422 422
        popup.loadInEditor(event.getEntityUuid());
423 423
        if(event.hasSource() && event.getSource().isReadOnly()){
424 424
            // avoid resetting readonly to false
......
444 444
        popup.setParentEditorActionContext(event.getContext());
445 445
        popup.grantToCurrentUser(EnumSet.of(CRUD.UPDATE,CRUD.DELETE));
446 446
        popup.withDeleteButton(true);
447
        configureTaxonNameEditor(popup);
447
        TaxonNamePopupEditorConfig.configureForNomenclaturalAct(popup);
448 448
        popup.loadInEditor(newTaxonNameForRegistration.getUuid());
449 449
    }
450 450

  
451 451
    /**
452
     * TODO consider putting this into a Configurer Bean per UIScope.
453
     * In the configurator bean this methods popup papamerter should be of the type
454
     * AbstractPopupEditor
455
     *
456
     * @param popup
457
     */
458
    protected void configureTaxonNameEditor(TaxonNamePopupEditorView popup) {
459
        popup.enableMode(TaxonNamePopupEditorMode.AUTOFILL_AUTHORSHIP_DATA);
460
        popup.enableMode(TaxonNamePopupEditorMode.NOMENCLATURALREFERENCE_SECTION_EDITING_ONLY);
461
        popup.enableMode(TaxonNamePopupEditorMode.VALIDATE_AGAINST_HIGHER_NAME_PART);
462
        // popup.enableMode(TaxonNamePopupEditorMode.REQUIRE_NOMENCLATURALREFERENCE);
463
    }
464

  
465
    /**
466 452
     * Creates a new <code>Registration</code> for a new name that has just been edited
467 453
     * using the <code>TaxonNamePopupEditor</code>. The new name was previously created
468 454
     * in this presenter as <code>newTaxonNameForRegistration</code> (see {@link #onTaxonNameEditorActionAdd(TaxonNameEditorAction)})
......
736 722
                if(rootContext.getParentView().equals(getView())){
737 723
                    Registration blockingRegistration = getRepo().getRegistrationService().createRegistrationForName(event.getEntityUuid());
738 724
                    TypedEntityReference<Registration> regReference = (TypedEntityReference<Registration>)rootContext.getParentEntity();
739
                    Registration registration = getRepo().getRegistrationService().load(regReference.getUuid(), REGISTRATION_INIT_STRATEGY);
725
//                    Registration registration = getRepo().getRegistrationService().load(regReference.getUuid(), REGISTRATION_INIT_STRATEGY);
726
//                    if(registration == null){
727
                    Registration registration = null;
728
                        for(int i = context.size()-1; i>0; i--){
729
                            if(NameTypeDesignationEditorView.class.isAssignableFrom(context.elementAt(i).getParentView().getClass())){
730
                                UUID registrationUUID = nameTypeDesignationPopupEditorRegistrationUUIDMap.get(context.elementAt(i).getParentView());
731
                                RegistrationDTO registrationDTO = workingset.getRegistrationDTO(registrationUUID).get();
732
                                registration = registrationDTO.registration();
733
                            }
734
                        }
735
                        if(registration == null){
736
                            throw new NullPointerException("Registration not found for the NameTypeDesignation");
737
                        }
738
//                    }
740 739
                    registration.getBlockedBy().add(blockingRegistration);
741 740
                    getRepo().getRegistrationService().saveOrUpdate(registration);
742 741
                    logger.debug("Blocking registration created");

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)