Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Defining which updatable collections have deletable elements

org.kuali.ricekfs.kns.bo.PersistableBusinessObject.buildListOfDeletionAwareLists() should be implemented for all business objects that require deletion of removed elements.
In a nutshell, this method returns a List of Collection of a BO. It returns a list of references to the actual collections storing data. Given a BO from the form to persist, it retrieves the corresponding BO from the database (based on primary key). Compares the collections returned by buildListOfDeletionAwareLists(), and deletes any elements contained within the DB-based BO and not in the form-based BO.

...

  1. Have the DAO class implement org.kuali.ricekfs.kns.util.OjbCollectionAware
  2. In the method that saves/updates the business object (e.g. save), retrieve the corresponding business object from the database with the same primary key values.
  3. Retrieve the org.kuali.ricekfs.kns.util.OjbCollectionHelper bean from the Spring bean factory. In rice, use KNSServiceLocator.getOjbCollectionHelper() and in KFS or Rice client code, use SpringContext.getBean(OjbCollectionHelper.class).
  4. Call org.kuali.ricekfs.kns.util.OjbCollectionHelper.processCollections(OjbCollectionAware theDAO, PersistableBusinessObject boFromForm, PersistableBusinessObject boFromDatabase)
  5. Store the BO from the form as normal (typically by calling getPersistenceBrokerTemplate().store(document)).

...