ERDDelayedNonNullConditionalAssignment Class Reference

Inherits er::directtoweb::assignments::delayed::ERDDelayedAssignment.

Collaboration diagram for ERDDelayedNonNullConditionalAssignment:

Collaboration graph
[legend]

List of all members.

Public Member Functions

NSArray dependentKeys (String keyPath)
 ERDDelayedNonNullConditionalAssignment (String key, Object value)
 ERDDelayedNonNullConditionalAssignment (EOKeyValueUnarchiver u)
Object fireNow (D2WContext c)

Static Public Member Functions

static Object decodeWithKeyValueUnarchiver (EOKeyValueUnarchiver eokeyvalueunarchiver)

Static Public Attributes

static final Logger log = Logger.getLogger("er.directtoweb.rules.DelayedNonNullConditionalAssigment")


Detailed Description

The delayed non-null conditional is a way to provide a branching result from a rule resolution. The value of this assignment must be a dictionary that has the following keys:

nonNullKeyPath key path to be tested for nullality off of the current D2W context. trueValue value to be returned if the key path is not null. falseValue value to be returned if the key path is null.

Because this assignment is a delayed assignment the above condition will be evaluated everytime that the D2W fired rule cache resolves to a rule of this class.
Example usage. Let's imagine that a User has a relationship called toOwnedHouse this relationship is only set if the User is a home owner. Now let's imagine that we have a page configuration for displaying information about a User. One of the propertyKeys for this page configuration is 'residence' which is not an attribute or relationship off of the User object. Imagine that we have already built a custom component for displaying the address of either an owned house or a rented house for a given User. However we want the displayed name to be either "Rented House" or "Owned House" depending on if the User is a home owner. The usual approach would be to create two page configurations and set the displayNameForProperty to be different for each of these page configurations. However by using a DelayedNonNullConditionalAssignment we will only have to use a single page configuration. Using this rule:

pageConfguration = 'InspectUser' AND propertyKey = 'residence' => displayNameForProperty = { nonNullKeyPath = "object.toOwnedHouse"; trueValue = "Owned House"; falseValue = "Rented House"; }


Constructor & Destructor Documentation

ERDDelayedNonNullConditionalAssignment ( EOKeyValueUnarchiver  u  ) 

Public constructor

Parameters:
u key-value unarchiver used when unarchiving from rule files.

ERDDelayedNonNullConditionalAssignment ( String  key,
Object  value 
)

Public constructor

Parameters:
key context key
value of the assignment


Member Function Documentation

static Object decodeWithKeyValueUnarchiver ( EOKeyValueUnarchiver  eokeyvalueunarchiver  )  [static]

Static constructor required by the EOKeyValueUnarchiver interface. If this isn't implemented then the default behavior is to construct the first super class that does implement this method. Very lame.

Parameters:
eokeyvalueunarchiver to be unarchived
Returns:
decoded assignment of this class

NSArray dependentKeys ( String  keyPath  ) 

Implementation of the ERDComputingAssignmentInterface. This assignment depends upon an array composed of the single value "nonNullKeyPath" from the dictionary of the value of this assignment. This array of keys is used when constructing the significant keys for the passed in keyPath.

Parameters:
keyPath to compute significant keys for.
Returns:
array of context keys this assignment depends upon.

Object fireNow ( D2WContext  c  )  [virtual]

Implementation of the abstract method from ERDDelayedAssignment. This method is called each time this Assignment is resolved from the rule firing cache. For the non-null conditional the dictionary key 'nonNullKeyPath' is checked against the current context. If the key path is indeed non-null then the object returned by the dictionarykey 'trueValue' will be returned otherwise the object returned by the dictionarykey 'falseValue' will be returned.

Parameters:
c current D2W context
Returns:
Either the 'trueValeue' or 'falseValue' depending on if the key path is non-null or null.

Implements ERDDelayedAssignment.


Member Data Documentation

final Logger log = Logger.getLogger("er.directtoweb.rules.DelayedNonNullConditionalAssigment") [static]

logging support


The documentation for this class was generated from the following file:

Generated on Sat May 26 06:42:50 2012 for Project Wonder by  doxygen 1.5.8