Package org.kie.services.client.serialization.jaxb.impl.query

Examples of org.kie.services.client.serialization.jaxb.impl.query.JaxbQueryProcessInstanceResult


        int[] pageInfo = getPageNumAndPageSize(params, oper);
        int maxNumResults = getMaxNumResultsNeeded(pageInfo);

        String identityNotNeeded = null;
        InternalProcInstQueryHelper queryHelper = new InternalProcInstQueryHelper(this);
        JaxbQueryProcessInstanceResult result
            = queryHelper.queryTaskOrProcInstAndAssociatedVariables(identityNotNeeded, params, pageInfo, maxNumResults);
        queryHelper.dispose();

        return createCorrectVariant(result, headers);
    }
View Full Code Here


        int [] pageInfo = { 0, 10 };
        int maxResults = 1000;
        Map<String, String[]> queryParams = new HashMap<String, String[]>();
       
        // simple (everything)
        JaxbQueryProcessInstanceResult result = queryProcInstHelper.queryTasksOrProcInstsAndVariables(queryParams, pageInfo, maxResults);
        assertNotNull( "null result", result );
        assertFalse( "empty result (all)", result.getProcessInstanceInfoList().isEmpty() );
        assertTrue( "not enough proc info's: " + result.getProcessInstanceInfoList().size(), result.getProcessInstanceInfoList().size() > 2 );
        long procInstMin = Long.MAX_VALUE;
        long procInstMax = -1l;
        for( JaxbQueryProcessInstanceInfo procInfo : result.getProcessInstanceInfoList() ) {
           long procInstId = procInfo.getProcessInstance().getId();
           if( procInstId > procInstMax ) {
               procInstMax = procInstId;
           }
           if( procInstId < procInstMin ) {
               procInstMin = procInstId;
           }
           String procId = procInfo.getProcessInstance().getProcessId();
           boolean myType = procId.contains("object");
           for( JaxbVariableInfo varInfo : procInfo.getVariables() ) {
               String varVal = (String) varInfo.getValue();
               String varName = varInfo.getName();
               assertTrue( procId + ": var value [" + varVal + "]", varVal.contains("{") || ! myType );
               assertTrue( procInstId + ": var value [" + varVal + "]", varVal.contains("check") || ! varName.equals("inputStr"));
           }
        }
      
        roundTripJson(result);
        roundTripXml(result);
      
        // complicated
        Long procInstId = null;
        String varName = null;
        String varVal = null;
        for( JaxbQueryProcessInstanceInfo procInfo : result.getProcessInstanceInfoList() ) {
            if( procInfo.getProcessInstance().getProcessId().equals(PROCESS_OBJ_VAR_ID) ) {
                procInstId = procInfo.getProcessInstance().getId();
                JaxbVariableInfo varInfo = procInfo.getVariables().get(0);
                if( ! varInfo.getName().equals("inputStr") ) {
                   varInfo = procInfo.getVariables().get(1);
                }
                varName = varInfo.getName();
                varVal = (String) varInfo.getValue();
                break;
            }
        }
        assertNotNull( "proc inst id", procInstId );
        assertNotNull( "var id", varName );
        assertNotNull( "var value ", varVal );
    
        addParams(queryParams, "processinstanceid", procInstId + "");
        addParams(queryParams, "processid_re", "*" + PROCESS_OBJ_VAR_ID.substring(10));
      
        Calendar cal = GregorianCalendar.getInstance();
        cal.roll(Calendar.DAY_OF_YEAR, +2);
        String tomorowStr = QUERY_PARAM_DATE_FORMAT.format(cal.getTime()).substring(0, 8);
        addParams(queryParams, "enddate_max", tomorowStr);
        String yesterdayStr = "00:00:01";
        addParams(queryParams, "stdt_min", yesterdayStr);
        addParams(queryParams, "var_" + varName, varVal );
       
        result = queryProcInstHelper.queryTasksOrProcInstsAndVariables(queryParams, pageInfo, maxResults);
        assertNotNull( "null result", result );
        assertFalse( "empty result", result.getProcessInstanceInfoList().isEmpty() );
        assertTrue( "more than 1 result", result.getProcessInstanceInfoList().size() == 1 );
        JaxbQueryProcessInstanceInfo procInfo = result.getProcessInstanceInfoList().get(0);
        assertNotNull( "no proc instance", procInfo.getProcessInstance() );
        assertEquals( "num variables", 1, procInfo.getVariables().size() );
     
        roundTripJson(result);
        roundTripXml(result);
      
        // more complicated
        queryParams.clear();
        --procInstMax;
        ++procInstMin;
        addParams(queryParams, "piid_min", String.valueOf(procInstMin));
        addParams(queryParams, "processinstanceid_max", String.valueOf(procInstMax));
        result = queryProcInstHelper.queryTasksOrProcInstsAndVariables(queryParams, pageInfo, maxResults);
        assertNotNull( "null result", result );
        assertFalse( "empty result", result.getProcessInstanceInfoList().isEmpty() );
        assertEquals( "number results", procInstMax - procInstMin+1, result.getProcessInstanceInfoList().size() );
        long findMin = Long.MAX_VALUE;
        long findMax = -1;
        for( JaxbQueryProcessInstanceInfo jaxbProcInfo : result.getProcessInstanceInfoList() ) {
           procInstId = jaxbProcInfo.getProcessInstance().getId();
           if( procInstId > findMax ) {
               findMax = procInstId;
           }
           if( procInstId < findMin ) {
               findMin = procInstId;
           }
        }
        assertEquals( "process instance id max", procInstMax, findMax );
        assertEquals( "process instance id min", procInstMin, findMin );
       
        // test bad parameter
        addParams(queryParams, "taskowner", USER_ID );
        boolean exThrown = false;
        try {
            result = queryProcInstHelper.queryTasksOrProcInstsAndVariables(queryParams, pageInfo, maxResults);
        } catch( Exception e ) {
           exThrown = true;
        }
        assertTrue( "Exception not thrown on invalid parameter 'taskowner'", exThrown);
     
       
        // varregex test
        queryParams.clear();
        addParams(queryParams, "processinstanceid", procInstId + "");
        addParams(queryParams, "processid_re", "*" + PROCESS_OBJ_VAR_ID.substring(10));
      
        addParams(queryParams, "vr_" + varName, "X" + varVal.substring(0, 3) + "*" );
       
        result = queryProcInstHelper.queryTasksOrProcInstsAndVariables(queryParams, pageInfo, maxResults);
        assertNotNull( "null result", result );
        assertTrue( "Expected empty result: " + result.getProcessInstanceInfoList().size(), result.getProcessInstanceInfoList().isEmpty() );
    }
View Full Code Here

                // TODO: retrieve process instance variables instead of log string values
            }
        }

        // create result
        JaxbQueryProcessInstanceResult result = createProcessInstanceResult(procLogs, varLogs, procVars);
        return result;
    }
View Full Code Here

    private JaxbQueryProcessInstanceResult createProcessInstanceResult(
            List<ProcessInstanceLog> procLogs,
            List<VariableInstanceLog> varLogs,
            List<JaxbVariableInfo> processVariables ) {
        JaxbQueryProcessInstanceResult result = new JaxbQueryProcessInstanceResult();

        Map<Long, JaxbQueryProcessInstanceInfo> procInstIdProcInstInfoMap = new HashMap<Long, JaxbQueryProcessInstanceInfo>();
        for( ProcessInstanceLog procLog : procLogs ) {
            long procInstId = procLog.getProcessInstanceId();
            JaxbQueryProcessInstanceInfo procInfo = getQueryProcessInstanceInfo(procInstId, procInstIdProcInstInfoMap);
            procInfo.setProcessInstance(new JaxbProcessInstance(procLog));
        }
        for( VariableInstanceLog varLog : varLogs ) {
            long procInstId = varLog.getProcessInstanceId();
            JaxbQueryProcessInstanceInfo procInfo = procInstIdProcInstInfoMap.get(procInstId);
            if( procInfo == null ) {
                throwDebugExceptionWithQueryInformation();
            }
            procInfo.getVariables().add(new JaxbVariableInfo(varLog));
        }

        result.getProcessInstanceInfoList().addAll(procInstIdProcInstInfoMap.values());
        return result;
    }
View Full Code Here

TOP

Related Classes of org.kie.services.client.serialization.jaxb.impl.query.JaxbQueryProcessInstanceResult

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.