cancel
Showing results for 
Search instead for 
Did you mean: 

myinstances feature

pavan_bukka_ait
Champ in-the-making
Champ in-the-making
Hi,
   We have developed an application using spring framework and integrated with activiti framework for implementing work flows,  things are going fine but our problem is ,in activiti-explorer2.0 project which comes from activiti distribution there is a feature for users to see their process instances in myinstancess tab by which they can understand at what stage their process is. in our application we have used jsp ,html and tiles for userinterface development how we can give the myinstancess feature which is their in  activiti-explorer project.PFA the document for the user interface we want to develop, in the picture u can see process is in first stage we want to give the same kind of feature in our application where the ui technologies we have used specified above.

Thanks in advance.
Bukka pavan kumar.
9 REPLIES 9

frederikherema1
Star Contributor
Star Contributor
Query used by activiti-explorer to get this info. It's always good to check out the activiti project from our SVN an look in there first…


List<HistoricProcessInstance> processInstances = historyService
      .createHistoricProcessInstanceQuery()
      .startedBy(ExplorerApp.get().getLoggedInUser().getId())
      .unfinished()
      .list();
   
    List<Item> items = new ArrayList<Item>();
    for (HistoricProcessInstance processInstance : processInstances) {
      items.add(createItem(processInstance));
    }
    return items;

The "startedBy" is available on the HistoricProcessInstance, so it requires the history to be on (not full, but not off)

ronald_van_kuij
Champ on-the-rise
Champ on-the-rise
Isn't kind of strange that for rumtime information, you neede the history? just like with adding comments. especially when you see the (very positive) performance figures of Activiti where enabeling history can decrease the throughput drastically.

pavan_bukka_ait
Champ in-the-making
Champ in-the-making
Hi ,
    Thank you so much for the reply .You have only replied me how to query but i also need to display the process diagram as show in the above image red mark around the Request expense task in my application.We are using jsp,html and tiles as UI technologies.

Kind regards,
Bukka pavan kumar.

frederikherema1
Star Contributor
Star Contributor
@Ronald: I guess the reason why the "startedBy" is stored in the history is that it's not really relevant for the "runtime" or "execution" of the process. If the initiator is needed in the process, this can be captured using activiti:initiator. The startedBy was added later to the history, for traceability purposes… Indeed, history has a performance impact, however for process-instance history, you don't need FULL history.

@Bukka: Check out the source code, this will get you a long way. Good starting point for what you need is org.activiti.explorer.ui.management.process.ProcessInstanceDetailPanel and  org.activiti.explorer.ui.process.ProcessDefinitionImageStreamResourceBuilder

pavan_bukka_ait
Champ in-the-making
Champ in-the-making
Hi ,
    Thanks for the reply.you have used vaadin framework for userinterface developement, but we have used jsp in spring environment . Could u tell us do we have to use vaadin framework in our application.

Kind regards,
Bukka pavan kumar.

frederikherema1
Star Contributor
Star Contributor
What UI-framework you use is entirely up to you. The classes I gave are examples of how the explorer uses the activiti API's. So you should look at the code and extract the stuff you need for your UI. In case of the diagram-image, you use the input-stream in a servlet, instead of in a Vaadin stream:


InputStream definitionImageStream = repositoryService.getResourceAsStream(
        processDefinition.getDeploymentId(), processDefinition.getDiagramResourceName());

pavan_bukka_ait
Champ in-the-making
Champ in-the-making
Hi ,
    Thank you so much for the reply. could u tell me how to switch on the history .
     I have tried this code to get the process Instances started by logged in user
List<HistoricProcessInstance> processInstances = historyService
    .createHistoricProcessInstanceQuery()
    .startedBy(user.getUserEmail())
    .unfinished()
    .list();
   but it is returning zero results.I checked the db,  In  act_hi_procinst table in activiti db START_USER_ID column is having null value, I think because of this it is returning zero result .But if i put the User Id in that column manually it is returning the result. I think since i have not turned on the history null is storing in the START_USER_ID column.

frederikherema1
Star Contributor
Star Contributor
You should always use the Authentication.setAuthenticatedUserId(…) before calling the Activiti API if you want the started by to work. And always, in a finally block, Authentication.setAuthenticatedUserId(null). This ensures the thread-local store of authentication to be empty for this tread, in car it's part of a pool.

pavan_bukka_ait
Champ in-the-making
Champ in-the-making
Thanks for the reply..

With regards,
Bukka pavan kumar.