use of cern.laser.business.data.AdminUser in project ACS by ACS-Community.
the class AlarmDefinitionServiceImpl method createMultiplicityLinkInternal.
private void createMultiplicityLinkInternal(String userId, ReductionLink link) throws LaserDefinitionException {
Alarm[] parent_child = validateReductionLink(link);
//alarmDAO.findAlarm(link.getParent().getAlarmId());
Alarm parent = parent_child[0];
//alarmDAO.findAlarm(link.getChild().getAlarmId());
Alarm child = parent_child[1];
if (((AlarmImpl) parent).getMultiplicityChildrenIds().contains(child.getAlarmId())) {
throw new LaserDefinitionDuplicationException("reduction child " + link.getChild().getAlarmId() + " does not exist");
}
AdminUser admin_user = adminUserDAO.findAdminUser(userId);
LOGGER.info("user " + admin_user.getName() + " creating multiplicity link : " + link);
parent.addMultiplicityChild(child);
alarmDAO.updateAlarm(parent);
LOGGER.info("multiplicity link created");
}
use of cern.laser.business.data.AdminUser in project ACS by ACS-Community.
the class AlarmDefinitionServiceImpl method removeMultiplicityLinkInternal.
private void removeMultiplicityLinkInternal(String userId, ReductionLink link) throws LaserDefinitionException {
Alarm[] parent_child = validateReductionLink(link);
AdminUser admin_user = adminUserDAO.findAdminUser(userId);
LOGGER.info("user " + admin_user.getName() + " removing multiplicity link : " + link);
//alarmDAO.findAlarm(link.getParent().getAlarmId());
Alarm parent = parent_child[0];
//alarmDAO.findAlarm(link.getChild().getAlarmId());
Alarm child = parent_child[1];
parent.removeMultiplicityChild(child);
alarmDAO.updateAlarm(parent);
LOGGER.info("multiplicity link removed");
}
use of cern.laser.business.data.AdminUser in project ACS by ACS-Community.
the class AlarmDefinitionServiceImpl method removeNodeLinkInternal.
private void removeNodeLinkInternal(String userId, ReductionLink link) throws LaserDefinitionException {
Alarm[] parent_child = validateReductionLink(link);
AdminUser admin_user = adminUserDAO.findAdminUser(userId);
LOGGER.info("user " + admin_user.getName() + " removing node link : " + link);
//alarmDAO.findAlarm(link.getParent().getAlarmId());
Alarm parent = parent_child[0];
//alarmDAO.findAlarm(link.getChild().getAlarmId());
Alarm child = parent_child[1];
parent.removeNodeChild(child);
alarmDAO.updateAlarm(parent);
LOGGER.info("node link removed");
}
use of cern.laser.business.data.AdminUser in project ACS by ACS-Community.
the class AlarmDefinitionServiceImpl method setMultiplicityThresholdEJB.
private void setMultiplicityThresholdEJB(String userId, MultiplicityThreshold threshold) throws LaserDefinitionException {
if ((threshold == null) || (threshold.getParent() == null) || (threshold.getThreshold() == null) || (threshold.getThreshold().intValue() <= 0))
throw new LaserDefinitionNotValidException("null parameter or negative threshold");
AdminUser admin_user = adminUserDAO.findAdminUser(userId);
LOGGER.info("user " + admin_user.getName() + " setting multiplicity threshold : " + threshold);
Alarm parent = alarmDAO.findAlarm(threshold.getParent().getAlarmId());
parent.setMultiplicityThreshold(threshold.getThreshold());
alarmDAO.updateAlarm(parent);
LOGGER.info("multiplicity threshold set");
}
use of cern.laser.business.data.AdminUser in project ACS by ACS-Community.
the class SourceDefinitionServiceImpl method updateSource.
public void updateSource(String userId, SourceDefinition sourceDefinition) throws LaserDefinitionException {
if (sourceDefinition == null) {
throw new LaserDefinitionNotValidException("source is null");
}
Source source = null;
source = sourceDAO.findSource(sourceDefinition.getSourceId());
if (!sourceDefinition.getName().equals(source.getName())) {
throw new LaserDefinitionNotValidException("source name cannot be changed");
}
AdminUser admin_user = adminUserDAO.findAdminUser(userId);
if (!admin_user.administersSource(source)) {
throw new LaserDefinitionNotAllowedException("not an administrator for source : " + sourceDefinition);
}
try {
LOGGER.info("user " + admin_user.getName() + " updating source : " + sourceDefinition);
source.setDefinition(sourceDefinition);
sourceDAO.updateSource(source);
String[] alarms = sourceDAO.getAlarms(source.getSourceId());
for (int i = 0; i < alarms.length; i++) {
try {
alarmCache.invalidate(alarms[i]);
} catch (Exception e) {
LOGGER.error("unable to propagate alarm source update", e);
}
}
LOGGER.info("source updated");
} catch (Exception e) {
throw new LaserDefinitionException("unable to update source " + sourceDefinition + " : " + e.getMessage(), e);
}
}
Aggregations