wt.rule
Class PersistentRule

java.lang.Object
  extended bywt.fc.WTObject
      extended bywt.fc.Item
          extended bywt.rule.PersistentRule
All Implemented Interfaces:
AccessControlled, DisplayIdentification, DomainAdministered, Externalizable, NetFactor, ObjectMappable, Persistable, RecentlyVisited, Rule, Serializable, WTContained
Direct Known Subclasses:
InstanceBasedRule, TypeBasedRule

public abstract class PersistentRule
extends Item
implements WTContained, Rule, Externalizable

A Rule provides a holder for business logic that describes actions to be performed under certain conditions. This business logic is specified using XML.

A Rule is uniquely identified by its name and ruleType.

Supported API: false

Extendable: false

See Also:
Serialized Form

Field Summary
private static String CLASSNAME
           
static String CONTAINER
          Label for the attribute.
private  WTContainerRef containerReference
           
private  boolean defaultRule
           
private  String description
           
private static long ENABLED
          The value of the enabledFlag attribute when a rule is enabled.
static String ENABLED_FLAG
          Label for the attribute; A flag used to indicate whether or not the rule is enabled.
private  long enabledFlag
           
static long EXTERNALIZATION_VERSION_UID
           
private  String name
           
protected static long OLD_FORMAT_VERSION_UID
           
private static String RESOURCE
           
private  RuleType ruleType
           
(package private) static long serialVersionUID
           
private  XMLLob specification
           
static String SPECIFICATION
          Label for the attribute; The specification of the business rule logic.
 
Fields inherited from class wt.fc.Item
VERSION_40_UID, VERSION_51_UID
 
Fields inherited from class wt.fc.WTObject
CREATE_TIMESTAMP, MODIFY_TIMESTAMP
 
Fields inherited from interface wt.inf.container.WTContained
CONTAINER_ID, CONTAINER_NAME, CONTAINER_REFERENCE
 
Fields inherited from interface wt.fc.Persistable
IDENTITY, PERSIST_INFO, TYPE
 
Fields inherited from interface wt.rule.Rule
DEFAULT_RULE, DESCRIPTION, NAME, RULE_TYPE
 
Fields inherited from interface wt.admin.DomainAdministered
DOMAIN_REF, INHERITED_DOMAIN
 
Fields inherited from interface wt.identity.DisplayIdentification
DISPLAY_IDENTIFIER, DISPLAY_IDENTITY, DISPLAY_TYPE
 
Constructor Summary
PersistentRule()
           
 
Method Summary
private  void containerReferenceValidate(WTContainerRef a_ContainerReference)
           
private  void descriptionValidate(String a_Description)
           
 boolean equals(Object obj)
          Indicates whether the given object is equal to this object from a persistence perspective, by comparing the two objects ObjectIdentifiers.
 WTContainer getContainer()
          Gets the object for the association that plays role: CONTAINER.
 String getContainerName()
          Gets the value of the attribute: CONTAINER_NAME.
 WTContainerRef getContainerReference()
          Gets the value of the attribute: CONTAINER_REFERENCE.
 String getContents()
          Get the String content of the rule's specification.
 String getDescription()
          Gets the value of the attribute: DESCRIPTION.
static SearchCondition getDisabledSearchCondition()
          Return a search condition that can be used to select disabled rules.
 long getEnabledFlag()
          Gets the value of the attribute: ENABLED_FLAG.
static SearchCondition getEnabledSearchCondition()
          Return a search condition that can be used to select enabled rules.
 String getEncoding()
          Get the character encoding of the rule's specification.
 InputSource getInputSource()
          Get an InputSource on the contents of this rule's XML specification.
 String getName()
          Gets the value of the attribute: NAME.
 RuleType getRuleType()
          Gets the value of the attribute: RULE_TYPE.
 XMLLob getSpecification()
          Gets the value of the attribute: SPECIFICATION.
 int hashCode()
          Returns a hash code for this object based upon its ObjectIdentifier.
protected  void initialize()
          Initialize the rule.
protected  void initialize(String name, RuleType ruleType)
          Initialize the rule with the given name and ruleType.
protected  void initialize(String name, RuleType ruleType, WTContainerRef container)
          Initialize the rule with the given name and ruleType.
protected  void initialize(WTContainerRef container)
          Initialize the rule.
 boolean isDefaultRule()
          Gets the value of the attribute: DEFAULT_RULE.
 boolean isEnabled()
          Specifies whether or not this rule is enabled.
private  void nameValidate(String a_Name)
           
 void readExternal(ObjectInput input)
          Reads the non-transient fields of this class from an external source.
 void readExternal(PersistentRetrieveIfc input)
          Used by Persistent Data Service to populate the persistent attributes of this class from a persistent store.
private  boolean readOldVersion(ObjectInput input, long readSerialVersionUID, boolean passThrough, boolean superDone)
          Reads the non-transient fields of this class from an external source, which is not the current version.
protected  boolean readVersion(PersistentRule thisObject, ObjectInput input, long readSerialVersionUID, boolean passThrough, boolean superDone)
          Reads the non-transient fields of this class from an external source.
 void setContainer(WTContainer a_Container)
          Sets the object for the association that plays role: CONTAINER.
 void setContainerReference(WTContainerRef a_ContainerReference)
          Sets the value of the attribute: CONTAINER_REFERENCE.
 void setContents(String xml)
          Set the content of the rule's specification to the the specified String.
 void setDefaultRule(boolean a_DefaultRule)
          Sets the value of the attribute: DEFAULT_RULE.
 void setDescription(String a_Description)
          Sets the value of the attribute: DESCRIPTION.
 void setEnabledFlag(long a_EnabledFlag)
          Sets the value of the attribute: ENABLED_FLAG.
 void setEncoding(String encoding)
          Set the encoding of the rule's specification.
 void setName(String a_Name)
          Sets the value of the attribute: NAME.
 void setRuleType(RuleType a_RuleType)
          Sets the value of the attribute: RULE_TYPE.
 void setSpecification(XMLLob a_Specification)
          Sets the value of the attribute: SPECIFICATION.
 void writeExternal(ObjectOutput output)
          Writes the non-transient fields of this class to an external source.
 void writeExternal(PersistentStoreIfc output)
          Used by Persistent Data Service to obtain the values of the persistent attributes of this class, so they can be written to a persistent store.
 
Methods inherited from class wt.fc.Item
getDomainRef, isInheritedDomain, readVersion, setDomainRef, setInheritedDomain
 
Methods inherited from class wt.fc.WTObject
checkAttributes, duplicate, finalize, getClassInfo, getCreateTimestamp, getDisplayIdentifier, getDisplayIdentity, getDisplayType, getIdentity, getModifyTimestamp, getPersistInfo, getType, readVersion, setPersistInfo, toString
 
Methods inherited from class java.lang.Object
clone, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface wt.fc.Persistable
checkAttributes, getIdentity, getPersistInfo, getType, setPersistInfo
 
Methods inherited from interface wt.fc.NetFactor
getClassInfo, getConceptualClassname
 

Field Detail

RESOURCE

private static final String RESOURCE
See Also:
Constant Field Values

CLASSNAME

private static final String CLASSNAME

SPECIFICATION

public static final String SPECIFICATION
Label for the attribute; The specification of the business rule logic. The specification is written in XML. The semantics of the specification depends on the rule's RuleType.

Supported API: false

See Also:
Constant Field Values

specification

private XMLLob specification

ENABLED_FLAG

public static final String ENABLED_FLAG
Label for the attribute; A flag used to indicate whether or not the rule is enabled. If this attribute is equal to zero then the rule is enabled. Otherwise, the rule is disabled.

Do not set this attribute directly. Instead use RuleService.enableRule(wt.rule.Rule) or RuleService.disableRule(wt.rule.Rule).

The enabledFlag is combined with other attributes to form a uniqueness constraint that allows only a single enabled rule but any number of disabled rules that share the same values for the other attributes.

Supported API: false

See Also:
Constant Field Values

enabledFlag

private long enabledFlag

ENABLED

private static final long ENABLED
The value of the enabledFlag attribute when a rule is enabled. If the enabledFlag attribute is not equal to this value then the rule is disabled.

See Also:
Constant Field Values

CONTAINER

public static final String CONTAINER
Label for the attribute.

Supported API: false

See Also:
Constant Field Values

containerReference

private WTContainerRef containerReference

name

private String name

ruleType

private RuleType ruleType

defaultRule

private boolean defaultRule

description

private String description

serialVersionUID

static final long serialVersionUID
See Also:
Constant Field Values

EXTERNALIZATION_VERSION_UID

public static final long EXTERNALIZATION_VERSION_UID
See Also:
Constant Field Values

OLD_FORMAT_VERSION_UID

protected static final long OLD_FORMAT_VERSION_UID
See Also:
Constant Field Values
Constructor Detail

PersistentRule

public PersistentRule()
Method Detail

writeExternal

public void writeExternal(ObjectOutput output)
                   throws IOException
Writes the non-transient fields of this class to an external source.

Supported API: false

Specified by:
writeExternal in interface Externalizable
Overrides:
writeExternal in class Item
Parameters:
output -
Throws:
IOException

readExternal

public void readExternal(ObjectInput input)
                  throws IOException,
                         ClassNotFoundException
Reads the non-transient fields of this class from an external source.

Supported API: false

Specified by:
readExternal in interface Externalizable
Overrides:
readExternal in class Item
Parameters:
input -
Throws:
IOException
ClassNotFoundException

readVersion

protected boolean readVersion(PersistentRule thisObject,
                              ObjectInput input,
                              long readSerialVersionUID,
                              boolean passThrough,
                              boolean superDone)
                       throws IOException,
                              ClassNotFoundException
Reads the non-transient fields of this class from an external source.

Supported API: false

Parameters:
thisObject -
input -
readSerialVersionUID -
passThrough -
superDone -
Returns:
boolean
Throws:
IOException
ClassNotFoundException

readOldVersion

private boolean readOldVersion(ObjectInput input,
                               long readSerialVersionUID,
                               boolean passThrough,
                               boolean superDone)
                        throws IOException,
                               ClassNotFoundException
Reads the non-transient fields of this class from an external source, which is not the current version.

Parameters:
input -
readSerialVersionUID -
passThrough -
superDone -
Returns:
boolean
Throws:
IOException
ClassNotFoundException

writeExternal

public void writeExternal(PersistentStoreIfc output)
                   throws SQLException,
                          DatastoreException
Used by Persistent Data Service to obtain the values of the persistent attributes of this class, so they can be written to a persistent store.

(Not intended for general use.)

Supported API: false

Specified by:
writeExternal in interface ObjectMappable
Overrides:
writeExternal in class Item
Parameters:
output -
Throws:
SQLException
DatastoreException

readExternal

public void readExternal(PersistentRetrieveIfc input)
                  throws SQLException,
                         DatastoreException
Used by Persistent Data Service to populate the persistent attributes of this class from a persistent store.

(Not intended for general use.)

Supported API: false

Specified by:
readExternal in interface ObjectMappable
Overrides:
readExternal in class Item
Parameters:
input -
Throws:
SQLException
DatastoreException

getSpecification

public XMLLob getSpecification()
Gets the value of the attribute: SPECIFICATION. The specification of the business rule logic. The specification is written in XML. The semantics of the specification depends on the rule's RuleType.

Supported API: false

Returns:
XMLLob

setSpecification

public void setSpecification(XMLLob a_Specification)
                      throws WTPropertyVetoException
Sets the value of the attribute: SPECIFICATION. The specification of the business rule logic. The specification is written in XML. The semantics of the specification depends on the rule's RuleType.

Supported API: false

Parameters:
a_Specification -
Throws:
WTPropertyVetoException

getEnabledFlag

public long getEnabledFlag()
Gets the value of the attribute: ENABLED_FLAG. A flag used to indicate whether or not the rule is enabled. If this attribute is equal to zero then the rule is enabled. Otherwise, the rule is disabled.

Do not set this attribute directly. Instead use RuleService.enableRule(wt.rule.Rule) or RuleService.disableRule(wt.rule.Rule).

The enabledFlag is combined with other attributes to form a uniqueness constraint that allows only a single enabled rule but any number of disabled rules that share the same values for the other attributes.

Supported API: false

Returns:
long

setEnabledFlag

public void setEnabledFlag(long a_EnabledFlag)
Sets the value of the attribute: ENABLED_FLAG. A flag used to indicate whether or not the rule is enabled. If this attribute is equal to zero then the rule is enabled. Otherwise, the rule is disabled.

Do not set this attribute directly. Instead use RuleService.enableRule(wt.rule.Rule) or RuleService.disableRule(wt.rule.Rule).

The enabledFlag is combined with other attributes to form a uniqueness constraint that allows only a single enabled rule but any number of disabled rules that share the same values for the other attributes.

Supported API: false

Parameters:
a_EnabledFlag -

getContents

public String getContents()
Get the String content of the rule's specification. The specification is written in XML. The semantics of the specification depends on the rule's RuleType.

Supported API: false

Specified by:
getContents in interface Rule
Returns:
String

setContents

public void setContents(String xml)
                 throws WTPropertyVetoException
Set the content of the rule's specification to the the specified String. The specification is written in XML. The semantics of the specification depends on the rule's RuleType.

Supported API: false

Specified by:
setContents in interface Rule
Parameters:
xml -
Throws:
WTPropertyVetoException

getEncoding

public String getEncoding()
Get the character encoding of the rule's specification. The specification is written in XML. The semantics of the specification depends on the rule's RuleType.

Supported API: false

Specified by:
getEncoding in interface Rule
Returns:
String

setEncoding

public void setEncoding(String encoding)
                 throws WTPropertyVetoException
Set the encoding of the rule's specification. The specification is written in XML. The semantics of the specification depends on the rule's RuleType.

Supported API: false

Specified by:
setEncoding in interface Rule
Parameters:
encoding -
Throws:
WTPropertyVetoException

getInputSource

public InputSource getInputSource()
                           throws UnsupportedEncodingException
Get an InputSource on the contents of this rule's XML specification.

This method returns null if the rule specification has no content.

Supported API: false

Specified by:
getInputSource in interface Rule
Returns:
InputSource
Throws:
UnsupportedEncodingException

isEnabled

public boolean isEnabled()
Specifies whether or not this rule is enabled. An enabled rule is available for use. A disabled rule should not be used.

Supported API: false

Specified by:
isEnabled in interface Rule
Returns:
boolean

getEnabledSearchCondition

public static SearchCondition getEnabledSearchCondition()
                                                 throws QueryException
Return a search condition that can be used to select enabled rules.

Supported API: false

Returns:
SearchCondition
Throws:
QueryException

getDisabledSearchCondition

public static SearchCondition getDisabledSearchCondition()
                                                  throws QueryException
Return a search condition that can be used to select disabled rules.

Supported API: false

Returns:
SearchCondition
Throws:
QueryException

getContainerName

public String getContainerName()
Gets the value of the attribute: CONTAINER_NAME. The name of the WTContainer this object is assigned to.

Supported API: false

Specified by:
getContainerName in interface WTContained
Returns:
String

getContainer

public WTContainer getContainer()
Gets the object for the association that plays role: CONTAINER.

Supported API: false

Specified by:
getContainer in interface WTContained
Returns:
WTContainer

setContainer

public void setContainer(WTContainer a_Container)
                  throws WTPropertyVetoException,
                         WTException
Sets the object for the association that plays role: CONTAINER.

Supported API: false

Specified by:
setContainer in interface WTContained
Parameters:
a_Container -
Throws:
WTPropertyVetoException
WTException

getContainerReference

public WTContainerRef getContainerReference()
Gets the value of the attribute: CONTAINER_REFERENCE.

Supported API: false

Specified by:
getContainerReference in interface WTContained
Returns:
WTContainerRef

setContainerReference

public void setContainerReference(WTContainerRef a_ContainerReference)
                           throws WTPropertyVetoException
Sets the value of the attribute: CONTAINER_REFERENCE.

Supported API: false

Specified by:
setContainerReference in interface WTContained
Parameters:
a_ContainerReference -
Throws:
WTPropertyVetoException

containerReferenceValidate

private void containerReferenceValidate(WTContainerRef a_ContainerReference)
                                 throws WTPropertyVetoException
Parameters:
a_ContainerReference -
Throws:
WTPropertyVetoException

getName

public String getName()
Gets the value of the attribute: NAME. The name of the rule.

Supported API: false

Specified by:
getName in interface Rule
Returns:
String

setName

public void setName(String a_Name)
             throws WTPropertyVetoException
Sets the value of the attribute: NAME. The name of the rule.

Supported API: false

Specified by:
setName in interface Rule
Parameters:
a_Name -
Throws:
WTPropertyVetoException

nameValidate

private void nameValidate(String a_Name)
                   throws WTPropertyVetoException
Parameters:
a_Name -
Throws:
WTPropertyVetoException

getRuleType

public RuleType getRuleType()
Gets the value of the attribute: RULE_TYPE. The type of business logic described by this rule.

Supported API: false

Specified by:
getRuleType in interface Rule
Returns:
RuleType

setRuleType

public void setRuleType(RuleType a_RuleType)
                 throws WTPropertyVetoException
Sets the value of the attribute: RULE_TYPE. The type of business logic described by this rule.

Supported API: false

Specified by:
setRuleType in interface Rule
Parameters:
a_RuleType -
Throws:
WTPropertyVetoException

isDefaultRule

public boolean isDefaultRule()
Gets the value of the attribute: DEFAULT_RULE. Specifies whether or not this is a default rule.

Supported API: false

Specified by:
isDefaultRule in interface Rule
Returns:
boolean

setDefaultRule

public void setDefaultRule(boolean a_DefaultRule)
                    throws WTPropertyVetoException
Sets the value of the attribute: DEFAULT_RULE. Specifies whether or not this is a default rule.

Supported API: false

Specified by:
setDefaultRule in interface Rule
Parameters:
a_DefaultRule -
Throws:
WTPropertyVetoException

getDescription

public String getDescription()
Gets the value of the attribute: DESCRIPTION. A description of the rule's content and purpose.

Supported API: false

Specified by:
getDescription in interface Rule
Returns:
String

setDescription

public void setDescription(String a_Description)
                    throws WTPropertyVetoException
Sets the value of the attribute: DESCRIPTION. A description of the rule's content and purpose.

Supported API: false

Specified by:
setDescription in interface Rule
Parameters:
a_Description -
Throws:
WTPropertyVetoException

descriptionValidate

private void descriptionValidate(String a_Description)
                          throws WTPropertyVetoException
Parameters:
a_Description -
Throws:
WTPropertyVetoException

equals

public boolean equals(Object obj)
Indicates whether the given object is equal to this object from a persistence perspective, by comparing the two objects ObjectIdentifiers. Changed or stale copies are still considered equal by this method. Delegates to PersistenceHelper.equals(Persistable,Object).

Warning: Certain core Windchill operations may depend upon equals being ObjectIdentifier-based. Changes to the default implementation should be done with care, if at all.

Supported API: false

Overrides:
equals in class Item
Parameters:
obj -
Returns:
boolean

hashCode

public int hashCode()
Returns a hash code for this object based upon its ObjectIdentifier. Delegates to PersistenceHelper.hashCode(Persistable).

Warning: Certain core Windchill operations may depend upon hashCode being ObjectIdentifier-based. Changes to the default implementation should be done with care, if at all.

Supported API: false

Overrides:
hashCode in class Item
Returns:
int

initialize

protected void initialize()
                   throws WTException
Initialize the rule.

Also set the specification to an empty XMLLob. The database doesn't seem to like empty blobs.

Would be nice if the code generator generated constructors and initialize methods for abstract classes.

Overrides:
initialize in class Item
Throws:
WTException

initialize

protected void initialize(WTContainerRef container)
                   throws WTException
Initialize the rule. The rule is created in the specified container.

Also set the specification to an empty XMLLob. The database doesn't seem to like empty blobs.

Would be nice if the code generator generated constructors and initialize methods for abstract classes.

Throws:
WTException

initialize

protected void initialize(String name,
                          RuleType ruleType,
                          WTContainerRef container)
                   throws WTException
Initialize the rule with the given name and ruleType. The rule is created in the specified container.

Also set the specification to an empty XMLLob. The database doesn't seem to like empty blobs.

Would be nice if the code generator generated constructors and initialize methods for abstract classes.

Throws:
WTException

initialize

protected void initialize(String name,
                          RuleType ruleType)
                   throws WTException
Initialize the rule with the given name and ruleType. The rule is created in the Classic container.

Also set the specification to an empty XMLLob. The database doesn't seem to like empty blobs.

Would be nice if the code generator generated constructors and initialize methods for absrtact classes.

Throws:
WTException