sbiUdpValue.setName(udpValue.getName());
sbiUdpValue.setProg(udpValue.getProg());
sbiUdpValue.setFamily(udpValue.getFamily());
sbiUdpValue.setReferenceId(idObject);
SbiUdp hibUdp = (SbiUdp) aSession.load(SbiUdp.class,
udpId);
sbiUdpValue.setSbiUdp(hibUdp);
sbiUdpValue.setValue(udpValue.getValue());
if(inserting){
logger.debug("Inserting Udp association between udp "+udpValue.getLabel() + " referencing family " + udpValue.getFamily() +
" with id "+ udpValue.getReferenceId() + "with value "+sbiUdpValue.getValue());
sbiUdpValue.setBeginTs(new Date());
DAOFactory.getUdpDAOValue().insert(aSession, sbiUdpValue);
logger.debug("value to Udp "+hibUdp.getLabel()+ " has been inserted");
}
else{
// the update must close the previous record and open a new one, but only if value has changed
if(openNewOne){
logger.debug("Close previous udp value and open Udp association between udp "+udpValue.getLabel() + " referencing family " + udpValue.getFamily() +
" with id "+ udpValue.getReferenceId() + "with value "+sbiUdpValue.getValue());
// close previous one
sbiUdpValueToClose.setBeginTs(already.getBeginTs());
sbiUdpValueToClose.setEndTs(new Date());
DAOFactory.getUdpDAOValue().update(aSession, sbiUdpValueToClose);
// insert new one
sbiUdpValue.setBeginTs(new Date());
DAOFactory.getUdpDAOValue().insert(aSession, sbiUdpValue);
}
else{
logger.debug("Update without closing Udp association between udp "+udpValue.getLabel() + " referencing family " + udpValue.getFamily() +
" with id "+ udpValue.getReferenceId() + "with value "+sbiUdpValue.getValue());
// just update fields no new opening
sbiUdpValue.setBeginTs(already.getBeginTs());
DAOFactory.getUdpDAOValue().update(aSession, sbiUdpValue);
}
logger.debug("value to Udp "+hibUdp.getLabel()+ " has been updated; associated to a "+family);
}
}
}
logger.debug("OUT");