Search in sources :

Example 6 with UserTaskInstanceWithVarsDesc

use of org.jbpm.services.api.model.UserTaskInstanceWithVarsDesc in project jbpm by kiegroup.

the class UserTaskInstanceWithCustomVarsQueryMapper method map.

@Override
public List<UserTaskInstanceWithVarsDesc> map(Object result) {
    if (result instanceof DataSet) {
        DataSet dataSetResult = (DataSet) result;
        List<UserTaskInstanceWithVarsDesc> mappedResult = new ArrayList<UserTaskInstanceWithVarsDesc>();
        if (dataSetResult != null) {
            Map<Long, UserTaskInstanceWithVarsDesc> tmp = new HashMap<Long, UserTaskInstanceWithVarsDesc>();
            for (int i = 0; i < dataSetResult.getRowCount(); i++) {
                Long taskId = getColumnLongValue(dataSetResult, COLUMN_TASKID, i);
                UserTaskInstanceWithVarsDesc ut = tmp.get(taskId);
                if (ut == null) {
                    ut = buildInstance(dataSetResult, i);
                    mappedResult.add(ut);
                    tmp.put(taskId, ut);
                }
                Map<String, Object> variables = readVariables(variablesMap, dataSetResult, i);
                ((org.jbpm.kie.services.impl.model.UserTaskInstanceWithVarsDesc) ut).setVariables(variables);
            }
        }
        return mappedResult;
    }
    throw new IllegalArgumentException("Unsupported result for mapping " + result);
}
Also used : DataSet(org.dashbuilder.dataset.DataSet) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) UserTaskInstanceWithVarsDesc(org.jbpm.services.api.model.UserTaskInstanceWithVarsDesc)

Aggregations

HashMap (java.util.HashMap)6 UserTaskInstanceWithVarsDesc (org.jbpm.services.api.model.UserTaskInstanceWithVarsDesc)6 SqlQueryDefinition (org.jbpm.kie.services.impl.query.SqlQueryDefinition)4 Test (org.junit.Test)4 QueryContext (org.kie.api.runtime.query.QueryContext)4 AbstractKieServicesBaseTest (org.jbpm.kie.test.util.AbstractKieServicesBaseTest)3 ArrayList (java.util.ArrayList)2 DataSet (org.dashbuilder.dataset.DataSet)2 RuntimeManager (org.kie.api.runtime.manager.RuntimeManager)2 AdvancedQueryContext (org.kie.api.runtime.query.AdvancedQueryContext)2 InternalRuntimeManager (org.kie.internal.runtime.manager.InternalRuntimeManager)2 Calendar (java.util.Calendar)1 Date (java.util.Date)1 Random (java.util.Random)1