public ExecutionPlanPartBean saveExecutionPlanPartBean(
      ExecutionPlanPartBean viewBean, User user, ITransactionHolder transactionPrm)
      throws BusinessException, ClientBusinessException {
    HibernatePersistenceAdapter persistenceAdapter = PersistenceUtil.getPersistenceAdapter();
    ExecutionPlanPart planPart = null;
    ITransactionHolder transaction = null;
    boolean isLocalTransaction = transactionPrm == null;
    try {
      if (isLocalTransaction) {
        transaction = persistenceAdapter.createTransaction();
      } else {
        transaction = transactionPrm;
      }
      planPart = gwt2Hib(viewBean, transaction);

      ActionType actionType = ActionType.get(planPart.getType());
      if (viewBean.getId() == null && actionType != ActionType.PARALLEL) {
        ExecutionPlanPart executionPlanPart =
            ExecutionPlanPartHelper.getInstance().findWithSameParentsAndType(planPart, transaction);
        if (executionPlanPart != null)
          throw new BusinessException(
              "executionPlan.part.saveError.uniqueType", planPart.getType());
      }
      if (planPart.isUseParallel()) {
        planPart.setTask(null);
        viewBean.setTaskBean(null);
      }

      ExecutionPlanPartHandler.getInstance().saveOrUpdate(planPart, user, transaction);

      viewBean.setId(planPart.getId());
      saveOrUpdateParallelParts(viewBean, planPart, user, transaction);

    } catch (BusinessException e) {
      throw e;
    } catch (Throwable ex) {
      if (isLocalTransaction && transaction != null && !transaction.isClosed()) {
        try {
          transaction.rollbackAndClose();
        } catch (DBException e1) {
          log.error(e1.getMessage(), e1);
        }
      }
      throw new SystemException(ex);
    } finally {
      if (isLocalTransaction && transaction != null && !transaction.isClosed()) {
        try {
          transaction.commitAndClose();
        } catch (Exception e) {
          log.error(e.getMessage(), e);
        }
      }
    }

    return hib2Gwt(planPart);
  }
  public void deleteExecutionPlanPart(
      ExecutionPlanPartBean executionPlanPartBean, boolean deleteAllRelatedDatas)
      throws ClientBusinessException {
    ExecutionPlanPart planPart = gwt2Hib(executionPlanPartBean);

    ITransactionHolder transactionHolder = null;
    try {
      transactionHolder = PersistenceUtil.getPersistenceAdapter().createTransaction();
      ExecutionPlanPartHelper.getInstance().delete(planPart, transactionHolder);
      transactionHolder.commitAndClose();
    } catch (Exception e) {
      transactionHolder.rollbackAndClose();
      throw new RuntimeException(e);
    }
    /*
     * List<ExecutionPlanPart> children = ExecutionPlanPartHelper.getInstance().findChildrenByPart(planPart); if
     * (children != null && children.size() > 0) { throw new
     * ClientBusinessException("executionPlan.part.delete.children.firstly"); } else {
     * ExecutionPlanPartHelper.getInstance().delete(planPart, deleteAllRelatedDatas); }
     */
  }
 public PartStatusBean[] getPartsStatusByIds(Integer[] ids) {
   List<PartStatusBean> statuses = new ArrayList<PartStatusBean>();
   HibernatePersistenceAdapter persistenceAdapter = PersistenceUtil.getPersistenceAdapter();
   ITransactionHolder transaction = null;
   try {
     transaction = persistenceAdapter.createTransaction();
     if (ids != null) {
       for (Integer id : ids) {
         ExecutionPlanPart part = ExecutionPlanPartHelper.getInstance().findById(id, transaction);
         if (part != null) {
           PartStatusBean bean = new PartStatusBean();
           bean.setId(part.getId());
           bean.setStatus(part.getStatus());
           PlanPartWrapper wrapper = new PlanPartWrapper(part);
           TaskExecutionBasicStatus taskExecutionBasicStatus =
               wrapper.getExecutionBasicStatus(transaction);
           if (taskExecutionBasicStatus != null) {
             bean.setTaskExecutionHistoryBasicStatus(taskExecutionBasicStatus.toString());
           }
           statuses.add(bean);
         }
       }
     }
   } catch (Throwable ex) {
     throw new SystemException(ex);
   } finally {
     if (transaction != null && !transaction.isClosed()) {
       try {
         transaction.commitAndClose();
       } catch (Exception e) {
         log.error(e.getMessage(), e);
       }
     }
   }
   return statuses.toArray(new PartStatusBean[statuses.size()]);
 }