use of cern.laser.business.definition.data.AlarmDefinition in project ACS by ACS-Community.
the class SourceDefinitionServiceImpl method createSource.
public void createSource(String userId, SourceDefinition sourceDefinition) throws LaserDefinitionException {
if (sourceDefinition == null) {
throw new LaserDefinitionNotValidException("source is null");
}
Source source = sourceDAO.getSource(sourceDefinition.getSourceId());
if (source != null) {
throw new LaserDefinitionDuplicationException("source " + sourceDefinition.getSourceId() + " already exist");
}
if (sourceDefinition.getResponsiblePersonId() == null) {
throw new LaserDefinitionNotValidException("responsible id for the source definition is null");
}
ResponsiblePerson responsible = responsiblePersonDAO.getResponsiblePerson(sourceDefinition.getResponsiblePersonId());
if (responsible == null) {
throw new LaserDefinitionNotValidException("responsible with id " + sourceDefinition.getResponsiblePersonId() + " does not exist");
}
AdminUser admin_user = adminUserDAO.findAdminUser(userId);
AdminUser laser_user = adminUserDAO.findByLaserAdminUser();
LOGGER.info("user " + admin_user.getName() + " creating source : " + sourceDefinition);
// create the source
source = new Source(sourceDefinition, responsible);
CategoryDefinition category_definition = new CategoryDefinition(SOURCE_CATEGORY_PATH_PREFIX + sourceDefinition.getName(), "Category for source " + sourceDefinition.getName());
Category parent_category = categoryDAO.findCategoryByPath(category_definition.getParentPath());
Category category = new CategoryImpl(category_definition);
parent_category.addChildCategory(category);
categoryDAO.saveCategory(category);
admin_user.addAdministeredCategory(category);
laser_user.addAdministeredCategory(category);
if (LOGGER.isDebugEnabled())
LOGGER.debug("default category " + category_definition.getPath() + "created for source " + sourceDefinition.getName());
source.setSurveillanceAlarmId(alarmDAO.findLaserSurveillanceAlarmId());
sourceDAO.saveSource(source);
// create the source surveillance alarm
AlarmDefinition surveillance_alarm_definition = (AlarmDefinition) SOURCE_SURVEILLANCE_ALARM_DEFINITION.clone();
surveillance_alarm_definition.setFaultMember(sourceDefinition.getName());
surveillance_alarm_definition.setIdentifier(sourceDefinition.getName());
Alarm surveillance_alarm = new AlarmImpl(surveillance_alarm_definition, source, responsible);
Category surveillance_category = categoryDAO.findBySurveillanceCategory();
surveillance_category.addAlarm(surveillance_alarm);
category.addAlarm(surveillance_alarm);
alarmDAO.saveAlarm(surveillance_alarm);
categoryDAO.updateCategory(surveillance_category);
categoryDAO.updateCategory(category);
if (LOGGER.isDebugEnabled())
LOGGER.debug("surveillance alarm created for source " + sourceDefinition.getName());
source.setSurveillanceAlarmId(surveillance_alarm.getAlarmId());
sourceDAO.updateSource(source);
admin_user.addAdministeredSource(source);
laser_user.addAdministeredSource(source);
adminUserDAO.updateAdminUser(admin_user);
adminUserDAO.updateAdminUser(laser_user);
LOGGER.info("source created");
}
use of cern.laser.business.definition.data.AlarmDefinition in project ACS by ACS-Community.
the class AlarmDefinitionServiceImpl method removeAlarms.
public void removeAlarms(String userId, Collection alarms) throws LaserDefinitionException {
if ((alarms == null) || (alarms.size() == 0)) {
return;
}
removeAlarmsInternal(userId, alarms);
Iterator iterator = alarms.iterator();
Alarm alarm_obj = null;
while (iterator.hasNext()) {
try {
alarm_obj = alarmCache.getCopy(((AlarmDefinition) iterator.next()).getAlarmId());
invalidateAlarm(alarm_obj);
propagateRemovedAlarm(alarm_obj);
} catch (Exception e) {
LOGGER.warn("unable to handle removed alarm " + alarm_obj.getTriplet() + " : " + e.getMessage());
}
}
}
use of cern.laser.business.definition.data.AlarmDefinition in project ACS by ACS-Community.
the class AlarmImpl method getDefinition.
/**
* @return
*/
public AlarmDefinition getDefinition() {
AlarmDefinition definition = new AlarmDefinition(getFaultFamily(), getFaultMember(), getFaultCode());
definition.setSystemName(getSystemName());
definition.setIdentifier(getIdentifier());
definition.setProblemDescription(getProblemDescription());
definition.setCause(getCause());
definition.setAction(getAction());
definition.setConsequence(getConsequence());
definition.setInstant(getInstant());
definition.setPriority(getPriority());
definition.setMnemonic(location.getMnemonic());
definition.setFloor(location.getFloor());
definition.setRoom(location.getRoom());
definition.setPosition(location.getPosition());
definition.setPiquetGSM(getPiquetGSM());
definition.setHelpURL(getHelpURLString());
definition.setResponsiblePersonId(getResponsiblePerson() == null ? null : getResponsiblePerson().getResponsibleId());
definition.setSourceName(getSource() == null ? null : getSource().getName());
definition.setBuilding(location.getBuilding() == null ? null : location.getBuilding().getBuildingNumber());
return definition;
}
Aggregations