Search in sources :

Example 1 with AbstractTemplate

use of org.wso2.carbon.identity.workflow.mgt.template.AbstractTemplate in project carbon-identity-framework by wso2.

the class WorkflowManagementServiceImpl method getTemplate.

@Override
public Template getTemplate(String templateId) throws WorkflowException {
    List<WorkflowListener> workflowListenerList = WorkflowServiceDataHolder.getInstance().getWorkflowListenerList();
    for (WorkflowListener workflowListener : workflowListenerList) {
        if (workflowListener.isEnable()) {
            workflowListener.doPreGetTemplate(templateId);
        }
    }
    AbstractTemplate abstractTemplate = WorkflowServiceDataHolder.getInstance().getTemplates().get(templateId);
    Template template = null;
    if (abstractTemplate != null) {
        template = new Template();
        template.setTemplateId(abstractTemplate.getTemplateId());
        template.setName(abstractTemplate.getName());
        template.setDescription(abstractTemplate.getDescription());
        template.setParametersMetaData(abstractTemplate.getParametersMetaData());
    }
    for (WorkflowListener workflowListener : workflowListenerList) {
        if (workflowListener.isEnable()) {
            workflowListener.doPostGetTemplate(templateId, template);
        }
    }
    return template;
}
Also used : AbstractTemplate(org.wso2.carbon.identity.workflow.mgt.template.AbstractTemplate) WorkflowListener(org.wso2.carbon.identity.workflow.mgt.listener.WorkflowListener) Template(org.wso2.carbon.identity.workflow.mgt.dto.Template) AbstractTemplate(org.wso2.carbon.identity.workflow.mgt.template.AbstractTemplate)

Example 2 with AbstractTemplate

use of org.wso2.carbon.identity.workflow.mgt.template.AbstractTemplate in project carbon-identity-framework by wso2.

the class WorkflowManagementAdminService method getWorkflow.

private WorkflowWizard getWorkflow(org.wso2.carbon.identity.workflow.mgt.bean.Workflow workflowBean) throws WorkflowException {
    try {
        WorkflowWizard workflow = null;
        if (workflowBean != null) {
            workflow = new WorkflowWizard();
            workflow.setWorkflowId(workflowBean.getWorkflowId());
            workflow.setWorkflowName(workflowBean.getWorkflowName());
            workflow.setWorkflowDescription(workflowBean.getWorkflowDescription());
            // workflow.setTemplateId(workflowBean.getTemplateId());
            // workflow.setWorkflowImplId(workflowBean.getWorkflowImplId());
            AbstractTemplate abstractTemplate = WorkflowServiceDataHolder.getInstance().getTemplates().get(workflowBean.getTemplateId());
            Template template = new Template();
            template.setTemplateId(abstractTemplate.getTemplateId());
            template.setName(abstractTemplate.getName());
            template.setDescription(abstractTemplate.getDescription());
            template.setParametersMetaData(abstractTemplate.getParametersMetaData());
            workflow.setTemplate(template);
            AbstractWorkflow abstractWorkflow = WorkflowServiceDataHolder.getInstance().getWorkflowImpls().get(workflowBean.getTemplateId()).get(workflowBean.getWorkflowImplId());
            WorkflowImpl workflowimpl = new WorkflowImpl();
            workflowimpl.setWorkflowImplId(abstractWorkflow.getWorkflowImplId());
            workflowimpl.setWorkflowImplName(abstractWorkflow.getWorkflowImplName());
            workflowimpl.setTemplateId(abstractWorkflow.getTemplateId());
            workflowimpl.setParametersMetaData(abstractWorkflow.getParametersMetaData());
            workflow.setWorkflowImpl(workflowimpl);
            List<Parameter> workflowParams = WorkflowServiceDataHolder.getInstance().getWorkflowService().getWorkflowParameters(workflowBean.getWorkflowId());
            List<Parameter> templateParams = new ArrayList<>();
            List<Parameter> workflowImplParams = new ArrayList<>();
            for (Parameter parameter : workflowParams) {
                if (parameter.getHolder().equals(WFConstant.ParameterHolder.TEMPLATE)) {
                    templateParams.add(parameter);
                } else if (parameter.getHolder().equals(WFConstant.ParameterHolder.WORKFLOW_IMPL)) {
                    workflowImplParams.add(parameter);
                }
            }
            workflow.setTemplateParameters(templateParams.toArray(new Parameter[templateParams.size()]));
            workflow.setWorkflowImplParameters(workflowImplParams.toArray(new Parameter[workflowImplParams.size()]));
        }
        return workflow;
    } catch (InternalWorkflowException e) {
        String errorMsg = "Error occurred while reading workflow object details for given workflow id, " + e.getMessage();
        log.error(errorMsg, e);
        throw new WorkflowException(errorMsg, e);
    }
}
Also used : WorkflowImpl(org.wso2.carbon.identity.workflow.mgt.dto.WorkflowImpl) InternalWorkflowException(org.wso2.carbon.identity.workflow.mgt.exception.InternalWorkflowException) AbstractTemplate(org.wso2.carbon.identity.workflow.mgt.template.AbstractTemplate) InternalWorkflowException(org.wso2.carbon.identity.workflow.mgt.exception.InternalWorkflowException) WorkflowException(org.wso2.carbon.identity.workflow.mgt.exception.WorkflowException) ArrayList(java.util.ArrayList) Parameter(org.wso2.carbon.identity.workflow.mgt.bean.Parameter) AbstractWorkflow(org.wso2.carbon.identity.workflow.mgt.workflow.AbstractWorkflow) WorkflowWizard(org.wso2.carbon.identity.workflow.mgt.dto.WorkflowWizard) Template(org.wso2.carbon.identity.workflow.mgt.dto.Template) AbstractTemplate(org.wso2.carbon.identity.workflow.mgt.template.AbstractTemplate)

Example 3 with AbstractTemplate

use of org.wso2.carbon.identity.workflow.mgt.template.AbstractTemplate in project carbon-identity-framework by wso2.

the class WorkflowManagementServiceImpl method listTemplates.

@Override
public List<Template> listTemplates() throws WorkflowException {
    List<WorkflowListener> workflowListenerList = WorkflowServiceDataHolder.getInstance().getWorkflowListenerList();
    for (WorkflowListener workflowListener : workflowListenerList) {
        if (workflowListener.isEnable()) {
            workflowListener.doPreListTemplates();
        }
    }
    Map<String, AbstractTemplate> templateMap = WorkflowServiceDataHolder.getInstance().getTemplates();
    List<AbstractTemplate> templateList = new ArrayList<>(templateMap.values());
    List<Template> templates = new ArrayList<Template>();
    if (templateList != null) {
        for (AbstractTemplate abstractTemplate : templateList) {
            Template template = new Template();
            template.setTemplateId(abstractTemplate.getTemplateId());
            template.setName(abstractTemplate.getName());
            template.setDescription(abstractTemplate.getDescription());
            template.setParametersMetaData(abstractTemplate.getParametersMetaData());
            templates.add(template);
        }
    }
    for (WorkflowListener workflowListener : workflowListenerList) {
        if (workflowListener.isEnable()) {
            workflowListener.doPostListTemplates(templates);
        }
    }
    return templates;
}
Also used : AbstractTemplate(org.wso2.carbon.identity.workflow.mgt.template.AbstractTemplate) ArrayList(java.util.ArrayList) WorkflowListener(org.wso2.carbon.identity.workflow.mgt.listener.WorkflowListener) Template(org.wso2.carbon.identity.workflow.mgt.dto.Template) AbstractTemplate(org.wso2.carbon.identity.workflow.mgt.template.AbstractTemplate)

Aggregations

Template (org.wso2.carbon.identity.workflow.mgt.dto.Template)3 AbstractTemplate (org.wso2.carbon.identity.workflow.mgt.template.AbstractTemplate)3 ArrayList (java.util.ArrayList)2 WorkflowListener (org.wso2.carbon.identity.workflow.mgt.listener.WorkflowListener)2 Parameter (org.wso2.carbon.identity.workflow.mgt.bean.Parameter)1 WorkflowImpl (org.wso2.carbon.identity.workflow.mgt.dto.WorkflowImpl)1 WorkflowWizard (org.wso2.carbon.identity.workflow.mgt.dto.WorkflowWizard)1 InternalWorkflowException (org.wso2.carbon.identity.workflow.mgt.exception.InternalWorkflowException)1 WorkflowException (org.wso2.carbon.identity.workflow.mgt.exception.WorkflowException)1 AbstractWorkflow (org.wso2.carbon.identity.workflow.mgt.workflow.AbstractWorkflow)1