Skip to content
This repository has been archived by the owner on Dec 22, 2023. It is now read-only.

Comment escape char #26

Merged
merged 3 commits into from
Jul 20, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang3.StringEscapeUtils;
import org.apache.commons.lang3.StringUtils;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
Expand Down Expand Up @@ -31,7 +32,7 @@ public static ContactInformation[] convertToEmergencyContactInformation(JSONObje
ContactInformation ci = new ContactInformation();
ci.setPreferredName(jcontact.getString("EMERGENCY NAME"));
ci.setRelationship(jcontact.getString("RELATION"));
ci.setComments(jcontact.getString("RELATION COMMENT"));
ci.setComments(StringEscapeUtils.unescapeJson(jcontact.getString("RELATION COMMENT")));
//le emailz
try {
for(int j = 1; j <=3; j++) {
Expand Down Expand Up @@ -94,7 +95,7 @@ public static ContactInformation convertToLocalContactInformation(JSONObject jso
ca.setState(address.getString("STATE"));
ca.setPostalCode(address.getString("ZIP"));
ca.setCountry(address.getString("COUNTRY"));
ca.setComment(address.getString("ADDRESS COMMENT"));
ca.setComment(StringEscapeUtils.unescapeJson(address.getString("ADDRESS COMMENT")));
ca.setType(address.getString("ADDRESS TYPE"));
ci.getAddresses().add(ca);
}
Expand All @@ -121,7 +122,11 @@ public static JSONObject convertToJSONObject(ContactInformation[] emergencyConta
address.put("STATE", ca.getState());
address.put("ZIP", ca.getPostalCode());
address.put("COUNTRY", ca.getCountry());
address.put("ADDRESS COMMENT", ca.getComment());
StringBuilder addressComment = new StringBuilder(ca.getComment());
if(addressComment!=null && addressComment.toString().endsWith("\"")){
addressComment.append(" ");
}
address.put("ADDRESS COMMENT", addressComment.toString());
address.put("ADDRESS PRIORITY", count);
DateTimeFormatter formatter = DateTimeFormat.forPattern("dd-MMM-YY");
address.put("ADDRESS DTTM", formatter.print(ci.getLastModified()));
Expand All @@ -145,7 +150,11 @@ private static JSONObject jsonifyEmergencyContact(ContactInformation eci) {
JSONObject emergencyContact = new JSONObject();
emergencyContact.put("EMERGENCY NAME", eci.getPreferredName());
emergencyContact.put("RELATION", eci.getRelationship());
emergencyContact.put("RELATION COMMENT", eci.getComments());
StringBuilder relationComment = new StringBuilder(eci.getComments());
if(relationComment!=null && relationComment.toString().endsWith("\"")){
relationComment.append(" ");
}
emergencyContact.put("RELATION COMMENT", relationComment);
//TODO: Get language from eci
//emergencyContact.put("LANGUAGE SPOKEN 1", eci.get);
//emergencyContact.put("LANGUAGE SPOKEN 2", eci.get);
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.1</version>
<version>3.2</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
Expand Down