Skip to content

Instantly share code, notes, and snippets.

@ctataryn
Created June 12, 2014 19:40
Show Gist options
  • Save ctataryn/a5fd1882ecb09c196102 to your computer and use it in GitHub Desktop.
Save ctataryn/a5fd1882ecb09c196102 to your computer and use it in GitHub Desktop.
@ApiModel("Outage Message")
public class OutageDto {
private String applicationName;
private DateTime outageDate;
private String message;
public OutageDto() {}
public OutageDto(Locale locale, Outage outage) {
//TODO source this from an i18n properties file?
this.applicationName = LtoUtils.isFrench(locale) ? outage.getApplication().getNameFrench() : outage.getApplication().getNameEnglish();
this.outageDate = new DateTime(outage.getStartTime());
this.message = LtoUtils.isFrench(locale) ? outage.getFrenchMessage() : outage.getEnglishMessage();
}
public String getApplicationName() {
return applicationName;
}
@JsonProperty("application_name")
@ApiModelProperty(value = "The name of the Application this Outage is for") //apparently swagger-springmvc doesn't support this yet
public void setApplicationName(String applicationName) {
this.applicationName = applicationName;
}
//don't want these in Json
public DateTime getOutageDate() {
return outageDate;
}
@JsonIgnore
public void setOutageDate(DateTime outageDate) {
this.outageDate = outageDate;
}
//creating this public view of the outageDate as a String so that Swagger doesn't try to
//document the Joda DateTime type for our consumers
@JsonProperty("outage_date")
@ApiModelProperty(value = "Date an outage occures", notes = "Format is yyyy-MM-dd'T'HH:mm:ss.SSSZZ")
private String getOutageDateStr() {
return JodaDataTimeMarshallers.serialize(outageDate);
}
private void setOutageDateStr(String outageDateStr) {
outageDate = JodaDataTimeMarshallers.deserialize(outageDateStr);
}
public String getMessage() {
return message;
}
@JsonProperty("message")
@ApiModelProperty(value = "Message describing this outage")
public void setMessage(String message) {
this.message = message;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment