Project

General

Profile

Download (3.27 KB) Statistics
| Branch: | Tag: | Revision:
1
// $Id$
2
/**
3
* Copyright (C) 2018 EDIT
4
* European Distributed Institute of Taxonomy
5
* http://www.e-taxonomy.eu
6
*
7
* The contents of this file are subject to the Mozilla Public License Version 1.1
8
* See LICENSE.TXT at the top of this package for the full license terms.
9
*/
10
package eu.etaxonomy.cdm.persistence.dto;
11

    
12
import java.util.HashSet;
13
import java.util.Set;
14
import java.util.UUID;
15

    
16
import eu.etaxonomy.cdm.model.term.Representation;
17
import eu.etaxonomy.cdm.model.term.TermType;
18

    
19
/**
20
 * @author pplitzner
21
 * @date 05.11.2018
22
 *
23
 */
24
public class TermCollectionDto extends AbstractTermDto {
25

    
26
    private static final long serialVersionUID = 6053392236860675874L;
27

    
28
    private Set<TermDto> terms;
29

    
30
    private boolean isAllowDuplicate;
31
    private boolean containsDuplicates = false;
32
    private boolean isOrderRelevant;
33
    private boolean isFlat;
34

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

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

    
47
        }
48
        return terms;
49
    }
50

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

    
61
    public void removeTerm(TermDto term){
62
        terms.remove(term);
63
    }
64

    
65

    
66

    
67
    /**
68
     * @return the isAllowDuplicate
69
     */
70
    public boolean isAllowDuplicate() {
71
        return isAllowDuplicate;
72
    }
73

    
74
    /**
75
     * @param isAllowDuplicate the isAllowDuplicate to set
76
     */
77
    public void setAllowDuplicate(boolean isAllowDuplicate) {
78
        this.isAllowDuplicate = isAllowDuplicate;
79
    }
80

    
81
    public boolean isContainsDuplicates() {
82
        return containsDuplicates;
83
    }
84

    
85
    public void setContainsDuplicates(boolean containsDuplicates) {
86
        this.containsDuplicates = containsDuplicates;
87
    }
88

    
89
    /**
90
     * @return the isOrderRelevant
91
     */
92
    public boolean isOrderRelevant() {
93
        return isOrderRelevant;
94
    }
95

    
96
    /**
97
     * @param isOrderRelevant the isOrderRelevant to set
98
     */
99
    public void setOrderRelevant(boolean isOrderRelevant) {
100
        this.isOrderRelevant = isOrderRelevant;
101
    }
102

    
103
    /**
104
     * @return the isFlat
105
     */
106
    public boolean isFlat() {
107
        return isFlat;
108
    }
109

    
110
    /**
111
     * @param isFlat the isFlat to set
112
     */
113
    public void setFlat(boolean isFlat) {
114
        this.isFlat = isFlat;
115
    }
116

    
117
    public static String getTermCollectionDtoSelect(){
118
        return getTermCollectionDtoSelect("TermVocabulary");
119
    }
120

    
121
    public static String getTermCollectionDtoSelect(String fromTable){
122
        return ""
123
                + "select a.uuid, "
124
                + "r, "
125
                + "a.termType,"
126
                + "a.titleCache,"
127
                + "a.allowDuplicates,"
128
                + "a.orderRelevant,"
129
                + "a.isFlat "
130

    
131
                + "FROM "+fromTable+" as a "
132
                + "LEFT JOIN a.representations AS r ";
133
    }
134

    
135

    
136

    
137

    
138
}
(21-21/26)