Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
add explicit json annotation to dto properties
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick Huang committed Jun 16, 2015
1 parent 8378695 commit 9fd9565
Show file tree
Hide file tree
Showing 12 changed files with 33 additions and 0 deletions.
Expand Up @@ -12,6 +12,7 @@
import javax.xml.bind.annotation.XmlType;

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.Email;
Expand Down Expand Up @@ -116,6 +117,7 @@ public void setEnabled(boolean enabled) {
}

@XmlElement(name = "role", namespace = Namespaces.ZANATA_OLD)
@JsonProperty("roles")
public Set<String> getRoles() {
return roles;
}
Expand All @@ -125,6 +127,7 @@ public void setRoles(Set<String> roles) {
}

@XmlElement(name = "tribe", namespace = Namespaces.ZANATA_OLD)
@JsonProperty("tribes")
public Set<String> getTribes() {
return tribes;
}
Expand Down
Expand Up @@ -30,6 +30,7 @@
import javax.xml.bind.annotation.XmlType;

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.Namespaces;
Expand Down Expand Up @@ -64,6 +65,7 @@ public class Glossary implements Serializable, HasMediaType {
@XmlElementWrapper(name = "source-locales", required = false,
namespace = Namespaces.ZANATA_OLD)
@XmlElement(name = "locale", namespace = Namespaces.ZANATA_OLD)
@JsonProperty("sourceLocales")
public LocaleList getSourceLocales() {
return sourceLocales;
}
Expand All @@ -75,6 +77,7 @@ public void setSourceLocales(LocaleList sourceLocales) {
@XmlElementWrapper(name = "target-locales", required = false,
namespace = Namespaces.ZANATA_OLD)
@XmlElement(name = "locale", namespace = Namespaces.ZANATA_OLD)
@JsonProperty("targetLocales")
public LocaleList getTargetLocales() {
return targetLocales;
}
Expand All @@ -86,6 +89,7 @@ public void setTargetLocales(LocaleList targetLocales) {
@XmlElementWrapper(name = "glossary-entries",
namespace = Namespaces.ZANATA_OLD)
@XmlElement(name = "glossary-entry", namespace = Namespaces.ZANATA_OLD)
@JsonProperty("glossaryEntries")
public List<GlossaryEntry> getGlossaryEntries() {
if (glossaryEntries == null) {
glossaryEntries = new ArrayList<GlossaryEntry>();
Expand Down
Expand Up @@ -30,6 +30,7 @@
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;

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;
Expand Down Expand Up @@ -58,6 +59,7 @@ public class GlossaryEntry implements Serializable {
private String sourcereference;

@XmlElement(name = "glossary-term", namespace = Namespaces.ZANATA_OLD)
@JsonProperty("glossaryTerms")
public List<GlossaryTerm> getGlossaryTerms() {
if (glossaryTerms == null) {
glossaryTerms = new ArrayList<GlossaryTerm>();
Expand All @@ -71,6 +73,7 @@ public void setGlossaryTerms(List<GlossaryTerm> glossaryTerms) {

@XmlAttribute(name = "src-lang")
@XmlJavaTypeAdapter(type = LocaleId.class, value = LocaleIdAdapter.class)
@JsonProperty("srcLang")
public LocaleId getSrcLang() {
return srcLang;
}
Expand All @@ -81,6 +84,7 @@ public void setSrcLang(LocaleId srcLang) {

@XmlElement(name = "source-reference", required = false,
namespace = Namespaces.ZANATA_OLD)
@JsonProperty("sourcereference")
public String getSourcereference() {
return sourcereference;
}
Expand Down
Expand Up @@ -31,6 +31,7 @@
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;

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;
Expand Down Expand Up @@ -61,6 +62,7 @@ public class GlossaryTerm implements Serializable {

@XmlAttribute(name = "lang", namespace = Namespaces.XML)
@XmlJavaTypeAdapter(type = LocaleId.class, value = LocaleIdAdapter.class)
@JsonProperty("locale")
public LocaleId getLocale() {
return locale;
}
Expand All @@ -80,6 +82,7 @@ public void setContent(String content) {
}

@XmlElement(name = "comment", namespace = Namespaces.ZANATA_OLD)
@JsonProperty("comments")
public List<String> getComments() {
if (comments == null) {
comments = new ArrayList<String>();
Expand Down
Expand Up @@ -9,6 +9,7 @@
import javax.xml.bind.annotation.XmlType;

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.Email;
Expand Down Expand Up @@ -65,6 +66,7 @@ public void setName(String name) {
*/
@XmlElement(name = "link", required = false,
namespace = Namespaces.ZANATA_OLD)
@JsonProperty("links")
public Links getLinks() {
return links;
}
Expand Down
Expand Up @@ -29,6 +29,8 @@
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;

import org.codehaus.jackson.annotate.JsonProperty;

/**
* Generic type to represent the status of a process.
*
Expand Down Expand Up @@ -84,6 +86,7 @@ public void setPercentageComplete(int percentageComplete) {

@XmlElement(name = "message")
@XmlElementWrapper(name = "messages", required = true)
@JsonProperty("messages")
public List<String> getMessages() {
if (messages == null) {
messages = new ArrayList<String>();
Expand Down
Expand Up @@ -15,6 +15,7 @@

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.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
Expand Down Expand Up @@ -131,6 +132,7 @@ public void setSourceCheckoutURL(String sourceCheckoutURL) {
}

@XmlElement(name = "link", namespace = Namespaces.ZANATA_API)
@JsonProperty("links")
public Links getLinks() {
return links;
}
Expand All @@ -149,6 +151,7 @@ public Links getLinks(boolean createIfNull) {
@XmlElementWrapper(name = "project-iterations",
namespace = Namespaces.ZANATA_OLD)
@XmlElementRef(namespace = Namespaces.ZANATA_OLD)
@JsonProperty("iterations")
public List<ProjectIteration> getIterations() {
return iterations;
}
Expand Down
Expand Up @@ -30,6 +30,7 @@
import javax.xml.bind.annotation.XmlType;

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.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
Expand Down Expand Up @@ -81,6 +82,7 @@ public void setId(String id) {
*/
@XmlElement(name = "link", required = false,
namespace = Namespaces.ZANATA_OLD)
@JsonProperty("links")
public Links getLinks() {
return links;
}
Expand Down
Expand Up @@ -9,6 +9,7 @@
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;

import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonProperty;
import org.zanata.common.ContentType;
import org.zanata.common.LocaleId;
import org.zanata.common.Namespaces;
Expand Down Expand Up @@ -88,6 +89,7 @@ public void setLang(LocaleId lang) {
@XmlJavaTypeAdapter(type = ContentType.class,
value = ContentTypeAdapter.class)
@XmlAttribute(name = "content-type", required = true)
@JsonProperty("contentType")
public ContentType getContentType() {
return contentType;
}
Expand Down
Expand Up @@ -9,6 +9,7 @@
import javax.xml.bind.annotation.XmlType;

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.Namespaces;
Expand All @@ -35,6 +36,7 @@ public Resource(String name) {
namespace = Namespaces.ZANATA_OLD)
@XmlElement(name = "text-flow",
namespace = org.zanata.common.Namespaces.ZANATA_API)
@JsonProperty("textFlows")
public List<TextFlow> getTextFlows() {
if (textFlows == null) {
textFlows = new ArrayList<TextFlow>();
Expand Down
Expand Up @@ -9,6 +9,7 @@

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;
Expand Down Expand Up @@ -46,6 +47,7 @@ public TextFlowTarget(String resId) {
}

@XmlElement(name = "person", namespace = Namespaces.ZANATA_API)
@JsonProperty("translator")
public Person getTranslator() {

This comment has been minimized.

Copy link
@seanf

seanf Jun 16, 2015

Contributor

The JSON mapping seems to be more meaningful than the XML mapping in this case. I wonder why we chose "person" rather than "translator"?

return translator;
}
Expand Down Expand Up @@ -109,6 +111,7 @@ public void setExtensions(ExtensionSet<TextFlowTargetExtension> extensions) {

@XmlAttribute(name = "res-id", required = true)
@NotEmpty
@JsonProperty("resId")
public String getResId() {
return resId;
}
Expand Down
Expand Up @@ -12,6 +12,7 @@

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.zanata.common.Namespaces;
Expand Down Expand Up @@ -62,6 +63,7 @@ public ExtensionSet<TranslationsResourceExtension> getExtensions(
@XmlElementWrapper(name = "targets", required = false,
namespace = Namespaces.ZANATA_OLD)
@XmlElement(name = "text-flow-target", namespace = Namespaces.ZANATA_API)
@JsonProperty("textFlowTargets")
public List<TextFlowTarget> getTextFlowTargets() {
if (textFlowTargets == null) {
textFlowTargets = new ArrayList<TextFlowTarget>();
Expand Down

0 comments on commit 9fd9565

Please sign in to comment.