| java.lang.Object org.drools.repository.RulesRepository
RulesRepository | public class RulesRepository (Code) | | 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.
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.)
The RulesRepository provides versioning of rules, rule packages, and DSLs.
This versioning works in a strictly linear fashion, with one version having
at most 1 predecessor version (or none, if it is the first version), and at
most 1 successor version (or none, if it is the most recently checked-in
version). The JCR specification supports a more complicated versioning
system, and if there is sufficient demand, we can modify our versioning
scheme to be better aligned with JCR's versioning abilities.
author: Ben Truitt author: Fernando Meyer author: Michael Neale |
Constructor Summary | |
public | RulesRepository(Session session) This requires a JCR session be setup, and the repository be configured. |
Method Summary | |
protected static Node | addNodeIfNew(Node parent, String nodeName, String type) Will add a node named 'nodeName' of type 'type' to 'parent' if such a
node does not already exist. | public boolean | containsPackage(String name) This returns true if the repository contains the specified package name. | public String | copyAsset(String uuidSource, String destinationPackage, String destinationName) This will copy an assets content to the new location. | public void | copyPackage(String sourcePackageName, String destPackageName) Copy a package to the target name. | public void | copyPackageSnapshot(String packageName, String snapshotName, String newName) Copies a snapshot to the new location/label.
Parameters: packageName - The name of the package. Parameters: snapshotName - The label of the source snapshot Parameters: newName - The new label. | public PackageItem | createPackage(String name, String description) Adds a package to the repository. | public void | createPackageSnapshot(String packageName, String snapshotName) This will copy the package to the snapshot area. | public StateItem | createState(String name) Create a status node of the given name. | public byte[] | dumpRepositoryXml() | public byte[] | exportRulesRepository() | public AssetItemIterator | findArchivedAssets() | public List | findAssetsByCategory(String categoryTag, boolean seekArchivedAsset) This will retrieve a list of RuleItem objects - that are allocated to the
provided category. | public List | findAssetsByCategory(String categoryTag) | public AssetItemIterator | findAssetsByName(String name, boolean seekArchived) This will search assets, looking for matches against the name. | public AssetItemIterator | findAssetsByName(String name) | public Session | getSession() | public StateItem | getState(String name) Gets a StateItem for the specified state name. | public void | importRulesRepository(byte[] byteArray) | boolean | isNotSnapshot(Node parentNode) | public String[] | listPackageSnapshots(String packageName) Return a list of the snapshots available for the given package name. | public Iterator | listPackages() an Iterator which will provide RulePackageItem's. | public StateItem[] | listStates() | public AssetItem | loadAssetByUUID(String uuid) Loads a rule by its UUID (generally the fastest way to load something). | public CategoryItem | loadCategory(String tagName) This will return a category for the given category path.
Parameters: tagName - the name of the tag to get. | public PackageItem | loadDefaultPackage() This will return or create the default package for rules that have no
home yet. | public PackageItem | loadPackage(String name) Loads a RulePackage for the specified package name. | public PackageItem | loadPackageByUUID(String uuid) Similar to above. | public PackageItem | loadPackageSnapshot(String packageName, String snapshotName) | public void | logout() Explicitly logout of the underlying JCR repository. | public void | moveRuleItemPackage(String newPackage, String uuid, String explanation) This moves a rule asset from one package to another, preserving history
etc etc. | public void | removePackageSnapshot(String packageName, String snapshotName) This will remove the specified snapshot. | public String | renameAsset(String uuid, String newAssetName) This will rename an assset and apply the change immediately. | public String | renamePackage(String uuid, String newPackageName) This will rename a package and apply the change immediately. | public void | restoreHistoricalAsset(AssetItem versionToRestore, AssetItem headVersion, String comment) This will restore the historical version, save, and check it in as a new
version with the given comment. | public void | save() Save any pending changes. |
DEFAULT_PACKAGE | final public static String DEFAULT_PACKAGE(Code) | | |
PACKAGE_SNAPSHOT_AREA | final public static String PACKAGE_SNAPSHOT_AREA(Code) | | The name of the rulepackage area of the repository
|
RULES_REPOSITORY_NAME | final public static String RULES_REPOSITORY_NAME(Code) | | The name of the rules repository within the JCR repository
|
RULE_PACKAGE_AREA | final public static String RULE_PACKAGE_AREA(Code) | | The name of the rulepackage area of the repository
|
STATE_AREA | final public static String STATE_AREA(Code) | | The name of the state area of the repository
|
TAG_AREA | final public static String TAG_AREA(Code) | | The name of the tag area of the repository
|
RulesRepository | public RulesRepository(Session session)(Code) | | This requires a JCR session be setup, and the repository be configured.
|
addNodeIfNew | protected static Node addNodeIfNew(Node parent, String nodeName, String type) throws RulesRepositoryException(Code) | | 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 Parameters: nodeName - the name of the new node Parameters: type - the type of the new node a reference to the Node object that is created by the addition,or, if the node already existed, a reference to the pre-existantnode. throws: RulesRepositoryException - |
containsPackage | public boolean containsPackage(String name)(Code) | | This returns true if the repository contains the specified package name.
|
copyAsset | public String copyAsset(String uuidSource, String destinationPackage, String destinationName)(Code) | | This will copy an assets content to the new location.
the UUID of the new asset. |
copyPackage | public void copyPackage(String sourcePackageName, String destPackageName)(Code) | | Copy a package to the target name.
|
copyPackageSnapshot | public void copyPackageSnapshot(String packageName, String snapshotName, String newName)(Code) | | Copies a snapshot to the new location/label.
Parameters: packageName - The name of the package. Parameters: snapshotName - The label of the source snapshot Parameters: newName - The new label. The old one is left intact. |
createPackageSnapshot | public void createPackageSnapshot(String packageName, String snapshotName)(Code) | | This will copy the package to the snapshot area. Creating a copy for
deployment, etc.
|
dumpRepositoryXml | public byte[] dumpRepositoryXml() throws PathNotFoundException, IOException, RepositoryException(Code) | | |
exportRulesRepository | public byte[] exportRulesRepository() throws IOException, PathNotFoundException, RepositoryException(Code) | | TODO: comment
throws: IOException - throws: PathNotFoundException - throws: RepositoryException - |
findAssetsByCategory | public List findAssetsByCategory(String categoryTag, boolean seekArchivedAsset) throws RulesRepositoryException(Code) | | This will retrieve a list of RuleItem objects - that are allocated to the
provided category. Only the latest versions of each RuleItem will be
returned (you will have to delve into the rules deepest darkest history
yourself... mahahahaha).
|
findAssetsByName | public AssetItemIterator findAssetsByName(String name, boolean seekArchived)(Code) | | This will search assets, looking for matches against the name.
|
getSession | public Session getSession()(Code) | | The JCR session that this repository is using. |
importRulesRepository | public void importRulesRepository(byte[] byteArray)(Code) | | Parameters: byteArray - |
isNotSnapshot | boolean isNotSnapshot(Node parentNode) throws RepositoryException(Code) | | Parameters: parentNode - throws: RepositoryException - |
listPackageSnapshots | public String[] listPackageSnapshots(String packageName)(Code) | | Return a list of the snapshots available for the given package name.
|
listPackages | public Iterator listPackages()(Code) | | an Iterator which will provide RulePackageItem's. This will showALL the packages, only returning latest versions, by default. |
listStates | public StateItem[] listStates()(Code) | | A list of statii in the system. |
loadAssetByUUID | public AssetItem loadAssetByUUID(String uuid)(Code) | | Loads a rule by its UUID (generally the fastest way to load something).
|
loadCategory | public CategoryItem loadCategory(String tagName) throws RulesRepositoryException(Code) | | This will return a category for the given category path.
Parameters: tagName - the name of the tag to get. If the tag to get is within aheirarchy of tag nodes, specify the full path to the tag nodeof interest (e.g. if you want to get back 'child-tag', use"parent-tag/child-tag") a TagItem object encapsulating the node for the tag in therepository throws: RulesRepositoryException - |
loadPackage | public PackageItem loadPackage(String name) throws RulesRepositoryException(Code) | | Loads a RulePackage for the specified package name. Will throw an
exception if the specified rule package does not exist.
Parameters: name - the name of the package to load a RulePackageItem object |
logout | public void logout()(Code) | | Explicitly logout of the underlying JCR repository.
|
moveRuleItemPackage | public void moveRuleItemPackage(String newPackage, String uuid, String explanation)(Code) | | This moves a rule asset from one package to another, preserving history
etc etc.
Parameters: newPackage - The destination package. Parameters: uuid - The UUID of the rule Parameters: explanation - The reason (which will be added as the checkin message). |
removePackageSnapshot | public void removePackageSnapshot(String packageName, String snapshotName)(Code) | | This will remove the specified snapshot.
|
renameAsset | public String renameAsset(String uuid, String newAssetName)(Code) | | This will rename an assset and apply the change immediately.
the UUID of the new asset |
renamePackage | public String renamePackage(String uuid, String newPackageName)(Code) | | This will rename a package and apply the change immediately.
the UUID of the package |
restoreHistoricalAsset | public void restoreHistoricalAsset(AssetItem versionToRestore, AssetItem headVersion, String comment)(Code) | | This will restore the historical version, save, and check it in as a new
version with the given comment.
Parameters: versionToRestore - Parameters: headVersion - Parameters: comment - |
save | public void save()(Code) | | Save any pending changes.
|
|
|