Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.drools.repository
Class RulesRepository

    java.lang.Object
      org.drools.repository.RulesRepository

    public class RulesRepository

extends java.lang.Object

RulesRepository is the class that defines the bahavior for the JBoss Rules (drools) rule repository based upon the JCR specification (JSR-170).

An instance of this class is capable of storing rules used by the JBoss Rule engine. It also provides a versioning capability for rules. Rules can be imported from specified files. The RulesRepository is also capable of storing DSL content. Rules can be explicitly tied to a particular DSL node within the repository, and this reference can either follow the head version, or a specific version of the DSL node.

The RulesRepository also is capable of storing RulePackages, which aggregate one or more Rules into a set. RulePackages hold references to the nodes storing the content of the rules in the set within the repository. Each entry in a rulepackage can either refer to the head version of the given rule node, or a specific version.

Rules can be tagged. Tags are stored in a separate area of the repository, and can be added on demand. Rules can have 0 or more tags. Tags are intended to help provide a means for searching for specific types of rules quickly, even when they aren't all part of the same rulepackage.

Rules can be associated with 0 or 1 states. States are created in a seperate area of the repository. States are intended to help track the progress of a rule as it traverses its life- cycle. (e.g. draft, approved, deprecated, etc.)

Author:
  btruitt

Field Summary
`static java.lang.String` | `DSL_AREA` The name of the DSL area of the repository
`static java.lang.String` | `RULE_AREA` The name of the rule area of the repository
`static java.lang.String` | `RULE_PACKAGE_AREA` The name of the rulepackage area of the repository
`static java.lang.String` | `RULES_REPOSITORY_NAME` The name of the rules repository within the JCR repository
`static java.lang.String` | `STATE_AREA` The name of the state area of the repository
`static java.lang.String` | `TAG_AREA` The name of the tag area of the repository

Constructor Summary
`RulesRepository()` This will create the JCR repository automatically if it does not already exist.
`RulesRepository(boolean clearRepository)` This will create the JCR repository automatically if it does not already exist.

Method Summary
`DslItem` | `addDslFromFile(java.io.File file)` Adds a DSL node in the repository using the content and attributes of the specified file
`protected javax.jcr.Node` | `addNodeIfNew(javax.jcr.Node parent, java.lang.String nodeName, java.lang.String type)` Will add a node named 'nodeName' of type 'type' to 'parent' if such a node does not already exist.
`RuleItem` | `addRuleFromFile(java.io.File file)` Adds a Rule node in the repository using the content and attributes of the specified file
`RuleItem` | `addRuleFromFile(java.io.File file, DslItem dslItem)` Adds a Rule node in the repository using the content and attributes of the specified file.
`RuleItem` | `addRuleFromFile(java.io.File file, DslItem dslItem, boolean followDslHead)` Adds a Rule node in the repository using the content and attributes of the specified file.
`void` | `clearRepository()` Clears out the entire tree below the rules repository node of the JCR repository.
`RulePackageItem` | `createRulePackage(java.lang.String name)` Adds a rule package node in the repository.
`void` | `dumpRepository()` Recursively outputs the contents of the workspace starting from root.
`StateItem` | `getState(java.lang.String name)` Gets a StateItem for the specified state name.
`TagItem` | `getTag(java.lang.String tagName)` Gets a TagItem object that encapsulates the node for the specified tag name.
`void` | `logout()` Explicitly logout of the underlying JCR repository.
`protected void` | `setupRepository()` Attempts to setup the repository.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### RULE_PACKAGE_AREA

    public static final java.lang.String RULE_PACKAGE_AREA

  The name of the rulepackage area of the repository

  See Also:
    Constant Field Values

### RULE_AREA

    public static final java.lang.String RULE_AREA

  The name of the rule area of the repository

  See Also:
    Constant Field Values

### DSL_AREA

    public static final java.lang.String DSL_AREA

  The name of the DSL area of the repository

  See Also:
    Constant Field Values

### TAG_AREA

    public static final java.lang.String TAG_AREA

  The name of the tag area of the repository

  See Also:
    Constant Field Values

### STATE_AREA

    public static final java.lang.String STATE_AREA

  The name of the state area of the repository

  See Also:
    Constant Field Values

### RULES_REPOSITORY_NAME

    public static final java.lang.String RULES_REPOSITORY_NAME

  The name of the rules repository within the JCR repository

  See Also:
    Constant Field Values

Constructor Detail

### RulesRepository

    public RulesRepository()

  This will create the JCR repository automatically if it does not already exist. It will call setupRepository() to attempt to setup the repository, in case it has not already been setup.

### RulesRepository

    public RulesRepository(boolean clearRepository)

  This will create the JCR repository automatically if it does not already exist. It will call setupRepository() to attempt to setup the repository, in case it has not already been setup.

  Parameters:
    `clearRepository` - whether or not to erase the contents of the rules repository portion of the JCR repository

Method Detail

### clearRepository

    public void clearRepository()

  Clears out the entire tree below the rules repository node of the JCR repository.

### setupRepository

    protected void setupRepository()
                            throws RulesRepositoryException

  Attempts to setup the repository. If the work that it tries to do has already been done, it will return with modifying the repository.

  Throws:
    `RulesRepositoryException`

### addNodeIfNew

    protected javax.jcr.Node addNodeIfNew(javax.jcr.Node parent,
                                          java.lang.String nodeName,
                                          java.lang.String type)
                                   throws RulesRepositoryException

  Will add a node named 'nodeName' of type 'type' to 'parent' if such a node does not already exist.

  Parameters:
    `parent` - the parent node to add the new node to
    `nodeName` - the name of the new node
    `type` - the type of the new node
  Returns:
    a reference to the Node object that is created by the addition, or, if the node already existed, a reference to the pre-existant node.
  Throws:
    `RulesRepositoryException`

### logout

    public void logout()

  Explicitly logout of the underlying JCR repository. If this is the last session to that repository, the repository will automatically be shutdown.

### dumpRepository

    public void dumpRepository()
                        throws RulesRepositoryException

  Recursively outputs the contents of the workspace starting from root. The large subtree called jcr:system is skipped. This method is just here for programmatic debugging purposes, and should be removed.

  Throws:
    `RulesRepositoryException`

### addDslFromFile

    public DslItem addDslFromFile(java.io.File file)
                           throws RulesRepositoryException

  Adds a DSL node in the repository using the content and attributes of the specified file

  Parameters:
    `file` - the file to use to import the DSL content and attributes
  Returns:
    a DslItem object encapsulating the node that gets added
  Throws:
    `RulesRepositoryException`

### addRuleFromFile

    public RuleItem addRuleFromFile(java.io.File file)
                             throws RulesRepositoryException

  Adds a Rule node in the repository using the content and attributes of the specified file

  Parameters:
    `file` - the file to use to import the DSL content and attributes
  Returns:
    a RuleItem object encapsulating the node that gets added
  Throws:
    `RulesRepositoryException`

### addRuleFromFile

    public RuleItem addRuleFromFile(java.io.File file,
                                    DslItem dslItem)
                             throws RulesRepositoryException

  Adds a Rule node in the repository using the content and attributes of the specified file. Links the newly created node with the specified DSL node within the repository. This link will follow the head verion of the DSL node.

  Parameters:
    `file` - the file to use to import the DSL content and attributes
    `dslItem` - the DslItem containing the node to link the newly created rule node with
  Returns:
    a RuleItem object encapsulting the node that gets added
  Throws:
    `RulesRepositoryException`

### addRuleFromFile

    public RuleItem addRuleFromFile(java.io.File file,
                                    DslItem dslItem,
                                    boolean followDslHead)
                             throws RulesRepositoryException

  Adds a Rule node in the repository using the content and attributes of the specified file. Links the newly created node with the specified DSL node within the repository.

  Parameters:
    `file` - the file to use to import the DSL content and attributes
    `dslItem` - the DslItem containing the node to link the newly created rule node with
    `followDslHead` - if true, the link to the DSL node will follow the head revision of that node. if false, it will continue to refer to the specified version even if a new version of the DSL node is checked in
  Returns:
    a RuleItem object encapsulating the node that gets added
  Throws:
    `RulesRepositoryException`

### createRulePackage

    public RulePackageItem createRulePackage(java.lang.String name)
                                      throws RulesRepositoryException

  Adds a rule package node in the repository. This node has a property called drools:rule_reference that is a multi-value reference property. It will hold an array of references to rule nodes that are subsequently added.

  Parameters:
    `name` - what to name the node added
  Returns:
    a RulePackageItem, encapsulating the created node
  Throws:
    `RulesRepositoryException`

### getState

    public StateItem getState(java.lang.String name)
                       throws RulesRepositoryException

  Gets a StateItem for the specified state name. If a node for the specified state does not yet exist, one is first created.

  Parameters:
    `name` - the name of the state to get
  Returns:
    a StateItem object encapsulating the retreived node
  Throws:
    `RulesRepositoryException`

### getTag

    public TagItem getTag(java.lang.String tagName)
                   throws RulesRepositoryException

  Gets a TagItem object that encapsulates the node for the specified tag name. If the tag does not already exist in the repository when this is called, it is first added to the repository and then returned.

  Parameters:
    `tagName` - the name of the tag to get. If the tag to get is within a heirarchy of tag nodes, specify the full path to the tag node of interest (e.g. if you want to get back 'child-tag', use "parent-tag/child-tag")
  Returns:
    a TagItem object encapsulating the node for the tag in the repository
  Throws:
    `RulesRepositoryException`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2006 Rackspace Corp. All Rights Reserved.