Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Process Manager (Stardust) » Using DataFilter IN on ActivityInstanceQuery(Using DataFilter IN on ActivityInstanceQuery)
Using DataFilter IN on ActivityInstanceQuery [message #853817] Mon, 23 April 2012 07:08 Go to next message
Vikram Kodak is currently offline Vikram Kodak
Messages: 57
Registered: October 2011
Member
Hi,

We have a requirement wherein we need to find the process OID having a certain activity in hibernated state.

Currently we are following an approach that we first find all process OIDs using getQueryService().getAllProcessInstances(processInstanceQuery). We have applied the required filter criteria for application to this query using processInstanceQuery.where().

We then iterate over all the process instances found as a result of above query to find desired activity in hibernated state. We use following code for the same.

for (ProcessInstance processInstance : instances) {
ActivityInstanceQuery activityInstanceQuery = ActivityInstanceQuery.findInState(state);
long pOid = processInstance.getOID();
activityInstanceQuery.where(PROCESS_INSTANCE_OID.isEqual(pOid)).and(
ActivityFilter.forAnyProcess(activityId));
.
.
.
.
}

The customer has performance issue in this flow.

Apparently ActivityInstanceQuery does not change except the process instance OID. Is there any configuration we can use to create prepared statement for such repetitive queries?

Also is it possible to avoid this looping by passing all process instance OIDs in one query inside IN criteria rather than looping through a list and querying database every time. I found DataFilter from Stardust API with IN method but I am not sure I can use it in this case to find activities
Re: Using DataFilter IN on ActivityInstanceQuery [message #853823 is a reply to message #853817] Mon, 23 April 2012 07:11 Go to previous messageGo to next message
Vikram Kodak is currently offline Vikram Kodak
Messages: 57
Registered: October 2011
Member
Hi,

You can apply the DataFilter.in filter on the ActivityInstanceQuery and passing the instance OID's.

Please refer the class ag.carnot.workflow.query.DataFilter

Function:

static DataFilter in(String dataID, Collection values)
Creates a filter matching workflow data being equal one of the given values.
Re: Using DataFilter IN on ActivityInstanceQuery [message #854790 is a reply to message #853823] Tue, 24 April 2012 04:34 Go to previous messageGo to next message
Vikram Kodak is currently offline Vikram Kodak
Messages: 57
Registered: October 2011
Member
Hi,

Can you please specify your requirement
Re: Using DataFilter IN on ActivityInstanceQuery [message #854794 is a reply to message #854790] Tue, 24 April 2012 04:37 Go to previous messageGo to next message
Vikram Kodak is currently offline Vikram Kodak
Messages: 57
Registered: October 2011
Member
We have a requirement as described below:
XXX is the process in our application and has fields A and B in process data. On UI user selects A and B and we need to find all process instances having selected A and B in process data AND the process having a certain activity in hibernated state. We need this information from Stardust database.

Firstly we get all the process instances for selected A and B. We then iterate over all instances found and use ActivityInstanceQuery to get hibernated activities. We need to optimize this code since clients have reported performance issue in this code.
Re: Using DataFilter IN on ActivityInstanceQuery [message #854829 is a reply to message #854794] Tue, 24 April 2012 05:11 Go to previous message
Vikram Kodak is currently offline Vikram Kodak
Messages: 57
Registered: October 2011
Member
As we understand your requirements, it can be achieve with this single query, assuming that you make the third data a descriptor:


public class AiQuery {

      public static void main(String[] args) {

            ServiceFactory sf = ServiceFactoryLocator.get("motu", "motu");

            QueryService qs = sf.getQueryService();

            ActivityInstanceQuery aiq = ActivityInstanceQuery
                        .findInStateHavingData("Hibernation", "HibernatedActivity",
                                    "Data1", "daat1", ActivityInstanceState.Hibernated);

            aiq.where(DataFilter.isEqual("Data2", "daat2"));
            aiq.setPolicy(DescriptorPolicy.WITH_DESCRIPTORS);
            
            ActivityInstances ais = qs.getAllActivityInstances(aiq);

            for (Iterator iterator = ais.iterator(); iterator.hasNext();) {
                  ActivityInstance ai = (ActivityInstance) iterator.next();
                  ProcessInstanceDetails piD = (ProcessInstanceDetails) ai.getProcessInstance();
                  
                  System.out.println("AI: " + ai.getOID() + " PI: " + ai.getProcessInstance().getOID() + " Data3:" + piD.getDescriptorValue("Data3"));
            }
            sf.close();

      }
}

[Updated on: Tue, 24 April 2012 05:12]

Report message to a moderator

Previous Topic:Problem with Install
Next Topic:Find process instances having 2 data and a specific activity in hibernated state
Goto Forum:
  


Current Time: Sat Apr 19 11:48:00 EDT 2014

Powered by FUDForum. Page generated in 0.01666 seconds