Class AlarmService

java.lang.Object
org.apache.camel.builder.BuilderSupport
org.apache.camel.builder.RouteBuilder
org.openremote.manager.alarm.AlarmService
All Implemented Interfaces:
org.apache.camel.builder.ModelRoutesBuilder, org.apache.camel.CamelContextAware, org.apache.camel.Ordered, org.apache.camel.RoutesBuilder, org.apache.camel.spi.HasCamelContext, org.apache.camel.spi.ResourceAware, org.openremote.model.ContainerService

public class AlarmService extends org.apache.camel.builder.RouteBuilder implements org.openremote.model.ContainerService
A service for managing SentAlarms. It also provides functionality for managing links between SentAlarms and Assets using AlarmAssetLinks.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Logger
     

    Fields inherited from class org.apache.camel.builder.RouteBuilder

    log

    Fields inherited from interface org.openremote.model.ContainerService

    DEFAULT_PRIORITY, HIGH_PRIORITY, LOW_PRIORITY, MED_PRIORITY

    Fields inherited from interface org.apache.camel.Ordered

    HIGHEST, LOWEST
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    org.openremote.model.alarm.SentAlarm
    getAlarm(Long alarmId)
    Retrieves the details of an existing alarm if the given user has access to the alarm realm.
    protected Set<String>
    getAlarmRealms(List<org.openremote.model.alarm.SentAlarm> alarms)
    Returns a set of all realms of the given alarms.
    List<org.openremote.model.alarm.SentAlarm>
    getAlarms(String realm, org.openremote.model.alarm.Alarm.Status status, String assetId, String assigneeId)
    Retrieves all existing alarms in a realm.
    List<org.openremote.model.alarm.SentAlarm>
    getAlarms(List<Long> alarmIds)
    Retrieves the details of existing alarms if the given user has access to the alarm realms.
    List<org.openremote.model.alarm.AlarmAssetLink>
    getAssetLinks(Long alarmId, String realm)
    Returns the assets linked to an alarm if the given user has access to the alarm realm.
    int
     
    void
    init(org.openremote.model.Container container)
     
    void
    linkAssets(List<String> assetIds, String realm, Long alarmId)
    Links multiple assets to an existing alarm.
    void
    linkAssets(List<org.openremote.model.alarm.AlarmAssetLink> links)
    Links multiple assets to existing alarms if the given user has access to the alarm realms.
    void
    removeAlarm(org.openremote.model.alarm.SentAlarm alarm)
    Removes an existing alarm if the given user has access to the alarm realm.
    void
    removeAlarms(List<org.openremote.model.alarm.SentAlarm> alarms, List<Long> alarmIds)
    Removes existing alarms if the given user has access to the alarm realms.
    org.openremote.model.alarm.SentAlarm
    sendAlarm(org.openremote.model.alarm.Alarm alarm, List<String> assetIds)
    Sends an alarm if the given user has access to the alarm realm.
    protected void
    sendAssigneeNotification(org.openremote.model.alarm.SentAlarm alarm, Set<String> excludeUserIds)
    Sends e-mail and push notifications for an alarm to the alarm assignee.
    void
    start(org.openremote.model.Container container)
     
    void
    stop(org.openremote.model.Container container)
     
    void
    updateAlarm(org.openremote.model.alarm.SentAlarm oldAlarm, org.openremote.model.alarm.SentAlarm newAlarm)
    Updates an existing alarm if the given user has access to the alarm realm.
    protected void
    Throws an IllegalArgumentException if alarmId is null or negative.
    protected void
    Throws an IllegalArgumentException if the given alarmIds are null, empty or negative.
    protected void
    Throws an IllegalArgumentException if the given assetIds are null or empty.

    Methods inherited from class org.apache.camel.builder.RouteBuilder

    addLifecycleInterceptor, addRoutes, addRoutesToCamelContext, addTemplatedRoutesToCamelContext, bindToRegistry, bindToRegistry, checkInitialized, configuration, configureRest, configureRests, configureRoute, configureRouteConfiguration, configureRoutes, configureRouteTemplate, configureTemplatedRoute, customize, customize, dataFormat, errorHandler, errorHandler, expression, from, from, from, fromF, fromV, fromV, getBeans, getOrder, getResource, getRestCollection, getRestConfiguration, getRests, getRouteCollection, getRoutes, getRouteTemplateCollection, getTemplatedRouteCollection, initializeCamelContext, intercept, interceptFrom, interceptFrom, interceptSendToEndpoint, loadRoutesBuilder, loadRoutesBuilder, onCompletion, onException, onException, populateBeans, populateOrUpdateRoutes, populateRests, populateRoutes, populateRouteTemplates, populateTemplatedRoutes, populateTransformers, populateValidators, prepareModel, property, propertyInject, removeLifecycleInterceptor, rest, rest, restConfiguration, routeTemplate, setErrorHandlerFactory, setResource, setRestCollection, setRouteTemplateCollection, setTemplatedRouteCollection, templatedRoute, tokenizer, toString, transformer, updateRoutesToCamelContext, validator

    Methods inherited from class org.apache.camel.builder.BuilderSupport

    body, bodyAs, constant, constant, constant, createErrorHandlerBuilder, csimple, csimple, datasonnet, datasonnet, datasonnet, deadLetterChannel, deadLetterChannel, defaultErrorHandler, endpoint, endpoint, exceptionMessage, exchangeProperty, expression, getCamelContext, getContext, getErrorHandlerFactory, hasErrorHandlerFactory, header, java, java, joor, joor, jq, jq, jsonpath, jsonpath, jtaTransactionErrorHandler, jtaTransactionErrorHandler, jtaTransactionErrorHandler, method, method, method, method, noErrorHandler, regexReplaceAll, regexReplaceAll, setCamelContext, simple, simple, simpleF, simpleF, springTransactionErrorHandler, springTransactionErrorHandler, springTransactionErrorHandler, systemProperty, systemProperty, variable, xpath, xpath, xpath, xpath

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • LOG

      public static final Logger LOG
  • Constructor Details

    • AlarmService

      public AlarmService()
  • Method Details

    • getPriority

      public int getPriority()
      Specified by:
      getPriority in interface org.openremote.model.ContainerService
    • init

      public void init(org.openremote.model.Container container) throws Exception
      Specified by:
      init in interface org.openremote.model.ContainerService
      Throws:
      Exception
    • start

      public void start(org.openremote.model.Container container) throws Exception
      Specified by:
      start in interface org.openremote.model.ContainerService
      Throws:
      Exception
    • stop

      public void stop(org.openremote.model.Container container) throws Exception
      Specified by:
      stop in interface org.openremote.model.ContainerService
      Throws:
      Exception
    • configure

      public void configure() throws Exception
      Specified by:
      configure in class org.apache.camel.builder.RouteBuilder
      Throws:
      Exception
    • getAlarmRealms

      protected Set<String> getAlarmRealms(List<org.openremote.model.alarm.SentAlarm> alarms)
      Returns a set of all realms of the given alarms.
    • validateAlarmId

      protected void validateAlarmId(Long alarmId)
      Throws an IllegalArgumentException if alarmId is null or negative.
    • validateAlarmIds

      protected void validateAlarmIds(Collection<Long> alarmIds)
      Throws an IllegalArgumentException if the given alarmIds are null, empty or negative.
    • validateAssetIds

      protected void validateAssetIds(Collection<String> assetIds)
      Throws an IllegalArgumentException if the given assetIds are null or empty.
    • sendAlarm

      public org.openremote.model.alarm.SentAlarm sendAlarm(org.openremote.model.alarm.Alarm alarm, List<String> assetIds)
      Sends an alarm if the given user has access to the alarm realm.
    • sendAssigneeNotification

      protected void sendAssigneeNotification(org.openremote.model.alarm.SentAlarm alarm, Set<String> excludeUserIds)
      Sends e-mail and push notifications for an alarm to the alarm assignee. If an assignee is not set all users having the Constants.READ_ADMIN_ROLE or Constants.WRITE_ALARMS_ROLE are notified.
      Parameters:
      alarm - the alarm to send e-mail and push notifications for
      excludeUserIds - users matching these user IDs will are excluded from the notifications
    • updateAlarm

      public void updateAlarm(org.openremote.model.alarm.SentAlarm oldAlarm, org.openremote.model.alarm.SentAlarm newAlarm)
      Updates an existing alarm if the given user has access to the alarm realm.
    • linkAssets

      public void linkAssets(List<String> assetIds, String realm, Long alarmId)
      Links multiple assets to an existing alarm.
    • linkAssets

      public void linkAssets(List<org.openremote.model.alarm.AlarmAssetLink> links)
      Links multiple assets to existing alarms if the given user has access to the alarm realms.
    • getAssetLinks

      public List<org.openremote.model.alarm.AlarmAssetLink> getAssetLinks(Long alarmId, String realm) throws IllegalArgumentException
      Returns the assets linked to an alarm if the given user has access to the alarm realm.
      Throws:
      IllegalArgumentException
    • getAlarm

      public org.openremote.model.alarm.SentAlarm getAlarm(Long alarmId) throws IllegalArgumentException
      Retrieves the details of an existing alarm if the given user has access to the alarm realm.
      Throws:
      IllegalArgumentException
    • getAlarms

      public List<org.openremote.model.alarm.SentAlarm> getAlarms(List<Long> alarmIds) throws IllegalArgumentException
      Retrieves the details of existing alarms if the given user has access to the alarm realms.
      Throws:
      IllegalArgumentException
    • getAlarms

      public List<org.openremote.model.alarm.SentAlarm> getAlarms(String realm, org.openremote.model.alarm.Alarm.Status status, String assetId, String assigneeId) throws IllegalArgumentException
      Retrieves all existing alarms in a realm. The status, assetId and assigneeId parameters are optional and if non-null are used for filtering the alarms.
      Throws:
      IllegalArgumentException
    • removeAlarm

      public void removeAlarm(org.openremote.model.alarm.SentAlarm alarm)
      Removes an existing alarm if the given user has access to the alarm realm.
    • removeAlarms

      public void removeAlarms(List<org.openremote.model.alarm.SentAlarm> alarms, List<Long> alarmIds) throws IllegalArgumentException
      Removes existing alarms if the given user has access to the alarm realms.
      Throws:
      IllegalArgumentException