private KpiInstance toKpiInstance(SbiKpiInstanceHistory kpiInstHist)
throws EMFUserError {
logger.debug("IN");
KpiInstance toReturn = new KpiInstance();
Integer kpiId = kpiInstHist.getSbiKpiInstance().getIdKpiInstance();
SbiKpi kpi = kpiInstHist.getSbiKpiInstance().getSbiKpi();
Integer k = kpi.getKpiId();
Date d = new Date();
d = kpiInstHist.getBeginDt();
Integer thresholdId = null;
if (kpiInstHist.getSbiThreshold()!=null) thresholdId = kpiInstHist.getSbiThreshold().getThresholdId();
Double weight = kpiInstHist.getWeight();
Double target = kpiInstHist.getTarget();
Integer idPeriodicity = null;
Set periods = kpiInstHist.getSbiKpiInstance().getSbiKpiInstPeriods();
if (!periods.isEmpty()) {
Iterator s = periods.iterator();
while (s.hasNext()) {
SbiKpiInstPeriod p = (SbiKpiInstPeriod) s.next();
if (p.isDefault_().booleanValue()) {
SbiKpiPeriodicity periodicity = p.getSbiKpiPeriodicity();
if (periodicity != null) {
idPeriodicity = periodicity.getIdKpiPeriodicity();
}
}
}
}
SbiMeasureUnit unit = kpiInstHist.getSbiMeasureUnit();
String scaleCode = null;
String scaleName = null;
if (unit != null) {
scaleCode = unit.getScaleCd();
scaleName = unit.getScaleNm();
}
toReturn.setWeight(weight);
logger.debug("KpiInstance weight setted");
toReturn.setTarget(target);
logger.debug("KpiInstance target setted");
toReturn.setKpiInstanceId(kpiId);
logger.debug("KpiInstance Id setted");
toReturn.setKpi(k);
logger.debug("KpiInstance kpi setted");
toReturn.setThresholdId(thresholdId);
logger.debug("KpiInstance thresholdId setted");
toReturn.setD(d);
logger.debug("KpiInstance date setted");
toReturn.setPeriodicityId(idPeriodicity);
logger.debug("KpiInstance periodicity ID setted");
toReturn.setScaleCode(scaleCode);
logger.debug("Kpi value scale Code setted");
toReturn.setScaleName(scaleName);
logger.debug("Kpi value scale Name setted");
logger.debug("OUT");
return toReturn;
}