org.openmrs.api.handler
Class BaseVoidHandler

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

@Handler(supports=Voidable.class)
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.

Since:
1.5
See Also:
RequiredDataAdvice, UnvoidHandler

Constructor Summary
BaseVoidHandler()
           
 
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

BaseVoidHandler

public BaseVoidHandler()
Method Detail

handle

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>
Parameters:
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

OpenMRS-1.7.x

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