QueryServicesClient.QUERY_MAP_RAW returns n times the first value
Environment
- Red Hat JBoss BPM Suite (BPMS) 6.4
-
Executing the following query:
List<List> result = queryServicesClient.query(QueryStartup.ALL_PROCESS_INSTANCES, QueryServicesClient.QUERY_MAP_RAW, queryFilterSpec, 0, 10000, List.class);
Issue
QueryServicesClient.QUERY_MAP_RAW
returns 10000 times the first raw;
Resolution
This is a bug, reported in Red Hat BPM Suite JIRA RHBPMS-4822 and it is resolved in JBoss BPM Suite 6.4 patch update 7. Upgrade do that version when it is out.
Until this problem is fixed, already existing RawList
mapper can be extended and used instead (see attached rawlistextender.zip for source code and jar file) .
Steps to extend RawList
mapper are given below:
- Create new Maven Project - define groupId and artifactId (for instance rawlistextender);
- Make sure that dependencies are properly set in the pom.xml (
jbpm-kie-services
is needed in this case) and packaging isjar
: -
Create new class - for instance
RawListQueryMapperEx.java
:package it.demo.bpms; import java.util.ArrayList; import java.util.List; import org.dashbuilder.dataset.DataColumn; import org.dashbuilder.dataset.DataSet; import org.jbpm.kie.services.impl.query.mapper.RawListQueryMapper; public class RawListQueryMapperEx extends RawListQueryMapper { private static final long serialVersionUID = 5935133069234696713L; @Override protected List<Object> buildInstance(DataSet dataSetResult, int index) { List<Object> row = new ArrayList<Object>(); for (DataColumn column : dataSetResult.getColumns()) { row.add(dataSetResult.getColumnById(column.getId()).getValues().get(index)); } return row; } @Override public String getName() { return "RawListExtended"; } }
-
Navigate to
src/main/resources
and createMETA-INF/services
; - Add new File:
org.jbpm.services.api.query.QueryResultMapper
; - Open
org.jbpm.services.api.query.QueryResultMapper
file and add the name of the extended mapperit.demo.bpms.RawListQueryMapperEx
; - Save above changes and build the project;
-
Copy built project to the kie-server's
WEB-INF/lib
folder - for instance:$ cp rawlistextender-0.0.1-SNAPSHOT.jar $KIE_SERVER_HOME/deployments/kie-server.war/WEB-INF/lib
-
Replace
QueryServicesClient.QUERY_MAP_RAW
with "RawListExtended" - for instance:List<List> result = queryServicesClient.query(QueryStartup.ALL_PROCESS_INSTANCES, "RawListExtended", queryFilterSpec, 0, 10000, List.class);
-
Save and redeploy the project;
Root Cause
RawListResultMapper
does not properly handle multiple rows due to a type of fetching values from data set.
Attachments
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.
Comments