Class AutomationProcessor

  • All Implemented Interfaces:
    java.lang.Runnable, ReadyRunnable

    public class AutomationProcessor
    extends java.lang.Object
    implements ReadyRunnable
    This class used to process automations configured in the vacuumd-configuration.xml file. Automations are identified by a name and they reference Triggers and Actions by name, as well. Autmations also have an interval attribute that determines how often they run.
    Version:
    $Id: $
    Author:
    David Hustace
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean containsTokens​(java.lang.String targetString)
      Simple helper method to determine if the targetString contains any '${token}'s.
      int countRows​(java.sql.ResultSet rs)
      Method used to count the rows in a ResultSet.
      org.opennms.netmgt.vacuumd.AutomationProcessor.ActionProcessor getAction()
      getAction
      Automation getAutomation()
      getAutomation
      Schedule getSchedule()
      getSchedule
      org.opennms.netmgt.vacuumd.AutomationProcessor.TriggerProcessor getTrigger()
      getTrigger
      boolean isReady()
      isReady
      void run()
      run
      boolean runAutomation()
      Called by the run method to execute the sql statements of triggers and actions defined for an automation.
      void setReady​(boolean ready)
      setReady
      void setSchedule​(Schedule schedule)
      setSchedule
      protected boolean verifyRowCount​(java.sql.ResultSet triggerResultSet)
      verifyRowCount
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AutomationProcessor

        public AutomationProcessor​(Automation automation)
        Public constructor.
        Parameters:
        automation - a Automation object.
    • Method Detail

      • getAction

        public org.opennms.netmgt.vacuumd.AutomationProcessor.ActionProcessor getAction()

        getAction

        Returns:
        a AutomationProcessor.ActionProcessor object.
      • getTrigger

        public org.opennms.netmgt.vacuumd.AutomationProcessor.TriggerProcessor getTrigger()

        getTrigger

        Returns:
        a AutomationProcessor.TriggerProcessor object.
      • run

        public void run()

        run

        Specified by:
        run in interface java.lang.Runnable
      • runAutomation

        public boolean runAutomation()
                              throws java.sql.SQLException
        Called by the run method to execute the sql statements of triggers and actions defined for an automation. An automation may have 0 or 1 trigger and must have 1 action. If the automation doesn't have a trigger than the action must not contain any tokens.
        Returns:
        a boolean.
        Throws:
        java.sql.SQLException - if any.
      • verifyRowCount

        protected boolean verifyRowCount​(java.sql.ResultSet triggerResultSet)
                                  throws java.sql.SQLException

        verifyRowCount

        Parameters:
        triggerResultSet - a ResultSet object.
        Returns:
        a boolean.
        Throws:
        java.sql.SQLException - if any.
      • countRows

        public int countRows​(java.sql.ResultSet rs)
                      throws java.sql.SQLException
        Method used to count the rows in a ResultSet. This probably requires that your ResultSet is scrollable.
        Parameters:
        rs - a ResultSet object.
        Returns:
        a int.
        Throws:
        java.sql.SQLException - if any.
      • containsTokens

        public boolean containsTokens​(java.lang.String targetString)
        Simple helper method to determine if the targetString contains any '${token}'s.
        Parameters:
        targetString - a String object.
        Returns:
        a boolean.
      • getAutomation

        public Automation getAutomation()

        getAutomation

        Returns:
        Returns the automation.
      • isReady

        public boolean isReady()

        isReady

        Specified by:
        isReady in interface ReadyRunnable
        Returns:
        a boolean.
      • getSchedule

        public Schedule getSchedule()

        getSchedule

        Returns:
        Returns the schedule.
      • setSchedule

        public void setSchedule​(Schedule schedule)

        setSchedule

        Parameters:
        schedule - The schedule to set.
      • setReady

        public void setReady​(boolean ready)

        setReady

        Parameters:
        ready - a boolean.