This repository has been archived by the owner on Nov 9, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
TextFlowTarget.java
250 lines (222 loc) · 7.54 KB
/
TextFlowTarget.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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
package org.zanata.rest.dto.resource;
import java.io.Serializable;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlType;
import org.codehaus.jackson.annotate.JsonIgnore;
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.hibernate.validator.constraints.NotEmpty;
import org.zanata.common.ContentState;
import org.zanata.common.Namespaces;
import org.zanata.rest.dto.DTOUtil;
import org.zanata.rest.dto.Extensible;
import org.zanata.rest.dto.Person;
import org.zanata.rest.dto.extensions.gettext.TextFlowTargetExtension;
@XmlType(name = "textFlowTargetType", propOrder = { "description",
"translator", "content", "contents", "sourceHash", "extensions" })
@JsonPropertyOrder({ "resId", "state", "translator", "content", "contents",
"sourceHash", "extensions" })
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
public class TextFlowTarget extends TextContainer implements Serializable,
Extensible<TextFlowTargetExtension> {
private static final long serialVersionUID = 1L;
private String resId;
private ContentState state = ContentState.New;
private Person translator;
private String description;
private ExtensionSet<TextFlowTargetExtension> extensions;
private Integer revision;
private Integer textFlowRevision;
private String sourceHash;
public TextFlowTarget() {
}
public TextFlowTarget(String resId) {
this.resId = resId;
}
@XmlElement(name = "person", namespace = Namespaces.ZANATA_API)
@JsonProperty("translator")
public Person getTranslator() {
return translator;
}
@Deprecated
/**
* Zanata server will ignore this field if set,
* If uploader wants to take credit for translations, use isMyTranslations
* flag.
*
* @see org.zanata.rest.service.AsynchronousProcessResource#startTranslatedDocCreationOrUpdate
*/
public void setTranslator(Person translator) {
this.translator = translator;
}
@XmlAttribute(name = "state", required = true)
public ContentState getState() {
return state;
}
public void setState(ContentState state) {
this.state = state;
}
/**
* Optional descriptive text to identify the TextFlowTarget, eg an
* abbreviated version of the source text being translated. This can be used
* for a more readable XML serialisation.
*
* @return
*/
@XmlElement(name = "description", required = false,
namespace = Namespaces.ZANATA_OLD)
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
@XmlElementWrapper(name = "extensions", required = false,
namespace = Namespaces.ZANATA_OLD)
@XmlElement(name = "extension", namespace = Namespaces.ZANATA_OLD)
public ExtensionSet<TextFlowTargetExtension> getExtensions() {
return extensions;
}
@JsonIgnore
public ExtensionSet<TextFlowTargetExtension> getExtensions(
boolean createIfNull) {
if (createIfNull && extensions == null)
extensions = new ExtensionSet<TextFlowTargetExtension>();
return extensions;
}
public void setExtensions(ExtensionSet<TextFlowTargetExtension> extensions) {
this.extensions = extensions;
}
@XmlAttribute(name = "res-id", required = true)
@NotEmpty
@JsonProperty("resId")
public String getResId() {
return resId;
}
public void setResId(String resId) {
this.resId = resId;
}
/**
* Optional MD5 hash of the source text.
* @return the sourceHash
*/
public String getSourceHash() {
return sourceHash;
}
/**
* Optional MD5 hash of the source text, which the server may use to check
* for outdated translations upon push. If the source text has multiple
* parts (eg msgid and msgid_plural), please concatenate them with '|'
* before hashing.
* @param hash
*/
public void setSourceHash(String hash) {
this.sourceHash = hash;
}
@Override
public String toString() {
return DTOUtil.toXML(this);
}
@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result =
prime * result
+ ((description == null) ? 0 : description.hashCode());
result =
prime * result
+ ((extensions == null) ? 0 : extensions.hashCode());
result = prime * result + ((resId == null) ? 0 : resId.hashCode());
result = prime * result + ((state == null) ? 0 : state.hashCode());
result =
prime * result
+ ((translator == null) ? 0 : translator.hashCode());
result =
prime * result + ((revision == null) ? 0 : revision.hashCode());
result =
prime
* result
+ ((textFlowRevision == null) ? 0 : textFlowRevision
.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!super.equals(obj)) {
return false;
}
if (!(obj instanceof TextFlowTarget)) {
return false;
}
TextFlowTarget other = (TextFlowTarget) obj;
if (description == null) {
if (other.description != null) {
return false;
}
} else if (!description.equals(other.description)) {
return false;
}
if (extensions == null) {
if (other.extensions != null) {
return false;
}
} else if (!extensions.equals(other.extensions)) {
return false;
}
if (resId == null) {
if (other.resId != null) {
return false;
}
} else if (!resId.equals(other.resId)) {
return false;
}
if (state != other.state) {
return false;
}
if (translator == null) {
if (other.translator != null) {
return false;
}
} else if (!translator.equals(other.translator)) {
return false;
}
if (revision == null) {
if (other.revision != null) {
return false;
}
} else if (!revision.equals(other.revision)) {
return false;
}
if (textFlowRevision == null) {
if (other.textFlowRevision != null) {
return false;
}
} else if (!textFlowRevision.equals(other.textFlowRevision)) {
return false;
}
return true;
}
@XmlAttribute(name = "revision", required = false)
public Integer getRevision() {
return revision;
}
public void setRevision(Integer i) {
revision = i;
}
@XmlAttribute(name = "resourceRevision", required = false)
public Integer getTextFlowRevision() {
return textFlowRevision;
}
public void setTextFlowRevision(Integer textFlowRevision) {
this.textFlowRevision = textFlowRevision;
}
}