Project

General

Profile

Revision db1db901

IDdb1db90169123bf1cb0ef824211fc0cdd6c33df0
Parent 68cc664b
Child d02788a3

Added by Andreas Kohlbecker over 1 year ago

fix #7831 excluding the current name from the WeaklyRelatedEntityCombobox for genus name and specific epithet

View differences:

src/main/java/eu/etaxonomy/cdm/service/TaxonNameStringFilterablePagingProvider.java
16 16
import java.util.UUID;
17 17

  
18 18
import org.apache.log4j.Logger;
19
import org.hibernate.criterion.Criterion;
20 19
import org.vaadin.viritin.fields.LazyComboBox.FilterableCountProvider;
21 20

  
22 21
import com.vaadin.data.Property.ValueChangeListener;
......
27 26
import eu.etaxonomy.cdm.api.service.pager.Pager;
28 27
import eu.etaxonomy.cdm.api.utility.TaxonNamePartsFilter;
29 28
import eu.etaxonomy.cdm.model.name.Rank;
29
import eu.etaxonomy.cdm.model.name.TaxonName;
30 30
import eu.etaxonomy.cdm.persistence.dto.TaxonNameParts;
31 31
import eu.etaxonomy.cdm.persistence.query.MatchMode;
32 32
import eu.etaxonomy.cdm.persistence.query.OrderHint;
......
57 57

  
58 58
    List<String> initStrategy = DEFAULT_INIT_STRATEGY;
59 59

  
60
    private List<Criterion> criteria = new ArrayList<>();
61

  
62 60
    private TaxonNamePartsFilter namePartsFilter = new TaxonNamePartsFilter();
63 61

  
64 62
    private Map<AbstractField<String>, ValueChangeListener> registeredToFields = new HashMap<>();
......
189 187
        return namePartStrings;
190 188
    }
191 189

  
192

  
193

  
194 190
    /**
195 191
     * {@inheritDoc}
196 192
     */
......
218 214
        this.pageSize = pageSize;
219 215
    }
220 216

  
221

  
222
    /**
223
     * The list of criteria is initially empty.
224
     *
225
     * @return the criteria
226
     */
227
    public List<Criterion> getCriteria() {
228
        return criteria;
229
    }
230

  
231 217
    /**
232 218
     * @return the lastPagedEntityUUIDs
233 219
     */
......
239 225
    public class UnknownFieldException extends Exception {
240 226

  
241 227
        private static final long serialVersionUID = 1L;
242

  
243

  
244 228
    }
245 229

  
246

  
247 230
    /**
248 231
     * {@inheritDoc}
249 232
     */
......
262 245
    public void clearIdCache() {
263 246
        lastPagedEntityUUIDs = null;
264 247
    }
248

  
249
    /**
250
     * @param asList
251
     * @return
252
     */
253
    public void excludeNames(TaxonName ... excludedTaxonNames) {
254
        namePartsFilter.getExludedNames().clear();
255
        for(TaxonName n : excludedTaxonNames){
256
            namePartsFilter.getExludedNames().add(n);
257
        }
258
    }
265 259
}
src/main/java/eu/etaxonomy/cdm/vaadin/view/name/TaxonNameEditorPresenter.java
331 331

  
332 332
        PropertyIdPath boundPropertyIdPath = boundPropertyIdPath(event.getNewField());
333 333
        if(boundPropertyIdPath != null){
334
            TaxonNameDTO taxonNamedto = ((AbstractPopupEditor<TaxonNameDTO, AbstractCdmDTOEditorPresenter<TaxonNameDTO, TaxonName,?>>)getView()).getBean();
334 335
            if(boundPropertyIdPath.matches("specificEpithet")){
335 336
                AbstractField<String> genusOrUninomialField = getView().getGenusOrUninomialField();
336 337
                if(event.getNewField() instanceof CompositeCustomField){
......
340 341
                    specificEpithetPartPagingProvider.listenToFields(
341 342
                            genusOrUninomialField,
342 343
                            null, null, null);
344
                    specificEpithetPartPagingProvider.excludeNames(taxonNamedto.cdmEntity());
343 345
                    specificEpithetPartPagingProvider.updateFromFields();
344 346
                    WeaklyRelatedEntityCombobox<TaxonName> specificEpithetField = (WeaklyRelatedEntityCombobox<TaxonName>)event.getNewField();
345 347
                    refreshSpecificEpithetComboBoxListener = e -> { specificEpithetField.getSelect().refresh(); specificEpithetField.setValue(null);};
346 348
                    specificEpithetField.loadFrom(specificEpithetPartPagingProvider, specificEpithetPartPagingProvider, specificEpithetPartPagingProvider.getPageSize());
347 349
                    specificEpithetField.setValue(event.getOldField().getValue());
350
                    specificEpithetField.reload();
348 351
                    genusOrUninomialField.addValueChangeListener(refreshSpecificEpithetComboBoxListener);
349 352
                } else {
350 353
                    if(specificEpithetPartPagingProvider != null){
......
366 369
                                getView().getSpecificEpithetField(),
367 370
                                getView().getInfraSpecificEpithetField()
368 371
                               );
372
                    genusOrUninomialPartPagingProvider.excludeNames(taxonNamedto.cdmEntity());
369 373
                    WeaklyRelatedEntityCombobox<TaxonName> genusOrUninomialField = (WeaklyRelatedEntityCombobox<TaxonName>)event.getNewField();
370 374
                    genusOrUninomialField.loadFrom(genusOrUninomialPartPagingProvider, genusOrUninomialPartPagingProvider, genusOrUninomialPartPagingProvider.getPageSize());
371 375
                    genusOrUninomialField.setValue(event.getOldField().getValue());
376
                    genusOrUninomialField.reload();
372 377
                }else {
373 378
                    if(genusOrUninomialPartPagingProvider != null){
374 379
                        genusOrUninomialPartPagingProvider.unlistenAllFields();
src/main/java/eu/etaxonomy/vaadin/component/WeaklyRelatedEntityCombobox.java
189 189

  
190 190

  
191 191
    /**
192
     * {@inheritDoc}
192
     * sets the selection to the <code>newFieldValue</code> only if the value can
193
     * be provided by the FilterablePagingProvider
194
     *
193 195
     */
194 196
    @Override
195 197
    public void setValue(String newFieldValue) throws com.vaadin.data.Property.ReadOnlyException, ConversionException {
196 198
        lazySelect.refresh();
197
        lazySelect.setValue(newFieldValue);
199
        if(lazySelect.getOptions().contains(newFieldValue)){
200
            lazySelect.setValue(newFieldValue);
201
        }
198 202
        lazySelect.markAsDirty();
199 203
    }
200 204

  

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)