org.opengts.extra.rule
Class RuleFactoryLite

java.lang.Object
  extended by org.opengts.db.RuleFactoryAdapter
      extended by org.opengts.extra.rule.RuleFactoryLite
All Implemented Interfaces:
RuleFactory

public class RuleFactoryLite
extends RuleFactoryAdapter


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.opengts.db.RuleFactory
RuleFactory.NotifyAction
 
Field Summary
static java.lang.String PROP_RuleFactoryLite_emailEnabled
           
 
Fields inherited from interface org.opengts.db.RuleFactory
ACTION_DEFAULT, ACTION_EMAIL_ACCOUNT, ACTION_EMAIL_ALL, ACTION_EMAIL_DEVICE, ACTION_EMAIL_RULE, ACTION_NONE, ACTION_NOTIFY_ACCOUNT, ACTION_NOTIFY_ALL, ACTION_NOTIFY_DEVICE, ACTION_NOTIFY_MASK, ACTION_NOTIFY_RULE, ACTION_SAVE_LAST, ACTION_VIA_EMAIL, ACTION_VIA_LISTENER, ACTION_VIA_MASK, ACTION_VIA_QUEUE, PRIORITY_HIGH, PRIORITY_LOW, PRIORITY_MEDIUM, PRIORITY_UNDEFINED, PROP_rule_workHours_
 
Constructor Summary
RuleFactoryLite()
           
 
Method Summary
protected  boolean _performAction(EventData evdb, org.opengts.extra.rule.RuleFactoryLite.RuleFunction ftn, int actionMask, java.lang.String emailTo, java.lang.String emailSubj, java.lang.String emailBody)
           
protected  boolean _sendNotification(EventData evdb, org.opengts.extra.rule.RuleFactoryLite.RuleFunction ftn, int actionMask, java.lang.String devEmailTo, java.lang.String devEmailSubj, java.lang.String devEmailBody)
           
 boolean checkRuntime()
          Initializes and returns true if successful
 boolean checkSelectorSyntax(java.lang.String selector)
          Return true if the specified selector is syntactically correct
 java.lang.String convertToENRE(java.lang.String selector)
           
static int cron(java.lang.String[] argv)
           
static void DebugSetSendNotification(boolean send)
           
 java.lang.Object evaluateSelector(java.lang.String selector, Account account)
          Evaluates a selector against the specified Account and returns the result
 java.lang.Object evaluateSelector(java.lang.String selector, EventData event)
          Evaluates a selector against the specified event and returns the result
 int executeRule(java.lang.String ruleID, EventData event)
          Executes the specified ruleID against the specified EventData record, and return a mask containing the actions performed.
 int executeRules(EventData event)
          May call an extended set of rule definitions
 int executeSelector(java.lang.String sel, EventData event)
          Checks the specified rule 'selector' against the specified event, and executes the default action devices by the current Device.
 java.lang.String getFunctionDescription(java.lang.String ftnName)
          Returns the description for the specified function name
 java.util.List<java.lang.String> getFunctionNames()
          Returns a list of all available selector function names
 java.lang.String getFunctionUsage(java.lang.String ftnName)
          Returns the function "usage" description for the specified function name
 java.lang.String getIdentifierDescription(java.lang.String idName)
          Returns the description for the specified identifier
 java.util.List<java.lang.String> getIdentifierNames()
          Returns a list of all available selector identifiers
 java.lang.String getName()
          Returns this RuleFactory name
 java.lang.String[] getRuleIDs(Account account)
          Returns a list of defined rule-ids for the specified Account.
 java.lang.String getRuleNotifyEmail(Account account, java.lang.String ruleID)
          Returns the rule notification email addresses for the specified rule-id, in the specified Account.
 java.lang.String getRuleSelector(Account account, java.lang.String ruleID)
          Return the selector for the specified rule-id
 java.lang.String getVersion()
          Return this RuleFactory version String
 boolean isSelectorMatch(java.lang.String selector, Account account)
           
 boolean isSelectorMatch(java.lang.String selector, EventData event)
          Return true if the specified 'event' matches the specified 'selector'
static void main(java.lang.String[] argv)
           
static boolean SendNotification()
           
 
Methods inherited from class org.opengts.db.RuleFactoryAdapter
getGeoCorridorDescription, getPredefinedRuleActions, ValidateActionMask
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROP_RuleFactoryLite_emailEnabled

public static final java.lang.String PROP_RuleFactoryLite_emailEnabled
See Also:
Constant Field Values
Constructor Detail

RuleFactoryLite

public RuleFactoryLite()
Method Detail

DebugSetSendNotification

public static void DebugSetSendNotification(boolean send)

SendNotification

public static boolean SendNotification()

getName

public java.lang.String getName()
Description copied from class: RuleFactoryAdapter
Returns this RuleFactory name

Specified by:
getName in interface RuleFactory
Specified by:
getName in class RuleFactoryAdapter
Returns:
This RuleFactory name

getVersion

public java.lang.String getVersion()
Description copied from class: RuleFactoryAdapter
Return this RuleFactory version String

Specified by:
getVersion in interface RuleFactory
Overrides:
getVersion in class RuleFactoryAdapter
Returns:
This RuleFactory version String

checkRuntime

public boolean checkRuntime()
Description copied from interface: RuleFactory
Initializes and returns true if successful

Returns:
True if initialization was succesful, false otherwise

getIdentifierNames

public java.util.List<java.lang.String> getIdentifierNames()
Description copied from interface: RuleFactory
Returns a list of all available selector identifiers

Returns:
A list of all available selector identifiers

getIdentifierDescription

public java.lang.String getIdentifierDescription(java.lang.String idName)
Description copied from interface: RuleFactory
Returns the description for the specified identifier

Parameters:
idName - The name of the identifier for which the description is returned.
Returns:
The description for the specified identifier

getFunctionNames

public java.util.List<java.lang.String> getFunctionNames()
Description copied from interface: RuleFactory
Returns a list of all available selector function names

Returns:
A list of all available selector function names

getFunctionUsage

public java.lang.String getFunctionUsage(java.lang.String ftnName)
Description copied from interface: RuleFactory
Returns the function "usage" description for the specified function name

Parameters:
ftnName - The name of the function for which the "usage" description is returned.
Returns:
The "usage" description for the specified function name

getFunctionDescription

public java.lang.String getFunctionDescription(java.lang.String ftnName)
Description copied from interface: RuleFactory
Returns the description for the specified function name

Parameters:
ftnName - The name of the function for which the description is returned.
Returns:
The description for the specified function name

getRuleIDs

public java.lang.String[] getRuleIDs(Account account)
Returns a list of defined rule-ids for the specified Account.

Parameters:
account - The account from which the rule-id list is returned
Returns:
The list of rule-ids

getRuleSelector

public java.lang.String getRuleSelector(Account account,
                                        java.lang.String ruleID)
Return the selector for the specified rule-id

Parameters:
account - the Account
ruleID - the rule-id
Returns:
The rule selector, or null if the rule-id is not defined

getRuleNotifyEmail

public java.lang.String getRuleNotifyEmail(Account account,
                                           java.lang.String ruleID)
Returns the rule notification email addresses for the specified rule-id, in the specified Account. Email addresses are returned as a comma-separated String value.

Parameters:
account - The account which owns the rule-id from which the notify email addresses are returned
ruleID - The Rule-ID which contains the notify email addresses to return
Returns:
The rule notification email addresses for the specified account and rule-id

checkSelectorSyntax

public boolean checkSelectorSyntax(java.lang.String selector)
Description copied from interface: RuleFactory
Return true if the specified selector is syntactically correct

Parameters:
selector - The rule selector to syntax check
Returns:
True if the selector is syntactically correct, false otherwise

isSelectorMatch

public boolean isSelectorMatch(java.lang.String selector,
                               EventData event)
Description copied from interface: RuleFactory
Return true if the specified 'event' matches the specified 'selector'

Parameters:
selector - The rule selector to check against the specified event
event - The event that contains the criteria used by the selector
Returns:
True if the events matches the specified selector, false otherwise

isSelectorMatch

public boolean isSelectorMatch(java.lang.String selector,
                               Account account)

convertToENRE

public java.lang.String convertToENRE(java.lang.String selector)

evaluateSelector

public java.lang.Object evaluateSelector(java.lang.String selector,
                                         EventData event)
Description copied from interface: RuleFactory
Evaluates a selector against the specified event and returns the result

Parameters:
selector - The selector to execute.
event - The event that contains the criteria used by the selector
Returns:
An object containing the result of the executed selector.

evaluateSelector

public java.lang.Object evaluateSelector(java.lang.String selector,
                                         Account account)
Description copied from interface: RuleFactory
Evaluates a selector against the specified Account and returns the result

Parameters:
selector - The selector to execute.
account - The Account that contains the criteria used by the selector
Returns:
An object containing the result of the executed selector.

executeSelector

public int executeSelector(java.lang.String sel,
                           EventData event)
Checks the specified rule 'selector' against the specified event, and executes the default action devices by the current Device.

Parameters:
sel - The rule selector
event - The current event
Returns:
The executed action-mask (or -1 if no action was triggered)

executeRules

public int executeRules(EventData event)
May call an extended set of rule definitions

Parameters:
event - The current incoming EventData record
Returns:
True if at least one of the exectued rules was triggered

executeRule

public int executeRule(java.lang.String ruleID,
                       EventData event)
Executes the specified ruleID against the specified EventData record, and return a mask containing the actions performed.

Parameters:
ruleID - The ruleID to execute against the specified event
event - The event that contains the criteria used by the rules
Returns:
The mask containing the 'actions' performed.

_performAction

protected boolean _performAction(EventData evdb,
                                 org.opengts.extra.rule.RuleFactoryLite.RuleFunction ftn,
                                 int actionMask,
                                 java.lang.String emailTo,
                                 java.lang.String emailSubj,
                                 java.lang.String emailBody)

_sendNotification

protected boolean _sendNotification(EventData evdb,
                                    org.opengts.extra.rule.RuleFactoryLite.RuleFunction ftn,
                                    int actionMask,
                                    java.lang.String devEmailTo,
                                    java.lang.String devEmailSubj,
                                    java.lang.String devEmailBody)

cron

public static int cron(java.lang.String[] argv)

main

public static void main(java.lang.String[] argv)