AnsweredAssumed Answered

startableByUser not returning results

Question asked by ykphuah on Oct 6, 2015
Latest reply on Oct 7, 2015 by ykphuah
I am trying to make use of the candidateStartUser field in the process definition, to be able to filter the deployed processes that can be started by a user, I have tried the following but it doesn't return any process definitions:


ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
if (processEngine == null) {
    logger.error("Could not start the Activiti Engine");
    return;
}

RepositoryService repositoryService = processEngine.getRepositoryService();
FormService formService = processEngine.getFormService();
TaskService taskService = processEngine.getTaskService();
IdentityService identityService = processEngine.getIdentityService();

// tried to create a new user using identity service, but still no impact
User kermit = identityService.newUser("kermit");
logger.info("Created kermit user:id=" + kermit.getId());
identityService.saveUser(kermit);

// tried setting authenticated user id as well, no impact
identityService.setAuthenticatedUserId("kermit");

DeploymentBuilder deploymentBuilder = repositoryService.createDeployment();

try {
    InputStream is = new FileInputStream(new File("C:/Users/Yee_Keat/Development/Adama/MyProcess.bpmn"));
    deploymentBuilder.addInputStream("MyProcess", is);
    Deployment deployment = deploymentBuilder.deploy();
    logger.info("Deployed:id=" + deployment.getId() + ",name=" + deployment.getName());
    is.close();
} catch (IOException e) {
    logger.error("failed to deploy", e);
} catch (ActivitiException e) {
    logger.error("failed to deploy", e);
}

List<ProcessDefinition> startableByKermit = repositoryService.createProcessDefinitionQuery().startableByUser(kermit.getId()).list();

// expecting to see some results from here, as my file have candidateStartUser=kermit configured
logger.info("processes that can be started by kermit = " + startableByKermit.size());
for (ProcessDefinition p : processDefinitions) {
    logger.info("Process Definition:id=" + p.getId() + ",name=" + p.getName());
}

Outcomes