Project

General

Profile

« Previous | Next » 

Revision a9527b12

Added by Andreas Kohlbecker over 3 years ago

ref #9252 determinig hasTypes from actual data and fixing type probelms in methods

View differences:

cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/dto/SpecimenOrObservationBaseDTO.java
11 11
import java.io.Serializable;
12 12
import java.util.AbstractMap;
13 13
import java.util.ArrayList;
14
import java.util.Collection;
14 15
import java.util.Comparator;
15 16
import java.util.HashSet;
16 17
import java.util.List;
......
58 59
    private String collectorsNumber;
59 60
    private String barcode;
60 61
    private String preservationMethod;
61
    private Set<SpecimenOrObservationBaseDTO> derivates;
62
    private Set<DerivedUnitDTO> derivates;
62 63

  
63 64
    private Set<SpecimenTypeDesignationDTO> specimenTypeDesignations;
64 65

  
......
79 80
                setSpecimenTypeDesignations(derivedUnit.getSpecimenTypeDesignations());
80 81
            }
81 82
        }
82

  
83

  
84 83
    }
85
//    @Override
86
//    public String getTitleCache() {
87
//        return getLabel();
88
//    }
89 84

  
90 85

  
91 86
    public String getListLabel() {
......
312 307

  
313 308

  
314 309

  
315
    public Set<SpecimenOrObservationBaseDTO> getDerivates() {
310
    public Set<DerivedUnitDTO> getDerivates() {
311
        if (this.derivates == null){
312
            this.derivates = new HashSet<>();
313
        }
316 314
        return derivates;
317 315
    }
318 316

  
319
    public void setDerivates(Set<SpecimenOrObservationBaseDTO> derivates) {
317
    public void setDerivates(Set<DerivedUnitDTO> derivates) {
320 318
        this.derivates = derivates;
321 319
    }
322 320

  
323
    public void addDerivate(SpecimenOrObservationBaseDTO derivate){
321
    public void addDerivate(DerivedUnitDTO derivate){
324 322
        if (this.derivates == null){
325 323
            this.derivates = new HashSet<>();
326 324
        }
327 325
        this.derivates.add(derivate);
328 326
    }
329
    public void addAllDerivates(Set<SpecimenOrObservationBaseDTO> derivates){
327
    public void addAllDerivates(Set<DerivedUnitDTO> derivates){
330 328
        if (this.derivates == null){
331 329
            this.derivates = new HashSet<>();
332 330
        }
333 331
        this.derivates.addAll(derivates);
334 332
    }
335 333

  
334
    /**
335
     * collects all derivatives from this an derivatives of this.
336
     */
337
    public Collection<DerivedUnitDTO> collectDerivatives() {
338
        return collectDerivatives(new HashSet<>());
339
    }
340

  
341
    /**
342
     * private partner method to {@link #collectDerivatives()} for recursive calls.
343
     *
344
     * @param dtos
345
     */
346
    private Collection<DerivedUnitDTO> collectDerivatives(Set<DerivedUnitDTO> dtos) {
347
        dtos.addAll(getDerivates());
348
        if(derivates != null) {
349
            for(SpecimenOrObservationBaseDTO subDto : derivates) {
350
                dtos.addAll(subDto.collectDerivatives(dtos));
351
            }
352
        }
353
        return dtos;
354
    }
355

  
336 356
    public DerivationEventDTO getDerivationEvent() {
337 357
        return derivationEvent;
338 358
    }

Also available in: Unified diff