public <T extends BeanLifecycle<HippoBean>> void saveSingleDocument(
     FormMap parentBeanMap,
     T parentBeanLifeCycleHandler,
     String baseAbsolutePathToReturnDocuments,
     String parentBeanAbsolutePath,
     String parentBeanNameSpace,
     String parentBeanNodeName,
     Session persistableSession,
     WorkflowPersistenceManager wpm)
     throws ObjectBeanManagerException, InstantiationException, IllegalAccessException {
   // Object parentBeanInSession = wpm.getObject(parentBean.getCanonicalUUID());
   boolean isNew = false;
   HippoBean parentBeanInSession = (HippoBean) wpm.getObject(parentBeanAbsolutePath);
   HippoBean beanBeforeUpdate = parentBeanInSession;
   if (parentBeanInSession == null) {
     // gotta create this damn thing
     if (log.isInfoEnabled()) {
       log.info("Parent Bean is missing, we will need to recreate it");
     }
     final String pathToParentBean =
         wpm.createAndReturn(
             baseAbsolutePathToReturnDocuments, parentBeanNameSpace, parentBeanNodeName, true);
     parentBeanInSession = (HippoBean) wpm.getObject(pathToParentBean);
     isNew = true;
     // initParentBean(parentBeanInSession);
   }
   // now set the value we received from the form submission
   if (parentBeanInSession instanceof FormMapFiller) {
     FormMapFiller formMapFiller = (FormMapFiller) parentBeanInSession;
     if (parentBeanLifeCycleHandler != null)
       parentBeanLifeCycleHandler.beforeFillParentBeanMap(parentBeanInSession);
     if (parentBeanMap != null) formMapFiller.fill(parentBeanMap);
     if (parentBeanLifeCycleHandler != null)
       parentBeanLifeCycleHandler.afterFillParentBeanMap(parentBeanInSession);
   }
   wpm.setWorkflowCallbackHandler(new FullReviewedWorkflowCallbackHandler());
   if (parentBeanInSession != null) {
     wpm.update(parentBeanInSession);
     // wpm.remove(parentBeanInSession);
     HippoBean beanAfterUpdate = parentBeanInSession;
     if (parentBeanLifeCycleHandler != null) {
       parentBeanLifeCycleHandler.afterUpdate(
           beanBeforeUpdate, beanAfterUpdate, wpm, parentBeanAbsolutePath, this);
     }
   }
 }
  /**
   * Action to Save Add New Child
   *
   * @param request
   * @param formMap
   * @param baseAbsolutePathToReturnDocuments
   * @param parentBeanAbsolutePath
   * @param parentBeanNameSpace
   * @param parentBeanNodeName
   * @param childBeanClass
   * @param persistableSession
   * @param wpm
   * @throws ObjectBeanManagerException
   * @throws IllegalAccessException
   * @throws InstantiationException
   */
  public <T extends BeanLifecycle<HippoBean>> void saveAddNewChild(
      FormMap childBeanMap,
      FormMap parentBeanMap,
      T childBeanLifeCycleHandler,
      T parentBeanLifeCycleHandler,
      String baseAbsolutePathToReturnDocuments,
      String parentBeanAbsolutePath,
      String parentBeanNameSpace,
      String parentBeanNodeName,
      Class<? extends HippoBean> childBeanClass,
      Session persistableSession,
      WorkflowPersistenceManager wpm)
      throws ObjectBeanManagerException, InstantiationException, IllegalAccessException {
    HippoBean parentBeanInSession = (HippoBean) wpm.getObject(parentBeanAbsolutePath);
    if (parentBeanInSession == null) {
      // gotta create this damn thing
      if (log.isInfoEnabled()) {
        log.info("Parent Bean is missing, we will need to recreate it");
      }
      // final String pathToParentBean =
      // wpm.createAndReturn(baseAbsolutePathToReturnDocuments,getParentBeanNameSpace(),getParentBeanNodeName(), true);
      final String pathToParentBean =
          wpm.createAndReturn(
              baseAbsolutePathToReturnDocuments, parentBeanNameSpace, parentBeanNodeName, true);
      parentBeanInSession = (HippoBean) wpm.getObject(pathToParentBean);

      // invoke the init method if there is any as a parent bean is created
      if (parentBeanLifeCycleHandler != null) {
        try {
          if (log.isInfoEnabled()) {
            log.info("Handler defined for parent bean creation invoke that handler now");
          }
          parentBeanLifeCycleHandler.afterCreate(parentBeanInSession);
        } catch (Exception ex) {
          log.error("parentBeanCreatedHandler handler", ex);
        }
      }
      if (parentBeanInSession instanceof FormMapFiller) {
        FormMapFiller formMapFiller = (FormMapFiller) parentBeanInSession;
        if (parentBeanLifeCycleHandler != null)
          parentBeanLifeCycleHandler.beforeFillParentBeanMap(parentBeanInSession);
        if (parentBeanMap != null) formMapFiller.fill(parentBeanMap);
        if (parentBeanLifeCycleHandler != null)
          parentBeanLifeCycleHandler.afterFillParentBeanMap(parentBeanInSession);
      }
    }
    // now set the value we received from the form submission
    // ChildBean childBeanLocal = getClass().getAnnotation(ChildBean.class);
    // HippoBean newChildBeanInstance = null;
    if (childBeanClass != null) {
      HippoBean childBean = childBeanClass.newInstance();
      // invoke the init method if there is any as a parent bean is created
      if (childBeanLifeCycleHandler != null) {
        try {
          if (log.isInfoEnabled()) {
            log.info("Handler defined for child bean creation invoke that handler now");
          }
          childBeanLifeCycleHandler.afterCreate(childBean);
        } catch (Exception ex) {
          log.error("parentBeanCreatedHandler handler", ex);
        }
      }
      if (childBean instanceof FormMapFiller) {
        if (childBeanLifeCycleHandler != null)
          childBeanLifeCycleHandler.beforeFillChildBeanMap(childBean);
        FormMapFiller formMapFiller = (FormMapFiller) childBean;
        if (childBeanMap != null) formMapFiller.fill(childBeanMap);
        if (childBeanLifeCycleHandler != null)
          childBeanLifeCycleHandler.afterFillChildBeanMap(childBean);
      }
      if (parentBeanInSession instanceof CompoundChildUpdate) {
        CompoundChildUpdate compoundChildUpdate = (CompoundChildUpdate) parentBeanInSession;
        compoundChildUpdate.add(childBean);
      }
      wpm.setWorkflowCallbackHandler(new FullReviewedWorkflowCallbackHandler());
      if (parentBeanInSession != null) {
        // if (!beforeSave(request)) return; // don't save if this method returns false
        wpm.update(parentBeanInSession);
      }
    }
  }