protected void checkConstrain(ExecutionPlanPartBean viewBean, ITransactionHolder transaction) throws ClientBusinessException { // if node type is "After", delete OnOk and OnError nodes if (viewBean != null && viewBean.getParent() != null) { if (ActionType.AFTER.equals(viewBean.getType())) { ExecutionPlanPart parentPart = gwt2Hib(viewBean.getParent(), transaction); List<ExecutionPlanPart> parts = ExecutionPlanPartHelper.getInstance().findChildrenByPart(parentPart, transaction); if (parts != null && parts.size() > 0) { for (ExecutionPlanPart part : parts) { if (!ActionType.get(part.getType()).equals(ActionType.AFTER)) { ExecutionPlanPartHelper.getInstance().delete(part, transaction); } } } } else if (!ActionType.AFTER.equals(viewBean.getType())) { ExecutionPlanPart parentPart = gwt2Hib(viewBean.getParent(), transaction); List<ExecutionPlanPart> parts = ExecutionPlanPartHelper.getInstance().findChildrenByPart(parentPart, transaction); if (parts != null && parts.size() > 0) { for (ExecutionPlanPart part : parts) { if (ActionType.get(part.getType()).equals(ActionType.AFTER)) { ExecutionPlanPartHelper.getInstance().delete(part, transaction); } } } } } }
/* * (non-Javadoc) * * @see org.talend.gwtadministrator.server.remoterepositorymgt.view.AbstractViewAdapter#gwt2Hib(java.lang.Object, * org.talend.administrator.common.persistence.hibernate.ITransactionHolder) */ @Override public ExecutionPlanPart gwt2Hib(ExecutionPlanPartBean gwtBean, ITransactionHolder transaction) { Action action = (gwtBean.getId() == null ? Constants.Action.ADD : Constants.Action.UPDATE); ExecutionPlanPart hibBean = null; switch (action) { case ADD: hibBean = ConductorFactory.eINSTANCE.createExecutionPlanPart(); break; case UPDATE: hibBean = ExecutionPlanPartHelper.getInstance().findById(gwtBean.getId(), transaction); if (hibBean != null) { hibBean.setId(gwtBean.getId()); } else { log.warn( "Can't find the plan part with the id=" + gwtBean.getId() + ", the plan part might have already been deleted"); return null; } break; } if (gwtBean.getPlanBean() != null) { ExecutionPlan executionPlan = ExecutionPlanHelper.getInstance().findById(gwtBean.getPlanBean().getId(), transaction); hibBean.setExecutionPlan(executionPlan); } if (gwtBean.getTaskBean() != null) { ExecutionTask executionTask = ExecutionTaskHelper.getInstance().findById(gwtBean.getTaskBean().getId(), transaction); hibBean.setTask(executionTask); } ExecutionPlanPartBean parent = gwtBean.getParent(); if (parent != null) { hibBean.setParent(gwt2Hib(parent, transaction)); } if (gwtBean.getType() != null) { hibBean.setType(gwtBean.getType().toString()); PlanPartStatus partStatus = PlanPartStatus.get(gwtBean.getType().toString()); hibBean.setStatus(partStatus.name()); } if (gwtBean.getStatus() != null) { hibBean.setStatus(gwtBean.getStatus()); } hibBean.setStartDate(gwtBean.getStartDate()); hibBean.setEndDate(gwtBean.getEndDate()); hibBean.setUseParallel(gwtBean.isUseParallel()); hibBean.setMaxThreads(gwtBean.getMaxThreads()); return hibBean; }