cancel
Showing results for 
Search instead for 
Did you mean: 

How to get a list of caracteristics of an active process ?

cnirparis
Champ in-the-making
Champ in-the-making
This topic has already been treated in this forum, unfortunately no solution works in my configuration (Activiti 5.15).
The problem is that when i do :


      RepositoryServiceImpl repo = (RepositoryServiceImpl) processEngine.getRepositoryService();
      ProcessDefinitionEntity pde = (ProcessDefinitionEntity) repositoryService
            .createProcessDefinitionQuery()
            .processDefinitionKey("MyProcessDefinitionKey")
            .latestVersion().singleResult();
      pde = (ProcessDefinitionEntity) repo.getDeployedProcessDefinition(pde.getId());
      Properties prop = new Properties();
      prop.load(new StringReader(pde.getDescription()));
      System.out.println(prop.getProperty("context"));
      System.out.println(prop.getProperty("desc"));
      System.out.println("process: " + pde.getDescription());
                Map<String,TaskDefinition> MyTableTasks = pde.getTaskDefinitions();

I always get a null object in "MyTableTasks".
Perhaps this no longer works in 5.15 ?
Thank you if anyone has a working solution.

6 REPLIES 6

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi,

Could you create jUnit test for it? (with process definition you use).

Regards
Martin

cnirparis
Champ in-the-making
Champ in-the-making
I do not see what it could change ?

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi,

what it could change ?

I created jUnit test as you describe. (processDefinitionKey differs, because I did not have your process definition)

  @Deployment(resources = {
    "org/activiti/engine/test/api/oneTaskProcess.bpmn20.xml"})
  public void testNPE() throws IOException {
    RepositoryServiceImpl repo = (RepositoryServiceImpl) processEngine.getRepositoryService();
    ProcessDefinitionEntity pde = (ProcessDefinitionEntity) repositoryService
      .createProcessDefinitionQuery()
      .processDefinitionKey("oneTaskProcess")
      .latestVersion().singleResult();
    pde = (ProcessDefinitionEntity) repo.getDeployedProcessDefinition(pde.getId());
    Properties prop = new Properties();
    prop.load(new StringReader(pde.getDescription()));
    System.out.println(prop.getProperty("context"));
    System.out.println(prop.getProperty("desc"));
    System.out.println("process: " + pde.getDescription());
    Map<String, TaskDefinition> MyTableTasks = pde.getTaskDefinitions();
  }

I was not able to reproduce your issue (jUnit test passed). If you create failing jUnit test it would be much easier to solve your problem.

Regards
Martin

cnirparis
Champ in-the-making
Champ in-the-making
if I add in the jUnit test (after the code shown above) :
<code>assertNotNull(pde.getDescription());</code>
the assertion fails, so it is actually null.

It's strange because <code>pde.getId();</code>
is not null and contains the process Id.
By the way, the <code>ProcessDefinitionEntity</code> class is not documented in the Activiti API 5.15 javadocs.
Perhaps there is an other way to do what I want.

Thank you for trying to solve my problem.

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi,

I added two assertions to the jUnit test:


  @Deployment(resources = {
    "org/activiti/engine/test/api/oneTaskProcess.bpmn20.xml"})
  public void testNPE() throws IOException {
    RepositoryServiceImpl repo = (RepositoryServiceImpl) processEngine.getRepositoryService();
    ProcessDefinitionEntity pde = (ProcessDefinitionEntity) repositoryService
      .createProcessDefinitionQuery()
      .processDefinitionKey("oneTaskProcess")
      .latestVersion().singleResult();
    pde = (ProcessDefinitionEntity) repo.getDeployedProcessDefinition(pde.getId());
    Properties prop = new Properties();
    prop.load(new StringReader(pde.getDescription()));
    System.out.println(prop.getProperty("context"));
    System.out.println(prop.getProperty("desc"));
    System.out.println("process: " + pde.getDescription());
    Map<String, TaskDefinition> myTableTasks = pde.getTaskDefinitions();
    assertNotNull(myTableTasks);
    assertNotNull(pde.getDescription());
  }

Test still passes.
Could you create failing jUnit test, please?

Regards
Martin

cnirparis
Champ in-the-making
Champ in-the-making
I've finally solved the problem doing a direct SQL Query.

Thank you M. Grofčík