Package org.jbpm.simulation

Examples of org.jbpm.simulation.NodeStatistic


                Long numberOfProcessInstances = rs.getLong(2);
                Timestamp minTs = rs.getTimestamp(3);
                Timestamp maxTs = rs.getTimestamp(4);
               

                enterStats.put(nodeIdbam, new NodeStatistic(nodeIdbam, minTs.getTime(), maxTs.getTime(), numberOfProcessInstances));
            }
           
           
            // collect information about node exit events
            pstmt = connection.prepareStatement(GET_PROCESS_INFO_QUERY);
            pstmt.setString(1, processId);
            pstmt.setInt(2, 1);
           
            rs = pstmt.executeQuery();

            while (rs.next()) {
                String nodeIdbam = rs.getString(1);
                Long numberOfProcessInstances = rs.getLong(2);
                Timestamp minTs = rs.getTimestamp(3);
                Timestamp maxTs = rs.getTimestamp(4);
               
                exitStats.put(nodeIdbam, new NodeStatistic(nodeIdbam, minTs.getTime(), maxTs.getTime(), numberOfProcessInstances));
            }
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            if (rs != null) {
                try {
                    rs.close();
                } catch (SQLException e) {

                }
            }
           
            if (pstmt != null) {
                try {
                    pstmt.close();
                } catch (SQLException e) {

                }
            }
           
            if (connection != null) {
                try {
                    connection.close();
                } catch (SQLException e) {

                }
            }
        }
       
        // process db information and construct single map with data
       
        Iterator<String> nodes = enterStats.keySet().iterator();
        while (nodes.hasNext()) {
            Map<String, Object> nodeProperties = new HashMap<String, Object>();
            String node = (String) nodes.next();
            NodeStatistic enterStat = enterStats.get(node);
            NodeStatistic exitStat = exitStats.remove(node);
            if (exitStat != null) {
                long minExec = exitStat.getMinTimeStamp() - enterStat.getMinTimeStamp();
                long maxExec = exitStat.getMaxTimeStamp() - enterStat.getMaxTimeStamp();
           
                nodeProperties.put("duration", new Double(StatUtils.mean(new double[]{minExec, maxExec})).longValue());
                nodeProperties.put("max-exec", maxExec);
                nodeProperties.put("min-exec", minExec);
                nodeProperties.put("range", (maxExec - minExec)/2);
                nodeProperties.put("numberOfInstance", enterStat.getInstances());
            } else {
                nodeProperties.put("duration", 0);
                nodeProperties.put("max-exec", 0);
                nodeProperties.put("min-exec", 0);
                nodeProperties.put("range", 0);
                nodeProperties.put("numberOfInstance", enterStat.getInstances());
            }
            this.processStatistics.put(node, nodeProperties);
        }
       
        if (!exitStats.isEmpty()) {
            nodes = exitStats.keySet().iterator();
            while (nodes.hasNext()) {
                Map<String, Object> nodeProperties = new HashMap<String, Object>();
                String node = (String) nodes.next();
                NodeStatistic exitStat = exitStats.get(node);

                nodeProperties.put("duration", 0);
                nodeProperties.put("max-exec", 0);
                nodeProperties.put("min-exec", 0);
                nodeProperties.put("range", 0);
                nodeProperties.put("numberOfInstance", exitStat.getInstances());
               
                this.processStatistics.put(node, nodeProperties);
            }
           
        }
View Full Code Here


                Long numberOfProcessInstances = rs.getLong(2);
                Timestamp minTs = rs.getTimestamp(3);
                Timestamp maxTs = rs.getTimestamp(4);
               

                enterStats.put(nodeIdbam, new NodeStatistic(nodeIdbam, minTs.getTime(), maxTs.getTime(), numberOfProcessInstances));
            }
           
           
            // collect information about node exit events
            pstmt = connection.prepareStatement(GET_PROCESS_INFO_QUERY);
            pstmt.setString(1, processId);
            pstmt.setInt(2, 1);
           
            rs = pstmt.executeQuery();

            while (rs.next()) {
                String nodeIdbam = rs.getString(1);
                Long numberOfProcessInstances = rs.getLong(2);
                Timestamp minTs = rs.getTimestamp(3);
                Timestamp maxTs = rs.getTimestamp(4);
               
                exitStats.put(nodeIdbam, new NodeStatistic(nodeIdbam, minTs.getTime(), maxTs.getTime(), numberOfProcessInstances));
            }
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            if (rs != null) {
                try {
                    rs.close();
                } catch (SQLException e) {

                }
            }
           
            if (pstmt != null) {
                try {
                    pstmt.close();
                } catch (SQLException e) {

                }
            }
           
            if (connection != null) {
                try {
                    connection.close();
                } catch (SQLException e) {

                }
            }
        }
       
        // process db information and construct single map with data
       
        Iterator<String> nodes = enterStats.keySet().iterator();
        while (nodes.hasNext()) {
            Map<String, Object> nodeProperties = new HashMap<String, Object>();
            String node = (String) nodes.next();
            NodeStatistic enterStat = enterStats.get(node);
            NodeStatistic exitStat = exitStats.remove(node);
            if (exitStat != null) {
                long minExec = exitStat.getMinTimeStamp() - enterStat.getMinTimeStamp();
                long maxExec = exitStat.getMaxTimeStamp() - enterStat.getMaxTimeStamp();
           
                nodeProperties.put("duration", new Double(StatUtils.mean(new double[]{minExec, maxExec})).longValue());
                nodeProperties.put("max-exec", maxExec);
                nodeProperties.put("min-exec", minExec);
                nodeProperties.put("range", (maxExec - minExec)/2);
                nodeProperties.put("numberOfInstance", enterStat.getInstances());
            } else {
                nodeProperties.put("duration", 0);
                nodeProperties.put("max-exec", 0);
                nodeProperties.put("min-exec", 0);
                nodeProperties.put("range", 0);
                nodeProperties.put("numberOfInstance", enterStat.getInstances());
            }
            this.processStatistics.put(node, nodeProperties);
        }
       
        if (!exitStats.isEmpty()) {
            nodes = exitStats.keySet().iterator();
            while (nodes.hasNext()) {
                Map<String, Object> nodeProperties = new HashMap<String, Object>();
                String node = (String) nodes.next();
                NodeStatistic exitStat = exitStats.get(node);

                nodeProperties.put("duration", 0);
                nodeProperties.put("max-exec", 0);
                nodeProperties.put("min-exec", 0);
                nodeProperties.put("range", 0);
                nodeProperties.put("numberOfInstance", exitStat.getInstances());
               
                this.processStatistics.put(node, nodeProperties);
            }
           
        }
View Full Code Here

TOP

Related Classes of org.jbpm.simulation.NodeStatistic

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.