cancel
Showing results for 
Search instead for 
Did you mean: 

Selective combination of querys

lestat86
Champ in-the-making
Champ in-the-making
Hi everyone.

i'm building a specific filter mechanism in my gui, that allows the user to select only some subset of processes based on a few different attributes (like start date, the value of certain process variables, and so on).
Being a filter, every filtering field can be present or not.
That said, i'm trying to find a way of combining pre made queries, like the following:

ProcessInstanceQuery q1 = getProcessInstance().createProcessInstanceQuery()… .involvedUser(user1);

ProcessInstanceQuery q1 = getProcessInstance().createProcessInstanceQuery()… .variableValueLike(var, value);




FinalQuery = q1 or q1 or … .listPage(start, number).

How can i implement the last part, i.e. the combining part?

Thanks a lot!
5 REPLIES 5

jbarrez
Star Contributor
Star Contributor
Currently we have only limited support for or queries. So we've got nothing out of the box sadly that would cover that. Maybe a custom query is the answer here?

lestat86
Champ in-the-making
Champ in-the-making
Hi and thanks for the reply.

Custom query might be the answer but it would be a rather complicated one… I've tried using null references and regular expressions but it doesn't work the way i expect.
Keep in mind that the user is using this filter in a multichoice way, meaning that he can select multiple value for multiple process variables and this can potentially generate null pointers like crazy (in my experience).

One way i thought it might be possible is to create a native query using string composition, but i've no idea how to print the sql of a custom generated query so i have no idea on how to modify the code…

jbarrez
Star Contributor
Star Contributor
Hmm so what about a custom Mybatis query: http://www.jorambarrez.be/blog/2014/01/17/execute-custom-sql-in-activiti/

Do note that I noticed that in the latest version the annotation approach seems to be bugged , the old-school XML counterpart does work.

echashnik
Champ in-the-making
Champ in-the-making
Did use direct connection to DB and it's work. Not sure that it's correct approach thou:

private static ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
private static RuntimeService runtimeService = processEngine.getRuntimeService();

private static String getEndPointByName(String name) throws SQLException {
  final String selEp = "SELECT PROTOCOL, HOST, PORT, PATHURI FROM ENDPOINT_CONFIGURATION WHERE NAME='" + name + "';";
  String ep = "";
  ProcessEngineConfiguration processEngineConfiguration = processEngine.getProcessEngineConfiguration();
  DataSource dataSource = processEngineConfiguration.getDataSource();
  Connection connection = dataSource.getConnection();
  PreparedStatement preparedStatement = connection.prepareStatement(selEp);
  ResultSet rs = preparedStatement.executeQuery();
  while (rs.next()) {
   String pt=rs.getString("PROTOCOL");
   String host = rs.getString("HOST");
   String port = rs.getString("PORT");
   String uri = rs.getString("PATHURI");
   ep="https://";
   if(pt.equals("0")){
    ep="http://";
   }
   ep += host;
   if (port != null) {
    ep += ":" + port;
   }
   ep += uri;
  }
  rs.close();
  preparedStatement.close();
  connection.close();
  return ep;
}

jbarrez
Star Contributor
Star Contributor
Not sure what you're trying to do here? Is this in the Alfresco BPM Suite?
If so, it's way easier of adding a custom Spring bean and injecting the corresponding Repository class to get db data.
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.