com.waveset.object
Class Rule

java.lang.Object
  extended bycom.waveset.object.PersistentObject
      extended bycom.waveset.object.Rule
All Implemented Interfaces:
java.lang.Comparable, Library.Member, com.sun.idm.debugger.common.Locatable, javax.naming.Referenceable, XmlObject

public class Rule
extends PersistentObject
implements Library.Member, com.sun.idm.debugger.common.Locatable

An object representing a rule.

Rules are essentially functions that compute a value. The value may be a static value, or may be calculated by an expression. Rules are run within an environment provided by the application. Rule expressions may reference variables whose values are supplied by the environment.

Rules may also formally declare arguments that are expected to have values in the environment.


Nested Class Summary
static class Rule.Argument
          Class describing a declared rule argument.
 class Rule.RuleResolver
          An ExResolver implementation we install in the ExState to handle references to rule arguments.
static class Rule.RuleState
          An default ExState that serves as the callback handler for resolving external references within the rule expression.
 
Nested classes inherited from class com.waveset.object.PersistentObject
PersistentObject.Comparator, PersistentObject.InitialInstance
 
Field Summary
static java.lang.String ATT_AUTHORIZE
           
static java.lang.String ATT_FIXED
           
static java.lang.String ATT_LOCAL_SCOPE
           
static java.lang.String ATT_NAME
           
static java.lang.String code_id
           
static java.lang.String EL_ACCESS_LIST
           
static java.lang.String EL_COMMENTS
           
static java.lang.String EL_DESCRIPTION
           
static java.lang.String EL_RUNAS
           
static java.lang.String EL_VALUE
           
 
Fields inherited from class com.waveset.object.PersistentObject
trace
 
Constructor Summary
Rule()
          Builds an empty Rule eagerly awaiting you to fill it.
Rule(org.w3c.dom.Element e)
          Builds a Rule from XML.
 
Method Summary
static AttributeCondition[] accountConfirmationRules()
           
static AttributeCondition[] accountCorrelationRules()
           
 void addArgument(Rule.Argument arg)
           
protected  void addSubclassAttributes(java.lang.StringBuffer b)
          Each concrete subclass may append to the buffer an XML representation of any fields it adds to PersistentObject (if those field values must persist).
static java.util.Map convertRuleArguments(java.util.List arglist)
          A static utility method to convert an List of argument values produced by evaluating the children of a expression into a Map of rule arguments.
 java.lang.Object eval(ExState state)
           
 java.lang.Object eval(ExState state, java.util.List args)
           
 java.lang.Object eval(ExState state, java.util.Map args)
          Evaluate the rule in a given expression environment.
 java.lang.Object eval(java.util.Map map)
          Evaluates the rule against a Map or GenericObject.
 java.lang.Object eval(WSUser user)
          Evaluates the rule against a WSUser object.
 java.lang.Object eval(WSUser user, WSUser user2)
          Evaluates the rule for a pair of users.
static AttributeCondition[] excludedResourceAccountsRules()
           
static Rule findRule(ObjectCache cache, java.lang.String name)
           
static Rule findRule(ObjectCache cache, java.lang.String name, Rule parent)
          Utility to locate a Rule by name within a cache.
 java.util.List getAccessList()
           
 java.util.Map getArgumentMap()
           
 java.util.List getArguments()
           
protected  WSAttribute getAttributeValues(java.lang.String attrName)
           
 java.lang.String getComments()
           
 java.lang.String getDescription()
           
 ExNode getExpression()
          Get the rule expression.
 Library getLibrary()
          Gets the library.
 com.sun.idm.debugger.common.Location getLocation()
           
 java.util.ArrayList getReferences()
          Return the list of references within this object.
 ObjectRef getRunAsRef()
           
 Type getType()
          Returns the associated Type object.
 java.lang.Object getValue()
          Get the fixed rule value.
 java.util.List listSummaryAttributes()
          Returns the complete list of defined attributes that this type of persistent object exposes as summary attributes (regardless of whether this particular object has a value for each).
protected  void parseSubclassAttributes(org.w3c.dom.Element e)
          Each concrete subclass should parse from the XML buffer any persisted subclass-specific fields (generally, the same ones that it writes into the buffer).
protected  void parseSubclassElements(org.w3c.dom.Element e)
          Each concrete subclass should parse from the XML buffer any persisted subclass-specific elements (generally, the same ones that it writes into the buffer).
 void setAccessList(java.util.List l)
           
 void setArguments(java.util.List args)
           
 void setComments(java.lang.String s)
           
 void setDescription(java.lang.String s)
           
 void setExpression(ExNode exp)
           
 void setLibrary(Library lib)
          Remember the Library that holds this Rule.
 void setLocation(com.sun.idm.debugger.common.Location l)
           
 void setRunAsRef(ObjectRef ref)
           
 void setTrace(boolean t)
          Control debugging trace messages.
 void setValue(java.lang.Object o)
           
static AttributeCondition[] taskScheduleRepetitionRules()
           
 void toXml(java.lang.StringBuffer b)
          This is what PersistentObject.toXml calls.
 void toXml(java.lang.StringBuffer b, int indent)
          This is what XmlObjectFactory calls.
 
Methods inherited from class com.waveset.object.PersistentObject
addCommonElements, addEndTag, addMemberObjectGroup, addMemberObjectGroup, addPersistentAttributes, addStartTag, addSubclassElements, addSummaryAttributes, addXmlHeader, attributesMatch, attributesMatch, attributesMatch, checkReference, checkReferences, clearId, cloneAs, cloneObject, compareTo, create, create, create, create, createLastModItem, createLastModItem, createLastModItemList, directObjectGroupMember, dump, dumpFile, equals, fakeId, getAttribute, getAttributeValues, getAuthReferences, getAuthType, getBasicAttributes, getBasicAttributes, getBasicAttributes, getCache, getCounterValue, getCreateDate, getCreator, getDisplayableName, getDisplayName, getElementName, getEncryptedValues, getId, getIdOrName, getInitialInstances, getLastMod, getLastModDate, getLastModifier, getLastModItemId, getLockInfo, getMemberObjectGroupRefs, getMemberObjectGroupRefsUpTo, getMemberObjectGroups, getName, getNameOrId, getProperties, getProperty, getPropertyAsString, getPropertyList, getQueryableAttributes, getReference, getRuleDrivenMemberObjectGroupRefs, getRuleDrivenMemberObjectGroupRefsUpTo, getRuleDrivenMemberObjectGroups, getSubtype, getSummaryAttributes, getSummaryString, hasEncryptedData, hashCode, identityEquals, isAlias, isHidden, isId, isProtected, isProtectedFromDelete, isReferencedIn, listOperationalAttributes, listQueryableAttributes, listQueryableReferenceAttributes, objectGroupMember, objectGroupMemberRef, parseCommonElement, parseCommonElements, parsePersistentAttributes, parseXml, parseXml, prepareForSerialization, prepareToSerialize, println, reEncrypt, reEncryptSubclassAttributes, removeMemberObjectGroup, removeProperty, resolve, resolve, resolve, resolveArray, resolveArrayByFetching, resolveObjectReference, resolveObjectReferences, resolveReference, resolveSummaryAttributes, resolveSummaryAttributes, ruleDrivenObjectGroupMemberRef, setAuthType, setAuthType, setCache, setCreateDate, setCreator, setDisplayName, setDisplayName, setHidden, setIsAlias, setLastMod, setLastMod, setLastModDate, setLastModifier, setMemberObjectGroupRef, setMemberObjectGroupRefs, setMemberObjectGroups, setName, setProperties, setProperty, setPropertyList, setProtected, setProtectedFromDelete, setRuleDrivenMembersCache, setSubtype, toString, toXml, toXmlFile, visit
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.waveset.object.Library.Member
getName
 

Field Detail

code_id

public static final java.lang.String code_id
See Also:
Constant Field Values

ATT_NAME

public static final java.lang.String ATT_NAME
See Also:
Constant Field Values

ATT_FIXED

public static final java.lang.String ATT_FIXED
See Also:
Constant Field Values

ATT_LOCAL_SCOPE

public static final java.lang.String ATT_LOCAL_SCOPE
See Also:
Constant Field Values

ATT_AUTHORIZE

public static final java.lang.String ATT_AUTHORIZE
See Also:
Constant Field Values

EL_DESCRIPTION

public static final java.lang.String EL_DESCRIPTION
See Also:
Constant Field Values

EL_ACCESS_LIST

public static final java.lang.String EL_ACCESS_LIST
See Also:
Constant Field Values

EL_COMMENTS

public static final java.lang.String EL_COMMENTS
See Also:
Constant Field Values

EL_VALUE

public static final java.lang.String EL_VALUE
See Also:
Constant Field Values

EL_RUNAS

public static final java.lang.String EL_RUNAS
See Also:
Constant Field Values
Constructor Detail

Rule

public Rule()
Builds an empty Rule eagerly awaiting you to fill it.


Rule

public Rule(org.w3c.dom.Element e)
     throws WavesetException
Builds a Rule from XML.

Method Detail

setExpression

public void setExpression(ExNode exp)

setValue

public void setValue(java.lang.Object o)

setDescription

public void setDescription(java.lang.String s)

setComments

public void setComments(java.lang.String s)

setArguments

public void setArguments(java.util.List args)

addArgument

public void addArgument(Rule.Argument arg)

getAccessList

public java.util.List getAccessList()

setAccessList

public void setAccessList(java.util.List l)

setTrace

public void setTrace(boolean t)
Control debugging trace messages.

Overrides:
setTrace in class PersistentObject

getRunAsRef

public ObjectRef getRunAsRef()

setRunAsRef

public void setRunAsRef(ObjectRef ref)

setLocation

public void setLocation(com.sun.idm.debugger.common.Location l)
Specified by:
setLocation in interface com.sun.idm.debugger.common.Locatable

getLocation

public com.sun.idm.debugger.common.Location getLocation()
Specified by:
getLocation in interface com.sun.idm.debugger.common.Locatable

setLibrary

public void setLibrary(Library lib)
Remember the Library that holds this Rule.

Specified by:
setLibrary in interface Library.Member

getLibrary

public Library getLibrary()
Description copied from interface: Library.Member
Gets the library.

Specified by:
getLibrary in interface Library.Member

findRule

public static Rule findRule(ObjectCache cache,
                            java.lang.String name,
                            Rule parent)
                     throws WavesetException
Utility to locate a Rule by name within a cache. Fail silently.

Throws:
WavesetException

findRule

public static Rule findRule(ObjectCache cache,
                            java.lang.String name)
                     throws WavesetException
Throws:
WavesetException

accountCorrelationRules

public static AttributeCondition[] accountCorrelationRules()
Returns:
attribute conditions to select account correlation rules.

accountConfirmationRules

public static AttributeCondition[] accountConfirmationRules()
Returns:
attribute conditions to select account confirmation rules.

excludedResourceAccountsRules

public static AttributeCondition[] excludedResourceAccountsRules()
Returns:
attribute conditions to select account correlation rules.

taskScheduleRepetitionRules

public static AttributeCondition[] taskScheduleRepetitionRules()
Returns:
attribute conditions to select rules that use useable in TaskSchedules.

getType

public Type getType()
Returns the associated Type object.

Specified by:
getType in class PersistentObject

getReferences

public java.util.ArrayList getReferences()
Return the list of references within this object. // Note that we do not include the runAs user in this list, // it must be checked in non-standard way since a user // is allowed to specify themselves, but they typically // to not control themselves.

Overrides:
getReferences in class PersistentObject

getExpression

public ExNode getExpression()
Get the rule expression.


getValue

public java.lang.Object getValue()
Get the fixed rule value.


getDescription

public java.lang.String getDescription()

getComments

public java.lang.String getComments()

getArguments

public java.util.List getArguments()

getArgumentMap

public java.util.Map getArgumentMap()

convertRuleArguments

public static java.util.Map convertRuleArguments(java.util.List arglist)
A static utility method to convert an List of argument values produced by evaluating the children of a expression into a Map of rule arguments. This is for temporary backward compatibility for calling rules with . You should now be using . Rules require keyword arguments, but only supports positional arguments. So we assume that when is used to call rules, that the argument list contains String/Object pairs that are converted to a Map. In addition if a Map is encountered where a name is expected it is assumed to be a preformatted argument map and is assimilated.


eval

public java.lang.Object eval(ExState state,
                             java.util.Map args)
                      throws WavesetException
Evaluate the rule in a given expression environment. This is the one that will normally be used, so the ExState can be reused across evaluations, and prerform more complex reference and function resolution. If this rule defines arguments, we push ourselves as a "resolver" object into the ExState so we can handle references to the arguments. UPDATE: Allowing an additional Map of argument values which may override locally declared arguments.

Throws:
WavesetException

eval

public java.lang.Object eval(ExState state)
                      throws WavesetException
Throws:
WavesetException

eval

public java.lang.Object eval(ExState state,
                             java.util.List args)
                      throws WavesetException
Throws:
WavesetException

eval

public java.lang.Object eval(java.util.Map map)
                      throws WavesetException
Evaluates the rule against a Map or GenericObject. Manufacture our own embedded RuleState to perform reference resolution.

Throws:
WavesetException

eval

public java.lang.Object eval(WSUser user)
                      throws WavesetException
Evaluates the rule against a WSUser object. Used only by the bulk loader for role and group rules. The things you can reference are the attributes defined in this user, plus a few special names defined by RuleState. This is pretty close to the WSUser.toHashMap namespace, but not at all like the user view.

Throws:
WavesetException

eval

public java.lang.Object eval(WSUser user,
                             WSUser user2)
                      throws WavesetException
Evaluates the rule for a pair of users.

Throws:
WavesetException

toXml

public void toXml(java.lang.StringBuffer b)
This is what PersistentObject.toXml calls.

Overrides:
toXml in class PersistentObject

toXml

public void toXml(java.lang.StringBuffer b,
                  int indent)
This is what XmlObjectFactory calls. If _library is non-null, we avoid irrelevant PersistentObject data.

Specified by:
toXml in interface XmlObject
Overrides:
toXml in class PersistentObject

addSubclassAttributes

protected void addSubclassAttributes(java.lang.StringBuffer b)
Description copied from class: PersistentObject
Each concrete subclass may append to the buffer an XML representation of any fields it adds to PersistentObject (if those field values must persist). PersistentObject's default implementation is a no-op.

NOTE: Any subclass that overrides this method must similarly override parseSubclassAttributes() so that the subclass attributes are restored.

Overrides:
addSubclassAttributes in class PersistentObject
See Also:


parseSubclassAttributes

protected void parseSubclassAttributes(org.w3c.dom.Element e)
                                throws WavesetException
Description copied from class: PersistentObject
Each concrete subclass should parse from the XML buffer any persisted subclass-specific fields (generally, the same ones that it writes into the buffer).

Overrides:
parseSubclassAttributes in class PersistentObject
Throws:
WavesetException
See Also:

PersistentObject's default implementation is a no-op.

, PersistentObject.parseXml(Element)

parseSubclassElements

protected void parseSubclassElements(org.w3c.dom.Element e)
                              throws WavesetException
Description copied from class: PersistentObject
Each concrete subclass should parse from the XML buffer any persisted subclass-specific elements (generally, the same ones that it writes into the buffer).

Overrides:
parseSubclassElements in class PersistentObject
Throws:
WavesetException
See Also:

PersistentObject's default implementation is a no-op.

, PersistentObject.parseXml(Element)

listSummaryAttributes

public java.util.List listSummaryAttributes()
Description copied from class: PersistentObject
Returns the complete list of defined attributes that this type of persistent object exposes as summary attributes (regardless of whether this particular object has a value for each).

Any subclass of PersistentObject that overrides this method should first invoke super.listSummaryAttributes() to ensure that the subclass includes summary attributes that are common to all PersistentObjects.

Any subclass that overrides this implementation must also consider the length of the summary string that will be generated from these attributes.

Overrides:
listSummaryAttributes in class PersistentObject
Returns:
the complete list of defined attributes that this type of PersistentObject exposes as summary attributes (regardless of whether this object has a value for each).

Any subclass of PersistentObject that overrides this method should first invoke super.getSummaryAttributes() to ensure that the subclass includes summary attributes that are common to all PersistentObjects.

See Also:
Constants.MAX_SUMMARY_STRING_LENGTH, PersistentObject.getSummaryString()

getAttributeValues

protected WSAttribute getAttributeValues(java.lang.String attrName)
Overrides:
getAttributeValues in class PersistentObject
Parameters:
attrName - - the (name of the) attribute for which to return values.
Returns:
a WSAttribute that represents the value (or values) that this object contains for the specified attribute.