Project

General

Profile

« Previous | Next » 

Revision 37f2b410

Added by Katja Luther almost 3 years ago

ref #8776: fix contains duplicates in dto

View differences:

cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dto/TermCollectionDto.java
9 9
*/
10 10
package eu.etaxonomy.cdm.persistence.dto;
11 11

  
12
import java.util.ArrayList;
12 13
import java.util.HashSet;
14
import java.util.List;
13 15
import java.util.Set;
14 16
import java.util.UUID;
15 17

  
......
25 27

  
26 28
    private static final long serialVersionUID = 6053392236860675874L;
27 29

  
28
    private Set<TermDto> terms;
30
    private List<TermDto> terms;
29 31

  
30 32
    private boolean isAllowDuplicate;
31 33
    private boolean containsDuplicates = false;
......
34 36

  
35 37
    public TermCollectionDto(UUID uuid, Set<Representation> representations, TermType termType, String titleCache, boolean isAllowDuplicate, boolean isOrderRelevant, boolean isFlat) {
36 38
        super(uuid, representations, titleCache);
37
        terms = new HashSet<>();
39
        terms = new ArrayList<>();
38 40
        setTermType(termType);
39 41
        this.isAllowDuplicate = isAllowDuplicate;
40 42
        this.isOrderRelevant = isOrderRelevant;
41 43
        this.isFlat = isFlat;
42 44
    }
43 45

  
44
    public Set<TermDto> getTerms() {
46
    public List<TermDto> getTerms() {
45 47
        if (terms.isEmpty()){
46 48

  
47 49
        }
......
49 51
    }
50 52

  
51 53
    public void addTerm(TermDto term){
54
        if (term == null){
55
            return;
56
        }
52 57
        if (terms == null){
53
            terms = new HashSet<>();
58
            terms = new ArrayList<>();
54 59
        }
55 60
        if (terms.contains(term)){
56 61
            containsDuplicates = true;
......
79 84
    }
80 85

  
81 86
    public boolean isContainsDuplicates() {
87
        Set<TermDto> dtoSet = new HashSet<>(terms);
88
        if (dtoSet.size() == terms.size()){
89
            containsDuplicates = false;
90
        }
91

  
82 92
        return containsDuplicates;
83 93
    }
84 94

  

Also available in: Unified diff