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.io.Serializable;
|
13
|
import java.net.URI;
|
14
|
import java.util.Set;
|
15
|
import java.util.UUID;
|
16
|
|
17
|
import eu.etaxonomy.cdm.model.common.Representation;
|
18
|
import eu.etaxonomy.cdm.model.common.TermType;
|
19
|
|
20
|
/**
|
21
|
* @author pplitzner
|
22
|
* @date 05.11.2018
|
23
|
*
|
24
|
*/
|
25
|
public class AbstractTermDto implements Serializable, Comparable<AbstractTermDto> {
|
26
|
|
27
|
private static final long serialVersionUID = -7160319884811828125L;
|
28
|
|
29
|
private final UUID uuid;
|
30
|
private URI uri;
|
31
|
private TermType termType;
|
32
|
private final Set<Representation> representations;
|
33
|
private String representation_L10n = null;
|
34
|
private String representation_L10n_abbreviatedLabel = null;
|
35
|
private String representation_L10n_text = null;
|
36
|
|
37
|
public AbstractTermDto(UUID uuid, Set<Representation> representations) {
|
38
|
this.representations = representations;
|
39
|
this.uuid = uuid;
|
40
|
}
|
41
|
|
42
|
/**
|
43
|
*
|
44
|
* @param representation_L10n a blank instance of ITermRepresentation_L10n
|
45
|
* created by the default constructor
|
46
|
*/
|
47
|
public void localize(ITermRepresentation_L10n representation_L10n) {
|
48
|
|
49
|
representation_L10n.localize(representations);
|
50
|
if (representation_L10n.getLabel() != null) {
|
51
|
setRepresentation_L10n(representation_L10n.getLabel());
|
52
|
}
|
53
|
if (representation_L10n.getAbbreviatedLabel() != null) {
|
54
|
setRepresentation_L10n_abbreviatedLabel(representation_L10n.getAbbreviatedLabel());
|
55
|
}
|
56
|
if (representation_L10n.getText() != null) {
|
57
|
setRepresentation_L10n_text(representation_L10n.getText());
|
58
|
}
|
59
|
}
|
60
|
|
61
|
public URI getUri() {
|
62
|
return uri;
|
63
|
}
|
64
|
|
65
|
public void setUri(URI uri) {
|
66
|
this.uri = uri;
|
67
|
}
|
68
|
|
69
|
public TermType getTermType() {
|
70
|
return termType;
|
71
|
}
|
72
|
|
73
|
public void setTermType(TermType termType) {
|
74
|
this.termType = termType;
|
75
|
}
|
76
|
|
77
|
public String getRepresentation_L10n() {
|
78
|
return representation_L10n;
|
79
|
}
|
80
|
|
81
|
public void setRepresentation_L10n(String representation_L10n) {
|
82
|
this.representation_L10n = representation_L10n;
|
83
|
}
|
84
|
|
85
|
public void addRepresentation(Representation representation) {
|
86
|
representations.add(representation);
|
87
|
|
88
|
}
|
89
|
|
90
|
public String getRepresentation_L10n_abbreviatedLabel() {
|
91
|
return representation_L10n_abbreviatedLabel;
|
92
|
}
|
93
|
|
94
|
public void setRepresentation_L10n_abbreviatedLabel(String representation_L10n_abbreviatedLabel) {
|
95
|
this.representation_L10n_abbreviatedLabel = representation_L10n_abbreviatedLabel;
|
96
|
}
|
97
|
|
98
|
public String getRepresentation_L10n_text() {
|
99
|
return representation_L10n_text;
|
100
|
}
|
101
|
|
102
|
public void setRepresentation_L10n_text(String representation_L10n_text) {
|
103
|
this.representation_L10n_text = representation_L10n_text;
|
104
|
}
|
105
|
|
106
|
|
107
|
public UUID getUuid() {
|
108
|
return uuid;
|
109
|
}
|
110
|
|
111
|
public Set<Representation> getRepresentations() {
|
112
|
return representations;
|
113
|
}
|
114
|
|
115
|
@Override
|
116
|
public int hashCode() {
|
117
|
final int prime = 31;
|
118
|
int result = 1;
|
119
|
result = prime * result + ((uuid == null) ? 0 : uuid.hashCode());
|
120
|
return result;
|
121
|
}
|
122
|
|
123
|
@Override
|
124
|
public boolean equals(Object obj) {
|
125
|
if (this == obj) {
|
126
|
return true;
|
127
|
}
|
128
|
if (obj == null) {
|
129
|
return false;
|
130
|
}
|
131
|
if (getClass() != obj.getClass()) {
|
132
|
return false;
|
133
|
}
|
134
|
AbstractTermDto other = (AbstractTermDto) obj;
|
135
|
if (uuid == null) {
|
136
|
if (other.uuid != null) {
|
137
|
return false;
|
138
|
}
|
139
|
} else if (!uuid.equals(other.uuid)) {
|
140
|
return false;
|
141
|
}
|
142
|
return true;
|
143
|
}
|
144
|
|
145
|
@Override
|
146
|
public int compareTo(AbstractTermDto o) {
|
147
|
if(o == null){
|
148
|
return 1;
|
149
|
}
|
150
|
if(o.getRepresentation_L10n()!=null){
|
151
|
if(representation_L10n==null){
|
152
|
return -1;
|
153
|
}
|
154
|
else{
|
155
|
return representation_L10n.toLowerCase().compareTo(o.getRepresentation_L10n().toLowerCase());
|
156
|
}
|
157
|
}
|
158
|
else if(representation_L10n!=null){
|
159
|
return 1;
|
160
|
}
|
161
|
return uuid.compareTo(o.getUuid());
|
162
|
}
|
163
|
|
164
|
}
|