Package org.apache.jetspeed.statistics

Examples of org.apache.jetspeed.statistics.InvalidCriteriaException


        {
            tableName = "PAGE_STATISTICS";
            groupColumn = "PAGE";
        } else
        {
            throw new InvalidCriteriaException(
                    " invalid queryType passed to queryStatistics");
        }
        String orderColumn = "itemcount";

        String ascDesc = "DESC";

        if (!PortalStatistics.QUERY_TYPE_USER.equals(queryType))
        {
            query = "select count(*) as itemcount , MIN(ELAPSED_TIME) as amin ,AVG(ELAPSED_TIME) as aavg ,MAX(ELAPSED_TIME) as amax from "
                    + tableName + " where time_stamp > ? and time_stamp < ?";
            query2 = "select count(*) as itemcount ,"
                    + groupColumn
                    + ", MIN(ELAPSED_TIME) as amin ,AVG(ELAPSED_TIME) as aavg ,MAX(ELAPSED_TIME) as amax "
                    + "from " + tableName
                    + " where time_stamp > ? and time_stamp < ? group by "
                    + groupColumn + "  order by " + orderColumn + " " + ascDesc;
        } else
        {
            query = "select count(*) as itemcount , MIN(ELAPSED_TIME) as amin,AVG(ELAPSED_TIME) as aavg ,MAX(ELAPSED_TIME) as amax from "
                    + tableName
                    + " where time_stamp > ? and time_stamp < ? and status = 2";
            query2 = "select count(*) as itemcount ,"
                    + groupColumn
                    + ", MIN(ELAPSED_TIME) as amin ,AVG(ELAPSED_TIME) as aavg ,MAX(ELAPSED_TIME) as amax "
                    + "from "
                    + tableName
                    + " where time_stamp > ? and time_stamp < ? and status = 2 group by "
                    + groupColumn + "  order by " + orderColumn + " " + ascDesc;
        }
        Connection con = null;
        try
        {
            con = ds.getConnection();
            PreparedStatement pstmt = con.prepareStatement(query);
            pstmt.setTimestamp(1, new Timestamp(start.getTime()));
            pstmt.setTimestamp(2, new Timestamp(end.getTime()));
            ResultSet rs = pstmt.executeQuery();
            float denominator = 1.0f;
            if (PortalStatistics.QUERY_TYPE_USER.equals(queryType))
            {
                denominator = 1000f * 60f; // this should convert from mS to
                                           // minutes
            }
            if (rs.next())
            {
                as.setHitCount(rs.getInt("itemcount"));

                as.setMinProcessingTime(rs.getFloat("amin") / denominator);
                as.setAvgProcessingTime(rs.getFloat("aavg") / denominator);
                as.setMaxProcessingTime(rs.getFloat("amax") / denominator);

            }
            PreparedStatement pstmt2 = con.prepareStatement(query2);
            pstmt2.setTimestamp(1, new Timestamp(start.getTime()));
            pstmt2.setTimestamp(2, new Timestamp(end.getTime()));
            ResultSet rs2 = pstmt2.executeQuery();

            int rowCount = 0;
            int totalRows = 5;
            String listsizeStr = criteria.getListsize();
            int temp = -1;
            try
            {
                temp = Integer.parseInt(listsizeStr);
            }
            catch (NumberFormatException e)
            {
            }
            if(temp != -1) {
                totalRows = temp;
            }
           
            while ((rs2.next()) && (rowCount < totalRows))
            {
                Map row = new HashMap();
                row.put("count", "" + rs2.getInt("itemcount"));
                String col = rs2.getString(groupColumn);
                int maxColLen = 35;
                if (col != null)
                {

                    if (col.length() > maxColLen)
                    {
                        col = col.substring(0, maxColLen);
                    }
                }

                row.put("groupColumn", col);
                row.put("min", ""
                        + floatFormatter(rs2.getFloat("amin") / denominator));
                row.put("avg", ""
                        + floatFormatter(rs2.getFloat("aavg") / denominator));
                row.put("max", ""
                        + floatFormatter(rs2.getFloat("amax") / denominator));
                as.addRow(row);
                rowCount++;
            }

        }
        catch (SQLException e)
        {
            throw new InvalidCriteriaException(e.toString());
        }
        finally
        {
            try
            {
View Full Code Here


        {
            tableName = "PAGE_STATISTICS";
            groupColumn = "PAGE";
        } else
        {
            throw new InvalidCriteriaException(
                    " invalid queryType passed to queryStatistics");
        }
        String orderColumn = "itemcount";

        String ascDesc = "DESC";

        if (!PortalStatistics.QUERY_TYPE_USER.equals(queryType))
        {
            query = "select count(*) as itemcount , MIN(ELAPSED_TIME) as amin ,AVG(ELAPSED_TIME) as aavg ,MAX(ELAPSED_TIME) as amax from "
                    + tableName + " where time_stamp > ? and time_stamp < ?";
            query2 = "select count(*) as itemcount ,"
                    + groupColumn
                    + ", MIN(ELAPSED_TIME) as amin ,AVG(ELAPSED_TIME) as aavg ,MAX(ELAPSED_TIME) as amax "
                    + "from " + tableName
                    + " where time_stamp > ? and time_stamp < ? group by "
                    + groupColumn + "  order by " + orderColumn + " " + ascDesc;
        } else
        {
            query = "select count(*) as itemcount , MIN(ELAPSED_TIME) as amin,AVG(ELAPSED_TIME) as aavg ,MAX(ELAPSED_TIME) as amax from "
                    + tableName
                    + " where time_stamp > ? and time_stamp < ? and status = 2";
            query2 = "select count(*) as itemcount ,"
                    + groupColumn
                    + ", MIN(ELAPSED_TIME) as amin ,AVG(ELAPSED_TIME) as aavg ,MAX(ELAPSED_TIME) as amax "
                    + "from "
                    + tableName
                    + " where time_stamp > ? and time_stamp < ? and status = 2 group by "
                    + groupColumn + "  order by " + orderColumn + " " + ascDesc;
        }
        Connection con = null;
        try
        {
            con = ds.getConnection();
            PreparedStatement pstmt = con.prepareStatement(query);
            pstmt.setTimestamp(1, new Timestamp(start.getTime()));
            pstmt.setTimestamp(2, new Timestamp(end.getTime()));
            ResultSet rs = pstmt.executeQuery();
            float denominator = 1.0f;
            if (PortalStatistics.QUERY_TYPE_USER.equals(queryType))
            {
                denominator = 1000f * 60f; // this should convert from mS to
                                           // minutes
            }
            if (rs.next())
            {
                as.setHitCount(rs.getInt("itemcount"));

                as.setMinProcessingTime(rs.getFloat("amin") / denominator);
                as.setAvgProcessingTime(rs.getFloat("aavg") / denominator);
                as.setMaxProcessingTime(rs.getFloat("amax") / denominator);

            }
            PreparedStatement pstmt2 = con.prepareStatement(query2);
            pstmt2.setTimestamp(1, new Timestamp(start.getTime()));
            pstmt2.setTimestamp(2, new Timestamp(end.getTime()));
            ResultSet rs2 = pstmt2.executeQuery();

            int rowCount = 0;
            int totalRows = 5;
            String listsizeStr = criteria.getListsize();
            int temp = -1;
            try
            {
                temp = Integer.parseInt(listsizeStr);
            }
            catch (NumberFormatException e)
            {
            }
            if(temp != -1) {
                totalRows = temp;
            }
           
            while ((rs2.next()) && (rowCount < totalRows))
            {
                Map row = new HashMap();
                row.put("count", "" + rs2.getInt("itemcount"));
                String col = rs2.getString(groupColumn);
                int maxColLen = 35;
                if (col != null)
                {

                    if (col.length() > maxColLen)
                    {
                        col = col.substring(0, maxColLen);
                    }
                }

                row.put("groupColumn", col);
                row.put("min", ""
                        + floatFormatter(rs2.getFloat("amin") / denominator));
                row.put("avg", ""
                        + floatFormatter(rs2.getFloat("aavg") / denominator));
                row.put("max", ""
                        + floatFormatter(rs2.getFloat("amax") / denominator));
                as.addRow(row);
                rowCount++;
            }

        }
        catch (SQLException e)
        {
            throw new InvalidCriteriaException(e.toString());
        }
        finally
        {
            try
            {
View Full Code Here

        {
            tableName = "PAGE_STATISTICS";
            groupColumn = "PAGE";
        } else
        {
            throw new InvalidCriteriaException(
                    " invalid queryType passed to queryStatistics");
        }
        String orderColumn = "itemcount";

        String ascDesc = "DESC";

        if (!PortalStatistics.QUERY_TYPE_USER.equals(queryType))
        {
            query = "select count(*) as itemcount , MIN(ELAPSED_TIME) as amin ,AVG(ELAPSED_TIME) as aavg ,MAX(ELAPSED_TIME) as amax from "
                    + tableName + " where time_stamp > ? and time_stamp < ?";
            query2 = "select count(*) as itemcount ,"
                    + groupColumn
                    + ", MIN(ELAPSED_TIME) as amin ,AVG(ELAPSED_TIME) as aavg ,MAX(ELAPSED_TIME) as amax "
                    + "from " + tableName
                    + " where time_stamp > ? and time_stamp < ? group by "
                    + groupColumn + "  order by " + orderColumn + " " + ascDesc;
        } else
        {
            query = "select count(*) as itemcount , MIN(ELAPSED_TIME) as amin,AVG(ELAPSED_TIME) as aavg ,MAX(ELAPSED_TIME) as amax from "
                    + tableName
                    + " where time_stamp > ? and time_stamp < ? and status = 2";
            query2 = "select count(*) as itemcount ,"
                    + groupColumn
                    + ", MIN(ELAPSED_TIME) as amin ,AVG(ELAPSED_TIME) as aavg ,MAX(ELAPSED_TIME) as amax "
                    + "from "
                    + tableName
                    + " where time_stamp > ? and time_stamp < ? and status = 2 group by "
                    + groupColumn + "  order by " + orderColumn + " " + ascDesc;
        }
        Connection con = null;
        try
        {
            con = ds.getConnection();
            PreparedStatement pstmt = con.prepareStatement(query);
            pstmt.setTimestamp(1, new Timestamp(start.getTime()));
            pstmt.setTimestamp(2, new Timestamp(end.getTime()));
            ResultSet rs = pstmt.executeQuery();
            float denominator = 1.0f;
            if (PortalStatistics.QUERY_TYPE_USER.equals(queryType))
            {
                denominator = 1000f * 60f; // this should convert from mS to
                                           // minutes
            }
            if (rs.next())
            {
                as.setHitCount(rs.getInt("itemcount"));

                as.setMinProcessingTime(rs.getFloat("amin") / denominator);
                as.setAvgProcessingTime(rs.getFloat("aavg") / denominator);
                as.setMaxProcessingTime(rs.getFloat("amax") / denominator);

            }
            PreparedStatement pstmt2 = con.prepareStatement(query2);
            pstmt2.setTimestamp(1, new Timestamp(start.getTime()));
            pstmt2.setTimestamp(2, new Timestamp(end.getTime()));
            ResultSet rs2 = pstmt2.executeQuery();

            int rowCount = 0;
            int totalRows = 5;
            String listsizeStr = criteria.getListsize();
            int temp = -1;
            try
            {
                temp = Integer.parseInt(listsizeStr);
            }
            catch (NumberFormatException e)
            {
            }
            if(temp != -1) {
                totalRows = temp;
            }
           
            while ((rs2.next()) && (rowCount < totalRows))
            {
                Map row = new HashMap();
                row.put("count", "" + rs2.getInt("itemcount"));
                String col = rs2.getString(groupColumn);
                int maxColLen = 35;
                if (col != null)
                {

                    if (col.length() > maxColLen)
                    {
                        col = col.substring(0, maxColLen);
                    }
                }

                row.put("groupColumn", col);
                row.put("min", ""
                        + floatFormatter(rs2.getFloat("amin") / denominator));
                row.put("avg", ""
                        + floatFormatter(rs2.getFloat("aavg") / denominator));
                row.put("max", ""
                        + floatFormatter(rs2.getFloat("amax") / denominator));
                as.addRow(row);
                rowCount++;
            }

        }
        catch (SQLException e)
        {
            throw new InvalidCriteriaException(e.toString());
        }
        finally
        {
            try
            {
View Full Code Here

        {
            tableName = "PAGE_STATISTICS";
            groupColumn = "PAGE";
        } else
        {
            throw new InvalidCriteriaException(
                    " invalid queryType passed to queryStatistics");
        }
        String orderColumn = "itemcount";

        String ascDesc = "DESC";

        if (!PortalStatistics.QUERY_TYPE_USER.equals(queryType))
        {
            query = "select count(*) as itemcount , MIN(ELAPSED_TIME) as amin ,AVG(ELAPSED_TIME) as aavg ,MAX(ELAPSED_TIME) as amax from "
                    + tableName + " where time_stamp > ? and time_stamp < ?";
            query2 = "select count(*) as itemcount ,"
                    + groupColumn
                    + ", MIN(ELAPSED_TIME) as amin ,AVG(ELAPSED_TIME) as aavg ,MAX(ELAPSED_TIME) as amax "
                    + "from " + tableName
                    + " where time_stamp > ? and time_stamp < ? group by "
                    + groupColumn + "  order by " + orderColumn + " " + ascDesc;
        } else
        {
            query = "select count(*) as itemcount , MIN(ELAPSED_TIME) as amin,AVG(ELAPSED_TIME) as aavg ,MAX(ELAPSED_TIME) as amax from "
                    + tableName
                    + " where time_stamp > ? and time_stamp < ? and status = 2";
            query2 = "select count(*) as itemcount ,"
                    + groupColumn
                    + ", MIN(ELAPSED_TIME) as amin ,AVG(ELAPSED_TIME) as aavg ,MAX(ELAPSED_TIME) as amax "
                    + "from "
                    + tableName
                    + " where time_stamp > ? and time_stamp < ? and status = 2 group by "
                    + groupColumn + "  order by " + orderColumn + " " + ascDesc;
        }
        Connection con = null;
        try
        {
            con = ds.getConnection();
            PreparedStatement pstmt = con.prepareStatement(query);
            pstmt.setTimestamp(1, new Timestamp(start.getTime()));
            pstmt.setTimestamp(2, new Timestamp(end.getTime()));
            ResultSet rs = pstmt.executeQuery();
            float denominator = 1.0f;
            if (PortalStatistics.QUERY_TYPE_USER.equals(queryType))
            {
                denominator = 1000f * 60f; // this should convert from mS to
                                           // minutes
            }
            if (rs.next())
            {
                as.setHitCount(rs.getInt("itemcount"));

                as.setMinProcessingTime(rs.getFloat("amin") / denominator);
                as.setAvgProcessingTime(rs.getFloat("aavg") / denominator);
                as.setMaxProcessingTime(rs.getFloat("amax") / denominator);

            }
            PreparedStatement pstmt2 = con.prepareStatement(query2);
            pstmt2.setTimestamp(1, new Timestamp(start.getTime()));
            pstmt2.setTimestamp(2, new Timestamp(end.getTime()));
            ResultSet rs2 = pstmt2.executeQuery();

            int rowCount = 0;
            int totalRows = 5;
            String listsizeStr = criteria.getListsize();
            int temp = -1;
            try
            {
                temp = Integer.parseInt(listsizeStr);
            }
            catch (NumberFormatException e)
            {
            }
            if(temp != -1) {
                totalRows = temp;
            }
           
            while ((rs2.next()) && (rowCount < totalRows))
            {
                Map row = new HashMap();
                row.put("count", "" + rs2.getInt("itemcount"));
                String col = rs2.getString(groupColumn);
                int maxColLen = 35;
                if (col != null)
                {

                    if (col.length() > maxColLen)
                    {
                        col = col.substring(0, maxColLen);
                    }
                }

                row.put("groupColumn", col);
                row.put("min", ""
                        + floatFormatter(rs2.getFloat("amin") / denominator));
                row.put("avg", ""
                        + floatFormatter(rs2.getFloat("aavg") / denominator));
                row.put("max", ""
                        + floatFormatter(rs2.getFloat("amax") / denominator));
                as.addRow(row);
                rowCount++;
            }

        }
        catch (SQLException e)
        {
            throw new InvalidCriteriaException(e.toString());
        }
        finally
        {
            try
            {
View Full Code Here

        {
            tableName = "PAGE_STATISTICS";
            groupColumn = "PAGE";
        } else
        {
            throw new InvalidCriteriaException(
                    " invalid queryType passed to queryStatistics");
        }
        String orderColumn = "itemcount";

        String ascDesc = "DESC";

        if (!PortalStatistics.QUERY_TYPE_USER.equals(queryType))
        {
            query = "select count(*) as itemcount , MIN(ELAPSED_TIME) as amin ,AVG(ELAPSED_TIME) as aavg ,MAX(ELAPSED_TIME) as amax from "
                    + tableName + " where time_stamp > ? and time_stamp < ?";
            query2 = "select count(*) as itemcount ,"
                    + groupColumn
                    + ", MIN(ELAPSED_TIME) as amin ,AVG(ELAPSED_TIME) as aavg ,MAX(ELAPSED_TIME) as amax "
                    + "from " + tableName
                    + " where time_stamp > ? and time_stamp < ? group by "
                    + groupColumn + "  order by " + orderColumn + " " + ascDesc;
        } else
        {
            query = "select count(*) as itemcount , MIN(ELAPSED_TIME) as amin,AVG(ELAPSED_TIME) as aavg ,MAX(ELAPSED_TIME) as amax from "
                    + tableName
                    + " where time_stamp > ? and time_stamp < ? and status = 2";
            query2 = "select count(*) as itemcount ,"
                    + groupColumn
                    + ", MIN(ELAPSED_TIME) as amin ,AVG(ELAPSED_TIME) as aavg ,MAX(ELAPSED_TIME) as amax "
                    + "from "
                    + tableName
                    + " where time_stamp > ? and time_stamp < ? and status = 2 group by "
                    + groupColumn + "  order by " + orderColumn + " " + ascDesc;
        }
        Connection con = null;
        try
        {
            con = ds.getConnection();
            PreparedStatement pstmt = con.prepareStatement(query);
            pstmt.setTimestamp(1, new Timestamp(start.getTime()));
            pstmt.setTimestamp(2, new Timestamp(end.getTime()));
            ResultSet rs = pstmt.executeQuery();
            float denominator = 1.0f;
            if (PortalStatistics.QUERY_TYPE_USER.equals(queryType))
            {
                denominator = 1000f * 60f; // this should convert from mS to
                                           // minutes
            }
            if (rs.next())
            {
                as.setHitCount(rs.getInt("itemcount"));

                as.setMinProcessingTime(rs.getFloat("amin") / denominator);
                as.setAvgProcessingTime(rs.getFloat("aavg") / denominator);
                as.setMaxProcessingTime(rs.getFloat("amax") / denominator);

            }
            PreparedStatement pstmt2 = con.prepareStatement(query2);
            pstmt2.setTimestamp(1, new Timestamp(start.getTime()));
            pstmt2.setTimestamp(2, new Timestamp(end.getTime()));
            ResultSet rs2 = pstmt2.executeQuery();

            int rowCount = 0;
            int totalRows = 5;
            String listsizeStr = criteria.getListsize();
            int temp = -1;
            try
            {
                temp = Integer.parseInt(listsizeStr);
            }
            catch (NumberFormatException e)
            {
            }
            if(temp != -1) {
                totalRows = temp;
            }
           
            while ((rs2.next()) && (rowCount < totalRows))
            {
                Map row = new HashMap();
                row.put("count", "" + rs2.getInt("itemcount"));
                String col = rs2.getString(groupColumn);
                int maxColLen = 35;
                if (col != null)
                {

                    if (col.length() > maxColLen)
                    {
                        col = col.substring(0, maxColLen);
                    }
                }

                row.put("groupColumn", col);
                row.put("min", ""
                        + floatFormatter(rs2.getFloat("amin") / denominator));
                row.put("avg", ""
                        + floatFormatter(rs2.getFloat("aavg") / denominator));
                row.put("max", ""
                        + floatFormatter(rs2.getFloat("amax") / denominator));
                as.addRow(row);
                rowCount++;
            }

        }
        catch (SQLException e)
        {
            throw new InvalidCriteriaException(e.toString());
        }
        finally
        {
            try
            {
View Full Code Here

        {
            tableName = "PAGE_STATISTICS";
            groupColumn = "PAGE";
        } else
        {
            throw new InvalidCriteriaException(
                    " invalid queryType passed to queryStatistics");
        }
        String orderColumn = "itemcount";

        String ascDesc = "DESC";

        if (!PortalStatistics.QUERY_TYPE_USER.equals(queryType))
        {
            query = "select count(*) as itemcount , MIN(ELAPSED_TIME) as amin ,AVG(ELAPSED_TIME) as aavg ,MAX(ELAPSED_TIME) as amax from "
                    + tableName + " where time_stamp > ? and time_stamp < ?";
            query2 = "select count(*) as itemcount ,"
                    + groupColumn
                    + ", MIN(ELAPSED_TIME) as amin ,AVG(ELAPSED_TIME) as aavg ,MAX(ELAPSED_TIME) as amax "
                    + "from " + tableName
                    + " where time_stamp > ? and time_stamp < ? group by "
                    + groupColumn + "  order by " + orderColumn + " " + ascDesc;
        } else
        {
            query = "select count(*) as itemcount , MIN(ELAPSED_TIME) as amin,AVG(ELAPSED_TIME) as aavg ,MAX(ELAPSED_TIME) as amax from "
                    + tableName
                    + " where time_stamp > ? and time_stamp < ? and status = 2";
            query2 = "select count(*) as itemcount ,"
                    + groupColumn
                    + ", MIN(ELAPSED_TIME) as amin ,AVG(ELAPSED_TIME) as aavg ,MAX(ELAPSED_TIME) as amax "
                    + "from "
                    + tableName
                    + " where time_stamp > ? and time_stamp < ? and status = 2 group by "
                    + groupColumn + "  order by " + orderColumn + " " + ascDesc;
        }
        Connection con = null;
        try
        {
            con = ds.getConnection();
            PreparedStatement pstmt = con.prepareStatement(query);
            pstmt.setTimestamp(1, new Timestamp(start.getTime()));
            pstmt.setTimestamp(2, new Timestamp(end.getTime()));
            ResultSet rs = pstmt.executeQuery();
            float denominator = 1.0f;
            if (PortalStatistics.QUERY_TYPE_USER.equals(queryType))
            {
                denominator = 1000f * 60f; // this should convert from mS to
                                           // minutes
            }
            if (rs.next())
            {
                as.setHitCount(rs.getInt("itemcount"));

                as.setMinProcessingTime(rs.getFloat("amin") / denominator);
                as.setAvgProcessingTime(rs.getFloat("aavg") / denominator);
                as.setMaxProcessingTime(rs.getFloat("amax") / denominator);

            }
            PreparedStatement pstmt2 = con.prepareStatement(query2);
            pstmt2.setTimestamp(1, new Timestamp(start.getTime()));
            pstmt2.setTimestamp(2, new Timestamp(end.getTime()));
            ResultSet rs2 = pstmt2.executeQuery();

            int rowCount = 0;
            int totalRows = 5;
            String listsizeStr = criteria.getListsize();
            int temp = -1;
            try
            {
                temp = Integer.parseInt(listsizeStr);
            }
            catch (NumberFormatException e)
            {
            }
            if(temp != -1) {
                totalRows = temp;
            }
           
            while ((rs2.next()) && (rowCount < totalRows))
            {
                Map row = new HashMap();
                row.put("count", "" + rs2.getInt("itemcount"));
                String col = rs2.getString(groupColumn);
                int maxColLen = 35;
                if (col != null)
                {

                    if (col.length() > maxColLen)
                    {
                        col = col.substring(0, maxColLen);
                    }
                }

                row.put("groupColumn", col);
                row.put("min", ""
                        + floatFormatter(rs2.getFloat("amin") / denominator));
                row.put("avg", ""
                        + floatFormatter(rs2.getFloat("aavg") / denominator));
                row.put("max", ""
                        + floatFormatter(rs2.getFloat("amax") / denominator));
                as.addRow(row);
                rowCount++;
            }

        }
        catch (SQLException e)
        {
            throw new InvalidCriteriaException(e.toString());
        }
        finally
        {
            try
            {
View Full Code Here

        {
            tableName = "PAGE_STATISTICS";
            groupColumn = "PAGE";
        } else
        {
            throw new InvalidCriteriaException(
                    " invalid queryType passed to queryStatistics");
        }
        String orderColumn = "itemcount";

        String ascDesc = "DESC";

        if (!PortalStatistics.QUERY_TYPE_USER.equals(queryType))
        {
            query1 = "select count(*) as itemcount , MIN(ELAPSED_TIME) as amin ,AVG(ELAPSED_TIME) as aavg ,MAX(ELAPSED_TIME) as amax from "
                    + tableName + " where time_stamp > ? and time_stamp < ?";
            query2 = "select count(*) as itemcount ,"
                    + groupColumn
                    + ", MIN(ELAPSED_TIME) as amin ,AVG(ELAPSED_TIME) as aavg ,MAX(ELAPSED_TIME) as amax "
                    + "from " + tableName
                    + " where time_stamp > ? and time_stamp < ? group by "
                    + groupColumn + "  order by " + orderColumn + " " + ascDesc;
        } else
        {
            query1 = "select count(*) as itemcount , MIN(ELAPSED_TIME) as amin,AVG(ELAPSED_TIME) as aavg ,MAX(ELAPSED_TIME) as amax from "
                    + tableName
                    + " where time_stamp > ? and time_stamp < ? and status = 2";
            query2 = "select count(*) as itemcount ,"
                    + groupColumn
                    + ", MIN(ELAPSED_TIME) as amin ,AVG(ELAPSED_TIME) as aavg ,MAX(ELAPSED_TIME) as amax "
                    + "from "
                    + tableName
                    + " where time_stamp > ? and time_stamp < ? and status = 2 group by "
                    + groupColumn + "  order by " + orderColumn + " " + ascDesc;
        }
       
        Connection con = null;
        PreparedStatement pstmt = null;
        ResultSet rs = null;
       
        try
        {
            con = ds.getConnection();
           
            // query 1
            pstmt = con.prepareStatement(query1);
            pstmt.setTimestamp(1, new Timestamp(start.getTime()));
            pstmt.setTimestamp(2, new Timestamp(end.getTime()));
            rs = pstmt.executeQuery();
            float denominator = 1.0f;
            if (PortalStatistics.QUERY_TYPE_USER.equals(queryType))
            {
                denominator = 1000f * 60f; // this should convert from mS to
                                           // minutes
            }
            if (rs.next())
            {
                as.setHitCount(rs.getInt("itemcount"));

                as.setMinProcessingTime(rs.getFloat("amin") / denominator);
                as.setAvgProcessingTime(rs.getFloat("aavg") / denominator);
                as.setMaxProcessingTime(rs.getFloat("amax") / denominator);
            }
           
            rs.close();
            rs = null;
            pstmt.close();
            pstmt = null;
           
            // query 2
            pstmt = con.prepareStatement(query2);
            pstmt.setTimestamp(1, new Timestamp(start.getTime()));
            pstmt.setTimestamp(2, new Timestamp(end.getTime()));
            rs = pstmt.executeQuery();

            int rowCount = 0;
            int totalRows = 5;
            String listsizeStr = criteria.getListsize();
            int temp = -1;
            try
            {
                temp = Integer.parseInt(listsizeStr);
            }
            catch (NumberFormatException e)
            {
            }
            if(temp != -1) {
                totalRows = temp;
            }
           
            while ((rs.next()) && (rowCount < totalRows))
            {
                Map row = new HashMap();
                row.put("count", "" + rs.getInt("itemcount"));
                String col = rs.getString(groupColumn);
                int maxColLen = 35;
                if (col != null)
                {

                    if (col.length() > maxColLen)
                    {
                        col = col.substring(0, maxColLen);
                    }
                }

                row.put("groupColumn", col);
                row.put("min", ""
                        + floatFormatter(rs.getFloat("amin") / denominator));
                row.put("avg", ""
                        + floatFormatter(rs.getFloat("aavg") / denominator));
                row.put("max", ""
                        + floatFormatter(rs.getFloat("amax") / denominator));
                as.addRow(row);
                rowCount++;
            }

        }
        catch (SQLException e)
        {
            throw new InvalidCriteriaException(e.toString());
        }
        finally
        {
            if(rs != null)
            {
View Full Code Here

TOP

Related Classes of org.apache.jetspeed.statistics.InvalidCriteriaException

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.