throw new SerializationException("ModelExtendedJSONSerializer is unable to serialize object of type: " + o.getClass().getName());
}
try {
ModelExtended modelExtended = (ModelExtended)o;
Model model = modelExtended.getModel();
result = new JSONObject();
result.put(MODEL_ID, model.getId() );
result.put(MODEL_GUIID, model.getGuiId() );
result.put(MODEL_PARENT_ID, model.getParentId() );
result.put(MODEL_CODE, model.getCode() );
result.put(MODEL_NAME, model.getName() );
result.put(MODEL_LABEL, model.getLabel() );
result.put(MODEL_DESCRIPTION, model.getDescription() );
//find kpi name
if(model.getKpiId() != null){
result.put(MODEL_KPI_ID, model.getKpiId());
Kpi kpi = DAOFactory.getKpiDAO().loadKpiById(model.getKpiId());
if(kpi != null){
result.put(MODEL_KPI, kpi.getKpiName());
}else{
result.put(MODEL_KPI, "");
}
result.put(KPI_NAME, kpi.getKpiName());
result.put(KPI_LABEL, kpi.getModelReference());
if(kpi.getThreshold() != null){
result.put(KPI_THRESHOLD, kpi.getThreshold().getName());
}
result.put(KPI_WEIGHT, kpi.getStandardWeight());
result.put(KPI_TARGET, kpi.getTargetAudience());
}
result.put(MODEL_TYPE, model.getTypeCd() );
result.put(MODEL_TYPE_ID, model.getTypeId() );
result.put(MODEL_TYPE_DESCR, model.getTypeDescription() );
if(model.getChildrenNodes() != null && !model.getChildrenNodes().isEmpty()){
result.put(MODEL_IS_LEAF, false );
}else{
result.put(MODEL_IS_LEAF, true );
}
result.put(MODEL_TEXT, model.getCode()+" - "+ model.getName() );
result.put(MODEL_ERROR, false);
// put udpValues assocated to ModelInstance Node
List udpValues = model.getUdpValues();
JSONArray udpValuesJSON = new JSONArray();
if(udpValues != null){
Iterator itUdpValues = udpValues.iterator();
while(itUdpValues.hasNext()){