-
Notifications
You must be signed in to change notification settings - Fork 51
/
GlossaryTerm.java
188 lines (162 loc) · 6.03 KB
/
GlossaryTerm.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
/*
* Copyright 2011, Red Hat, Inc. and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.zanata.rest.dto;
import java.io.Serializable;
import java.util.Date;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import com.webcohesion.enunciate.metadata.DocumentationExample;
import com.webcohesion.enunciate.metadata.Label;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.annotate.JsonProperty;
import org.codehaus.jackson.annotate.JsonPropertyOrder;
import org.codehaus.jackson.map.annotate.JsonSerialize;
import org.zanata.common.LocaleId;
import org.zanata.common.Namespaces;
/**
* A single glossary term for a single locale
* @author Alex Eng <a href="mailto:aeng@redhat.com">aeng@redhat.com</a>
*
*/
@XmlType(name = "glossaryTermType", propOrder = {"comment", "content", "locale", "lastModifiedDate", "lastModifiedBy"})
@JsonPropertyOrder({ "content", "comment", "locale", "lastModifiedDate", "lastModifiedBy" })
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
@Label("Glossary Term")
public class GlossaryTerm implements Serializable {
/**
*
*/
private static final long serialVersionUID = 6140176481272689471L;
@NotNull
private LocaleId locale;
@Size(max = 500)
private String content;
@Size(max = 500)
private String comment;
private String lastModifiedBy;
private Date lastModifiedDate;
public GlossaryTerm() {
}
/**
* Term's locale
*/
@XmlAttribute(name = "lang", namespace = Namespaces.XML)
@XmlJavaTypeAdapter(type = LocaleId.class, value = LocaleIdAdapter.class)
@JsonProperty("locale")
@DocumentationExample(value = "es-ES", value2 = "ja")
public LocaleId getLocale() {
return locale;
}
public void setLocale(LocaleId locale) {
this.locale = locale;
}
/**
* The term's translation in the given locale
*/
@XmlElement(name = "content", required = false,
namespace = Namespaces.ZANATA_OLD)
@JsonProperty("content")
@DocumentationExample(value = "Una casa", value2 = "家")
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
@XmlElement(name = "comment", namespace = Namespaces.ZANATA_API)
@JsonProperty("comment")
public String getComment() {
return comment;
}
public void setComment(String comment) {
this.comment = comment;
}
/**
* A string which identifies the user who last modififed this entry
*/
@XmlElement(name = "lastModifiedBy", required = false,
namespace = Namespaces.ZANATA_API)
@JsonProperty("lastModifiedBy")
@DocumentationExample("homer")
public String getLastModifiedBy() {
return lastModifiedBy;
}
public void setLastModifiedBy(String lastModifiedBy) {
this.lastModifiedBy = lastModifiedBy;
}
/**
* A timestamp indicating the last modification date for this entry
*/
@XmlElement(name = "lastModifiedDate", required = false,
namespace = Namespaces.ZANATA_API)
@JsonProperty("lastModifiedDate")
public Date getLastModifiedDate() {
return lastModifiedDate != null ? new Date(
lastModifiedDate.getTime()) : null;
}
public void setLastModifiedDate(Date lastModifiedDate) {
this.lastModifiedDate =
lastModifiedDate != null ? new Date(
lastModifiedDate.getTime()) : null;
}
@Override
public String toString() {
return DTOUtil.toXML(this);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof GlossaryTerm)) return false;
GlossaryTerm that = (GlossaryTerm) o;
if (comment != null ? !comment.equals(that.comment) :
that.comment != null)
return false;
if (content != null ? !content.equals(that.content) :
that.content != null)
return false;
if (lastModifiedBy != null ?
!lastModifiedBy.equals(that.lastModifiedBy) :
that.lastModifiedBy != null) return false;
if (lastModifiedDate != null ?
!lastModifiedDate.equals(that.lastModifiedDate) :
that.lastModifiedDate != null) return false;
if (locale != null ? !locale.equals(that.locale) : that.locale != null)
return false;
return true;
}
@Override
public int hashCode() {
int result = locale != null ? locale.hashCode() : 0;
result = 31 * result + (content != null ? content.hashCode() : 0);
result = 31 * result + (comment != null ? comment.hashCode() : 0);
result =
31 * result +
(lastModifiedBy != null ? lastModifiedBy.hashCode() : 0);
result = 31 * result +
(lastModifiedDate != null ? lastModifiedDate.hashCode() : 0);
return result;
}
}