Examples of InvalidCriteriaException


Examples of com.tll.criteria.InvalidCriteriaException

  }

  @Override
  public <E extends IEntity> List<E> findEntities(Criteria<E> criteria, final Sorting sorting)
  throws InvalidCriteriaException, DataAccessException {
    if(criteria == null) throw new InvalidCriteriaException("No criteria specified.");

    final Query query = getDb4oTemplate().query();

    if(criteria.getCriteriaType().isQuery()) {
      if(nqt == null) throw new InvalidCriteriaException("No db4o named query translator specified.");
      nqt.translateNamedQuery(criteria.getNamedQueryDefinition(), criteria.getQueryParams(), query);
    }
    else {
      query.constrain(criteria.getEntityClass());
      final CriterionGroup pg = criteria.getPrimaryGroup();
      if(pg != null && pg.isSet()) {
        for(final ICriterion ic : pg) {
          if(ic.isGroup()) throw new InvalidCriteriaException("Nested criterion groups are not supported");
          if(!ic.isSet()) throw new InvalidCriteriaException("criterion not set");
          final Criterion ctn = (Criterion) ic;
          final Object checkValue = ctn.getValue();
          final String pname = ctn.getPropertyName();

          Query pquery;
          if(pname.indexOf('.') > 0) {
            pquery = query;
            // descend one time for each node in the pname (which may be a dot
            // notated property path)
            final PropertyPath path = new PropertyPath(pname);
            for(final String node : path.nodes()) {
              pquery = pquery.descend(node);
            }
          }
          else {
            pquery = query.descend(pname);
          }

          switch(ctn.getComparator()) {
          case BETWEEN: {
            Object min, max;
            if(checkValue instanceof NumberRange) {
              final NumberRange range = (NumberRange) checkValue;
              min = range.getMinimumNumber();
              max = range.getMaximumNumber();
            }
            else if(checkValue instanceof DateRange) {
              final DateRange range = (DateRange) checkValue;
              min = range.getStartDate();
              max = range.getEndDate();
            }
            else {
              // presume an object array
              final Object[] oarr = (Object[]) checkValue;
              min = oarr[0];
              max = oarr[1];
            }
            pquery.constrain(min).greater().equal().or(pquery.constrain(max).smaller().equal());
            break;
          }
          case CONTAINS:
            pquery.constrain(checkValue).contains();
            break;
          case ENDS_WITH:
            pquery.constrain(checkValue).endsWith(ctn.isCaseSensitive());
            break;
          case EQUALS:
            if(!ctn.isCaseSensitive())
              throw new InvalidCriteriaException("Case insensitive equals checking is currently not supported");
            pquery.constrain(checkValue);
            break;
          case GREATER_THAN:
            pquery.constrain(checkValue).greater();
            break;
          case GREATER_THAN_EQUALS:
            pquery.constrain(checkValue).greater().equal();
            break;
          case IN: {
            Object[] arr;
            if(checkValue.getClass().isArray()) {
              arr = (Object[]) checkValue;
            }
            else if(checkValue instanceof Collection<?>) {
              arr = ((Collection) checkValue).toArray();
            }
            else if(checkValue instanceof String) {
              // assume comma-delimited string
              arr =
                org.springframework.util.ObjectUtils.toObjectArray(org.springframework.util.StringUtils
                    .commaDelimitedListToStringArray((String) checkValue));
            }
            else {
              throw new InvalidCriteriaException(
                  "Unsupported or null type for IN comparator: " + checkValue == null ? "<null>" : checkValue
                      .getClass().toString());
            }
            Constraint c = null;
            for(final Object o : arr) {
              if(c == null) {
                c = pquery.constrain(o);
              }
              else {
                c.or(pquery.constrain(o));
              }
            }
            break;
          }
          case IS:
            if(checkValue instanceof DBType == false) {
              throw new InvalidCriteriaException("IS clauses support only check values of type: "
                  + DBType.class.getSimpleName());
            }
            final DBType dbType = (DBType) checkValue;
            if(dbType == DBType.NULL) {
              // null
View Full Code Here

Examples of com.tll.criteria.InvalidCriteriaException

      case COLLECTION:
        return create(dataProvider.find(criteria, null), sorting);

      case IDLIST:
        if(criteria.getCriteriaType().isQuery()) {
          throw new InvalidCriteriaException("Id list handling does not support query based criteria");
        }
        slh = new IdListHandler<E>(dataProvider, criteria, sorting);
        break;

      case PAGE:
View Full Code Here

Examples of com.tll.criteria.InvalidCriteriaException

        break;
      case CUSTOMER:
        sq = q.descend("isAvailableCustomer");
        break;
      default:
        throw new InvalidCriteriaException();
      }
      sq.constrain(true);
    }

    else throw new InvalidCriteriaException("Unhandled named query: " + qname);
  }
View Full Code Here

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

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

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

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

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

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

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))
        {
            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
Copyright © 2018 www.massapi.com. 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.