logger.error("Threshold type CD does not exist");
throw new SpagoBIServiceException(SERVICE_NAME, "Threshold Type ID is undefined");
}
if (name != null && typeID != null && code != null) {
Threshold thr = new Threshold();
thr.setName(name);
thr.setThresholdTypeCode(typeCD);
thr.setThresholdTypeId(typeID);
thr.setCode(code);
if(description != null){
thr.setDescription(description);
}
List thrValuesList = new ArrayList();
if(typeCD != null){
if(typeCD.equals("MINIMUM") || typeCD.equals("MAXIMUM")){
ThresholdValue tVal = new ThresholdValue();
if(thrValId!= null && !thrValId.equals("") && !thrValId.equals("0")){
tVal.setId(Integer.valueOf(thrValId));
}
tVal.setLabel(label);
tVal.setPosition(position);
tVal.setColourString(colourString);
tVal.setValue(value);
tVal.setSeverityCd(severityCd);
if(severityCd!=null && !severityCd.equals("")){
Integer severityId = domainIds.get(severityCd);
tVal.setSeverityId(severityId);
}
if(typeCD.equals("MINIMUM")){
tVal.setMinClosed(minClosed);
tVal.setMinValue(minValue);
}else if(typeCD.equals("MAXIMUM")){
tVal.setMaxClosed(maxClosed);
tVal.setMaxValue(maxValue);
}
thrValuesList.add(tVal);
}else if(typeCD.equals("RANGE")){
if(thrValuesJSON!=null){
try {
thrValuesList = deserializeThresholdValuesJSONArray(thrValuesJSON, domainIds);
} catch (JSONException e) {
logger.error("JSON Exception");
e.printStackTrace();
}
}
}
thr.setThresholdValues(thrValuesList);
}
try {
Integer idToReturnToClient = null;
if(id != null && !id.equals("") && !id.equals("0")){
//modify
thr.setId(Integer.valueOf(id));
try{
thrDao.modifyThreshold(thr);
}catch(EMFUserError e){
logger.error(e.getMessage(), e);
throw e;