org.opennms.netmgt.dao.support
Class JdbcFilterDao

java.lang.Object
  extended by org.opennms.netmgt.dao.support.JdbcFilterDao
All Implemented Interfaces:
FilterDao, org.springframework.beans.factory.InitializingBean

public class JdbcFilterDao
extends java.lang.Object
implements FilterDao, org.springframework.beans.factory.InitializingBean


Constructor Summary
JdbcFilterDao()
           
 
Method Summary
 void afterPropertiesSet()
           
 DatabaseSchemaConfigFactory getDatabaseSchemaConfigFactory()
           
 javax.sql.DataSource getDataSource()
           
protected  java.lang.String getInterfaceWithServiceStatement(java.lang.String rule)
           
 java.util.List<java.lang.String> getIPList(java.lang.String rule)
          This method returns a list of all ip addresses that match the rule that is passed in.
 java.util.Map<java.lang.String,java.util.Set<java.lang.String>> getIPServiceMap(java.lang.String rule)
           
protected  java.lang.String getIPServiceMappingStatement(java.lang.String rule)
           
 NodeDao getNodeDao()
           
 java.util.SortedMap<java.lang.Integer,java.lang.String> getNodeMap(java.lang.String rule)
          This method returns a map of all nodeids and nodelabels that match the rule that is passed in, sorted by nodeid.
protected  java.lang.String getNodeMappingStatement(java.lang.String rule)
           
protected  java.lang.String getSQLStatement(java.lang.String rule)
          This method parses a rule and returns the SQL select statement equivalent of the rule.
protected  java.lang.String getSQLStatement(java.lang.String rule, long nodeId, java.lang.String ipaddr, java.lang.String service)
           
 boolean isRuleMatching(java.lang.String rule)
          Does this rule match anything in the database? In particular, does it return at least one record from the database?
 boolean isValid(java.lang.String addr, java.lang.String rule)
          This method verifies if an ip address adhers to a given rule.
 void setDatabaseSchemaConfigFactory(DatabaseSchemaConfigFactory factory)
           
 void setDataSource(javax.sql.DataSource dataSource)
           
 void setNodeDao(NodeDao nodeDao)
           
 void validateRule(java.lang.String rule)
           
 void walkMatchingNodes(java.lang.String rule, org.opennms.netmgt.model.EntityVisitor visitor)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JdbcFilterDao

public JdbcFilterDao()
Method Detail

getNodeMap

public java.util.SortedMap<java.lang.Integer,java.lang.String> getNodeMap(java.lang.String rule)
                                                                   throws FilterParseException
This method returns a map of all nodeids and nodelabels that match the rule that is passed in, sorted by nodeid.

Specified by:
getNodeMap in interface FilterDao
Parameters:
rule - an expression rule to be parsed and executed.
Returns:
SortedMap containing all nodeids/nodelabels selected by the rule.
Throws:
FilterParseException - if a rule is syntactically incorrect or failed in executing the SQL statement

afterPropertiesSet

public void afterPropertiesSet()
Specified by:
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean

getNodeDao

public NodeDao getNodeDao()

setNodeDao

public void setNodeDao(NodeDao nodeDao)

getDataSource

public javax.sql.DataSource getDataSource()

setDataSource

public void setDataSource(javax.sql.DataSource dataSource)

setDatabaseSchemaConfigFactory

public void setDatabaseSchemaConfigFactory(DatabaseSchemaConfigFactory factory)

getDatabaseSchemaConfigFactory

public DatabaseSchemaConfigFactory getDatabaseSchemaConfigFactory()

getIPServiceMap

public java.util.Map<java.lang.String,java.util.Set<java.lang.String>> getIPServiceMap(java.lang.String rule)
Specified by:
getIPServiceMap in interface FilterDao

getIPList

public java.util.List<java.lang.String> getIPList(java.lang.String rule)
                                           throws FilterParseException
This method returns a list of all ip addresses that match the rule that is passed in.

Specified by:
getIPList in interface FilterDao
Parameters:
rule - an expression rule to be parsed and executed.
Returns:
interface containing all ip addresses selected by the rule.
Throws:
FilterParseException - if a rule is syntactically incorrect or failed in executing the SQL statement

isValid

public boolean isValid(java.lang.String addr,
                       java.lang.String rule)
                throws FilterParseException
This method verifies if an ip address adhers to a given rule.

Specified by:
isValid in interface FilterDao
Parameters:
addr - an octet string ip to be validated against a rule.
rule - an expression rule to be parsed and executed.
Returns:
indicating that the ip is included in the rule
Throws:
FilterParseException - if a rule is syntactically incorrect or failed in executing the SQL statement.

validateRule

public void validateRule(java.lang.String rule)
                  throws FilterParseException
Specified by:
validateRule in interface FilterDao
Throws:
FilterParseException

getSQLStatement

protected java.lang.String getSQLStatement(java.lang.String rule)
This method parses a rule and returns the SQL select statement equivalent of the rule.

Returns:
the sql select statement

getSQLStatement

protected java.lang.String getSQLStatement(java.lang.String rule,
                                           long nodeId,
                                           java.lang.String ipaddr,
                                           java.lang.String service)

getIPServiceMappingStatement

protected java.lang.String getIPServiceMappingStatement(java.lang.String rule)

getNodeMappingStatement

protected java.lang.String getNodeMappingStatement(java.lang.String rule)

getInterfaceWithServiceStatement

protected java.lang.String getInterfaceWithServiceStatement(java.lang.String rule)

isRuleMatching

public boolean isRuleMatching(java.lang.String rule)
Description copied from interface: FilterDao
Does this rule match anything in the database? In particular, does it return at least one record from the database?

Specified by:
isRuleMatching in interface FilterDao
Parameters:
rule - rule to match on
Returns:
true if there is at least one match, false otherwise

walkMatchingNodes

public void walkMatchingNodes(java.lang.String rule,
                              org.opennms.netmgt.model.EntityVisitor visitor)
Specified by:
walkMatchingNodes in interface FilterDao


Copyright © 2007. All Rights Reserved.