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); } */ }