use of org.wso2.carbon.identity.workflow.mgt.dto.WorkflowImpl in project carbon-identity-framework by wso2.
the class WorkflowManagementAdminService method addWorkflow.
/**
* Add new workflow
*
* @param workflow Workflow details
* @throws WorkflowException
*/
public void addWorkflow(WorkflowWizard workflow) throws WorkflowException {
String id = workflow.getWorkflowId();
if (StringUtils.isBlank(id)) {
id = UUID.randomUUID().toString();
}
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
try {
org.wso2.carbon.identity.workflow.mgt.bean.Workflow workflowBean = new org.wso2.carbon.identity.workflow.mgt.bean.Workflow();
workflowBean.setWorkflowId(id);
workflowBean.setWorkflowName(workflow.getWorkflowName());
workflowBean.setWorkflowDescription(workflow.getWorkflowDescription());
String templateId = workflow.getTemplateId() == null ? workflow.getTemplate().getTemplateId() : workflow.getTemplateId();
if (templateId == null) {
throw new WorkflowException("template id can't be empty");
}
workflowBean.setTemplateId(templateId);
String workflowImplId = workflow.getWorkflowImplId() == null ? workflow.getWorkflowImpl().getWorkflowImplId() : workflow.getWorkflowImplId();
if (workflowImplId == null) {
throw new WorkflowException("workflowimpl id can't be empty");
}
workflowBean.setWorkflowImplId(workflowImplId);
List<Parameter> parameterList = new ArrayList<>();
if (workflow.getTemplateParameters() != null) {
parameterList.addAll(Arrays.asList(workflow.getTemplateParameters()));
}
if (workflow.getWorkflowImplParameters() != null) {
parameterList.addAll(Arrays.asList(workflow.getWorkflowImplParameters()));
}
WorkflowServiceDataHolder.getInstance().getWorkflowService().addWorkflow(workflowBean, parameterList, tenantId);
} catch (WorkflowRuntimeException e) {
log.error("Error when adding workflow " + workflow.getWorkflowName(), e);
throw new WorkflowException(e.getMessage());
} catch (WorkflowException e) {
log.error("Server error when adding workflow " + workflow.getWorkflowName(), e);
throw new WorkflowException("Server error occurred when adding the workflow");
}
}
use of org.wso2.carbon.identity.workflow.mgt.dto.WorkflowImpl in project carbon-identity-framework by wso2.
the class WorkflowManagementServiceImpl method listWorkflowImpls.
@Override
public List<WorkflowImpl> listWorkflowImpls(String templateId) throws WorkflowException {
List<WorkflowListener> workflowListenerList = WorkflowServiceDataHolder.getInstance().getWorkflowListenerList();
for (WorkflowListener workflowListener : workflowListenerList) {
if (workflowListener.isEnable()) {
workflowListener.doPreListWorkflowImpls(templateId);
}
}
Map<String, AbstractWorkflow> abstractWorkflowMap = WorkflowServiceDataHolder.getInstance().getWorkflowImpls().get(templateId);
List<WorkflowImpl> workflowList = new ArrayList<>();
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);
}
}
for (WorkflowListener workflowListener : workflowListenerList) {
if (workflowListener.isEnable()) {
workflowListener.doPostListWorkflowImpls(templateId, workflowList);
}
}
return workflowList;
}
use of org.wso2.carbon.identity.workflow.mgt.dto.WorkflowImpl in project carbon-identity-framework by wso2.
the class WorkflowUIUtil method loadWorkflowImplParameters.
/**
* Load implementaions related parameters of a workflow
*
* @param requestParameterMap parameter map
* @param workflowWizard Workflow object
*/
public static void loadWorkflowImplParameters(Map<String, String[]> requestParameterMap, WorkflowWizard workflowWizard) {
Parameter[] workflowImplParameters = workflowWizard.getWorkflowImplParameters();
Map<String, Parameter> workflowImplParameterMap = new HashMap<>();
if (workflowImplParameters != null) {
for (Parameter param : workflowImplParameters) {
workflowImplParameterMap.put(param.getQName(), param);
}
}
WorkflowImpl workflowImpl = workflowWizard.getWorkflowImpl();
if (workflowImpl != null) {
ParametersMetaData parametersMetaData = workflowImpl.getParametersMetaData();
if (parametersMetaData != null && parametersMetaData.getParameterMetaData() != null) {
ParameterMetaData[] parameterMetaData = parametersMetaData.getParameterMetaData();
for (ParameterMetaData metaData : parameterMetaData) {
if (requestParameterMap.get(metaData.getName()) != null) {
Parameter parameter = workflowImplParameterMap.get(metaData.getName());
String value = requestParameterMap.get(metaData.getName())[0];
if (parameter == null) {
parameter = new Parameter();
parameter.setParamName(metaData.getName());
parameter.setHolder(WorkflowUIConstants.ParameterHolder.WORKFLOW_IMPL);
workflowImplParameterMap.put(parameter.getParamName(), parameter);
}
parameter.setParamValue(value);
parameter.setQName(metaData.getName());
} else {
for (Map.Entry<String, String[]> entry : requestParameterMap.entrySet()) {
if (entry != null && entry.getKey().startsWith(metaData.getName())) {
Parameter parameter = workflowImplParameterMap.get(entry.getKey());
if (parameter == null) {
parameter = new Parameter();
parameter.setParamName(metaData.getName());
parameter.setHolder(WorkflowUIConstants.ParameterHolder.WORKFLOW_IMPL);
parameter.setQName(entry.getKey());
workflowImplParameterMap.put(entry.getKey(), parameter);
}
String[] values = requestParameterMap.get(entry.getKey());
if (values != null && values.length > 0) {
String aValue = values[0];
parameter.setParamValue(aValue);
}
}
}
}
}
}
}
Collection<Parameter> values = workflowImplParameterMap.values();
Parameter[] parameters = values.toArray(new Parameter[values.size()]);
workflowWizard.setWorkflowImplParameters(parameters);
}
use of org.wso2.carbon.identity.workflow.mgt.dto.WorkflowImpl in project product-is by wso2.
the class UserApprovalTestBase method getWorkflowDTO.
private WorkflowWizard getWorkflowDTO(String workflowName, String workflowDescription) throws RemoteException, WorkflowAdminServiceWorkflowException {
WorkflowWizard workflowDTO = new WorkflowWizard();
workflowDTO.setWorkflowName(workflowName);
workflowDTO.setWorkflowDescription(workflowDescription);
workflowDTO.setTemplateId(templateId);
workflowDTO.setWorkflowImplId(workflowImplId);
Template template = client.getTemplate(templateId);
workflowDTO.setTemplate(template);
WorkflowImpl workflowImpl = client.getWorkflowImpl(templateId, workflowImplId);
workflowDTO.setWorkflowImpl(workflowImpl);
Parameter[] parametersImpl = new Parameter[2];
Parameter parameter = new Parameter();
parameter.setParamName("BPSProfile");
parameter.setParamValue("embeded_bps");
parameter.setHolder("WorkflowImpl");
parameter.setQName("BPSProfile");
parametersImpl[0] = parameter;
parameter = new Parameter();
parameter.setParamName("HTSubject");
parameter.setParamValue("sample approval task");
parameter.setHolder("WorkflowImpl");
parameter.setQName("HTSubject");
parametersImpl[1] = parameter;
Parameter[] parametersTmp = new Parameter[1];
parameter = new Parameter();
parameter.setParamName("UserAndRole");
parameter.setParamValue("admin");
parameter.setHolder("Template");
parameter.setQName("UserAndRole-step-1-roles");
parametersTmp[0] = parameter;
workflowDTO.setTemplateParameters(parametersTmp);
workflowDTO.setWorkflowImplParameters(parametersImpl);
return workflowDTO;
}
use of org.wso2.carbon.identity.workflow.mgt.dto.WorkflowImpl in project product-is by wso2.
the class WorkflowManagementTestCase method getWorkflowDTO.
private WorkflowWizard getWorkflowDTO(String workflowName, String workflowDescription) throws RemoteException, WorkflowAdminServiceWorkflowException {
WorkflowWizard workflowDTO = new WorkflowWizard();
workflowDTO.setWorkflowName(workflowName);
workflowDTO.setWorkflowDescription(workflowDescription);
workflowDTO.setTemplateId(templateId);
workflowDTO.setWorkflowImplId(workflowImplId);
Template template = client.getTemplate(templateId);
workflowDTO.setTemplate(template);
WorkflowImpl workflowImpl = client.getWorkflowImpl(templateId, workflowImplId);
workflowDTO.setWorkflowImpl(workflowImpl);
Parameter[] parametersImpl = new Parameter[2];
Parameter parameter = new Parameter();
parameter.setParamName("BPSProfile");
parameter.setParamValue("embeded_bps");
parameter.setHolder("WorkflowImpl");
parameter.setQName("BPSProfile");
parametersImpl[0] = parameter;
parameter = new Parameter();
parameter.setParamName("HTSubject");
parameter.setParamValue("sample ht");
parameter.setHolder("WorkflowImpl");
parameter.setQName("HTSubject");
parametersImpl[1] = parameter;
Parameter[] parametersTmp = new Parameter[1];
parameter = new Parameter();
parameter.setParamName("UserAndRole");
parameter.setParamValue("admin");
parameter.setHolder("Template");
parameter.setQName("UserAndRole-step-1-roles");
parametersTmp[0] = parameter;
workflowDTO.setTemplateParameters(parametersTmp);
workflowDTO.setWorkflowImplParameters(parametersImpl);
return workflowDTO;
}
Aggregations