Пример #1
0
 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);
     }
   }
 }
Пример #2
0
 public <T extends BeanLifecycle<HippoBean>> void saveUpdateExistingChild(
     FormMap childBeanMap,
     FormMap parentBeanMap,
     T childBeanLifeCycleHandler,
     T parentBeanLifeCycleHandler,
     String baseAbsolutePathToReturnDocuments,
     String parentBeanAbsolutePath,
     String parentBeanNameSpace,
     String parentBeanNodeName,
     Class<? extends HippoBean> childBeanClass,
     Session persistableSession,
     WorkflowPersistenceManager wpm,
     String childBeanCanonicalUUID)
     throws ObjectBeanManagerException {
   // now set the value we received from the form submission
   // ChildBean childBeanLocal = getClass().getAnnotation(ChildBean.class);
   // HippoBean newChildBeanInstance = null;
   HippoBean childBean = (HippoBean) wpm.getObjectByUuid(childBeanCanonicalUUID);
   HippoBean childBeanBeforeUpdate = childBean;
   if (childBeanClass != null && childBean != null) {
     // HippoBean childBean = childBeanClass.newInstance();
     HippoBean parentBeanInSession = childBean.getParentBean();
     HippoBean parentBeanBeforeUpdate = parentBeanInSession;
     // 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");
         }
       } catch (Exception ex) {
         log.error("parentBeanCreatedHandler handler", ex);
       }
     }
     if (childBean instanceof FormMapFiller) {
       FormMapFiller formMapFiller = (FormMapFiller) childBean;
       if (childBeanLifeCycleHandler != null)
         childBeanLifeCycleHandler.beforeFillChildBeanMap(childBean);
       if (childBeanMap != null) formMapFiller.fill(childBeanMap);
       if (childBeanLifeCycleHandler != null)
         childBeanLifeCycleHandler.afterFillChildBeanMap(childBean);
     }
     if (parentBeanInSession instanceof CompoundChildUpdate) {
       CompoundChildUpdate compoundChildUpdate = (CompoundChildUpdate) parentBeanInSession;
       compoundChildUpdate.update(childBean);
     }
     wpm.setWorkflowCallbackHandler(new FullReviewedWorkflowCallbackHandler());
     if (parentBeanInSession != null) {
       try {
         // if (!beforeSave(request)) return; // don't save if this method returns false
         if (childBeanLifeCycleHandler != null) childBeanLifeCycleHandler.beforeUpdate(childBean);
         wpm.update(parentBeanInSession);
         HippoBean childBeanAfterUpdate = childBean;
         HippoBean parentBeanAfterUpdate = parentBeanInSession;
         if (childBeanLifeCycleHandler != null)
           childBeanLifeCycleHandler.afterUpdateChild(
               parentBeanBeforeUpdate,
               parentBeanAfterUpdate,
               childBeanBeforeUpdate,
               childBeanAfterUpdate,
               wpm,
               this);
       } catch (ObjectBeanPersistenceException e) {
         // TODO Auto-generated catch block
         e.printStackTrace();
         log.error("Error in Save", e);
       }
     }
   }
 }
Пример #3
0
  /**
   * 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);
      }
    }
  }