com.ail.insurance.policy
Class AssessmentSheet

java.lang.Object
  extended by com.ail.core.Type
      extended by com.ail.insurance.policy.AssessmentSheet
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable

public class AssessmentSheet
extends Type

Groups together a collection of assessment lines and provides utility methods for manipulating them.

Version:
$Revision: 1.11 $
See Also:
Serialized Form

Field Summary
 
Fields inherited from class com.ail.core.Type
jXPathContext, NOT_PERSISTED
 
Constructor Summary
AssessmentSheet()
          Default constructor
 
Method Summary
 void addAssessmentNote(java.lang.String reason, Reference relatesTo)
          Add an assessment note to this sheet.
 void addAssessmentNote(java.lang.String id, java.lang.String reason, Reference relatesTo)
          Add an assessment note to this sheet.
 void addDecline(java.lang.String reason, Reference relatesTo)
          Same as addDecline, but automatically generates a line id
 void addDecline(java.lang.String id, java.lang.String reason, Reference relatesTo)
          Add a decline line to this sheet.
 void addDiscount(java.lang.String reason, Reference relatesTo, java.lang.String contributesTo, java.lang.String dependsOn, Rate rate)
          Same as addDiscount, but generates the line id automatically.
 void addDiscount(java.lang.String reason, Reference relatesTo, java.lang.String contributesTo, java.lang.String dependsOn, Rate rate, int priority)
          Same as addDiscount, but generates the line id automatically.
 void addDiscount(java.lang.String id, java.lang.String reason, Reference relatesTo, java.lang.String contributesTo, java.lang.String dependsOn, Rate rate)
          Add a rate based dicount entry to the sheet.
 void addFixedSum(java.lang.String reason, Reference relatesTo, java.lang.String contributesTo, CurrencyAmount amount)
          Same as addFixedSum, but generates a line id automatically.
 void addFixedSum(java.lang.String reason, Reference relatesTo, java.lang.String contributesTo, CurrencyAmount amount, int priority)
          Same as addFixedSum, but generates a line id automatically.
 void addFixedSum(java.lang.String id, java.lang.String reason, Reference relatesTo, java.lang.String contributesTo, CurrencyAmount amount)
          Add a fixed sum line to this sheet.
 void addFixedSum(java.lang.String id, java.lang.String reason, Reference relatesTo, java.lang.String contributesTo, CurrencyAmount amount, int priority)
          Add a fixed sum line to this sheet.
 void addLine(AssessmentLine line)
          Add a line to the collection associated with this object.
 void addLoading(java.lang.String reason, Reference relatesTo, java.lang.String contributesTo, java.lang.String dependsOn, Rate rate)
          Add a loading with a generated lineId, and the specified arguments.
 void addLoading(java.lang.String reason, Reference relatesTo, java.lang.String contributesTo, java.lang.String dependsOn, Rate rate, int priority)
          Add a loading with a generated lineId, and the specified arguments.
 void addLoading(java.lang.String id, java.lang.String reason, Reference relatesTo, java.lang.String contributesTo, java.lang.String dependsOn, Rate rate)
          Add a rate based loading entry to the sheet.
 void addReferral(java.lang.String reason, Reference relatesTo)
          Same as addReferral, but automatically generates the line id.
 void addReferral(java.lang.String id, java.lang.String reason, Reference relatesTo)
          Add a referral line to this sheet.
 void clearLockingActor()
          Unlock the assessment sheet - set locking actor to null.
 java.lang.Object clone()
          Clone this object.
 void disableLine(AssessmentLine line)
          Disable the specified line.
 void disableLine(java.lang.String id)
          Disable the specified line.
 void enableLine(AssessmentLine line)
          Enable the specified line.
 void enableLine(java.lang.String id)
          Enable the specified line.
 AssessmentLine findLineById(java.lang.String id)
          Fetch a named entry from the sheet.
 MarkerResolution findResolutionByMarkerId(java.lang.String id)
          Find and return the resolution for a marker.
 int generateAutoPriority()
          Return the next auto priority.
 java.lang.String generateLineId()
          Generate a unique lineId.
 java.util.Map<java.lang.String,AssessmentLine> getAssessmentLine()
          Get a list of the assessment lines associated with this sheet as a Map keyed on the line IDs.
 java.util.Map<java.lang.String,AssessmentLine> getAssessmentList()
          Deprecated. use getAssessmentLine() instead.
 int getAutoPriority()
          When lines are added to the assessment sheet the caller may or may not give them a specific priority (which is used to order the lines during processing).
 java.util.Collection<AssessmentLine> getDisabledLine()
          Fetch a collection of the disabled line objects associated with this instance.
 int getDisabledLineCount()
          Fetch a count of the number of disabled line objects associated with this instance.
 java.util.Collection<AssessmentLine> getEnabledLine()
          Fetch a collection of all the line objects associated with this instance.
 int getEnabledLineCount()
          Fetch a count of the number of line objects associated with this instance.
 java.util.Collection<AssessmentLine> getLine()
          Fetch the collection of line objects associated with this instance.
 int getLineCount()
          Fetch a count of the number of line objects associated with this instance.
<T> java.util.Hashtable<java.lang.String,T>
getLinesOfType(java.lang.Class<T> clazz)
          Get a hashtable of all the lines in the sheet of a specific type.
 java.lang.String getLockingActor()
          Getter returning the value of the lockingActor property.
 boolean isMarkedForDecline()
          Determine if the sheet is marked for decline or not.
 boolean isMarkedForRefer()
          Determine if the sheet is marked for referral or not.
 boolean isMarkedForSubjectivity()
          Determine if the sheet includes an unresolved subjectivity.
 void removeLine(AssessmentLine line)
          Remove a specific instance of AssessmentLine from the collection associated with this object.
 void removeLinesByOrigin(java.lang.String origin)
          Remove the lines "owned" (or created) by an actor.
 void setAssessmentLine(java.util.Map<java.lang.String,AssessmentLine> assessmentLine)
          Set the lines associated with this sheet to the values defined in a Map.
 void setAssessmentList(java.util.Map<java.lang.String,AssessmentLine> assessmentLine)
          Deprecated. use setAssessmentLine(Map) instead.
 void setAutoPriority(int autoPriority)
           
 void setLine(java.util.Collection<AssessmentLine> line)
          Set the collection of AssessmentLines associated with this sheet.
 void setLockingActor(java.lang.String lockingActor)
          Setter to update the value of the lockingActor property.
 
Methods inherited from class com.ail.core.Type
addAttribute, deleteLock, deleteSerialVersion, fetchJXPathContext, getAttribute, getAttribute, getAttributeCount, getForeignSystemId, getLock, getSerialVersion, getSystemId, hasLock, hasSerialVersion, hasSystemId, isPersisted, markAsNotPersisted, mergeWithDataFrom, removeAttribute, removeAttribute, setAttribute, setForeignSystemId, setLock, setSerialVersion, setSystemId, xpathGet, xpathGet, xpathIterate, xpathSet
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AssessmentSheet

public AssessmentSheet()
Default constructor

Method Detail

getLinesOfType

public <T> java.util.Hashtable<java.lang.String,T> getLinesOfType(java.lang.Class<T> clazz)
Get a hashtable of all the lines in the sheet of a specific type.

Parameters:
clazz - The type to search for.
Returns:
Hashtable of lines keyed on Id, this may be an empty table.

getLine

public java.util.Collection<AssessmentLine> getLine()
Fetch the collection of line objects associated with this instance. The Collection returned includes disabled lines. Use getEnabledLine to fetch only those that are enabled.

Returns:
A collection of instances of AssessmentLine.

getAssessmentList

public java.util.Map<java.lang.String,AssessmentLine> getAssessmentList()
Deprecated. use getAssessmentLine() instead.

Returns:

setAssessmentList

public void setAssessmentList(java.util.Map<java.lang.String,AssessmentLine> assessmentLine)
Deprecated. use setAssessmentLine(Map) instead.

Parameters:
assessmentLine -

getAssessmentLine

public java.util.Map<java.lang.String,AssessmentLine> getAssessmentLine()
Get a list of the assessment lines associated with this sheet as a Map keyed on the line IDs.

Returns:
Lines associated with this sheet.

setAssessmentLine

public void setAssessmentLine(java.util.Map<java.lang.String,AssessmentLine> assessmentLine)
Set the lines associated with this sheet to the values defined in a Map.

Parameters:
assessmentLine - New values.

getEnabledLine

public java.util.Collection<AssessmentLine> getEnabledLine()
Fetch a collection of all the line objects associated with this instance. The Collection returned excludes disabled lines. Use getLine to fetch all line.

Returns:
A collection of instances of AssessmentLine. The list may be empty, but it will never be null.

getDisabledLine

public java.util.Collection<AssessmentLine> getDisabledLine()
Fetch a collection of the disabled line objects associated with this instance.

Returns:
A collection of instances of AssessmentLine. The list may be empty, but it will never be null.

setLine

public void setLine(java.util.Collection<AssessmentLine> line)
Set the collection of AssessmentLines associated with this sheet.

Parameters:
line - Collection of AssessmentLines.

getLineCount

public int getLineCount()
Fetch a count of the number of line objects associated with this instance.

Returns:
Count of line objects. The count includes disabled lines, use getEnabledLineCount to get a count of the enabled lines only.

getEnabledLineCount

public int getEnabledLineCount()
Fetch a count of the number of line objects associated with this instance. The count excludes disabled lines, use getLineCount to get a count of all lines.

Returns:
Count of line objects.

getDisabledLineCount

public int getDisabledLineCount()
Fetch a count of the number of disabled line objects associated with this instance.

Returns:
Count of line objects.

addLine

public void addLine(AssessmentLine line)
Add a line to the collection associated with this object. If the line being added has an origin (creating actor) of null, then this sheet must be locked to an actor (lockingActor) and that actor will be used as the origin.

Parameters:
line - Instance of AssessmentLine to add.
Throws:
java.lang.IllegalStateException - If line.origin is null and this sheet is not locked to an actor.
DuplicateAssessmentLineError - If a line with the same id as line is already in the sheet

removeLine

public void removeLine(AssessmentLine line)
Remove a specific instance of AssessmentLine from the collection associated with this object.

Parameters:
line - Object to be removed from the collection.

disableLine

public void disableLine(java.lang.String id)
Disable the specified line. If the line is already disabled this has no effect.

Parameters:
id - The id of the line to disable.
Throws:
java.lang.IllegalStateException - If the specified line does not exist.

disableLine

public void disableLine(AssessmentLine line)
Disable the specified line. If the line is already disabled this has no effect.

Parameters:
line - The line to disable.

enableLine

public void enableLine(java.lang.String id)
Enable the specified line. If the line is already enabled this has no effect.

Parameters:
id - The id of the line to enabled.
Throws:
java.lang.IllegalStateException - If the specified line does not exist.

enableLine

public void enableLine(AssessmentLine line)
Enable the specified line. If the line is already enabled this has no effect.

Parameters:
line - The line to enable.

removeLinesByOrigin

public void removeLinesByOrigin(java.lang.String origin)
Remove the lines "owned" (or created) by an actor. Each assessment line has an origin(ating) actor - the name of the actor who created the line. That actor may remove the lines later using this method. Lines will be removed even if they are disabled.

Parameters:
origin - Name of the origin to remove lines for

findLineById

public AssessmentLine findLineById(java.lang.String id)
Fetch a named entry from the sheet. This method will not return disabled lines.

Parameters:
id - The id of the entry to return
Returns:
Instance of line for id, or null if id is not known.

findResolutionByMarkerId

public MarkerResolution findResolutionByMarkerId(java.lang.String id)
Find and return the resolution for a marker. Disabled lines are ignored by this method.

Parameters:
id - Marker's id
Returns:
resolution, or null if the marker is not resolved.

isMarkedForDecline

public boolean isMarkedForDecline()
Determine if the sheet is marked for decline or not. The sheet is marked for decline if any Markers of type decline are found, and are not resolved. Disabled lines are ignored by this method.

Returns:
true if the sheet is marked for decline, false otherwise.

isMarkedForRefer

public boolean isMarkedForRefer()
Determine if the sheet is marked for referral or not. The sheet is marked for referral if any Markers of type refer are found, and are not resolved. Disabled lines are ignored by this method.

Returns:
true if the sheet is marked for referral, false otherwise.

isMarkedForSubjectivity

public boolean isMarkedForSubjectivity()
Determine if the sheet includes an unresolved subjectivity. The sheet is marked for subjectivity if any Markers of type subjectivity are found, that are not resolved. Disabled lines are ignored by this method.

Returns:
true if the sheet is marked for decline, false otherwise.

generateLineId

public java.lang.String generateLineId()
Generate a unique lineId. Each line in an assessment sheet must have a unique id - lines refer to each other using this id. This method makes up a random id, checks that it is not in use and returns it.

Returns:
unique (unused) line id

generateAutoPriority

public int generateAutoPriority()
Return the next auto priority. This method of line priorotizaion orders lines in the sheet by the order they were added to the sheet.

Returns:
next priority;

addLoading

public void addLoading(java.lang.String id,
                       java.lang.String reason,
                       Reference relatesTo,
                       java.lang.String contributesTo,
                       java.lang.String dependsOn,
                       Rate rate)
Add a rate based loading entry to the sheet. This helper method simply creates a RateBehaviour instance with the arguments supplied and adds that instance to the sheet as a new line.

The suggested rule syntax is:

 Load by {rate} of {dependsOn} to {contributesTo} because {reason}. This relates to {relatesTo}. Use id {id}.
 
Note: Lines added using this methods are automatically assigned a priority based on the order they are added.

Parameters:
id - The Id to use for this line
reason - Free text reson for this behaviour being created.
relatesTo - Optional reference to the part of the policy that caused this behaviour.
contributesTo - The Id of the line that this one cntributes to.
dependsOn - The Id of the line that this on is derived from.
rate - The rate to be used in the calculation.

addLoading

public void addLoading(java.lang.String reason,
                       Reference relatesTo,
                       java.lang.String contributesTo,
                       java.lang.String dependsOn,
                       Rate rate)
Add a loading with a generated lineId, and the specified arguments.
Note: Lines added using this methods are automatically assigned a priority based on the order they are added.

Parameters:
reason - Free text reson for this behaviour being created.
relatesTo - Optional reference to the part of the policy that caused this behaviour.
contributesTo - The Id of the line that this one cntributes to.
dependsOn - The Id of the line that this on is derived from.
rate - The rate to be used in the calculation.

addLoading

public void addLoading(java.lang.String reason,
                       Reference relatesTo,
                       java.lang.String contributesTo,
                       java.lang.String dependsOn,
                       Rate rate,
                       int priority)
Add a loading with a generated lineId, and the specified arguments.

Parameters:
reason - Free text reson for this behaviour being created.
relatesTo - Optional reference to the part of the policy that caused this behaviour.
contributesTo - The Id of the line that this one cntributes to.
dependsOn - The Id of the line that this on is derived from.
rate - The rate to be used in the calculation.
priority - The priority of this line wrt other lines in this sheet (low value=low priority)

addDiscount

public void addDiscount(java.lang.String id,
                        java.lang.String reason,
                        Reference relatesTo,
                        java.lang.String contributesTo,
                        java.lang.String dependsOn,
                        Rate rate)
Add a rate based dicount entry to the sheet. This helper method simply creates a RateBehaviour instance with the arguments supplied and adds that instance to the sheet as a new line.
Note: Lines added using this methods are automatically assigned a priority based on the order they are added.

Parameters:
id - The Id to use for this line
reason - Free text reson for this discount being created.
relatesTo - Optional reference to the part of the policy that caused this discount.
contributesTo - The Id of the line that this one contributes to.
dependsOn - The Id of the line that this on is derived from.
rate - The rate to be used in the calculation.

addDiscount

public void addDiscount(java.lang.String reason,
                        Reference relatesTo,
                        java.lang.String contributesTo,
                        java.lang.String dependsOn,
                        Rate rate)
Same as addDiscount, but generates the line id automatically.
Note: Lines added using this methods are automatically assigned a priority based on the order they are added.

Parameters:
reason - Free text reson for this discount being created.
relatesTo - Optional reference to the part of the policy that caused this discount.
contributesTo - The Id of the line that this one contributes to.
dependsOn - The Id of the line that this on is derived from.
rate - The rate to be used in the calculation.
See Also:
addDiscount(java.lang.String, java.lang.String, com.ail.insurance.policy.Reference, java.lang.String, java.lang.String, com.ail.util.Rate)

addDiscount

public void addDiscount(java.lang.String reason,
                        Reference relatesTo,
                        java.lang.String contributesTo,
                        java.lang.String dependsOn,
                        Rate rate,
                        int priority)
Same as addDiscount, but generates the line id automatically.

Parameters:
reason - Free text reson for this discount being created.
relatesTo - Optional reference to the part of the policy that caused this discount.
contributesTo - The Id of the line that this one contributes to.
dependsOn - The Id of the line that this on is derived from.
rate - The rate to be used in the calculation.
priority - The priority of this line wrt other lines in this sheet (low value=low priority)
See Also:
addDiscount(java.lang.String, java.lang.String, com.ail.insurance.policy.Reference, java.lang.String, java.lang.String, com.ail.util.Rate)

addReferral

public void addReferral(java.lang.String id,
                        java.lang.String reason,
                        Reference relatesTo)
Add a referral line to this sheet. This helper method simply creates a Marker instance with the arguments supplied and adds it to the sheet as a new line.

Parameters:
id - The Id to use for this line
reason - Free text reson for this referral being created.
relatesTo - Optional reference to the part of the policy that caused referral.

addReferral

public void addReferral(java.lang.String reason,
                        Reference relatesTo)
Same as addReferral, but automatically generates the line id.

Parameters:
reason - Free text reson for this referral being created.
relatesTo - Optional reference to the part of the policy that caused referral.
See Also:
addReferral(java.lang.String, java.lang.String, com.ail.insurance.policy.Reference)

addDecline

public void addDecline(java.lang.String id,
                       java.lang.String reason,
                       Reference relatesTo)
Add a decline line to this sheet. This helper method simply creates a Marker instance with the arguments supplied and adds it to the sheet as a new line.

Parameters:
id - The Id to use for this line
reason - Free text reson for this decline being created.
relatesTo - Optional reference to the part of the policy that caused decline line.

addDecline

public void addDecline(java.lang.String reason,
                       Reference relatesTo)
Same as addDecline, but automatically generates a line id

Parameters:
reason - Free text reson for this decline being created.
relatesTo - Optional reference to the part of the policy that caused decline line.
See Also:
addDecline(java.lang.String, java.lang.String, com.ail.insurance.policy.Reference)

addFixedSum

public void addFixedSum(java.lang.String id,
                        java.lang.String reason,
                        Reference relatesTo,
                        java.lang.String contributesTo,
                        CurrencyAmount amount)
Add a fixed sum line to this sheet. This helper method simply creates a FixedSum instance using the arguments supplied and adds it to the sheet as a new line.
Note: Lines added using this methods are automatically assigned a priority based on the order they are added.

Parameters:
id - This line's Id
reason - Free text reson for this behaviour being created.
relatesTo - Optional reference to the part of the policy that caused this behaviour.
contributesTo - The Id of the line that this one will contribute to.
amount - The amount to be contributed.

addFixedSum

public void addFixedSum(java.lang.String id,
                        java.lang.String reason,
                        Reference relatesTo,
                        java.lang.String contributesTo,
                        CurrencyAmount amount,
                        int priority)
Add a fixed sum line to this sheet. This helper method simply creates a FixedSum instance using the arguments supplied and adds it to the sheet as a new line.

Parameters:
id - This line's Id
reason - Free text reson for this behaviour being created.
relatesTo - Optional reference to the part of the policy that caused this behaviour.
contributesTo - The Id of the line that this one will contribute to.
amount - The amount to be contributed.#
priority - The priority of this line wrt other lines in this sheet (low value=low priority)

addFixedSum

public void addFixedSum(java.lang.String reason,
                        Reference relatesTo,
                        java.lang.String contributesTo,
                        CurrencyAmount amount)
Same as addFixedSum, but generates a line id automatically.
Note: Lines added using this methods are automatically assigned a priority based on the order they are added.

Parameters:
reason - Free text reson for this behaviour being created.
relatesTo - Optional reference to the part of the policy that caused this behaviour.
contributesTo - The Id of the line that this one will contribute to.
amount - The amount to be contributed.
See Also:
addFixedSum(java.lang.String, java.lang.String, com.ail.insurance.policy.Reference, java.lang.String, com.ail.financial.CurrencyAmount)

addFixedSum

public void addFixedSum(java.lang.String reason,
                        Reference relatesTo,
                        java.lang.String contributesTo,
                        CurrencyAmount amount,
                        int priority)
Same as addFixedSum, but generates a line id automatically.

Parameters:
reason - Free text reson for this behaviour being created.
relatesTo - Optional reference to the part of the policy that caused this behaviour.
contributesTo - The Id of the line that this one will contribute to.
amount - The amount to be contributed.
priority - The priority of this line wrt other lines in this sheet (low value=low priority)
See Also:
addFixedSum(java.lang.String, java.lang.String, com.ail.insurance.policy.Reference, java.lang.String, com.ail.financial.CurrencyAmount)

addAssessmentNote

public void addAssessmentNote(java.lang.String reason,
                              Reference relatesTo)
Add an assessment note to this sheet. This helper method simply creates a AssessmentNote to the sheet using the reason and releatesTo values passed in. The line's ID is automatically generated.

Parameters:
reason - Free text of note.
relatesTo - Optional reference to the part of the policy that the note related to (may be null).
See Also:
addAssessmentNote(java.lang.String, com.ail.insurance.policy.Reference)

addAssessmentNote

public void addAssessmentNote(java.lang.String id,
                              java.lang.String reason,
                              Reference relatesTo)
Add an assessment note to this sheet. This helper method simply creates a AssessmentNote to the sheet using the reason and releatesTo values passed in. The line's ID is automatically generated.

Parameters:
id - The Id to use for this line
reason - Free text of note.
relatesTo - Optional reference to the part of the policy that the note related to (may be null).
See Also:
addAssessmentNote(java.lang.String, com.ail.insurance.policy.Reference)

getLockingActor

public java.lang.String getLockingActor()
Getter returning the value of the lockingActor property. An assessment sheet must be locked to an actor before entries can be made. This allows the sheet to know who is making entries and to associate the entries with that actor.

Returns:
Value of the lockingActor property

setLockingActor

public void setLockingActor(java.lang.String lockingActor)
Setter to update the value of the lockingActor property. An assessment sheet must be locked to an actor before entries can be made. This allows the sheet to know who is making entries and to associate the entries with that actor.

Parameters:
lockingActor - New value for the lockingActor property
Throws:
java.lang.IllegalStateException - If the sheet is already locked by another actor

clearLockingActor

public void clearLockingActor()
Unlock the assessment sheet - set locking actor to null.


clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Description copied from class: Type
Clone this object. This clone method is used by all Type subclasses to handle deep cloning. For the factory to operate correctly it is essential that Types can be deep cloned, as it hangs onto prototyped instances by name and simply clones them when a request is made for an instance of a named type.

Overrides:
clone in class Type
Throws:
java.lang.CloneNotSupportedException - If the type cannot be deep cloned.

getAutoPriority

public int getAutoPriority()
When lines are added to the assessment sheet the caller may or may not give them a specific priority (which is used to order the lines during processing). If the caller does not specify a priority, the current value of autoPriority is used for the added line. The autoPriority property is incremented each time it is used, thus meaning that lines have a priority defined by the order in which they are added to the sheet.

Returns:
the autoPriority

setAutoPriority

public void setAutoPriority(int autoPriority)
Parameters:
autoPriority - the autoPriority to set
See Also:
getAutoPriority()