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); }
/** * DOC gwu Comment method "findByAuthor". * * @param author * @param transaction * @return List<Project> * @throws DBException */ public List<Project> findByAuthor(User author, ITransactionHolder transaction) throws DBException { Project project = AdminFactory.eINSTANCE.createProject(); project.setAuthor(author); return PersistenceUtil.getPersistenceAdapter() .retrieve( transaction, project, HibernatePersistenceAdapter.createCriterions(project, new String[] {"author"}), dependentObjects); }
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()]); }
private List<Project> listProjects( boolean loadActiveProjectsOnly, boolean loadFolders, User sessionUser, ITransactionHolder transactionHolder) throws DBException { Project project = AdminFactory.eINSTANCE.createProject(); List<String> matches = new ArrayList<String>(); Criterion[] criterions = null; if (loadActiveProjectsOnly) { project.setDeleted(false); matches.add("deleted"); } if (matches != null) { criterions = HibernatePersistenceAdapter.createCriterions(project, matches.toArray(new String[] {})); } String[] projectDependantObjects; if (loadFolders) { projectDependantObjects = getDependentObjectsWithFolders(); } else { projectDependantObjects = dependentObjects; } List<Project> retrieve = null; if (transactionHolder == null) { retrieve = PersistenceUtil.getPersistenceAdapter() .retrieve(project, criterions, projectDependantObjects); } else { retrieve = PersistenceUtil.getPersistenceAdapter() .retrieve(transactionHolder, project, criterions, projectDependantObjects); } ProjectFilter<Project> projectFilter = new EmfProjectFilter(sessionUser); retrieve = projectFilter.filter(retrieve); return retrieve; }
/** * DOC kpchen Comment method "listReferenceProjects". * * @param sessionUser * @return List<Project> * @throws DBException */ public List<Project> listReferenceProjects(User sessionUser) throws DBException { Project project = AdminFactory.eINSTANCE.createProject(); List<String> matches = new ArrayList<String>(); Criterion[] criterions = null; project.setReference(true); matches.add("reference"); if (matches != null) { criterions = HibernatePersistenceAdapter.createCriterions(project, matches.toArray(new String[] {})); } String[] projectDependantObjects = dependentObjects; List<Project> toReturn = PersistenceUtil.getPersistenceAdapter() .retrieve(project, criterions, projectDependantObjects); ProjectFilter<Project> projectFilter = new EmfProjectFilter(sessionUser); toReturn = projectFilter.filter(toReturn); return toReturn; }