Project

General

Profile

« Previous | Next » 

Revision 4e19a89d

Added by Andreas Kohlbecker over 5 years ago

ref #7648 using CdmEntityInstantiator to disentangle the handling the creation of new taxon names for registrations

View differences:

src/main/java/eu/etaxonomy/cdm/vaadin/view/name/TaxonNameEditorPresenter.java
225 225
        }
226 226

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

  
245
                // new Reference only a sub sections of the publishedUnit
246
                newReferenceInstantiator = new BeanInstantiator<Reference>() {
247
                    @Override
248
                    public Reference createNewBean() {
249
                        Reference newRef = ReferenceFactory.newSection();
250
                        newRef.setInReference(publishedUnit);
251
                        return newRef;
252
                    }
253
                };
228
            Reference nomRef = taxonName.getNomenclaturalReference();
254 229

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

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

  
256 255
        }
257 256
        return taxonName;
258 257
    }

Also available in: Unified diff