站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > JBoss RULES 4.0.0.11754MR2 API 英文版文档

PackageItem (Drools 4.0.0.11754MR2 API) - JBoss RULES 4.0.0.11754MR2 API 英文版文档


org.drools.repository
Class PackageItem

java.lang.Object
  extended by org.drools.repository.Item
      extended by org.drools.repository.VersionableItem
          extended by org.drools.repository.PackageItem

public class PackageItem
extends VersionableItem

A PackageItem object aggregates a set of assets (for example, rules). This is advantageous for systems using the JBoss Rules engine where the application might make use of many related rules.

A PackageItem refers to rule nodes within the RulesRepository. It contains the "master copy" of assets (which may be linked into other packages or other types of containers). This is a container "node".

Author:
btruitt

Field Summary
static String ASSET_FOLDER_NAME
          This is the name of the rules "subfolder" where rules are kept for this package.
static String EXTERNAL_URI_PROPERTY_NAME
           
static String HEADER_PROPERTY_NAME
           
static String PACKAGE_FORMAT
          The dublin core format attribute.
static String RULE_PACKAGE_TYPE_NAME
          The name of the rule package node type
 
Fields inherited from class org.drools.repository.VersionableItem
CATEGORY_PROPERTY_NAME, CHECKIN_COMMENT, CONTENT_PROPERTY_ARCHIVE_FLAG, COVERAGE_PROPERTY_NAME, CREATOR_PROPERTY_NAME, DEFAULT_CONTENT_FORMAT, DESCRIPTION_PROPERTY_NAME, FORMAT_PROPERTY_NAME, LAST_CONTRIBUTOR_PROPERTY_NAME, LAST_MODIFIED_PROPERTY_NAME, PUBLISHER_PROPERTY_NAME, RELATION_PROPERTY_NAME, RIGHTS_PROPERTY_NAME, SOURCE_PROPERTY_NAME, STATE_PROPERTY_NAME, SUBJECT_PROPERTY_NAME, TITLE_PROPERTY_NAME, TYPE_PROPERTY_NAME, VERSION_NUMBER_PROPERTY_NAME
 
Fields inherited from class org.drools.repository.Item
node, rulesRepository
 
Constructor Summary
PackageItem(RulesRepository rulesRepository, javax.jcr.Node node)
          Constructs an object of type RulePackageItem corresponding the specified node
 
Method Summary
 AssetItem addAsset(String assetName, String description)
          Adds a rule to the current package with no category (not recommended !).
 AssetItem addAsset(String assetName, String description, String initialCategory, String format)
          This adds a rule to the current physical package (you can move it later).
 void changeStatus(String newState)
          This will change the status of this package, and all the contained assets.
 Iterator getAssets()
          Return an iterator for the rules in this package
 Iterator getAssetsWithStatus(StateItem state)
          This will return a list of assets for a given state.
 Iterator getAssetsWithStatus(StateItem state, StateItem ignoreState)
          This will return a list of assets for a given state.
 byte[] getCompiledPackageBytes()
          This is a convenience method for returning the binary data as a byte array.
 String getExternalURI()
           
 String getHeader()
           
 String getName()
          Return the name of the package.
 VersionableItem getPrecedingVersion()
          Clients of this method can cast the resulting object to the type of object they are calling the method on (e.g.
 String getSnapshotName()
          returns the name of the snapshot, if this package is really a snapshot.
 VersionableItem getSucceedingVersion()
          Clients of this method can cast the resulting object to the type of object they are calling the method on (e.g.
 boolean isSnapshot()
           
 AssetItemIterator listAssetsByFormat(String[] formats)
          This will load an iterator for assets of the given format type.
 AssetItem loadAsset(String name)
          Load a specific rule asset by name.
 AssetItemIterator queryAssets(String fieldPredicates)
           
 AssetItemIterator queryAssets(String fieldPredicates, boolean seekArchived)
          This will query any assets stored under this package.
 void removeAsset(String name)
          Remove an asset by name After doing this, you will need to check in the package as removing an item effects the parent package.
 String toString()
          Nicely formats the information contained by the node that this object encapsulates
 void updateCheckinComment(String comment)
          Update the checkin comment.
 PackageItem updateCompiledPackage(InputStream data)
          If the asset is a binary asset, then use this to update the content (do NOT use text).
 void updateExternalURI(String uri)
           
 void updateHeader(String header)
           
 
Methods inherited from class org.drools.repository.VersionableItem
archiveItem, checkin, checkIsUpdateable, checkout, getCheckinComment, getCoverage, getCreatedDate, getCreator, getDescription, getExternalRelation, getExternalSource, getFormat, getLastContributor, getLastModified, getLongProperty, getPrecedingVersionNode, getPublisher, getRealContentFromVersion, getRights, getState, getStateDescription, getStringProperty, getSubject, getSucceedingVersionNode, getTitle, getType, getUUID, getVersionContentNode, getVersionNumber, getVersionSnapshotUUID, isArchived, isHistoricalVersion, sameState, updateCoverage, updateDescription, updateExternalRelation, updateExternalSource, updateFormat, updatePublisher, updateRights, updateState, updateState, updateStringProperty, updateSubject, updateTitle, updateType
 
Methods inherited from class org.drools.repository.Item
equals, getNode, getRulesRepository, hashCode
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ASSET_FOLDER_NAME

public static final String ASSET_FOLDER_NAME
This is the name of the rules "subfolder" where rules are kept for this package.

See Also:
Constant Field Values

PACKAGE_FORMAT

public static final String PACKAGE_FORMAT
The dublin core format attribute.

See Also:
Constant Field Values

RULE_PACKAGE_TYPE_NAME

public static final String RULE_PACKAGE_TYPE_NAME
The name of the rule package node type

See Also:
Constant Field Values

HEADER_PROPERTY_NAME

public static final String HEADER_PROPERTY_NAME
See Also:
Constant Field Values

EXTERNAL_URI_PROPERTY_NAME

public static final String EXTERNAL_URI_PROPERTY_NAME
See Also:
Constant Field Values
Constructor Detail

PackageItem

public PackageItem(RulesRepository rulesRepository,
                   javax.jcr.Node node)
            throws RulesRepositoryException
Constructs an object of type RulePackageItem corresponding the specified node

Parameters:
rulesRepository - the rulesRepository that instantiated this object
node - the node to which this object corresponds
Throws:
RulesRepositoryException
Method Detail

getName

public String getName()
Return the name of the package.

Overrides:
getName in class VersionableItem
Returns:
the name of the node that this item encapsultes

isSnapshot

public boolean isSnapshot()
Returns:
true if this package is actually a snapshot.

getSnapshotName

public String getSnapshotName()
returns the name of the snapshot, if this package is really a snapshot. If it is not, it will just return the name of the package, so use wisely !


addAsset

public AssetItem addAsset(String assetName,
                          String description)
Adds a rule to the current package with no category (not recommended !). Without categories, its going to be hard to find rules later on (unless packages are enough for you).


addAsset

public AssetItem addAsset(String assetName,
                          String description,
                          String initialCategory,
                          String format)
This adds a rule to the current physical package (you can move it later). With the given category. This will NOT check the asset in, just create the basic record.

Parameters:
assetName - The name of the asset (the file name minus the extension)
description - A description of the asset.
initialCategory - The initial category the asset is placed in (can belong to multiple ones later).
format - The dublin core format (which also determines what editor is used) - this is effectively the file extension.

removeAsset

public void removeAsset(String name)
Remove an asset by name After doing this, you will need to check in the package as removing an item effects the parent package.


getAssets

public Iterator getAssets()
Return an iterator for the rules in this package


queryAssets

public AssetItemIterator queryAssets(String fieldPredicates,
                                     boolean seekArchived)
This will query any assets stored under this package. For example, you can pass in "drools:format = 'drl'" to get a list of only a certain type of asset.

Parameters:
fieldPredicates - A predicate string (SQL style).
Returns:
A list of matches.

queryAssets

public AssetItemIterator queryAssets(String fieldPredicates)

listAssetsByFormat

public AssetItemIterator listAssetsByFormat(String[] formats)
This will load an iterator for assets of the given format type.


loadAsset

public AssetItem loadAsset(String name)
Load a specific rule asset by name.


toString

public String toString()
Nicely formats the information contained by the node that this object encapsulates

Overrides:
toString in class Object

getPrecedingVersion

public VersionableItem getPrecedingVersion()
                                    throws RulesRepositoryException
Description copied from class: VersionableItem
Clients of this method can cast the resulting object to the type of object they are calling the method on (e.g.
           RuleItem item;
           ...
           RuleItem predcessor = (RuleItem) item.getPrecedingVersion();
         

Specified by:
getPrecedingVersion in class VersionableItem
Returns:
a VersionableItem object encapsulating the predessor node of this node in the version history, or null if no predecessor version exists
Throws:
RulesRepositoryException

getSucceedingVersion

public VersionableItem getSucceedingVersion()
                                     throws RulesRepositoryException
Description copied from class: VersionableItem
Clients of this method can cast the resulting object to the type of object they are calling the method on (e.g.
           RuleItem item;
           ...
           RuleItem successor = (RuleItem) item.getSucceedingVersion();
         

Specified by:
getSucceedingVersion in class VersionableItem
Returns:
a VersionableItem object encapsulating the successor node of this node in the version history.
Throws:
RulesRepositoryException

getAssetsWithStatus

public Iterator getAssetsWithStatus(StateItem state,
                                    StateItem ignoreState)
This will return a list of assets for a given state. It works through the assets that belong to this package, and if they are not in the correct state, walks backwards until it finds one in the correct state. If it walks all the way back up the versions looking for the "latest" version with the appropriate state, and can't find one, that asset is not included in the result. This will exclude any items that have the "ignoreState" set (so for example, retired items, invalid items etc).

Parameters:
state - The state of assets to retrieve.
ignoreState - The statuses to not include in the results (it will look at the status of the latest one).

getAssetsWithStatus

public Iterator getAssetsWithStatus(StateItem state)
This will return a list of assets for a given state. It works through the assets that belong to this package, and if they are not in the correct state, walks backwards until it finds one in the correct state. If it walks all the way back up the versions looking for the "latest" version with the appropriate state, and can't find one, that asset is not included in the result.


getHeader

public String getHeader()
Returns:
The header contents as pertains to a package of rule assets.

getExternalURI

public String getExternalURI()
Returns:
The external URI which will be used to sync this package to an external resource. Generally this will resolve to a directory in (for example) Subversion - with each asset being a file (with the format property as the file extension).

updateHeader

public void updateHeader(String header)

updateExternalURI

public void updateExternalURI(String uri)

updateCheckinComment

public void updateCheckinComment(String comment)
Update the checkin comment.


changeStatus

public void changeStatus(String newState)
This will change the status of this package, and all the contained assets. No new versions are created of anything.

Parameters:
newState - The status tag to change it to.

updateCompiledPackage

public PackageItem updateCompiledPackage(InputStream data)
If the asset is a binary asset, then use this to update the content (do NOT use text).


getCompiledPackageBytes

public byte[] getCompiledPackageBytes()
This is a convenience method for returning the binary data as a byte array.



Copyright © 2001-2007 JBoss Inc.. All Rights Reserved.