@Handler(supports=Retireable.class) public class RetireSaveHandler extends Object implements SaveHandler<Retireable>
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
Retireable
, this class is called to handle setting the
Retireable.setRetiredBy(User)
, and Retireable.setDateRetired(Date)
if not set
already. RequiredDataAdvice
class will loop over child collections on this
Retireable
that are themselves a Retireable
and retiredBy/dateRetired are set,
but ONLY IF the retired bit was set on them as well. Using the associated retire* method
in the service on the parent instance is preferred so that all child objects are indeed retired.RequiredDataAdvice
,
SaveHandler
,
RequiredDataAdvice
Constructor and Description |
---|
RetireSaveHandler() |
Modifier and Type | Method and Description |
---|---|
void |
handle(Retireable retireableObject,
User currentUser,
Date currentDate,
String notUsed)
This method does not set "retired" to true, but rather only sets the retiredBy/dateRetired if
they are null and retired==true.
|
public void handle(Retireable retireableObject, User currentUser, Date currentDate, String notUsed)
handle
in interface RequiredDataHandler<Retireable>
handle
in interface SaveHandler<Retireable>
retireableObject
- 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 retired bit
Should not set the retireReason
Should set retired by
Should not set retired by if non null
Should set dateRetired
Should not set dateRetired if non null
Should not set the dateRetired if retired is false
Should set retireReason to null if retired is true
Should set dateRetired to null if retired is true
Should set retiredBy to null if retired is true
Copyright © 2024 OpenMRS Inc.. All rights reserved.