@Override public void addWorkflow(Workflow workflow, List<Parameter> parameterList, int tenantId) throws WorkflowException { // TODO:Workspace Name may contain spaces , so we need to remove spaces and prepare process for // that Parameter workflowNameParameter = new Parameter( workflow.getWorkflowId(), WFConstant.ParameterName.WORKFLOW_NAME, workflow.getWorkflowName(), WFConstant.ParameterName.WORKFLOW_NAME, WFConstant.ParameterHolder.WORKFLOW_IMPL); if (!parameterList.contains(workflowNameParameter)) { parameterList.add(workflowNameParameter); } else { workflowNameParameter = parameterList.get(parameterList.indexOf(workflowNameParameter)); } if (!workflowNameParameter.getParamValue().equals(workflow.getWorkflowName())) { workflowNameParameter.setParamValue(workflow.getWorkflowName()); // TODO:Since the user has changed the workflow name, we have to undeploy bpel package that is // already // deployed using previous workflow name. } AbstractWorkflow abstractWorkflow = WorkflowServiceDataHolder.getInstance() .getWorkflowImpls() .get(workflow.getTemplateId()) .get(workflow.getWorkflowImplId()); // deploying the template abstractWorkflow.deploy(parameterList); // add workflow to the database if (workflowDAO.getWorkflow(workflow.getWorkflowId()) == null) { workflowDAO.addWorkflow(workflow, tenantId); WorkflowManagementUtil.createAppRole( StringUtils.deleteWhitespace(workflow.getWorkflowName())); } else { workflowDAO.removeWorkflowParams(workflow.getWorkflowId()); workflowDAO.updateWorkflow(workflow); } workflowDAO.addWorkflowParams(parameterList, workflow.getWorkflowId()); }
@Override public List<WorkflowImpl> listWorkflowImpls(String templateId) throws WorkflowException { Map<String, AbstractWorkflow> abstractWorkflowMap = WorkflowServiceDataHolder.getInstance().getWorkflowImpls().get(templateId); List<WorkflowImpl> workflowList = new ArrayList<WorkflowImpl>(); if (abstractWorkflowMap != null) { List<AbstractWorkflow> abstractWorkflowList = new ArrayList<>(abstractWorkflowMap.values()); for (AbstractWorkflow abstractWorkflow : abstractWorkflowList) { WorkflowImpl workflow = new WorkflowImpl(); workflow.setWorkflowImplId(abstractWorkflow.getWorkflowImplId()); workflow.setWorkflowImplName(abstractWorkflow.getWorkflowImplName()); workflow.setParametersMetaData(abstractWorkflow.getParametersMetaData()); workflow.setTemplateId(abstractWorkflow.getTemplateId()); workflowList.add(workflow); } } return workflowList; }
@Override public WorkflowImpl getWorkflowImpl(String templateId, String workflowImplId) throws WorkflowException { WorkflowImpl workflowImpl = null; Map<String, AbstractWorkflow> abstractWorkflowMap = WorkflowServiceDataHolder.getInstance().getWorkflowImpls().get(templateId); if (abstractWorkflowMap != null) { AbstractWorkflow tmp = abstractWorkflowMap.get(workflowImplId); if (tmp != null) { workflowImpl = new WorkflowImpl(); workflowImpl.setWorkflowImplId(tmp.getWorkflowImplId()); workflowImpl.setWorkflowImplName(tmp.getWorkflowImplName()); workflowImpl.setParametersMetaData(tmp.getParametersMetaData()); workflowImpl.setTemplateId(tmp.getTemplateId()); } } return workflowImpl; }