Project

General

Profile

Revision 1f016f08

ID1f016f085dbd0429382f8fb393ac53c81ed4a04b
Parent 98a2455f
Child 2ef98d3e

Added by Andreas Kohlbecker 4 months ago

fix #7937 excluding current name from name relation selects

View differences:

src/main/java/eu/etaxonomy/cdm/service/CdmFilterablePagingProvider.java
234 234
                    values.add(v);
235 235
                }
236 236
            }
237
            prepared.add(new Restriction(r.getPropertyName(), r.getOperator(), r.getMatchMode(), values.toArray(new String[values.size()])));
237
            prepared.add(new Restriction(r.getPropertyName(), r.getOperator(), r.getMatchMode(), values.toArray(new Object[values.size()])));
238 238
        }
239 239
        return prepared;
240 240
    }
src/main/java/eu/etaxonomy/cdm/vaadin/view/name/TaxonNameEditorPresenter.java
37 37
import eu.etaxonomy.cdm.model.reference.Reference;
38 38
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
39 39
import eu.etaxonomy.cdm.model.reference.ReferenceType;
40
import eu.etaxonomy.cdm.persistence.dao.common.Restriction;
41
import eu.etaxonomy.cdm.persistence.dao.common.Restriction.Operator;
40 42
import eu.etaxonomy.cdm.persistence.hibernate.permission.CRUD;
41 43
import eu.etaxonomy.cdm.service.CdmFilterablePagingProvider;
42 44
import eu.etaxonomy.cdm.service.TaxonNameStringFilterablePagingProvider;
......
102 104

  
103 105
    private Property.ValueChangeListener refreshSpecificEpithetComboBoxListener;
104 106

  
107
    private CdmFilterablePagingProvider<TaxonName, TaxonName> relatedNamePagingProvider;
108

  
105 109
    /**
106 110
     * {@inheritDoc}
107 111
     */
......
139 143

  
140 144
        getView().getBasionymComboboxSelect().setCaptionGenerator(new CdmTitleCacheCaptionGenerator<TaxonName>());
141 145

  
142
        CdmFilterablePagingProvider<TaxonName, TaxonName> basionymPagingProvider = new CdmFilterablePagingProvider<TaxonName, TaxonName>(getRepo().getNameService());
143
        basionymPagingProvider.setInitStrategy(BASIONYM_INIT_STRATEGY);
144
        getView().getBasionymComboboxSelect().setPagingProviders(basionymPagingProvider, basionymPagingProvider, basionymPagingProvider.getPageSize(), this);
146
        relatedNamePagingProvider = new CdmFilterablePagingProvider<TaxonName, TaxonName>(getRepo().getNameService());
147
        relatedNamePagingProvider.setInitStrategy(BASIONYM_INIT_STRATEGY);
148
        getView().getBasionymComboboxSelect().setPagingProviders(relatedNamePagingProvider, relatedNamePagingProvider, relatedNamePagingProvider.getPageSize(), this);
145 149

  
146 150
        getView().getReplacedSynonymsComboboxSelect().setCaptionGenerator( new CdmTitleCacheCaptionGenerator<TaxonName>());
147 151
        // reusing the basionymPagingProvider for the replaced synonyms to benefit from caching
148
        getView().getReplacedSynonymsComboboxSelect().setPagingProviders(basionymPagingProvider, basionymPagingProvider, basionymPagingProvider.getPageSize(), this);
152
        getView().getReplacedSynonymsComboboxSelect().setPagingProviders(relatedNamePagingProvider, relatedNamePagingProvider, relatedNamePagingProvider.getPageSize(), this);
149 153

  
150 154
        getView().getValidationField().getValidatedNameComboBox().getSelect().setCaptionGenerator(new CdmTitleCacheCaptionGenerator<TaxonName>());
151 155
        // reusing the basionymPagingProvider for the replaced synonyms to benefit from caching
152
        getView().getValidationField().getValidatedNameComboBox().loadFrom(basionymPagingProvider, basionymPagingProvider, basionymPagingProvider.getPageSize());
156
        getView().getValidationField().getValidatedNameComboBox().loadFrom(relatedNamePagingProvider, relatedNamePagingProvider, relatedNamePagingProvider.getPageSize());
153 157
        getView().getValidationField().getValidatedNameComboBox().getSelect().addValueChangeListener(new ToOneRelatedEntityReloader<>(getView().getValidationField().getValidatedNameComboBox(), this));
154 158

  
155 159
        getView().getNomReferenceCombobox().getSelect().setCaptionGenerator(new CdmTitleCacheCaptionGenerator<Reference>());
......
251 255

  
252 256
        }
253 257

  
258
        relatedNamePagingProvider.addRestriction(new Restriction<>("id", Operator.AND_NOT, null, Integer.valueOf(taxonName.getId())));
259

  
254 260
        return taxonName;
255 261
    }
256 262

  

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)