Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 4.0

...

The RequiredDataAdvice (add link) class is AOP'd around all methods that start with save/(un)void/(un)retire. (create/update are also in there for backwards compatibility to pre 1.5 modules).

...

  1. Make sure your object extends the right parent class from openmrs core: Auditable, Voidable, or Retireable.
  2. Make sure the method name starts with the right phrase.  It should be "save__" or "void__", "unvoid_", "retire__", or "unretire___"
  3. Add the "listener" with id="requiredDataInterceptor" to your service definition in the spring module application context file:
    <property name="preInterceptors">
    <ref bean="serviceInterceptors" />
    </property>

Disabling Handlers

All RequiredDataHandlers are called on all child collections the OpenmrsObject being handled. Therefore, for instance, if you void an Encounter, the VoidHandler is called for all Obs associated with that Encounter. In a one-to-many relationship, this is the functionality we want, but it is not necessarily what we want in a many-to-many case. For instance, in the Provider Management module, there is  a "ProviderRole" object that contains the collection of RelationshipTypes that the particular ProviderRole can support. As more than one ProviderRole can support the same relationship type, when retiring a ProviderRole we do NOT want to retire the associated RelationshipTypes. 

By annotating a Collection with a @DisableHandlers annotation, you specific that RequiredDataAdvice should NOT apply the specified handler(s) to a child collection.  For example:
 

Code Block
private class ClassWithDisableHandlersAnnotation extends BaseOpenmrsData {
          @DisableHandlers(handlerTypes = {VoidHandler.class, SaveHandler.class})
           private List<Person> persons;
}

...