logger.debug("Loading the root node of the goal tree with:");
JSONObject jo;
Integer goalId = getAttributeAsInteger("goalId");
Integer ouId = getAttributeAsInteger("ouId");
logger.debug("goalId: "+goalId+" ,ouId "+ouId);
GoalNode root = daoGoal.getRootNode(goalId, ouId);
try{
if(root!=null){
jo = (JSONObject) SerializerFactory.getSerializer("application/json").serialize(root, getLocale());
}else{
jo = new JSONObject();
}
writeBackToClient(new JSONSuccess(jo));
} catch (Exception e){
logger.debug("Error getting the root of the goal");
throw new SpagoBIServiceException(SERVICE_NAME, "Error getting the root of the goal",e);
}
logger.debug("Goal root loaded");
}
if (serviceType != null && serviceType.equalsIgnoreCase(INSERT_GOAL_NODE)) {
logger.debug("Adding the goal node: ");
JSONObject JSONGoal = getAttributeAsJSONObject("goalNode");
Integer goalId = getAttributeAsInteger("goalId");
Integer ouId = getAttributeAsInteger("ouId");
logger.debug("JSONGoal: "+JSONGoal);
try{
GoalNode gn = insertGoalNode(JSONGoal, null, goalId, ouId);
JSONObject jo = (JSONObject) SerializerFactory.getSerializer("application/json").serialize(gn, getLocale());
writeBackToClient(new JSONSuccess(jo));
} catch (Exception e){
logger.debug("Error inserting the goal node");
throw new SpagoBIServiceException(SERVICE_NAME, "Error inserting the goal node",e);
}
logger.debug("Node added");
}
if (serviceType != null && serviceType.equalsIgnoreCase(INSERT_GOAL_DETAILS)) {
logger.debug("Adding the details of the goal node: ");
List<GoalKpi> kpisList = new ArrayList<GoalKpi>();
JSONObject JSONGoalDetails = getAttributeAsJSONObject("goalDetails");
JSONObject goalNode = JSONGoalDetails.optJSONObject("goalNode");
Integer goalNodeId = goalNode.optInt("id");
String goalDesc = goalNode.optString("goalDesc");
String goalName = goalNode.optString("name");
logger.debug(goalNode);
GoalNode gn = new GoalNode(goalName, "", goalDesc, null, null);
gn.setId(goalNodeId);
JSONArray kpis = JSONGoalDetails.optJSONArray("kpis");
try{
for(int i=0; i<kpis.length(); i++){
kpisList.add(deserializeKpiNode((JSONObject)kpis.get(i), goalNodeId));