use of org.wso2.carbon.identity.workflow.mgt.dto.WorkflowWizard in project carbon-identity-framework by wso2.
the class WorkflowManagementAdminService method listWorkflows.
/**
* List workflows
*
* @return
* @throws WorkflowException
*/
public WorkflowWizard[] listWorkflows() throws WorkflowException {
List<WorkflowWizard> workflowWizards = new ArrayList<>();
List<Workflow> workflowBeans = null;
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
try {
workflowBeans = WorkflowServiceDataHolder.getInstance().getWorkflowService().listWorkflows(tenantId);
for (Workflow workflow : workflowBeans) {
WorkflowWizard workflowTmp = getWorkflow(workflow);
workflowWizards.add(workflowTmp);
}
} catch (InternalWorkflowException e) {
log.error("Server error when listing workflows", e);
throw new WorkflowException("Server error occurred when listing workflows");
}
return workflowWizards.toArray(new WorkflowWizard[workflowWizards.size()]);
}
use of org.wso2.carbon.identity.workflow.mgt.dto.WorkflowWizard 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.WorkflowWizard 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.WorkflowWizard in project carbon-identity-framework by wso2.
the class WorkflowUIUtil method loadTemplateParameters.
/**
* Load parameters of a workflow template
*
* @param requestParameterMap parameter map
* @param workflowWizard Workflow object
*/
public static void loadTemplateParameters(Map<String, String[]> requestParameterMap, WorkflowWizard workflowWizard) {
Map<String, Parameter> templateParameterMap = new HashMap<>();
Template template = workflowWizard.getTemplate();
if (template != null) {
ParametersMetaData parametersMetaData = template.getParametersMetaData();
if (parametersMetaData != null && parametersMetaData.getParameterMetaData() != null) {
ParameterMetaData[] parameterMetaData = parametersMetaData.getParameterMetaData();
for (ParameterMetaData metaData : parameterMetaData) {
if (requestParameterMap.get(metaData.getName()) != null) {
String value = requestParameterMap.get(metaData.getName())[0];
Parameter parameter = new Parameter();
parameter.setParamName(metaData.getName());
parameter.setHolder(WorkflowUIConstants.ParameterHolder.TEMPLATE);
templateParameterMap.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 = new Parameter();
parameter.setParamName(metaData.getName());
parameter.setHolder(WorkflowUIConstants.ParameterHolder.TEMPLATE);
parameter.setQName(entry.getKey());
templateParameterMap.put(entry.getKey(), parameter);
String[] values = entry.getValue();
if (values != null && values.length > 0) {
String aValue = values[0];
parameter.setParamValue(aValue);
}
}
}
}
}
}
}
Collection<Parameter> values = templateParameterMap.values();
Parameter[] parameters = values.toArray(new Parameter[values.size()]);
workflowWizard.setTemplateParameters(parameters);
}
use of org.wso2.carbon.identity.workflow.mgt.dto.WorkflowWizard in project product-is by wso2.
the class UserApprovalTestBase method addWorkflow.
private void addWorkflow() throws Exception {
String workflowDescription = "TestWorkflowDescription";
WorkflowWizard workflowDTO = getWorkflowDTO(addUserWorkflowName, workflowDescription);
log.info("Adding workflow " + addUserWorkflowName + " to tenant:" + this.tenant);
this.client.addWorkflow(workflowDTO);
WorkflowWizard[] workflows = this.client.listWorkflows();
for (WorkflowWizard workflow : workflows) {
if (this.addUserWorkflowName.equals(workflow.getWorkflowName()) && workflowDescription.equals(workflow.getWorkflowDescription())) {
// setting for future tests
this.workflowId = workflow.getWorkflowId();
break;
}
}
}
Aggregations