Person person = new Person();
JAXBContext jc = JAXBContext.newInstance(person.getClass());
Unmarshaller unmarshaller = jc.createUnmarshaller();
JAXBElement<?> p = unmarshaller.unmarshal(new StreamSource(new StringReader(stringBuffer.toString())), Person.class);
Person pt = (Person)p.getValue();
PathClientService pcs = new PathClientService();
PathClient pc = new PathClient();
try {
String lfn = pt.getLegalFirstName().getUnhashed().getValue();
if (lfn != null) {
pc.setNameFirst(lfn);
}
}
catch(Exception e){log.info("Couldn't get LegalFirstName. This is okay.");}
try {
String lln = pt.getLegalLastName().getUnhashed().getValue();
if (lln != null) {
pc.setNameLast(lln);
}
}
catch(Exception e){log.info("Couldn't get LegalLastName. This is okay.");}
try {
String lmn = pt.getLegalMiddleName().getUnhashed().getValue();
if (lmn != null) {
pc.setNameMiddle(lmn);
}
}
catch(Exception e){log.info("Couldn't get LegalMiddleName. This is okay.");}
try {
BigDecimal gender = new BigDecimal(pt.getGender().getUnhashed().getValue());
if (gender != null) {
pc.setGenderCode(gender);
}
}
catch(Exception e){log.info("Couldn't get Gender. This is okay.");}
try {
BigDecimal ethnicity = new BigDecimal(pt.getEthnicity().getUnhashed().getValue());
if (ethnicity != null) {
pc.setEthnicityCode(ethnicity);
}
}
catch(Exception e){log.info("Couldn't get Ethnicity. This is okay.");}
try {
Date dob = pt.getDateOfBirth().getUnhashed().getValue().toGregorianCalendar().getTime();
if (dob != null) {
pc.setDateOfBirth(dob);
}
}
catch(Exception e){log.info("Couldn't get DoB. This is okay.");}
try {
Integer ssn = Integer.valueOf(pt.getSocialSecurityNumber().getUnhashed().getValue());
if (ssn != null) {
pc.setSsn(ssn);
}
}
catch(Exception e){log.info("Couldn't get SSN. This is okay.");}
try {
Integer ssnQualityCode = (int) pt.getSocialSecurityNumber().getSocialSecNumberQualityCode().getValue();
if (ssnQualityCode != null) {
pc.setSsnQuality(ssnQualityCode);
}
}
catch(Exception e){log.info("Couldn't get SSN Quality Code. This is okay.");}
//we only use int ids, not strings in openciss
try {
clientID = pt.getPersonID().getIDNum().intValue();
if (clientID != 0) {
pc.setClientKey(clientID);
}
}
catch(Exception e){log.info("could not get person ID Number as an integer. Maybe they sent id strings?");}
try {
// assuming newly added clients aren't immediately inactivated
pc.setInactive(0);
}
catch(Exception e){log.info("Could not set inactive to false");}
//clientID = pcs.createPathClient(pc);
//client_id is -1 if not successful, a positive client id number if successful
return pcs.createPathClient(pc);
} catch (JAXBException e) {
e.printStackTrace();
return -1;
}