logger.debug("OUT: returning " + toReturn);
}
private void insertGoalKpi(GoalKpi goalKpi, SbiGoalHierarchy goalNodel, Session aSession, Transaction tx) {
logger.debug("IN: goalKpi = " + goalKpi);
SbiGoalKpi exists = null;
SbiGoalKpi hibSbiGoalKpi = new SbiGoalKpi();
//hibSbiGoalKpi.setGoalKpiId(goalKpi.getId());
hibSbiGoalKpi.setKpiInstanceId(goalKpi.getModelInstanceId());
hibSbiGoalKpi.setSbiGoalHierarchy(goalNodel);
if(goalKpi.getThreshold1()!=null){
hibSbiGoalKpi.setThreshold1(goalKpi.getThreshold1());
}
hibSbiGoalKpi.setThreshold1sign(goalKpi.getSign1());
if(goalKpi.getThreshold2()!=null){
hibSbiGoalKpi.setThreshold2(goalKpi.getThreshold2());
}
hibSbiGoalKpi.setThreshold2sign(goalKpi.getSign2());
hibSbiGoalKpi.setWeight1(goalKpi.getWeight1());
hibSbiGoalKpi.setWeight2(goalKpi.getWeight2());
//look for preexisting one with same same label-name key
if(goalKpi.getId()!=null){
Query hibQuery = aSession.createQuery(" from SbiGoalKpi n where n.sbiGoalHierarchy.goalHierarchyId = ? and n.kpiInstanceId = ?");
hibQuery.setInteger(0, goalNodel.getGoalHierarchyId());
hibQuery.setInteger(1, hibSbiGoalKpi.getKpiInstanceId());
exists= (SbiGoalKpi)hibQuery.uniqueResult();
}
updateSbiCommonInfo4Insert(hibSbiGoalKpi);
if(exists == null){
aSession.save(hibSbiGoalKpi);
goalKpi.setId(hibSbiGoalKpi.getGoalKpiId());
}else{
aSession.delete(exists);
aSession.save(hibSbiGoalKpi);
goalKpi.setId(hibSbiGoalKpi.getGoalKpiId());
}
logger.debug("OUT: goalKpi = " + goalKpi);
}