@Handler(supports=Voidable.class) public class VoidSaveHandler extends Object implements SaveHandler<Voidable>
RequiredDataAdvice
class uses AOP around each method in every service to check to see
if its a save* method. If it is a save* method, and the object being saved implements
Voidable
, this class is called to handle setting the Voidable.setVoidedBy(User)
,
and Voidable.setDateVoided(Date)
if not set already. RequiredDataAdvice
class will loop over child collections on this
Voidable
that are themselves a Voidable
and voidedBy/dateVoided are set, but
ONLY IF the voided bit was set on them as well. Using the associated void* method in the
service on the parent instance is preferred so that all child objects are indeed voided.RequiredDataAdvice
,
SaveHandler
,
RequiredDataAdvice
Constructor and Description |
---|
VoidSaveHandler() |
Modifier and Type | Method and Description |
---|---|
void |
handle(Voidable voidableObject,
User currentUser,
Date currentDate,
String notUsed)
This method does not set "voided" to true, but rather only sets the voidedBy/dateVoided if
they are null and voided==true.
|
public void handle(Voidable voidableObject, User currentUser, Date currentDate, String notUsed)
handle
in interface RequiredDataHandler<Voidable>
handle
in interface SaveHandler<Voidable>
voidableObject
- an OpenmrsObject that needs to have some required data setcurrentUser
- the user who is saving this objectcurrentDate
- the datetime this object is being savednotUsed
- (optional) would be the second argument in the save method, if existsShould not set the voided bit
Should not set the voidReason
Should set voided by
Should not set voided by if non null
Should set dateVoided
Should not set dateVoided if non null
Should not set the dateVoided if voided is false
Should set voidReason to null if voided is true
Should set dateVoided to null if voided is true
Should set voidedBy to null if voided is true
Copyright © 2024 OpenMRS Inc.. All rights reserved.