public Alarm toAlarm(SbiAlarm sbiAlarm) throws EMFUserError{
Alarm toReturn=new Alarm();
toReturn.setDescr(sbiAlarm.getDescr());
toReturn.setId(sbiAlarm.getId());
toReturn.setLabel(sbiAlarm.getLabel());
toReturn.setName(sbiAlarm.getName());
toReturn.setText(sbiAlarm.getText());
toReturn.setUrl(sbiAlarm.getUrl());
Boolean autoDis=(sbiAlarm.isAutoDisabled()!=null) ? sbiAlarm.isAutoDisabled(): null;
if(autoDis!=null){
toReturn.setAutoDisabled(autoDis.booleanValue());
}
Boolean single=(sbiAlarm.isSingleEvent()!=null) ? sbiAlarm.isSingleEvent(): null;
if(single!=null){
toReturn.setSingleEvent(single.booleanValue());
}
ISbiAlarmContactDAO alarmContactDAO=DAOFactory.getAlarmContactDAO();
Set<AlarmContact> contactsToInsert = new HashSet<AlarmContact>(0);
Set<SbiAlarmContact> contacts=sbiAlarm.getSbiAlarmContacts();
if(contacts!=null){
for (Iterator iterator = contacts.iterator(); iterator.hasNext();) {
SbiAlarmContact sbiAlarmContact = (SbiAlarmContact) iterator.next();
Integer idAlarmContact=sbiAlarmContact.getId();
AlarmContact alarmContact=alarmContactDAO.loadById(idAlarmContact);
contactsToInsert.add(alarmContact);
}
}
toReturn.setSbiAlarmContacts(contactsToInsert);
if(sbiAlarm.getSbiKpiInstance()!=null){
toReturn.setIdKpiInstance(sbiAlarm.getSbiKpiInstance().getIdKpiInstance());
}
if(sbiAlarm.getSbiThresholdValue()!=null){
toReturn.setIdThresholdValue(sbiAlarm.getSbiThresholdValue().getIdThresholdValue());
}
if(sbiAlarm.getModality()!=null){
toReturn.setModalityId(sbiAlarm.getModality().getValueId());
}
return toReturn;
}