Project

General

Profile

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

    
11
import java.util.ArrayList;
12
import java.util.List;
13
import java.util.UUID;
14

    
15
import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode;
16
import eu.etaxonomy.cdm.model.taxon.Synonym;
17
import eu.etaxonomy.cdm.model.taxon.Taxon;
18
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
19
import eu.etaxonomy.cdm.strategy.cache.TaggedText;
20

    
21
/**
22
 * @author a.kohlbecker
23
 * @since Jun 13, 2016
24
 *
25
 */
26
public class TaxonNodeDto extends UuidAndTitleCache<ITaxonTreeNode> {
27

    
28
    private static final long serialVersionUID = -7169646913528213604L;
29

    
30
    /**
31
     * count of the direct taxonomic children
32
     */
33
    private final int taxonomicChildrenCount;
34

    
35
    /**
36
     * The UUID of the associated secundum reference
37
     */
38
    private UUID secUuid = null;
39

    
40
    /**
41
     * The uuid of the associated Taxon entity
42
     */
43
    private UUID taxonUuid = null;
44

    
45
    /**
46
     * the taggedTitle of the associated TaxonName entity
47
     */
48
    private List<TaggedText> taggedTitle = new ArrayList<>();
49

    
50
    /**
51
     * The unplaced flag of the Taxon entity
52
     */
53
    private final boolean unplaced;
54

    
55
    /**
56
     * The excluded flag of the Taxon entity
57
     */
58
    private final boolean excluded;
59

    
60
    /**
61
     * The doubtful flag of the TaxonNode entity
62
     */
63
    private final boolean doubtful;
64

    
65
    /**
66
     * The Rank.label value of the rank to which the associated TaxonName entity is assigned to.
67
     */
68
    private String rankLabel = null;
69
    private Integer rankOrderIndex;
70

    
71
    private final TaxonStatus status;
72

    
73
    private final UUID classificationUUID;
74
    private final UUID parentUUID;
75

    
76
    private final String treeIndex;
77
    private final Integer sortIndex;
78

    
79
    /**
80
     * @param taxonNode
81
     */
82
    public TaxonNodeDto(TaxonNode taxonNode) {
83
        this(null, taxonNode);
84
    }
85

    
86
    public TaxonNodeDto(Class type, TaxonNode taxonNode) {
87
        super(type, taxonNode.getUuid(), taxonNode.getId(), null);
88
        Taxon taxon = taxonNode.getTaxon();
89
        if (taxon != null){
90
            setTitleCache(taxon.getName() != null ? taxon.getName().getTitleCache() : taxon.getTitleCache());
91
            secUuid = taxon.getSec() != null ? taxon.getSec().getUuid() : null;
92
            taxonUuid = taxon.getUuid();
93
            taggedTitle = taxon.getName() != null? taxon.getName().getTaggedName() : taxon.getTaggedTitle();
94
            rankLabel = taxon.getNullSafeRank() != null ? taxon.getNullSafeRank().getLabel() : null;
95
            this.setAbbrevTitleCache(taxon.getTitleCache());
96
            rankOrderIndex =taxon.getNullSafeRank() != null ? taxon.getNullSafeRank().getOrderIndex() : null;
97

    
98
        }else{
99
            setTitleCache(taxonNode.getClassification().getTitleCache());
100
            rankOrderIndex = null;
101
        }
102
        taxonomicChildrenCount = taxonNode.getCountChildren();
103
        unplaced = taxonNode.isUnplaced();
104
        excluded = taxonNode.isExcluded();
105
        doubtful = taxonNode.isDoubtful();
106

    
107
        status = TaxonStatus.Accepted;
108
        classificationUUID = taxonNode.getClassification().getUuid();
109
        treeIndex = taxonNode.treeIndex();
110
        parentUUID = taxonNode.getParent() == null? null:taxonNode.getParent().getUuid();
111
        sortIndex = taxonNode.getSortIndex();
112
    }
113

    
114
    /**
115
     * @param taxonNode
116
     */
117
    public TaxonNodeDto(Synonym synonym, boolean isHomotypic) {
118
        super(null, synonym.getName().getTitleCache());
119

    
120
        taxonomicChildrenCount = 0;
121
        secUuid = synonym.getSec().getUuid();
122
        taxonUuid = synonym.getUuid();
123
//        setTitleCache(synonym.getName().getTitleCache());
124
        taggedTitle = synonym.getName().getTaggedName();
125
        unplaced = false;
126
        excluded = false;
127
        doubtful = false;
128
        rankLabel = synonym.getNullSafeRank() != null ? synonym.getNullSafeRank().getLabel() : null;
129
        rankOrderIndex =synonym.getNullSafeRank() != null ? synonym.getNullSafeRank().getOrderIndex() : null;
130
        status = isHomotypic ? TaxonStatus.SynonymObjective : TaxonStatus.Synonym;
131
        classificationUUID = null;
132
        treeIndex = null;
133
        sortIndex = null;
134
        parentUUID = null;
135

    
136
    }
137

    
138

    
139

    
140
    /**
141
     * @return the taxonomicChildrenCount
142
     */
143
    public int getTaxonomicChildrenCount() {
144
        return taxonomicChildrenCount;
145
    }
146

    
147
    /**
148
     * @return the secUuid
149
     */
150
    public UUID getSecUuid() {
151
        return secUuid;
152
    }
153

    
154
    /**
155
     * @return the taxonUuid
156
     */
157
    public UUID getTaxonUuid() {
158
        return taxonUuid;
159
    }
160

    
161

    
162
    /**
163
     * @return the taggedTitle
164
     */
165
    public List<TaggedText> getTaggedTitle() {
166
        return taggedTitle;
167
    }
168

    
169
    /**
170
     * @return the unplaced
171
     */
172
    public boolean isUnplaced() {
173
        return unplaced;
174
    }
175

    
176
    /**
177
     * @return the excluded
178
     */
179
    public boolean isExcluded() {
180
        return excluded;
181
    }
182

    
183
    /**
184
     * @return the doubtful
185
     */
186
    public boolean isDoubtful() {
187
        return doubtful;
188
    }
189
    /**
190
     * @return the rankLabel
191
     */
192
    public String getRankLabel() {
193
        return rankLabel;
194
    }
195

    
196
    /**
197
     * @return the status
198
     */
199
    public TaxonStatus getStatus() {
200
        return status;
201
    }
202

    
203
    public UUID getClassificationUUID() {
204
        return classificationUUID;
205
    }
206

    
207
    public String getTreeIndex() {
208
        return treeIndex;
209
    }
210

    
211
    public UUID getParentUUID() {
212
        return parentUUID;
213
    }
214

    
215
    public Integer getSortIndex() {
216
        return sortIndex;
217
    }
218

    
219
    public Integer getRankOrderIndex() {
220
        return rankOrderIndex;
221
    }
222

    
223
    public String getTaxonTitleCache(){
224
        return getAbbrevTitleCache();
225
    }
226

    
227
    public String getNameTitleCache(){
228
        return getTitleCache();
229
    }
230

    
231

    
232
    @Override
233
    public boolean equals(Object node2){
234
        if (node2 instanceof TaxonNodeDto){
235
            return this.getUuid().equals(((TaxonNodeDto)node2).getUuid());
236
        } else{
237
            return false;
238
        }
239

    
240

    
241
    }
242

    
243

    
244
}
(9-9/16)