Search in sources :

Example 6 with AdminUser

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");
}
Also used : Alarm(cern.laser.business.data.Alarm) AdminUser(cern.laser.business.data.AdminUser) LaserDefinitionDuplicationException(cern.laser.business.definition.LaserDefinitionDuplicationException)

Example 7 with AdminUser

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");
}
Also used : Alarm(cern.laser.business.data.Alarm) AdminUser(cern.laser.business.data.AdminUser)

Example 8 with AdminUser

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");
}
Also used : Alarm(cern.laser.business.data.Alarm) AdminUser(cern.laser.business.data.AdminUser)

Example 9 with AdminUser

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");
}
Also used : LaserDefinitionNotValidException(cern.laser.business.definition.LaserDefinitionNotValidException) Alarm(cern.laser.business.data.Alarm) AdminUser(cern.laser.business.data.AdminUser)

Example 10 with AdminUser

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);
    }
}
Also used : LaserDefinitionNotValidException(cern.laser.business.definition.LaserDefinitionNotValidException) LaserDefinitionNotAllowedException(cern.laser.business.definition.LaserDefinitionNotAllowedException) LaserDefinitionException(cern.laser.business.definition.LaserDefinitionException) AdminUser(cern.laser.business.data.AdminUser) Source(cern.laser.business.data.Source) LaserDefinitionNotFoundException(cern.laser.business.definition.LaserDefinitionNotFoundException) LaserDefinitionNotAllowedException(cern.laser.business.definition.LaserDefinitionNotAllowedException) LaserDefinitionDuplicationException(cern.laser.business.definition.LaserDefinitionDuplicationException) LaserDefinitionException(cern.laser.business.definition.LaserDefinitionException) LaserDefinitionNotValidException(cern.laser.business.definition.LaserDefinitionNotValidException)

Aggregations

AdminUser (cern.laser.business.data.AdminUser)22 LaserDefinitionDuplicationException (cern.laser.business.definition.LaserDefinitionDuplicationException)14 LaserDefinitionNotValidException (cern.laser.business.definition.LaserDefinitionNotValidException)14 LaserDefinitionNotFoundException (cern.laser.business.definition.LaserDefinitionNotFoundException)13 Alarm (cern.laser.business.data.Alarm)11 LaserDefinitionNotAllowedException (cern.laser.business.definition.LaserDefinitionNotAllowedException)11 Category (cern.laser.business.data.Category)8 LaserDefinitionException (cern.laser.business.definition.LaserDefinitionException)8 AlarmCacheException (cern.laser.business.cache.AlarmCacheException)7 Source (cern.laser.business.data.Source)6 ArrayList (java.util.ArrayList)4 Collection (java.util.Collection)4 LaserRuntimeException (cern.laser.business.LaserRuntimeException)3 ResponsiblePerson (cern.laser.business.data.ResponsiblePerson)3 AlarmImpl (cern.laser.business.data.AlarmImpl)2 CategoryImpl (cern.laser.business.data.CategoryImpl)2 Building (cern.laser.business.data.Building)1 AlarmDefinition (cern.laser.business.definition.data.AlarmDefinition)1 CategoryDefinition (cern.laser.business.definition.data.CategoryDefinition)1