Project

General

Profile

Download (45.9 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.HashMap;
14
import java.util.HashSet;
15
import java.util.List;
16
import java.util.Map;
17
import java.util.Optional;
18
import java.util.Set;
19
import java.util.UUID;
20

    
21
import org.apache.commons.lang.StringUtils;
22
import org.apache.log4j.Logger;
23
import org.hibernate.criterion.Restrictions;
24
import org.springframework.context.annotation.Scope;
25
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
26
import org.vaadin.viritin.fields.AbstractElementCollection;
27

    
28
import com.vaadin.data.Property;
29
import com.vaadin.data.util.BeanItemContainer;
30
import com.vaadin.spring.annotation.SpringComponent;
31
import com.vaadin.ui.AbstractField;
32
import com.vaadin.ui.AbstractSelect.ItemCaptionMode;
33
import com.vaadin.ui.Field;
34

    
35
import eu.etaxonomy.cdm.api.service.INameService;
36
import eu.etaxonomy.cdm.format.reference.ReferenceEllypsisFormatter;
37
import eu.etaxonomy.cdm.format.reference.ReferenceEllypsisFormatter.LabelType;
38
import eu.etaxonomy.cdm.model.agent.AgentBase;
39
import eu.etaxonomy.cdm.model.agent.Person;
40
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
41
import eu.etaxonomy.cdm.model.common.AnnotationType;
42
import eu.etaxonomy.cdm.model.common.CdmBase;
43
import eu.etaxonomy.cdm.model.common.Language;
44
import eu.etaxonomy.cdm.model.name.NomenclaturalCodeEdition;
45
import eu.etaxonomy.cdm.model.name.NomenclaturalStatus;
46
import eu.etaxonomy.cdm.model.name.NomenclaturalStatusType;
47
import eu.etaxonomy.cdm.model.name.Rank;
48
import eu.etaxonomy.cdm.model.name.TaxonName;
49
import eu.etaxonomy.cdm.model.name.TaxonNameFactory;
50
import eu.etaxonomy.cdm.model.permission.CRUD;
51
import eu.etaxonomy.cdm.model.reference.Reference;
52
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
53
import eu.etaxonomy.cdm.model.reference.ReferenceType;
54
import eu.etaxonomy.cdm.model.term.DefinedTermBase;
55
import eu.etaxonomy.cdm.model.term.TermType;
56
import eu.etaxonomy.cdm.persistence.dao.common.Restriction;
57
import eu.etaxonomy.cdm.persistence.dao.common.Restriction.Operator;
58
import eu.etaxonomy.cdm.persistence.dao.initializer.EntityInitStrategy;
59
import eu.etaxonomy.cdm.service.CdmFilterablePagingProvider;
60
import eu.etaxonomy.cdm.service.TaxonNameStringFilterablePagingProvider;
61
import eu.etaxonomy.cdm.service.UserHelperAccess;
62
import eu.etaxonomy.cdm.service.initstrategies.AgentBaseInit;
63
import eu.etaxonomy.cdm.vaadin.event.EditorActionTypeFilter;
64
import eu.etaxonomy.cdm.vaadin.event.EntityChangeEvent;
65
import eu.etaxonomy.cdm.vaadin.event.ReferenceEditorAction;
66
import eu.etaxonomy.cdm.vaadin.event.TaxonNameEditorAction;
67
import eu.etaxonomy.cdm.vaadin.event.TaxonNameEditorActionStrRep;
68
import eu.etaxonomy.cdm.vaadin.event.ToOneRelatedEntityButtonUpdater;
69
import eu.etaxonomy.cdm.vaadin.event.ToOneRelatedEntityReloader;
70
import eu.etaxonomy.cdm.vaadin.model.name.NomenclaturalStatusDTO;
71
import eu.etaxonomy.cdm.vaadin.model.name.TaxonNameDTO;
72
import eu.etaxonomy.cdm.vaadin.ui.RegistrationUIDefaults;
73
import eu.etaxonomy.cdm.vaadin.util.CdmTitleCacheCaptionGenerator;
74
import eu.etaxonomy.cdm.vaadin.util.ReferenceEllypsisCaptionGenerator;
75
import eu.etaxonomy.cdm.vaadin.view.reference.ReferencePopupEditor;
76
import eu.etaxonomy.cdm.vaadin.view.reference.RegistrationUiReferenceEditorFormConfigurator;
77
import eu.etaxonomy.vaadin.component.CompositeCustomField;
78
import eu.etaxonomy.vaadin.component.ReloadableLazyComboBox;
79
import eu.etaxonomy.vaadin.component.ToOneRelatedEntityCombobox;
80
import eu.etaxonomy.vaadin.component.WeaklyRelatedEntityCombobox;
81
import eu.etaxonomy.vaadin.component.WeaklyRelatedEntityField;
82
import eu.etaxonomy.vaadin.event.FieldReplaceEvent;
83
import eu.etaxonomy.vaadin.mvp.AbstractCdmDTOEditorPresenter;
84
import eu.etaxonomy.vaadin.mvp.AbstractPopupEditor;
85
import eu.etaxonomy.vaadin.mvp.BeanInstantiator;
86
import eu.etaxonomy.vaadin.mvp.BoundField;
87
import eu.etaxonomy.vaadin.ui.view.PopupView;
88
import eu.etaxonomy.vaadin.util.PropertyIdPath;
89

    
90
/**
91
 * @author a.kohlbecker
92
 * @since May 22, 2017
93
 *
94
 */
95
@SpringComponent
96
@Scope("prototype")
97
public class TaxonNameEditorPresenter
98
        extends AbstractCdmDTOEditorPresenter<TaxonNameDTO, TaxonName, TaxonNamePopupEditorView> {
99

    
100
    private static final long serialVersionUID = -3538980627079389221L;
101

    
102
    private static final EnumSet<CRUD> SUB_EDITOR_CRUD = EnumSet.of(CRUD.UPDATE, CRUD.DELETE);
103

    
104
    private static final List<String> RELATED_NAME_INIT_STRATEGY = Arrays.asList("$", "nomenclaturalSource.annotations",
105
            "relationsFromThisName", "relationsToThisName.type", "homotypicalGroup.typifiedNames");
106

    
107
    public static List<String> REFERENCE_INIT_STRATEGY = ReferenceEllypsisFormatter.INIT_STRATEGY;
108

    
109
    private static final Logger logger = Logger.getLogger(TaxonNameEditorPresenter.class);
110

    
111
    private CdmFilterablePagingProvider<Reference, Reference> nomReferencePagingProvider;
112

    
113
    private Reference publishedUnit;
114

    
115
    private BeanInstantiator<Reference> newReferenceInstantiator;
116

    
117
    private Map<ReferencePopupEditor, NomenclaturalStatusRow> statusTypeReferencePopupEditorsRowMap = new HashMap<>();
118

    
119
    private TaxonNameStringFilterablePagingProvider genusOrUninomialPartPagingProvider;
120

    
121
    private TaxonNameStringFilterablePagingProvider specificEpithetPartPagingProvider;
122

    
123
    private Property.ValueChangeListener refreshSpecificEpithetComboBoxListener;
124

    
125
    private CdmFilterablePagingProvider<TaxonName, TaxonName> relatedNamePagingProvider;
126

    
127
    private CdmFilterablePagingProvider<TaxonName, TaxonName> orthographicVariantNamePagingProvider;
128

    
129
    private Restriction<Reference> orthographicCorrectionRestriction;
130

    
131
    private Integer taxonNameId;
132

    
133
    /**
134
     * {@inheritDoc}
135
     */
136
    @SuppressWarnings("serial")
137
    @Override
138
    public void handleViewEntered() {
139

    
140
        super.handleViewEntered();
141

    
142
        List<NomenclaturalCodeEdition> nomCodes = NomenclaturalCodeEdition
143
                .forCode(RegistrationUIDefaults.NOMENCLATURAL_CODE);
144
        BeanItemContainer<NomenclaturalCodeEdition> codeEditionItemContainer = cdmBeanItemContainerFactory
145
                .buildEnumTermItemContainer(NomenclaturalCodeEdition.class,
146
                        nomCodes.toArray(new NomenclaturalCodeEdition[nomCodes.size()]));
147

    
148
        getView().getRankSelect()
149
                .setContainerDataSource(cdmBeanItemContainerFactory.buildTermItemContainer(TermType.Rank));
150
        getView().getRankSelect().setItemCaptionPropertyId("label");
151

    
152
        CdmFilterablePagingProvider<AgentBase, TeamOrPersonBase> termOrPersonPagingProvider = pagingProviderFactory
153
                .teamOrPersonPagingProvider();
154
        termOrPersonPagingProvider.setInitStrategy(AgentBaseInit.TEAM_OR_PERSON_INIT_STRATEGY);
155
        CdmFilterablePagingProvider<AgentBase, Person> personPagingProvider = pagingProviderFactory
156
                .personPagingProvider();
157

    
158
        getView().getCombinationAuthorshipField().setFilterableTeamPagingProvider(termOrPersonPagingProvider, this);
159
        getView().getCombinationAuthorshipField().setFilterablePersonPagingProvider(personPagingProvider, this);
160

    
161
        getView().getExCombinationAuthorshipField().setFilterableTeamPagingProvider(termOrPersonPagingProvider, this);
162
        getView().getExCombinationAuthorshipField().setFilterablePersonPagingProvider(personPagingProvider, this);
163

    
164
        getView().getBasionymAuthorshipField().setFilterableTeamPagingProvider(termOrPersonPagingProvider, this);
165
        getView().getBasionymAuthorshipField().setFilterablePersonPagingProvider(personPagingProvider, this);
166

    
167
        getView().getExBasionymAuthorshipField().setFilterableTeamPagingProvider(termOrPersonPagingProvider, this);
168
        getView().getExBasionymAuthorshipField().setFilterablePersonPagingProvider(personPagingProvider, this);
169

    
170
        nomReferencePagingProvider = pagingProviderFactory.referencePagingProvider();
171
        nomReferencePagingProvider.setInitStrategy(REFERENCE_INIT_STRATEGY);
172
        getView().getNomReferenceCombobox().loadFrom(nomReferencePagingProvider, nomReferencePagingProvider,
173
                nomReferencePagingProvider.getPageSize());
174
        getView().getNomReferenceCombobox().setNestedButtonStateUpdater(
175
                new ToOneRelatedEntityButtonUpdater<Reference>(getView().getNomReferenceCombobox()));
176
        getView().getNomReferenceCombobox().getSelect().setCaptionGenerator(new ReferenceEllypsisCaptionGenerator(
177
                LabelType.NOMENCLATURAL, getView().getNomReferenceCombobox().getSelect()));
178
        getView().getNomReferenceCombobox().getSelect()
179
                .addValueChangeListener(new ToOneRelatedEntityReloader<>(getView().getNomReferenceCombobox(), this));
180
        getView().getNomReferenceCombobox().getSelect()
181
                .addValueChangeListener(e -> updateOrthographicCorrectionRestriction());
182

    
183
        CdmFilterablePagingProvider<Reference, Reference> icbnCodesPagingProvider = pagingProviderFactory
184
                .referencePagingProvider();
185
        // @formatter:off
186
        // TODO use markers on references instead of isbn. The marker type
187
        // MarkerType.NOMENCLATURAL_RELEVANT() has already prepared (#7466)
188
        icbnCodesPagingProvider.getCriteria().add(Restrictions.in("isbn", new String[] {
189
                "3-904144-22-7",     // Saint Louis Code
190
                "3-906166-48-1",     // Vienna Code
191
                "978-3-87429-425-6", // Melbourne Code
192
                "978-3-946583-16-5", // Shenzhen Code
193
                "0-85301-006-4"      // ICZN 1999
194
                                     // ICNB
195
        }));
196
        // @formatter:on
197

    
198
        statusTypeReferencePopupEditorsRowMap.clear();
199
        getView().getNomStatusCollectionField().addElementAddedListener(e -> addNomenclaturalStatus(e.getElement()));
200
        getView().getNomStatusCollectionField()
201
                .setEditorInstantiator(new AbstractElementCollection.Instantiator<NomenclaturalStatusRow>() {
202

    
203
                    @Override
204
                    public NomenclaturalStatusRow create() {
205
                        NomenclaturalStatusRow row = new NomenclaturalStatusRow();
206

    
207
                        BeanItemContainer<DefinedTermBase> statusTypeItemContainer = cdmBeanItemContainerFactory
208
                                .buildVocabularyTermsItemContainer(
209
                                        NomenclaturalStatusType.ALTERNATIVE().getVocabulary().getUuid());
210
                        row.type.setContainerDataSource(statusTypeItemContainer);
211
                        row.type.setItemCaptionMode(ItemCaptionMode.EXPLICIT);
212
                        for (DefinedTermBase term : statusTypeItemContainer.getItemIds()) {
213
                            row.type.setItemCaption(term,
214
                                    term.getPreferredRepresentation(Language.DEFAULT()).getAbbreviatedLabel());
215
                        }
216
                        row.type.setNullSelectionAllowed(false);
217

    
218
                        row.citation.loadFrom(icbnCodesPagingProvider, icbnCodesPagingProvider,
219
                                icbnCodesPagingProvider.getPageSize());
220
                        row.citation.getSelect().setCaptionGenerator(new ReferenceEllypsisCaptionGenerator(
221
                                LabelType.NOMENCLATURAL, row.citation.getSelect()));
222
                        row.citation.getSelect().addValueChangeListener(new ToOneRelatedEntityReloader<Reference>(
223
                                row.citation.getSelect(), TaxonNameEditorPresenter.this));
224
                        row.citation.addClickListenerAddEntity(e -> doReferenceEditorAdd(row));
225
                        row.citation.addClickListenerEditEntity(e -> {
226
                            if (row.citation.getValue() != null) {
227
                                doReferenceEditorEdit(row);
228
                            }
229
                        });
230
                        row.codeEdition.setContainerDataSource(codeEditionItemContainer);
231

    
232
                        getView().applyDefaultComponentStyle(row.components());
233

    
234
                        return row;
235
                    }
236
                });
237

    
238
        relatedNamePagingProvider = pagingProviderFactory.taxonNamesWithoutOrthophicIncorrect();
239
        relatedNamePagingProvider.setInitStrategy(RELATED_NAME_INIT_STRATEGY);
240
        getView().getBasionymComboboxSelect().setCaptionGenerator(new CdmTitleCacheCaptionGenerator<TaxonName>());
241
        getView().getBasionymComboboxSelect().setPagingProviders(relatedNamePagingProvider, relatedNamePagingProvider,
242
                relatedNamePagingProvider.getPageSize(), this);
243

    
244
        getView().getReplacedSynonymsComboboxSelect()
245
                .setCaptionGenerator(new CdmTitleCacheCaptionGenerator<TaxonName>());
246
        getView().getReplacedSynonymsComboboxSelect().setPagingProviders(relatedNamePagingProvider,
247
                relatedNamePagingProvider, relatedNamePagingProvider.getPageSize(), this);
248

    
249
        getView().getValidationField().getRelatedNameComboBox().getSelect()
250
                .setCaptionGenerator(new CdmTitleCacheCaptionGenerator<TaxonName>());
251
        getView().getValidationField().getRelatedNameComboBox().loadFrom(relatedNamePagingProvider,
252
                relatedNamePagingProvider, relatedNamePagingProvider.getPageSize());
253
        getView().getValidationField().getRelatedNameComboBox().getSelect().addValueChangeListener(
254
                new ToOneRelatedEntityReloader<>(getView().getValidationField().getRelatedNameComboBox(), this));
255
        getView().getValidationField().getCitatonComboBox().getSelect()
256
                .setCaptionGenerator(new ReferenceEllypsisCaptionGenerator(LabelType.BIBLIOGRAPHIC,
257
                        getView().getValidationField().getCitatonComboBox().getSelect()));
258
        getView().getValidationField().getCitatonComboBox().loadFrom(icbnCodesPagingProvider, icbnCodesPagingProvider,
259
                icbnCodesPagingProvider.getPageSize());
260
        getView().getValidationField().getCitatonComboBox().getSelect().addValueChangeListener(
261
                new ToOneRelatedEntityReloader<>(getView().getValidationField().getCitatonComboBox(), this));
262
        getView().getValidationField().getCodeEditionSelect().setContainerDataSource(codeEditionItemContainer);
263

    
264
        getView().getOrthographicVariantField().getRelatedNameComboBox().getSelect()
265
                .setCaptionGenerator(new CdmTitleCacheCaptionGenerator<TaxonName>());
266
        getView().getOrthographicVariantField().getRelatedNameComboBox().getSelect().addValueChangeListener(
267
                new ToOneRelatedEntityReloader<>(getView().getOrthographicVariantField().getRelatedNameComboBox(),
268
                        this));
269
        getView().getOrthographicVariantField().getRelatedNameComboBox().loadFrom(relatedNamePagingProvider,
270
                relatedNamePagingProvider, relatedNamePagingProvider.getPageSize());
271
        // The Mode TaxonNamePopupEditorMode.ORTHOGRAPHIC_CORRECTION will be
272
        // handled in the updateOrthographicCorrectionRestriction() method
273
        getView().getOrthographicVariantField().getCitatonComboBox().getSelect()
274
                .setCaptionGenerator(new ReferenceEllypsisCaptionGenerator(LabelType.BIBLIOGRAPHIC,
275
                        getView().getOrthographicVariantField().getCitatonComboBox().getSelect()));
276
        getView().getOrthographicVariantField().getCitatonComboBox().loadFrom(icbnCodesPagingProvider,
277
                icbnCodesPagingProvider, icbnCodesPagingProvider.getPageSize());
278
        getView().getOrthographicVariantField().getCitatonComboBox().getSelect().addValueChangeListener(
279
                new ToOneRelatedEntityReloader<>(getView().getOrthographicVariantField().getCitatonComboBox(), this));
280
        getView().getOrthographicVariantField().getCodeEditionSelect().setContainerDataSource(codeEditionItemContainer);
281

    
282
        getView().getAnnotationsField().setAnnotationTypeItemContainer(cdmBeanItemContainerFactory
283
                .buildVocabularyTermsItemContainer(AnnotationType.EDITORIAL().getVocabulary().getUuid()));
284
    }
285

    
286
    /**
287
     * @param element
288
     * @return
289
     */
290
    @Deprecated
291
    private void addNomenclaturalStatus(NomenclaturalStatusDTO element) {
292
        // Nothing to do
293
    }
294

    
295
    @Override
296
    protected void adaptDataProviders() {
297
        updateOrthographicCorrectionRestriction();
298
    }
299

    
300
    private void updateOrthographicCorrectionRestriction() {
301

    
302
        if (getView().isModeEnabled(TaxonNamePopupEditorMode.ORTHOGRAPHIC_CORRECTION)) {
303
            if (orthographicVariantNamePagingProvider == null) {
304
                orthographicVariantNamePagingProvider = new CdmFilterablePagingProvider<TaxonName, TaxonName>(
305
                        getRepo().getNameService());
306
                orthographicVariantNamePagingProvider.setInitStrategy(RELATED_NAME_INIT_STRATEGY);
307
                orthographicVariantNamePagingProvider
308
                        .addRestriction(new Restriction<>("id", Operator.AND_NOT, null, taxonNameId));
309
                getView().getOrthographicVariantField().getRelatedNameComboBox().loadFrom(
310
                        orthographicVariantNamePagingProvider, orthographicVariantNamePagingProvider,
311
                        orthographicVariantNamePagingProvider.getPageSize());
312
            }
313
            Reference nomReference = getView().getNomReferenceCombobox().getValue();
314
            if (nomReference == null && orthographicCorrectionRestriction != null) {
315
                orthographicVariantNamePagingProvider.getRestrictions().remove(orthographicCorrectionRestriction);
316
            } else {
317
                if (orthographicCorrectionRestriction == null) {
318
                    orthographicCorrectionRestriction = new Restriction<>("nomenclaturalSource.citation", Operator.AND,
319
                            null, nomReference);
320
                    orthographicVariantNamePagingProvider.addRestriction(orthographicCorrectionRestriction);
321
                } else {
322
                    orthographicCorrectionRestriction.setValues(Arrays.asList(nomReference));
323
                }
324
            }
325
            getView().getOrthographicVariantField().getRelatedNameComboBox().getSelect().refresh();
326
        }
327
    }
328

    
329
    @Override
330
    protected TaxonName loadCdmEntity(UUID identifier) {
331

    
332
        EntityInitStrategy initStrategy = new EntityInitStrategy(
333
                Arrays.asList(
334
                "$",
335
                "annotations.type",
336
                "annotations.*", // needed as log as we are using a table in FilterableAnnotationsField
337
                "rank.vocabulary", // needed for comparing ranks
338

    
339
                "nomenclaturalSource.citation",
340
                "nomenclaturalSource.annotations", // needed to allow access in AnnotatableEntity.checkEmpty()
341
                "nomenclaturalSource.markers",  // needed to allow access in AnnotatableEntity.checkEmpty()
342
                "nomenclaturalSource.links",  // needed to allow access in OriginalSourceBase.checkEmpty()
343

    
344
                "status.type",
345
                "status.citation",
346

    
347
                "combinationAuthorship",
348
                "exCombinationAuthorship",
349
                "basionymAuthorship",
350
                "exBasionymAuthorship",
351

    
352
                // basionyms: relationsToThisName.fromName
353
                "relationsToThisName.type",
354
                "relationsToThisName.fromName.rank",
355
                "relationsToThisName.fromName.combinationAuthorship",
356
                "relationsToThisName.fromName.exCombinationAuthorship",
357
                "relationsToThisName.fromName.nomenclaturalSource.citation.authorship",
358
                "relationsToThisName.fromName.nomenclaturalSource.citation.inReference.authorship",
359
                "relationsToThisName.fromName.nomenclaturalSource.citation.inReference.inReference.inReference.authorship",
360
                "relationsToThisName.fromName.relationsToThisName",
361
                "relationsToThisName.fromName.relationsFromThisName",
362
                "relationsToThisName.citation",
363
                "relationsFromThisName",
364
                "homotypicalGroup.typifiedNames"
365
                )
366
              );
367
        initStrategy.extend("nomenclaturalSource.citation", ReferenceEllypsisFormatter.INIT_STRATEGY, false);
368
        initStrategy.extend("status.citation", ReferenceEllypsisFormatter.INIT_STRATEGY, false);
369
        initStrategy.extend("relationsToThisName.citation", ReferenceEllypsisFormatter.INIT_STRATEGY, false);
370

    
371
        TaxonName taxonName;
372
        if (identifier != null) {
373
            taxonName = getRepo().getNameService().load(identifier, initStrategy.getPropertyPaths());
374
        } else {
375
            taxonName = createCdmEntity();
376
        }
377

    
378
        if (getView().isModeEnabled(TaxonNamePopupEditorMode.NOMENCLATURALREFERENCE_SECTION_EDITING_ONLY)) {
379
            Reference nomRef = taxonName.getNomenclaturalReference();
380

    
381
            // getView().getNomReferenceCombobox().setEnabled(nomRef.isOfType(ReferenceType.Section));
382
            publishedUnit = nomRef;
383
            if (publishedUnit != null) {
384
                while (publishedUnit.isOfType(ReferenceType.Section) && publishedUnit.getInReference() != null) {
385
                    publishedUnit = nomRef.getInReference();
386
                }
387
                // reduce available references to those which are sections of
388
                // the publishedUnit and the publishedUnit itself
389
                // nomReferencePagingProvider
390
                nomReferencePagingProvider.getCriteria()
391
                        .add(Restrictions.or(
392
                                Restrictions.and(Restrictions.eq("inReference", publishedUnit),
393
                                        Restrictions.eq("type", ReferenceType.Section)),
394
                                Restrictions.idEq(publishedUnit.getId())));
395
            }
396
            // and remove the empty option
397
            getView().getNomReferenceCombobox().getSelect().setNullSelectionAllowed(false);
398

    
399
            // new Reference only a sub sections of the publishedUnit
400
            newReferenceInstantiator = new BeanInstantiator<Reference>() {
401
                @Override
402
                public Reference createNewBean() {
403
                    Reference newRef = ReferenceFactory.newSection();
404
                    newRef.setInReference(publishedUnit);
405
                    return newRef;
406
                }
407
            };
408

    
409
        }
410

    
411
        taxonNameId = Integer.valueOf(taxonName.getId());
412
        relatedNamePagingProvider.addRestriction(new Restriction<>("id", Operator.AND_NOT, null, taxonNameId));
413

    
414
        return taxonName;
415
    }
416

    
417
    @Override
418
    protected TaxonNameDTO preSaveBean(TaxonNameDTO bean) {
419
        // ---- sync the name.nomenclaturalStatus set with the modifications
420
        Set<NomenclaturalStatus> removeCandidates = new HashSet<>(bean.cdmEntity().getStatus());
421
        for (NomenclaturalStatusDTO statusDTO : bean.getStatus()) {
422
            if (statusDTO.getId() > 0) {
423
                Optional<NomenclaturalStatus> originalEntity = bean.cdmEntity().getStatus().stream()
424
                        .filter(s -> s.getId() == statusDTO.getId()).findFirst();
425
                if (originalEntity.isPresent()) {
426
                    statusDTO.update(originalEntity.get());
427
                    removeCandidates.remove(originalEntity.get());
428
                } else {
429
                    throw new RuntimeException("No original NomenclaturalStatus found for DTO with id="
430
                            + statusDTO.getId() + ". Was the TaxonName modified otherwise when opened in the editor?");
431
                }
432
            } else {
433
                // all new status with id = 0
434
                bean.cdmEntity().addStatus(statusDTO.update(null));
435
            }
436
        }
437
        for(NomenclaturalStatus toBeRemoved : removeCandidates) {
438
            bean.cdmEntity().removeStatus(toBeRemoved);
439
        }
440
        return super.preSaveBean(bean);
441
    }
442

    
443
    /**
444
     * {@inheritDoc}
445
     */
446
    @Override
447
    protected void guaranteePerEntityCRUDPermissions(UUID identifier) {
448
        if (crud != null) {
449
            newAuthorityCreated = UserHelperAccess.userHelper().createAuthorityForCurrentUser(TaxonName.class,
450
                    identifier, crud, null);
451
        }
452

    
453
    }
454

    
455
    /**
456
     * {@inheritDoc}
457
     */
458
    @Override
459
    protected void guaranteePerEntityCRUDPermissions(TaxonName bean) {
460
        if (crud != null) {
461
            newAuthorityCreated = UserHelperAccess.userHelper().createAuthorityForCurrentUser(bean, crud, null);
462
        }
463
    }
464

    
465
    /**
466
     * {@inheritDoc}
467
     */
468
    @Override
469
    protected INameService getService() {
470
        return getRepo().getNameService();
471
    }
472

    
473
    public void doReferenceEditorAdd(NomenclaturalStatusRow row) {
474

    
475
        ReferencePopupEditor referencePopupEditor = openPopupEditor(ReferencePopupEditor.class, null);
476

    
477
        referencePopupEditor.withReferenceTypes(RegistrationUIDefaults.MEDIA_REFERENCE_TYPES);
478
        referencePopupEditor.grantToCurrentUser(SUB_EDITOR_CRUD);
479
        referencePopupEditor.withDeleteButton(true);
480
        referencePopupEditor.loadInEditor(null);
481

    
482
        statusTypeReferencePopupEditorsRowMap.put(referencePopupEditor, row);
483
    }
484

    
485
    public void doReferenceEditorEdit(NomenclaturalStatusRow row) {
486

    
487
        ReferencePopupEditor referencePopupEditor = openPopupEditor(ReferencePopupEditor.class, null);
488
        referencePopupEditor.withReferenceTypes(RegistrationUIDefaults.MEDIA_REFERENCE_TYPES);
489
        referencePopupEditor.grantToCurrentUser(SUB_EDITOR_CRUD);
490
        referencePopupEditor.withDeleteButton(true);
491
        referencePopupEditor.loadInEditor(row.citation.getValue().getUuid());
492

    
493
        statusTypeReferencePopupEditorsRowMap.put(referencePopupEditor, row);
494
    }
495

    
496
    /**
497
     * @param referenceEditorPopup
498
     */
499
    private void configureReferencePopupEditor(ReferencePopupEditor referenceEditorPopup, UUID referenceUUID) {
500
        boolean nomRefSectionEditingOnly = getView()
501
                .isModeEnabled(TaxonNamePopupEditorMode.NOMENCLATURALREFERENCE_SECTION_EDITING_ONLY);
502
        if (nomRefSectionEditingOnly) {
503
            referenceEditorPopup.setBeanInstantiator(newReferenceInstantiator);
504
        }
505

    
506
        // TODO this should be configurable per UI -
507
        // RegistrationUiReferenceEditorFormConfigurator as spring bean,
508
        // different spring profiles
509
        referenceEditorPopup.setEditorComponentsConfigurator(new RegistrationUiReferenceEditorFormConfigurator(
510
                nomRefSectionEditingOnly && newReferenceInstantiator != null));
511

    
512
        referenceEditorPopup.loadInEditor(referenceUUID);
513
        if (!nomRefSectionEditingOnly) {
514
            referenceEditorPopup.getTypeSelect().setValue(ReferenceType.Article);
515
        }
516
    }
517

    
518
    @EventBusListenerMethod(filter = EditorActionTypeFilter.Add.class)
519
    public void onReferenceEditorActionAdd(ReferenceEditorAction event) {
520

    
521
        if (getView() == null || event.getSourceView() != getView()) {
522
            return;
523
        }
524

    
525
        ReferencePopupEditor referenceEditorPopup = openPopupEditor(ReferencePopupEditor.class, event);
526

    
527
        referenceEditorPopup.grantToCurrentUser(EnumSet.of(CRUD.UPDATE, CRUD.DELETE));
528
        referenceEditorPopup.withDeleteButton(true);
529
        configureReferencePopupEditor(referenceEditorPopup, null);
530
    }
531

    
532
    @EventBusListenerMethod(filter = EditorActionTypeFilter.Edit.class)
533
    public void onReferenceEditorActionEdit(ReferenceEditorAction event) {
534

    
535
        if (!isFromOwnView(event)) {
536
            return;
537
        }
538
        ReferencePopupEditor referenceEditorPopup = openPopupEditor(ReferencePopupEditor.class, event);
539

    
540
        referenceEditorPopup.withDeleteButton(true);
541
        configureReferencePopupEditor(referenceEditorPopup, event.getEntityUuid());
542
    }
543

    
544
    @EventBusListenerMethod
545
    public void onFieldReplaceEvent(FieldReplaceEvent<String> event) {
546

    
547
        PropertyIdPath boundPropertyIdPath = boundPropertyIdPath(event.getNewField());
548
        if (boundPropertyIdPath != null) {
549
            TaxonNameDTO taxonNamedto = ((AbstractPopupEditor<TaxonNameDTO, AbstractCdmDTOEditorPresenter<TaxonNameDTO, TaxonName, ?>>) getView())
550
                    .getBean();
551
            if (boundPropertyIdPath.matches("specificEpithet")) {
552
                AbstractField<String> genusOrUninomialField = getView().getGenusOrUninomialField();
553
                if (event.getNewField() instanceof CompositeCustomField) {
554
                    if (specificEpithetPartPagingProvider == null) {
555
                        specificEpithetPartPagingProvider = new TaxonNameStringFilterablePagingProvider(
556
                                getRepo().getNameService(), Rank.SPECIES());
557
                    }
558
                    specificEpithetPartPagingProvider.listenToFields(genusOrUninomialField, null, null, null);
559
                    specificEpithetPartPagingProvider.excludeNames(taxonNamedto.cdmEntity());
560
                    specificEpithetPartPagingProvider.updateFromFields();
561
                    WeaklyRelatedEntityCombobox<TaxonName> specificEpithetField = (WeaklyRelatedEntityCombobox<TaxonName>) event
562
                            .getNewField();
563
                    refreshSpecificEpithetComboBoxListener = e -> {
564
                        specificEpithetField.getSelect().refresh();
565
                        specificEpithetField.setValue(null);
566
                    };
567
                    specificEpithetField.loadFrom(specificEpithetPartPagingProvider, specificEpithetPartPagingProvider,
568
                            specificEpithetPartPagingProvider.getPageSize());
569
                    specificEpithetField.setValue(event.getOldField().getValue());
570
                    specificEpithetField.reload();
571
                    genusOrUninomialField.addValueChangeListener(refreshSpecificEpithetComboBoxListener);
572
                } else {
573
                    if (specificEpithetPartPagingProvider != null) {
574
                        specificEpithetPartPagingProvider.unlistenAllFields();
575
                    }
576
                    if (refreshSpecificEpithetComboBoxListener != null) {
577
                        genusOrUninomialField.removeValueChangeListener(refreshSpecificEpithetComboBoxListener);
578
                        refreshSpecificEpithetComboBoxListener = null;
579
                    }
580
                }
581
            } else if (boundPropertyIdPath.matches("genusOrUninomial")) {
582
                if (event.getNewField() instanceof CompositeCustomField) {
583
                    if (genusOrUninomialPartPagingProvider == null) {
584
                        genusOrUninomialPartPagingProvider = new TaxonNameStringFilterablePagingProvider(
585
                                getRepo().getNameService());
586
                    }
587
                    genusOrUninomialPartPagingProvider.listenToFields(null, getView().getInfraGenericEpithetField(),
588
                            getView().getSpecificEpithetField(), getView().getInfraSpecificEpithetField());
589
                    genusOrUninomialPartPagingProvider.excludeNames(taxonNamedto.cdmEntity());
590
                    WeaklyRelatedEntityCombobox<TaxonName> genusOrUninomialField = (WeaklyRelatedEntityCombobox<TaxonName>) event
591
                            .getNewField();
592
                    genusOrUninomialField.loadFrom(genusOrUninomialPartPagingProvider,
593
                            genusOrUninomialPartPagingProvider, genusOrUninomialPartPagingProvider.getPageSize());
594
                    genusOrUninomialField.setValue(event.getOldField().getValue());
595
                    genusOrUninomialField.reload();
596
                } else {
597
                    if (genusOrUninomialPartPagingProvider != null) {
598
                        genusOrUninomialPartPagingProvider.unlistenAllFields();
599
                    }
600
                }
601

    
602
            }
603
        }
604

    
605
    }
606

    
607
    @EventBusListenerMethod
608
    public void onEntityChangeEvent(EntityChangeEvent<?> event) {
609

    
610
        if (event.getSourceView() instanceof AbstractPopupEditor) {
611

    
612
            BoundField boundTargetField = boundTargetField((PopupView) event.getSourceView());
613

    
614
            if (boundTargetField != null) {
615
                if (boundTargetField.matchesPropertyIdPath("genusOrUninomial")) {
616
                    if (event.isCreateOrModifiedType()) {
617
                        getCache().load(event.getEntity());
618
                        if (getView().getGenusOrUninomialField() instanceof WeaklyRelatedEntityCombobox) {
619
                            WeaklyRelatedEntityCombobox<TaxonName> weaklyRelatedEntityCombobox = (WeaklyRelatedEntityCombobox<TaxonName>) getView()
620
                                    .getGenusOrUninomialField();
621
                            weaklyRelatedEntityCombobox.setValue(((TaxonName) event.getEntity()).getGenusOrUninomial());
622
                            // NOTE: in contrast to the ToOneRelatedEntityCombobox the .discard() does not
623
                            // work here since no datasource is bound to the field, see weaklyRelatedEntityCombobox.reload()
624
                            weaklyRelatedEntityCombobox.updateButtons();
625
                        }
626
                    }
627
                } else if (boundTargetField.matchesPropertyIdPath("specificEpithet")) {
628
                    if (event.isCreateOrModifiedType()) {
629
                        getCache().load(event.getEntity());
630
                        if (getView().getSpecificEpithetField() instanceof WeaklyRelatedEntityCombobox) {
631
                            WeaklyRelatedEntityCombobox<TaxonName> weaklyRelatedEntityCombobox = (WeaklyRelatedEntityCombobox<TaxonName>) getView()
632
                                    .getSpecificEpithetField();
633
                            getView().getSpecificEpithetField()
634
                                    .setValue(((TaxonName) event.getEntity()).getSpecificEpithet());
635
                            weaklyRelatedEntityCombobox.reload();
636
                            // NOTE: in contrast to the ToOneRelatedEntityCombobox the .discard() does not
637
                            // work here since no datasource is bound to the field, see weaklyRelatedEntityCombobox.reload()
638
                            weaklyRelatedEntityCombobox.updateButtons();
639
                        }
640
                    }
641
                } else if (boundTargetField.matchesPropertyIdPath("nomenclaturalReference")) {
642
                    if (event.isCreateOrModifiedType()) {
643
                        getCache().load(event.getEntity());
644
                        if (event.isCreatedType()) {
645
                            getView().getNomReferenceCombobox().setValue((Reference) event.getEntity());
646
                        } else {
647
                            getView().getNomReferenceCombobox().reload(); // refreshSelectedValue(modifiedReference);
648
                        }
649
                        getView().getCombinationAuthorshipField().discard(); //refresh from the datasource
650
                        getView().updateAuthorshipFields();
651
                    }
652
                } else if (boundTargetField.matchesPropertyIdPath("validationFor.otherName")
653
                        || boundTargetField.matchesPropertyIdPath("orthographicVariant.otherName")) {
654
                    ReloadableLazyComboBox<TaxonName> otherNameField = asReloadableLazyComboBox(
655
                            boundTargetField.getField(TaxonName.class));
656
                    TaxonName otherName = (TaxonName) event.getEntity();
657
                    if (event.isCreateOrModifiedType()) {
658
                        getCache().load(otherName);
659
                        if (event.isCreatedType()) {
660
                            // TODO use reloadWith((TaxonName)
661
                            // event.getEntity()); also in this case?
662
                            otherNameField.setValue(otherName);
663
                        } else {
664
                            otherNameField.reloadWith(otherName);
665
                        }
666

    
667
                    } else if (event.isRemovedType()) {
668
                        otherNameField.setValue(null);
669
                    }
670
                } else if (boundTargetField.matchesPropertyIdPath("basionyms")) {
671
                    ReloadableLazyComboBox<TaxonName> basionymSourceField = asReloadableLazyComboBox(
672
                            boundTargetField.getField(TaxonName.class));
673
                    if (event.isCreateOrModifiedType()) {
674
                        getCache().load(event.getEntity());
675
                        if (event.isCreatedType()) {
676
                            // TODO use reloadWith((TaxonName)
677
                            // event.getEntity()); also in this case?
678
                            basionymSourceField.setValue((TaxonName) event.getEntity());
679
                        } else {
680
                            basionymSourceField.reloadWith((TaxonName) event.getEntity());
681
                        }
682
                        getView().getBasionymAuthorshipField().discard(); //refresh from the datasource
683
                        getView().getExBasionymAuthorshipField().discard(); //refresh from the datasource
684
                        getView().updateAuthorshipFields();
685
                    } else if (event.isRemovedType()) {
686
                        basionymSourceField.setValue(null);
687
                        getView().updateAuthorshipFields();
688
                    }
689
                } else if (boundTargetField.matchesPropertyIdPath("replacedSynonyms")) {
690
                    ReloadableLazyComboBox<TaxonName> replacedSynonyms = asReloadableLazyComboBox(
691
                            boundTargetField.getField(TaxonName.class));
692
                    if (event.isCreateOrModifiedType()) {
693
                        getCache().load(event.getEntity());
694
                        if (event.isCreatedType()) {
695
                            // TODO use reloadWith((TaxonName)
696
                            // event.getEntity()); also in this case?
697
                            replacedSynonyms.setValue((TaxonName) event.getEntity());
698
                        } else {
699
                            replacedSynonyms.reloadWith((TaxonName) event.getEntity());
700
                        }
701
                        getView().getExCombinationAuthorshipField().discard(); //refresh from the datasource
702
                        getView().updateAuthorshipFields();
703
                    } else if (event.isRemovedType()) {
704
                        replacedSynonyms.setValue(null);
705
                        getView().updateAuthorshipFields();
706
                    }
707
                }
708

    
709
            }
710
        }
711
    }
712

    
713
    protected <CDM extends CdmBase> ReloadableLazyComboBox<CDM> asReloadableLazyComboBox(Field<CDM> field) {
714

    
715
        if (field instanceof ToOneRelatedEntityCombobox) {
716
            field = ((ToOneRelatedEntityCombobox<CDM>) field).getSelect();
717
        }
718
        return (ReloadableLazyComboBox<CDM>) field;
719
    }
720

    
721
    @EventBusListenerMethod(filter = EditorActionTypeFilter.Edit.class)
722
    public void onTaxonNameEditorActionEdit(TaxonNameEditorAction event) {
723

    
724
        if (getView() == null || event.getSourceView() != getView()) {
725
            return;
726
        }
727

    
728
        PropertyIdPath boundPropertyId = boundPropertyIdPath(event.getTarget());
729

    
730
        if (boundPropertyId != null) {
731
            if (boundPropertyId.matches("validationFor.otherName") || boundPropertyId.matches("basionyms")
732
                    || boundPropertyId.matches("replacedSynonyms")
733
                    || boundPropertyId.matches("orthographicVariant.otherName")) {
734
                TaxonNamePopupEditor namePopup = openPopupEditor(TaxonNamePopupEditor.class, event);
735
                namePopup.withDeleteButton(true);
736
                getView().getModesActive().stream()
737
                        .filter(m -> !TaxonNamePopupEditorMode.NOMENCLATURALREFERENCE_SECTION_EDITING_ONLY.equals(m))
738
                        .forEach(m -> namePopup.enableMode(m));
739
                if (boundPropertyId.matches("orthographicVariant.otherName")
740
                        && getView().isModeEnabled(TaxonNamePopupEditorMode.ORTHOGRAPHIC_CORRECTION)) {
741
                    namePopup.enableMode(TaxonNamePopupEditorMode.NOMENCLATURALREFERENCE_SECTION_EDITING_ONLY);
742
                    namePopup.disableMode(TaxonNamePopupEditorMode.VALIDATE_AGAINST_HIGHER_NAME_PART);
743
                    namePopup.getOrthographicVariantToggle().setVisible(false);
744
                }
745
                namePopup.loadInEditor(event.getEntityUuid());
746
            }
747
        }
748
    }
749

    
750
    @EventBusListenerMethod(filter = EditorActionTypeFilter.Edit.class)
751
    public void onTaxonNameEditorActionStrRepEdit(TaxonNameEditorActionStrRep event) {
752

    
753
        if (getView() == null || event.getSourceView() != getView()) {
754
            return;
755
        }
756

    
757
        PropertyIdPath boundPropertyId = boundPropertyIdPath(event.getTarget());
758

    
759
        if (boundPropertyId != null) {
760
            if (boundPropertyId.matches("genusOrUninomial") || boundPropertyId.matches("specificEpithet")) {
761
                TaxonNamePopupEditor namePopup = openPopupEditor(TaxonNamePopupEditor.class, event);
762
                namePopup.withDeleteButton(true);
763
                getView().getModesActive().stream()
764
                        .filter(m -> !TaxonNamePopupEditorMode.NOMENCLATURALREFERENCE_SECTION_EDITING_ONLY.equals(m))
765
                        .forEach(m -> namePopup.enableMode(m));
766
                namePopup.loadInEditor(event.getEntityUuid());
767
            }
768
        }
769
    }
770

    
771
    @EventBusListenerMethod(filter = EditorActionTypeFilter.Add.class)
772
    public void onTaxonNameEditorActionAdd(TaxonNameEditorAction event) {
773

    
774
        if (getView() == null || event.getSourceView() != getView()) {
775
            return;
776
        }
777

    
778
        PropertyIdPath boundPropertyId = boundPropertyIdPath(event.getTarget());
779

    
780
        if (boundPropertyId != null) {
781
            if (boundPropertyId.matches("validationFor.otherName") || boundPropertyId.matches("basionyms")
782
                    || boundPropertyId.matches("replacedSynonyms")
783
                    || boundPropertyId.matches("orthographicVariant.otherName")) {
784
                TaxonNamePopupEditor namePopup = openPopupEditor(TaxonNamePopupEditor.class, event);
785
                namePopup.grantToCurrentUser(EnumSet.of(CRUD.UPDATE, CRUD.DELETE));
786
                namePopup.withDeleteButton(true);
787
                getView().getModesActive().stream()
788
                        .filter(m -> !TaxonNamePopupEditorMode.NOMENCLATURALREFERENCE_SECTION_EDITING_ONLY.equals(m))
789
                        .forEach(m -> namePopup.enableMode(m));
790
                if (boundPropertyId.matches("orthographicVariant.otherName")
791
                        && getView().isModeEnabled(TaxonNamePopupEditorMode.ORTHOGRAPHIC_CORRECTION)) {
792
                    namePopup.enableMode(TaxonNamePopupEditorMode.NOMENCLATURALREFERENCE_SECTION_EDITING_ONLY);
793
                    namePopup.disableMode(TaxonNamePopupEditorMode.VALIDATE_AGAINST_HIGHER_NAME_PART);
794
                    Reference nomrefPreset = (Reference) ((AbstractPopupEditor<TaxonNameDTO, TaxonNameEditorPresenter>) getView())
795
                            .getBean().getNomenclaturalReference();
796
                    namePopup.setCdmEntityInstantiator(new BeanInstantiator<TaxonName>() {
797

    
798
                        @Override
799
                        public TaxonName createNewBean() {
800
                            TaxonName newTaxonName = TaxonNameFactory
801
                                    .NewNameInstance(RegistrationUIDefaults.NOMENCLATURAL_CODE, Rank.SPECIES());
802
                            newTaxonName.setNomenclaturalReference(getRepo().getReferenceService()
803
                                    .load(nomrefPreset.getUuid(), TaxonNameEditorPresenter.REFERENCE_INIT_STRATEGY));
804
                            return newTaxonName;
805
                        }
806
                    });
807
                    namePopup.getOrthographicVariantToggle().setVisible(false);
808
                }
809
                namePopup.loadInEditor(null);
810
            }
811
        }
812
    }
813

    
814
    @EventBusListenerMethod(filter = EditorActionTypeFilter.Add.class)
815
    public void onTaxonNameEditorActionStrRepAdd(TaxonNameEditorActionStrRep event) {
816

    
817
        if (getView() == null || event.getSourceView() != getView()) {
818
            return;
819
        }
820

    
821
        PropertyIdPath boundPropertyId = boundPropertyIdPath(event.getTarget());
822

    
823
        if (boundPropertyId != null) {
824
            if (boundPropertyId.matches("genusOrUninomial") || boundPropertyId.matches("specificEpithet")) {
825
                TaxonNamePopupEditor namePopup = openPopupEditor(TaxonNamePopupEditor.class, event);
826
                namePopup.grantToCurrentUser(EnumSet.of(CRUD.UPDATE, CRUD.DELETE));
827
                namePopup.withDeleteButton(true);
828
                getView().getModesActive().stream()
829
                        .filter(m -> !TaxonNamePopupEditorMode.NOMENCLATURALREFERENCE_SECTION_EDITING_ONLY.equals(m))
830
                        .forEach(m -> namePopup.enableMode(m));
831
                namePopup.loadInEditor(null);
832
                if (boundPropertyId.matches("genusOrUninomial")) {
833
                    namePopup.getRankSelect().setValue(Rank.GENUS());
834
                }
835
                if (boundPropertyId.matches("specificEpithet")) {
836
                    namePopup.getGenusOrUninomialField().setValue(getView().getGenusOrUninomialField().getValue());
837
                    namePopup.getRankSelect().setValue(Rank.SPECIES());
838
                }
839
                if (WeaklyRelatedEntityField.class.isAssignableFrom(event.getTarget().getClass())) {
840
                    WeaklyRelatedEntityField<TaxonName> taxoNameField = (WeaklyRelatedEntityField<TaxonName>) event
841
                            .getTarget();
842
                    if (!taxoNameField.isValueInOptions()) {
843
                        String nameString = event.getTarget().getValue();
844
                        if (StringUtils.isNotEmpty(nameString)) {
845
                            if (boundPropertyId.matches("genusOrUninomial")) {
846
                                namePopup.getGenusOrUninomialField().setValue(nameString);
847
                            }
848
                            if (boundPropertyId.matches("specificEpithet")) {
849
                                namePopup.getSpecificEpithetField().setValue(nameString);
850
                            }
851
                        }
852
                    }
853
                }
854
            }
855
        }
856
    }
857

    
858
    /**
859
     * {@inheritDoc}
860
     */
861
    @Override
862
    protected TaxonNameDTO createDTODecorator(TaxonName cdmEntitiy) {
863
        return new TaxonNameDTO(cdmEntitiy);
864
    }
865

    
866
    /**
867
     * {@inheritDoc}
868
     */
869
    @Override
870
    protected BeanInstantiator<TaxonName> defaultCdmEntityInstantiator() {
871
        return new BeanInstantiator<TaxonName>() {
872

    
873
            @Override
874
            public TaxonName createNewBean() {
875
                return TaxonNameFactory.NewNameInstance(RegistrationUIDefaults.NOMENCLATURAL_CODE, Rank.SPECIES());
876
            }
877
        };
878
    }
879

    
880
}
(11-11/15)