Package org.opennms.netmgt.vacuumd
Class AutomationProcessor
- java.lang.Object
-
- org.opennms.netmgt.vacuumd.AutomationProcessor
-
- All Implemented Interfaces:
Runnable,ReadyRunnable
public class AutomationProcessor extends 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
-
-
Constructor Summary
Constructors Constructor Description AutomationProcessor(Automation automation)Public constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancontainsTokens(String targetString)Simple helper method to determine if the targetString contains any '${token}'s.intcountRows(ResultSet rs)Method used to count the rows in a ResultSet.org.opennms.netmgt.vacuumd.AutomationProcessor.ActionProcessorgetAction()getActionAutomationgetAutomation()getAutomationSchedulegetSchedule()getScheduleorg.opennms.netmgt.vacuumd.AutomationProcessor.TriggerProcessorgetTrigger()getTriggerbooleanisReady()isReadyvoidrun()runbooleanrunAutomation()Called by the run method to execute the sql statements of triggers and actions defined for an automation.voidsetReady(boolean ready)setReadyvoidsetSchedule(Schedule schedule)setScheduleprotected booleanverifyRowCount(ResultSet triggerResultSet)verifyRowCount
-
-
-
Constructor Detail
-
AutomationProcessor
public AutomationProcessor(Automation automation)
Public constructor.- Parameters:
automation- aAutomationobject.
-
-
Method Detail
-
getAction
public org.opennms.netmgt.vacuumd.AutomationProcessor.ActionProcessor getAction()
getAction
- Returns:
- a
AutomationProcessor.ActionProcessorobject.
-
getTrigger
public org.opennms.netmgt.vacuumd.AutomationProcessor.TriggerProcessor getTrigger()
getTrigger
- Returns:
- a
AutomationProcessor.TriggerProcessorobject.
-
runAutomation
public boolean runAutomation() throws SQLExceptionCalled 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:
SQLException- if any.
-
verifyRowCount
protected boolean verifyRowCount(ResultSet triggerResultSet) throws SQLException
verifyRowCount
- Parameters:
triggerResultSet- aResultSetobject.- Returns:
- a boolean.
- Throws:
SQLException- if any.
-
countRows
public int countRows(ResultSet rs) throws SQLException
Method used to count the rows in a ResultSet. This probably requires that your ResultSet is scrollable.- Parameters:
rs- aResultSetobject.- Returns:
- a int.
- Throws:
SQLException- if any.
-
containsTokens
public boolean containsTokens(String targetString)
Simple helper method to determine if the targetString contains any '${token}'s.- Parameters:
targetString- aStringobject.- Returns:
- a boolean.
-
getAutomation
public Automation getAutomation()
getAutomation
- Returns:
- Returns the automation.
-
isReady
public boolean isReady()
isReady
- Specified by:
isReadyin interfaceReadyRunnable- 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.
-
-