* @param JSONGrant the JSON representation of the OrganizationalUnitGrant object
* @return the OrganizationalUnitGrant
* @throws Exception
*/
private OrganizationalUnitGrant deserializeOrganizationalUnitGrant(JSONObject JSONGrant) throws Exception{
OrganizationalUnitGrant organizationalUnitGrant = new OrganizationalUnitGrant();
organizationalUnitGrant.setDescription(JSONGrant.getString("description"));
SingletonConfig config = SingletonConfig.getInstance();
String format = config.getConfigValue("SPAGOBI.DATE-FORMAT-SERVER.format");
organizationalUnitGrant.setEndDate(toDate(JSONGrant.getString("enddate"), format));
organizationalUnitGrant.setStartDate(toDate(JSONGrant.getString("startdate"), format));
organizationalUnitGrant.setLabel(JSONGrant.getString("label"));
organizationalUnitGrant.setName(JSONGrant.getString("name"));
try{
organizationalUnitGrant.setId(JSONGrant.getInt("id"));
}catch(JSONException e){}
int hierarchyId = JSONGrant.getInt("hierarchy");
int modelInstanceId = JSONGrant.getInt("modelinstance");
ModelInstance modelInstance = DAOFactory.getModelInstanceDAO().loadModelInstanceWithChildrenById(modelInstanceId);
OrganizationalUnitHierarchy organizationalUnitHierarchy = orUnitDao.getHierarchy(hierarchyId);
organizationalUnitGrant.setModelInstance(modelInstance);
organizationalUnitGrant.setHierarchy(organizationalUnitHierarchy);
return organizationalUnitGrant;
}