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;
}
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);
}
}
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;
}
Aggregations