ObjectMapper mapper = new ObjectMapper();
try {
// unmarshall the JSON
JsonNode ob = mapper.readValue(incomingJSON, JsonNode.class);
// look up this client, and add a sequential outreach
ClientOutreach co = new ClientOutreach();
PathClientService pcs = new PathClientService();
try {
Integer clientID = Integer.valueOf(ob.get("Client_ID").getTextValue());
if (clientID != null) {
System.out.println("client id is: " + clientID);
co.setClientKey(pcs.getPathClient(clientID).getClientKey());
//co.setClientKey(clientID.intValue());
}
BigDecimal latitude = BigDecimal.valueOf(Double.valueOf(ob.get("Latitude").getTextValue()));
if (latitude != null) {
co.setLatitude(latitude);
}
BigDecimal longitude = BigDecimal.valueOf(Double.valueOf(ob.get("Longitude").getTextValue()));
if (longitude != null) {
co.setLongitude(longitude);
}
DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssz");
Date contactDate = df.parse(ob.get("Contact_Date").getTextValue());
if (contactDate != null) {
co.setContactDate(contactDate);
}
Date engagementDate = df.parse(ob.get("Engagement_Date").getTextValue());
if (engagementDate != null) {
co.setEngagementDate(engagementDate);
}
} catch (Exception e){System.out.println(e);}
ClientOutreachService cos = new ClientOutreachService();
String outreachID = String.valueOf(cos.createClientOutreach(co));
// return the generated id