Class BaseVoidHandler

  extended by org.openmrs.api.handler.BaseVoidHandler
All Implemented Interfaces:
RequiredDataHandler<Voidable>, VoidHandler<Voidable>

public class BaseVoidHandler
extends java.lang.Object
implements VoidHandler<Voidable>

This is the super interface for all void* actions that take place on all services. The RequiredDataAdvice class uses AOP around each method in every service to check to see if its a void* method. If it is a void* method, this class is called to handle setting the Voidable.isVoided(), Voidable.setVoidReason(String), Voidable#setVoiddBy(User), and Voidable#setDateVoidd(Date).

Child collections on this Voidable that are themselves a Voidable are looped over and also voided by the RequiredDataAdvice class.

This class will only set the voidedBy and dateVoided attributes if voided is set to false. If voided is set to true it is assumed that this object is in a list of things that is getting voided but that it itself was previously voided. The workaround to this is that if the voided bit is true OR the voidedBy is null, the voidedBy, dateVoided, and voidReason will be set.

See Also:
RequiredDataAdvice, UnvoidHandler

Constructor Summary
Method Summary
 void handle(Voidable voidableObject, User voidingUser, java.util.Date voidedDate, java.lang.String voidReason)
          Sets all void attributes to the given parameters.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public BaseVoidHandler()
Method Detail


public void handle(Voidable voidableObject,
                   User voidingUser,
                   java.util.Date voidedDate,
                   java.lang.String voidReason)
Sets all void attributes to the given parameters.

Specified by:
handle in interface RequiredDataHandler<Voidable>
Specified by:
handle in interface VoidHandler<Voidable>
voidableObject - an OpenmrsObject that needs to have some required data set
voidingUser - the currently authenticated User
voidedDate - the current Date
voidReason - (optional) would be the second argument in the save/void/unvoid/etc method, if exists
See Also:
RequiredDataHandler.handle(org.openmrs.OpenmrsObject, org.openmrs.User, java.util.Date, java.lang.String)
Expected behavior:
set the voided bit, set the voidReason, set voidedBy, not set voidedBy if non null, set dateVoided, not set dateVoided if non null, not set the voidReason if already voided, set voidedBy even if voided bit is set but voidedBy is null


Generated Apr 27 2012 10:06 PM. NOTE - these libraries are in active development and subject to change