map.addAttribute("username", user.getUsername());
WorkflowProcess process = null;
boolean processFound = false;
Collection<WorkflowProcess> processList = null;
PackageDefinition packageDefinition = appDef.getPackageDefinition();
if (packageDefinition != null) {
Long packageVersion = packageDefinition.getVersion();
processList = workflowManager.getProcessList(appId, packageVersion.toString());
if (processDefId != null && processDefId.trim().length() > 0) {
// find matching process by definition (without version)
for (WorkflowProcess wp : processList) {
String processIdWithoutVersion = WorkflowUtil.getProcessDefIdWithoutVersion(wp.getId());
if (processIdWithoutVersion.equals(processDefId) && wp.getVersion().equals(packageVersion.toString())) {
process = wp;
processDefId = wp.getId();
processFound = true;
break;
}
}
}
}
checkAppPublishedVersion(appDef);
if (!processFound) {
// specific process not found, get list of processes
if (processList != null && processList.size() == 1) {
// remove attributes to prevent passing over as url parameters
map.clear();
// redirect to the only process
WorkflowProcess wp = processList.iterator().next();
return "redirect:/web/console/app/" + appId + "/" + version + "/processes/" + wp.getIdWithoutVersion();
} else {
// show process list
map.addAttribute("processList", processList);
return "console/apps/processList";
}
}
//get activity list
Collection<WorkflowActivity> activityList = workflowManager.getProcessActivityDefinitionList(processDefId);
//add 'Run Process' activity to activityList
WorkflowActivity runProcessActivity = new WorkflowActivity();
runProcessActivity.setId(WorkflowUtil.ACTIVITY_DEF_ID_RUN_PROCESS);
runProcessActivity.setName("Run Process");
runProcessActivity.setType("normal");
activityList.add(runProcessActivity);
//remove route
Iterator iterator = activityList.iterator();
while (iterator.hasNext()) {
WorkflowActivity activity = (WorkflowActivity) iterator.next();
if (activity.getType().equals(WorkflowActivity.TYPE_ROUTE)) {
iterator.remove();
}
}
//get activity plugin mapping
Map<String, Plugin> pluginMap = new HashMap<String, Plugin>();
Map<String, PackageActivityPlugin> activityPluginMap = (packageDefinition != null) ? packageDefinition.getPackageActivityPluginMap() : new HashMap<String, PackageActivityPlugin>();
for (String activityDefId : activityPluginMap.keySet()) {
PackageActivityPlugin pap = activityPluginMap.get(activityDefId);
String pluginName = pap.getPluginName();
Plugin plugin = pluginManager.getPlugin(pluginName);
pluginMap.put(activityDefId, plugin);
}
//get activity form mapping
Map<String, PackageActivityForm> activityFormMap = (packageDefinition != null) ? packageDefinition.getPackageActivityFormMap() : new HashMap<String, PackageActivityForm>();
// get form map
Map<String, FormDefinition> formMap = new HashMap<String, FormDefinition>();
for (String activityDefId : activityFormMap.keySet()) {
PackageActivityForm paf = activityFormMap.get(activityDefId);
String formId = paf.getFormId();
if (PackageActivityForm.ACTIVITY_FORM_TYPE_SINGLE.equals(paf.getType()) && formId != null && !formId.isEmpty()) {
FormDefinition formDef = formDefinitionDao.loadById(formId, appDef);
formMap.put(activityDefId, formDef);
}
}
//get variable list
Collection<WorkflowVariable> variableList = workflowManager.getProcessVariableDefinitionList(processDefId);
//get participant list
Collection<WorkflowParticipant> participantList = workflowManager.getProcessParticipantDefinitionList(processDefId);
WorkflowParticipant processStartWhiteList = new WorkflowParticipant();
processStartWhiteList.setId("processStartWhiteList");
processStartWhiteList.setName(ResourceBundleUtil.getMessage("console.app.process.common.label.processStartWhiteList"));
processStartWhiteList.setPackageLevel(false);
participantList.add(processStartWhiteList);
// get participant map
Map<String, PackageParticipant> participantMap = (packageDefinition != null) ? packageDefinition.getPackageParticipantMap() : new HashMap<String, PackageParticipant>();
// get participant plugin map
Map<String, Plugin> participantPluginMap = pluginManager.loadPluginMap(ParticipantPlugin.class);
String processIdWithoutVersion = WorkflowUtil.getProcessDefIdWithoutVersion(processDefId);