if( !(o instanceof Goal) ) {
throw new SerializationException("GoalJSONSerializer is unable to serialize object of type: " + o.getClass().getName());
}
try {
Goal goal = (Goal) o;
result = new JSONObject();
result.put(ID, goal.getId() );
result.put(NAME, goal.getName() );
result.put(DESCRIPTION, goal.getDescription() );
result.put(LABEL, goal.getLabel() );
String df = GeneralUtilities.getServerDateFormat();
SimpleDateFormat dateFormat = new SimpleDateFormat();
dateFormat.applyPattern(df);
dateFormat.setLenient(false);
result.put(START_DATE, dateFormat.format(goal.getStartDate()) );
result.put(END_DATE, dateFormat.format(goal.getEndDate()) );
if(goal.getGrant()!=null){
OrganizationalUnitGrant grant = DAOFactory.getOrganizationalUnitDAO().getGrant(goal.getGrant());
result.put(GRANT_ID, goal.getGrant());
result.put(GRANT_NAME, grant.getName());
}
} catch (Throwable t) {
throw new SerializationException("An error occurred while serializing object: " + o, t);