Project

General

Profile

Download (24.7 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2017 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.view.name;
10

    
11
import java.util.Arrays;
12
import java.util.EnumSet;
13
import java.util.List;
14
import java.util.UUID;
15

    
16
import org.apache.log4j.Logger;
17
import org.hibernate.criterion.Restrictions;
18
import org.springframework.context.annotation.Scope;
19
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
20
import org.vaadin.viritin.fields.LazyComboBox;
21

    
22
import com.vaadin.data.Property;
23
import com.vaadin.spring.annotation.SpringComponent;
24
import com.vaadin.ui.Field;
25

    
26
import eu.etaxonomy.cdm.api.service.INameService;
27
import eu.etaxonomy.cdm.model.agent.AgentBase;
28
import eu.etaxonomy.cdm.model.agent.Person;
29
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
30
import eu.etaxonomy.cdm.model.common.AnnotationType;
31
import eu.etaxonomy.cdm.model.common.CdmBase;
32
import eu.etaxonomy.cdm.model.common.TermType;
33
import eu.etaxonomy.cdm.model.name.Rank;
34
import eu.etaxonomy.cdm.model.name.TaxonName;
35
import eu.etaxonomy.cdm.model.name.TaxonNameFactory;
36
import eu.etaxonomy.cdm.model.reference.Reference;
37
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
38
import eu.etaxonomy.cdm.model.reference.ReferenceType;
39
import eu.etaxonomy.cdm.persistence.hibernate.permission.CRUD;
40
import eu.etaxonomy.cdm.service.CdmFilterablePagingProvider;
41
import eu.etaxonomy.cdm.service.TaxonNameStringFilterablePagingProvider;
42
import eu.etaxonomy.cdm.service.initstrategies.AgentBaseInit;
43
import eu.etaxonomy.cdm.vaadin.component.CdmBeanItemContainerFactory;
44
import eu.etaxonomy.cdm.vaadin.event.EditorActionTypeFilter;
45
import eu.etaxonomy.cdm.vaadin.event.EntityChangeEvent;
46
import eu.etaxonomy.cdm.vaadin.event.ReferenceEditorAction;
47
import eu.etaxonomy.cdm.vaadin.event.TaxonNameEditorAction;
48
import eu.etaxonomy.cdm.vaadin.event.ToOneRelatedEntityButtonUpdater;
49
import eu.etaxonomy.cdm.vaadin.event.ToOneRelatedEntityReloader;
50
import eu.etaxonomy.cdm.vaadin.model.name.TaxonNameDTO;
51
import eu.etaxonomy.cdm.vaadin.permission.UserHelper;
52
import eu.etaxonomy.cdm.vaadin.ui.RegistrationUIDefaults;
53
import eu.etaxonomy.cdm.vaadin.util.CdmTitleCacheCaptionGenerator;
54
import eu.etaxonomy.cdm.vaadin.view.reference.ReferencePopupEditor;
55
import eu.etaxonomy.vaadin.component.ReloadableLazyComboBox;
56
import eu.etaxonomy.vaadin.component.ToOneRelatedEntityCombobox;
57
import eu.etaxonomy.vaadin.event.FieldReplaceEvent;
58
import eu.etaxonomy.vaadin.mvp.AbstractCdmDTOEditorPresenter;
59
import eu.etaxonomy.vaadin.mvp.AbstractPopupEditor;
60
import eu.etaxonomy.vaadin.mvp.BeanInstantiator;
61
import eu.etaxonomy.vaadin.mvp.BoundField;
62
import eu.etaxonomy.vaadin.ui.view.PopupView;
63
import eu.etaxonomy.vaadin.util.PropertyIdPath;
64

    
65
/**
66
 * @author a.kohlbecker
67
 * @since May 22, 2017
68
 *
69
 */
70
@SpringComponent
71
@Scope("prototype")
72
public class TaxonNameEditorPresenter extends AbstractCdmDTOEditorPresenter<TaxonNameDTO, TaxonName, TaxonNamePopupEditorView> {
73

    
74

    
75
    private static final List<String> BASIONYM_INIT_STRATEGY = Arrays.asList(
76
            "$",
77
            "relationsFromThisName",
78
            "relationsToThisName.type",
79
            "homotypicalGroup.typifiedNames"
80
            );
81

    
82
    private static final List<String> REFERENCE_INIT_STRATEGY = Arrays.asList("authorship", "inReference.authorship", "inReference.inReference.authorship", "inReference.inReference.inReference.authorship");
83

    
84
    private static final long serialVersionUID = -3538980627079389221L;
85

    
86
    private static final Logger logger = Logger.getLogger(TaxonNameEditorPresenter.class);
87

    
88
    private CdmFilterablePagingProvider<Reference, Reference> nomReferencePagingProvider;
89

    
90
    private Reference publishedUnit;
91

    
92
    private BeanInstantiator<Reference> newReferenceInstantiator;
93

    
94
    private TaxonNameStringFilterablePagingProvider genusOrUninomialPartPagingProvider;
95

    
96
    private TaxonNameStringFilterablePagingProvider specificEpithetPartPagingProvider;
97

    
98
    private Property.ValueChangeListener refreshSpecificEpithetComboBoxListener;
99

    
100
    /**
101
     * {@inheritDoc}
102
     */
103
    @Override
104
    public void handleViewEntered() {
105

    
106
        super.handleViewEntered();
107

    
108
        CdmBeanItemContainerFactory selectFieldFactory = new CdmBeanItemContainerFactory(getRepo());
109
        getView().getRankSelect().setContainerDataSource(selectFieldFactory.buildBeanItemContainer(TermType.Rank));
110
        getView().getRankSelect().setItemCaptionPropertyId("label");
111

    
112
        // genusOrUninomialField
113
        if(getView().getGenusOrUninomialField() instanceof LazyComboBox){
114
            genusOrUninomialPartPagingProvider = new TaxonNameStringFilterablePagingProvider(getRepo().getNameService());
115
            genusOrUninomialPartPagingProvider.listenToFields(
116
                    null,
117
                    getView().getInfraGenericEpithetField(),
118
                    getView().getSpecificEpithetField(),
119
                    getView().getInfraSpecificEpithetField()
120
                   );
121
            ((LazyComboBox)getView().getGenusOrUninomialField()).loadFrom(genusOrUninomialPartPagingProvider, genusOrUninomialPartPagingProvider, genusOrUninomialPartPagingProvider.getPageSize());
122
        }
123

    
124
        CdmFilterablePagingProvider<AgentBase, TeamOrPersonBase> termOrPersonPagingProvider = new CdmFilterablePagingProvider<AgentBase, TeamOrPersonBase>(getRepo().getAgentService(), TeamOrPersonBase.class);
125
        termOrPersonPagingProvider.setInitStrategy(AgentBaseInit.TEAM_OR_PERSON_INIT_STRATEGY);
126
        CdmFilterablePagingProvider<AgentBase, Person> personPagingProvider = new CdmFilterablePagingProvider<AgentBase, Person>(getRepo().getAgentService(), Person.class);
127

    
128
        getView().getCombinationAuthorshipField().setFilterableTeamPagingProvider(termOrPersonPagingProvider, this);
129
        getView().getCombinationAuthorshipField().setFilterablePersonPagingProvider(personPagingProvider, this);
130

    
131
        getView().getExCombinationAuthorshipField().setFilterableTeamPagingProvider(termOrPersonPagingProvider, this);
132
        getView().getExCombinationAuthorshipField().setFilterablePersonPagingProvider(personPagingProvider, this);
133

    
134
        getView().getBasionymAuthorshipField().setFilterableTeamPagingProvider(termOrPersonPagingProvider, this);
135
        getView().getBasionymAuthorshipField().setFilterablePersonPagingProvider(personPagingProvider, this);
136

    
137
        getView().getExBasionymAuthorshipField().setFilterableTeamPagingProvider(termOrPersonPagingProvider, this);
138
        getView().getExBasionymAuthorshipField().setFilterablePersonPagingProvider(personPagingProvider, this);
139

    
140
        getView().getNomReferenceCombobox().getSelect().setCaptionGenerator(new CdmTitleCacheCaptionGenerator<Reference>());
141
        nomReferencePagingProvider = pagingProviderFactory.referencePagingProvider();
142
        nomReferencePagingProvider.setInitStrategy(REFERENCE_INIT_STRATEGY);
143
        getView().getNomReferenceCombobox().loadFrom(nomReferencePagingProvider, nomReferencePagingProvider, nomReferencePagingProvider.getPageSize());
144
        getView().getNomReferenceCombobox().getSelect().addValueChangeListener(new ToOneRelatedEntityButtonUpdater<Reference>(getView().getNomReferenceCombobox()));
145
        getView().getNomReferenceCombobox().getSelect().addValueChangeListener(new ToOneRelatedEntityReloader<>(getView().getNomReferenceCombobox(), this));
146

    
147
        getView().getBasionymComboboxSelect().setCaptionGenerator(new CdmTitleCacheCaptionGenerator<TaxonName>());
148

    
149
        CdmFilterablePagingProvider<TaxonName, TaxonName> basionymPagingProvider = new CdmFilterablePagingProvider<TaxonName, TaxonName>(getRepo().getNameService());
150
        basionymPagingProvider.setInitStrategy(BASIONYM_INIT_STRATEGY);
151
        getView().getBasionymComboboxSelect().setPagingProviders(basionymPagingProvider, basionymPagingProvider, basionymPagingProvider.getPageSize(), this);
152

    
153
        getView().getReplacedSynonymsComboboxSelect().setCaptionGenerator( new CdmTitleCacheCaptionGenerator<TaxonName>());
154
        // reusing the basionymPagingProvider for the replaced synonyms to benefit from caching
155
        getView().getReplacedSynonymsComboboxSelect().setPagingProviders(basionymPagingProvider, basionymPagingProvider, basionymPagingProvider.getPageSize(), this);
156

    
157
        getView().getValidationField().getValidatedNameComboBox().getSelect().setCaptionGenerator(new CdmTitleCacheCaptionGenerator<TaxonName>());
158
        // reusing the basionymPagingProvider for the replaced synonyms to benefit from caching
159
        getView().getValidationField().getValidatedNameComboBox().loadFrom(basionymPagingProvider, basionymPagingProvider, basionymPagingProvider.getPageSize());
160
        getView().getValidationField().getValidatedNameComboBox().getSelect().addValueChangeListener(new ToOneRelatedEntityReloader<>(getView().getValidationField().getValidatedNameComboBox(), this));
161

    
162
        getView().getNomReferenceCombobox().getSelect().setCaptionGenerator(new CdmTitleCacheCaptionGenerator<Reference>());
163
        CdmFilterablePagingProvider<Reference, Reference> icbnCodesPagingProvider = pagingProviderFactory.referencePagingProvider();
164
        icbnCodesPagingProvider.setInitStrategy(REFERENCE_INIT_STRATEGY);
165
        // @formatter:off
166
        // TODO use markers on references instead of isbn. The marker type MarkerType.NOMENCLATURAL_RELEVANT() has already prepared (#7466)
167
        icbnCodesPagingProvider.getCriteria().add(Restrictions.in("isbn", new String[]{
168
                "3-904144-22-7",     // Saint Louis Code
169
                "3-906166-48-1",     // Vienna Code
170
                "978-3-87429-425-6", // Melbourne Code
171
                "978-3-946583-16-5", // Shenzhen Code
172
                "0-85301-006-4"      // ICZN 1999
173
                                     // ICNB
174
                }));
175
        // @formatter:on
176
        getView().getValidationField().getCitatonComboBox().getSelect().setCaptionGenerator(new CdmTitleCacheCaptionGenerator<Reference>());
177
        getView().getValidationField().getCitatonComboBox().loadFrom(icbnCodesPagingProvider, icbnCodesPagingProvider, icbnCodesPagingProvider.getPageSize());
178
        getView().getValidationField().getCitatonComboBox().getSelect().addValueChangeListener(new ToOneRelatedEntityReloader<>(getView().getValidationField().getCitatonComboBox(), this));
179

    
180
        getView().getAnnotationsField().setAnnotationTypeItemContainer(selectFieldFactory.buildTermItemContainer(
181
                AnnotationType.EDITORIAL().getUuid(), AnnotationType.TECHNICAL().getUuid()));
182
    }
183

    
184
    /**
185
     * {@inheritDoc}
186
     */
187
    @Override
188
    protected TaxonName loadCdmEntity(UUID identifier) {
189

    
190
        List<String> initStrategy = Arrays.asList(
191
                "$",
192
                "annotations.type",
193
                "annotations.*", // needed as log as we are using a table in FilterableAnnotationsField
194
                "rank.vocabulary", // needed for comparing ranks
195

    
196
                "nomenclaturalReference.authorship",
197
                "nomenclaturalReference.inReference.authorship",
198
                "nomenclaturalReference.inReference.inReference.authorship",
199
                "nomenclaturalReference.inReference.inReference.inReference.authorship",
200

    
201
                "status.type",
202

    
203
                "combinationAuthorship",
204
                "exCombinationAuthorship",
205
                "basionymAuthorship",
206
                "exBasionymAuthorship",
207

    
208
                // basionyms: relationsToThisName.fromName
209
                "relationsToThisName.type",
210
                "relationsToThisName.fromName.rank",
211
                "relationsToThisName.fromName.combinationAuthorship",
212
                "relationsToThisName.fromName.exCombinationAuthorship",
213
                "relationsToThisName.fromName.nomenclaturalReference.authorship",
214
                "relationsToThisName.fromName.nomenclaturalReference.inReference.authorship",
215
                "relationsToThisName.fromName.nomenclaturalReference.inReference.inReference.inReference.authorship",
216
                "relationsToThisName.fromName.relationsToThisName",
217
                "relationsToThisName.fromName.relationsFromThisName",
218
                "relationsToThisName.citation",
219

    
220
                "relationsFromThisName",
221
                "homotypicalGroup.typifiedNames"
222
        );
223

    
224
        TaxonName taxonName;
225
        if(identifier != null){
226
            taxonName = getRepo().getNameService().load(identifier, initStrategy);
227
        } else {
228
            taxonName = TaxonNameFactory.NewNameInstance(RegistrationUIDefaults.NOMENCLATURAL_CODE, Rank.SPECIES());
229
        }
230

    
231
        if(getView().isModeEnabled(TaxonNamePopupEditorMode.NOMENCLATURALREFERENCE_SECTION_EDITING_ONLY)){
232
            if(taxonName.getNomenclaturalReference() != null){
233
                Reference nomRef = taxonName.getNomenclaturalReference();
234
                //getView().getNomReferenceCombobox().setEnabled(nomRef.isOfType(ReferenceType.Section));
235
                publishedUnit = nomRef;
236
                while(publishedUnit.isOfType(ReferenceType.Section) && publishedUnit.getInReference() != null){
237
                    publishedUnit = nomRef.getInReference();
238
                }
239
                // reduce available references to those which are sections of the publishedUnit and the publishedUnit itself
240
                // nomReferencePagingProvider
241
                nomReferencePagingProvider.getCriteria().add(Restrictions.or(
242
                        Restrictions.and(Restrictions.eq("inReference", publishedUnit), Restrictions.eq("type", ReferenceType.Section)),
243
                        Restrictions.idEq(publishedUnit.getId())
244
                        )
245
                );
246
                // and remove the empty option
247
                getView().getNomReferenceCombobox().getSelect().setNullSelectionAllowed(false);
248

    
249
                // new Reference only a sub sections of the publishedUnit
250
                newReferenceInstantiator = new BeanInstantiator<Reference>() {
251
                    @Override
252
                    public Reference createNewBean() {
253
                        Reference newRef = ReferenceFactory.newSection();
254
                        newRef.setInReference(publishedUnit);
255
                        return newRef;
256
                    }
257
                };
258

    
259
            }
260
        }
261
        return taxonName;
262
    }
263

    
264
    /**
265
     * {@inheritDoc}
266
     */
267
    @Override
268
    protected void guaranteePerEntityCRUDPermissions(UUID identifier) {
269
        if(crud != null){
270
            newAuthorityCreated = UserHelper.fromSession().createAuthorityForCurrentUser(TaxonName.class, identifier, crud, null);
271
        }
272

    
273
    }
274

    
275
    /**
276
     * {@inheritDoc}
277
     */
278
    @Override
279
    protected void guaranteePerEntityCRUDPermissions(TaxonName bean) {
280
        if(crud != null){
281
            newAuthorityCreated = UserHelper.fromSession().createAuthorityForCurrentUser(bean, crud, null);
282
        }
283
    }
284

    
285
    /**
286
     * {@inheritDoc}
287
     */
288
    @Override
289
    protected INameService getService() {
290
        return getRepo().getNameService();
291
    }
292

    
293
    @EventBusListenerMethod(filter = EditorActionTypeFilter.Add.class)
294
    public void onReferenceEditorActionAdd(ReferenceEditorAction event) {
295

    
296
        if(getView() == null || event.getSourceView() != getView() ){
297
            return;
298
        }
299

    
300
        ReferencePopupEditor referenceEditorPopup = openPopupEditor(ReferencePopupEditor.class, event);
301

    
302
        referenceEditorPopup.grantToCurrentUser(EnumSet.of(CRUD.UPDATE, CRUD.DELETE));
303
        referenceEditorPopup.withDeleteButton(true);
304
        referenceEditorPopup.setBeanInstantiator(newReferenceInstantiator);
305
        referenceEditorPopup.loadInEditor(null);
306
        if(newReferenceInstantiator != null){
307
            // this is a bit clumsy, we actually need to inject something like a view configurer
308
            // which can enable, disable fields
309
            referenceEditorPopup.getInReferenceCombobox().setEnabled(false);
310
            referenceEditorPopup.getTypeSelect().setEnabled(false);
311
        }
312
    }
313

    
314
    @EventBusListenerMethod(filter = EditorActionTypeFilter.Edit.class)
315
    public void onReferenceEditorActionEdit(ReferenceEditorAction event) {
316

    
317

    
318
        if(!isFromOwnView(event)){
319
            return;
320
        }
321
        ReferencePopupEditor referenceEditorPopup = openPopupEditor(ReferencePopupEditor.class, event);
322

    
323
        referenceEditorPopup.withDeleteButton(true);
324
        referenceEditorPopup.setBeanInstantiator(newReferenceInstantiator);
325
        referenceEditorPopup.loadInEditor(event.getEntityUuid());
326
        if(newReferenceInstantiator != null){
327
            // this is a bit clumsy, we actually need to inject something like a view configurator
328
            // which can enable, disable fields
329
            referenceEditorPopup.getInReferenceCombobox().setEnabled(false);
330
            referenceEditorPopup.getTypeSelect().setEnabled(false);
331
        }
332
    }
333

    
334
    @EventBusListenerMethod
335
    public void onFieldReplaceEvent(FieldReplaceEvent<String> event){
336

    
337
        PropertyIdPath boundPropertyIdPath = boundPropertyIdPath(event.getNewField());
338
        if(boundPropertyIdPath != null && boundPropertyIdPath.matches("specificEpithet")){
339
            if(event.getNewField() instanceof LazyComboBox){
340

    
341
                if(specificEpithetPartPagingProvider  == null){
342
                    specificEpithetPartPagingProvider = new TaxonNameStringFilterablePagingProvider(getRepo().getNameService(), Rank.SPECIES());
343
                }
344
                specificEpithetPartPagingProvider.listenToFields(
345
                        getView().getGenusOrUninomialField(),
346
                        null, null, null);
347
                specificEpithetPartPagingProvider.updateFromFields();
348
                LazyComboBox<String> specificEpithetField = (LazyComboBox<String>)event.getNewField();
349
                refreshSpecificEpithetComboBoxListener = e -> { specificEpithetField.refresh(); specificEpithetField.setValue(null);};
350
                getView().getGenusOrUninomialField().addValueChangeListener(refreshSpecificEpithetComboBoxListener);
351
                specificEpithetField.loadFrom(specificEpithetPartPagingProvider, specificEpithetPartPagingProvider, specificEpithetPartPagingProvider.getPageSize());
352
            } else {
353
                if(specificEpithetPartPagingProvider != null){
354
                    specificEpithetPartPagingProvider.unlistenAllFields();
355
                }
356
                if(refreshSpecificEpithetComboBoxListener != null){
357
                    getView().getGenusOrUninomialField().removeValueChangeListener(refreshSpecificEpithetComboBoxListener);
358
                    refreshSpecificEpithetComboBoxListener = null;
359
                }
360
            }
361
        }
362

    
363
    }
364

    
365
    @EventBusListenerMethod
366
    public void onEntityChangeEvent(EntityChangeEvent<?> event){
367

    
368
        if(event.getSourceView() instanceof AbstractPopupEditor) {
369

    
370
            BoundField boundTargetField = boundTargetField((PopupView) event.getSourceView());
371

    
372
            if(boundTargetField != null){
373
                if(boundTargetField.matchesPropertyIdPath("nomenclaturalReference")){
374
                    if(event.isCreateOrModifiedType()){
375

    
376
                        getCache().load(event.getEntity());
377
                        if(event.isCreatedType()){
378
                            getView().getNomReferenceCombobox().setValue((Reference) event.getEntity());
379
                        } else {
380
                            getView().getNomReferenceCombobox().reload(); // refreshSelectedValue(modifiedReference);
381
                        }
382
                        getView().getCombinationAuthorshipField().discard(); //refresh from the datasource
383
                        getView().updateAuthorshipFields();
384
                    }
385
                }
386
                if(boundTargetField.matchesPropertyIdPath("validationFor.otherName")){
387
                    ReloadableLazyComboBox<TaxonName> otherNameField = asReloadableLazyComboBox(boundTargetField.getField(TaxonName.class));
388
                    if(event.isCreateOrModifiedType()){
389
                        getCache().load(event.getEntity());
390
                        if(event.isCreatedType()){
391
                            otherNameField.setValue((TaxonName) event.getEntity());
392
                        } else {
393
                            otherNameField.reload();
394
                        }
395
                    } else
396
                    if(event.isRemovedType()){
397
                        otherNameField.setValue(null);
398
                    }
399
                } else
400
                if(boundTargetField.matchesPropertyIdPath("basionyms")){
401
                    ReloadableLazyComboBox<TaxonName> basionymSourceField = asReloadableLazyComboBox(boundTargetField.getField(TaxonName.class));
402
                    if(event.isCreateOrModifiedType()){
403
                        getCache().load(event.getEntity());
404
                        if(event.isCreatedType()){
405
                            basionymSourceField .setValue((TaxonName) event.getEntity());
406
                        } else {
407
                            basionymSourceField.reload();
408
                        }
409
                        getView().getBasionymAuthorshipField().discard(); //refresh from the datasource
410
                        getView().getExBasionymAuthorshipField().discard(); //refresh from the datasource
411
                        getView().updateAuthorshipFields();
412
                    } else
413
                    if(event.isRemovedType()){
414
                        basionymSourceField.setValue(null);
415
                        getView().updateAuthorshipFields();
416
                    }
417
                } else
418
                if(boundTargetField.matchesPropertyIdPath("replacedSynonyms")){
419
                    ReloadableLazyComboBox<TaxonName> replacedSynonyms = asReloadableLazyComboBox(boundTargetField.getField(TaxonName.class));
420
                    if(event.isCreateOrModifiedType()){
421
                        getCache().load(event.getEntity());
422
                        if(event.isCreatedType()){
423
                            replacedSynonyms .setValue((TaxonName) event.getEntity());
424
                        } else {
425
                            replacedSynonyms.reload();
426
                        }
427
                        getView().getExCombinationAuthorshipField().discard(); //refresh from the datasource
428
                        getView().updateAuthorshipFields();
429
                    } else
430
                    if(event.isRemovedType()){
431
                        replacedSynonyms.setValue(null);
432
                        getView().updateAuthorshipFields();
433
                    }
434
                }
435

    
436
            }
437
        }
438
    }
439

    
440
    protected <CDM extends CdmBase> ReloadableLazyComboBox<CDM> asReloadableLazyComboBox(Field<CDM> field){
441

    
442
        if(field instanceof ToOneRelatedEntityCombobox){
443
            field = ((ToOneRelatedEntityCombobox<CDM>)field).getSelect();
444
        }
445
        return (ReloadableLazyComboBox<CDM>)field;
446
    }
447

    
448

    
449

    
450
    @EventBusListenerMethod(filter = EditorActionTypeFilter.Edit.class)
451
    public void onTaxonNameEditorActionEdit(TaxonNameEditorAction event) {
452

    
453
        if(getView() == null || event.getSourceView() != getView() ){
454
            return;
455
        }
456

    
457
        PropertyIdPath boundPropertyId = boundPropertyIdPath(event.getTarget());
458

    
459
        if(boundPropertyId != null){
460
            if(boundPropertyId.matches("validationFor.otherName") || boundPropertyId.matches("basionyms") || boundPropertyId.matches("replacedSynonyms")){
461
                TaxonNamePopupEditor validatedNamePopup = openPopupEditor(TaxonNamePopupEditor.class, event);
462
                validatedNamePopup.withDeleteButton(true);
463
                getView().getModesActive().stream()
464
                    .filter(m -> !TaxonNamePopupEditorMode.NOMENCLATURALREFERENCE_SECTION_EDITING_ONLY.equals(m))
465
                    .forEach(m -> validatedNamePopup.enableMode(m));
466
                validatedNamePopup.loadInEditor(event.getEntityUuid());
467
            }
468
        }
469

    
470
    }
471

    
472
    @EventBusListenerMethod(filter = EditorActionTypeFilter.Add.class)
473
    public void onTaxonNameEditorActionAdd(TaxonNameEditorAction event) {
474

    
475
        if(getView() == null || event.getSourceView() != getView() ){
476
            return;
477
        }
478

    
479
        PropertyIdPath boundPropertyId = boundPropertyIdPath(event.getTarget());
480

    
481
        if(boundPropertyId != null){
482
            if(boundPropertyId.matches("validationFor.otherName") || boundPropertyId.matches("basionyms") || boundPropertyId.matches("replacedSynonyms")){
483
                TaxonNamePopupEditor validatedNamePopup = openPopupEditor(TaxonNamePopupEditor.class, event);
484
                validatedNamePopup.grantToCurrentUser(EnumSet.of(CRUD.UPDATE, CRUD.DELETE));
485
                validatedNamePopup.withDeleteButton(true);
486
                getView().getModesActive().stream()
487
                        .filter(m -> !TaxonNamePopupEditorMode.NOMENCLATURALREFERENCE_SECTION_EDITING_ONLY.equals(m))
488
                        .forEach(m -> validatedNamePopup.enableMode(m));
489
                validatedNamePopup.loadInEditor(null);
490
            }
491
        }
492
    }
493

    
494
    /**
495
     * {@inheritDoc}
496
     */
497
    @Override
498
    protected TaxonNameDTO createDTODecorator(TaxonName cdmEntitiy) {
499
        return new TaxonNameDTO(cdmEntitiy);
500
    }
501

    
502

    
503

    
504

    
505
}
(9-9/13)