incubator-connectors-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r1222233 - in /incubator/lcf/trunk/framework: core/src/main/java/org/apache/manifoldcf/core/database/ core/src/main/java/org/apache/manifoldcf/core/interfaces/ core/src/main/java/org/apache/manifoldcf/core/util/ crawler-ui/src/main/webapp/ ...
Date Thu, 22 Dec 2011 13:58:50 GMT
Author: kwright
Date: Thu Dec 22 13:58:49 2011
New Revision: 1222233

URL: http://svn.apache.org/viewvc?rev=1222233&view=rev
Log:
Get the max activity report actually returning data

Added:
    incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/util/
    incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/util/Converter.java
  (with props)
Modified:
    incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/BaseTable.java
    incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfaceDerby.java
    incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfaceHSQLDB.java
    incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfaceMySQL.java
    incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfacePostgreSQL.java
    incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/interfaces/IDBInterface.java
    incubator/lcf/trunk/framework/crawler-ui/src/main/webapp/adminHeaders.jsp
    incubator/lcf/trunk/framework/crawler-ui/src/main/webapp/maxactivityreport.jsp
    incubator/lcf/trunk/framework/crawler-ui/src/main/webapp/maxbandwidthreport.jsp
    incubator/lcf/trunk/framework/crawler-ui/src/main/webapp/simplereport.jsp
    incubator/lcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/repository/RepositoryHistoryManager.java

Modified: incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/BaseTable.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/BaseTable.java?rev=1222233&r1=1222232&r2=1222233&view=diff
==============================================================================
--- incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/BaseTable.java
(original)
+++ incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/BaseTable.java
Thu Dec 22 13:58:49 2011
@@ -310,6 +310,17 @@ public class BaseTable
     return CacheKeyFactory.makeTableKey(null,tableName,dbInterface.getDatabaseName());
   }
 
+  /** Construct a cast to a double value.
+  * On most databases this cast needs to be explicit, but on some it is implicit (and cannot
be in fact
+  * specified).
+  *@param value is the value to be cast.
+  *@return the query chunk needed.
+  */
+  public String constructDoubleCastClause(String value)
+  {
+    return dbInterface.constructDoubleCastClause(value);
+  }
+
   /** Construct a count clause.
   * On most databases this will be COUNT(col), but on some the count needs to be cast to
a BIGINT, so
   * CAST(COUNT(col) AS BIGINT) will be emitted instead.

Modified: incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfaceDerby.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfaceDerby.java?rev=1222233&r1=1222232&r2=1222233&view=diff
==============================================================================
--- incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfaceDerby.java
(original)
+++ incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfaceDerby.java
Thu Dec 22 13:58:49 2011
@@ -1019,6 +1019,17 @@ public class DBInterfaceDerby extends Da
     }
   }
 
+  /** Construct a cast to a double value.
+  * On most databases this cast needs to be explicit, but on some it is implicit (and cannot
be in fact
+  * specified).
+  *@param value is the value to be cast.
+  *@return the query chunk needed.
+  */
+  public String constructDoubleCastClause(String value)
+  {
+    return "CAST("+value+" AS DOUBLE PRECISION)";
+  }
+
   /** Construct a count clause.
   * On most databases this will be COUNT(col), but on some the count needs to be cast to
a BIGINT, so
   * CAST(COUNT(col) AS BIGINT) will be emitted instead.

Modified: incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfaceHSQLDB.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfaceHSQLDB.java?rev=1222233&r1=1222232&r2=1222233&view=diff
==============================================================================
--- incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfaceHSQLDB.java
(original)
+++ incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfaceHSQLDB.java
Thu Dec 22 13:58:49 2011
@@ -970,6 +970,17 @@ public class DBInterfaceHSQLDB extends D
     }
   }
 
+  /** Construct a cast to a double value.
+  * On most databases this cast needs to be explicit, but on some it is implicit (and cannot
be in fact
+  * specified).
+  *@param value is the value to be cast.
+  *@return the query chunk needed.
+  */
+  public String constructDoubleCastClause(String value)
+  {
+    return "CAST("+value+" AS DOUBLE PRECISION)";
+  }
+
   /** Construct a count clause.
   * On most databases this will be COUNT(col), but on some the count needs to be cast to
a BIGINT, so
   * CAST(COUNT(col) AS BIGINT) will be emitted instead.

Modified: incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfaceMySQL.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfaceMySQL.java?rev=1222233&r1=1222232&r2=1222233&view=diff
==============================================================================
--- incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfaceMySQL.java
(original)
+++ incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfaceMySQL.java
Thu Dec 22 13:58:49 2011
@@ -816,6 +816,17 @@ public class DBInterfaceMySQL extends Da
     }
   }
 
+  /** Construct a cast to a double value.
+  * On most databases this cast needs to be explicit, but on some it is implicit (and cannot
be in fact
+  * specified).
+  *@param value is the value to be cast.
+  *@return the query chunk needed.
+  */
+  public String constructDoubleCastClause(String value)
+  {
+    return value;
+  }
+
   /** Construct a count clause.
   * On most databases this will be COUNT(col), but on some the count needs to be cast to
a BIGINT, so
   * CAST(COUNT(col) AS BIGINT) will be emitted instead.

Modified: incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfacePostgreSQL.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfacePostgreSQL.java?rev=1222233&r1=1222232&r2=1222233&view=diff
==============================================================================
--- incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfacePostgreSQL.java
(original)
+++ incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfacePostgreSQL.java
Thu Dec 22 13:58:49 2011
@@ -857,6 +857,17 @@ public class DBInterfacePostgreSQL exten
     }
   }
 
+  /** Construct a cast to a double value.
+  * On most databases this cast needs to be explicit, but on some it is implicit (and cannot
be in fact
+  * specified).
+  *@param value is the value to be cast.
+  *@return the query chunk needed.
+  */
+  public String constructDoubleCastClause(String value)
+  {
+    return "CAST("+value+" AS DOUBLE PRECISION)";
+  }
+
   /** Construct a count clause.
   * On most databases this will be COUNT(col), but on some the count needs to be cast to
a BIGINT, so
   * CAST(COUNT(col) AS BIGINT) will be emitted instead.

Modified: incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/interfaces/IDBInterface.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/interfaces/IDBInterface.java?rev=1222233&r1=1222232&r2=1222233&view=diff
==============================================================================
--- incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/interfaces/IDBInterface.java
(original)
+++ incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/interfaces/IDBInterface.java
Thu Dec 22 13:58:49 2011
@@ -253,6 +253,14 @@ public interface IDBInterface
     int maxResults, ResultSpecification resultSpec, ILimitChecker returnLimit)
     throws ManifoldCFException;
 
+  /** Construct a cast to a double value.
+  * On most databases this cast needs to be explicit, but on some it is implicit (and cannot
be in fact
+  * specified).
+  *@param value is the value to be cast.
+  *@return the query chunk needed.
+  */
+  public String constructDoubleCastClause(String value);
+  
   /** Construct a count clause.
   * On most databases this will be COUNT(col), but on some the count needs to be cast to
a BIGINT, so
   * CAST(COUNT(col) AS BIGINT) will be emitted instead.

Added: incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/util/Converter.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/util/Converter.java?rev=1222233&view=auto
==============================================================================
--- incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/util/Converter.java
(added)
+++ incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/util/Converter.java
Thu Dec 22 13:58:49 2011
@@ -0,0 +1,61 @@
+/* $Id$ */
+
+/**
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.manifoldcf.core.util;
+
+import org.apache.manifoldcf.core.interfaces.*;
+
+/** Various useful converter methods for working with JDBC output
+*/
+public class Converter
+{
+  public static final String _rcsid = "@(#)$Id$";
+
+  /** Convert a JDBC output value to a double.
+  */
+  public static double asDouble(Object o)
+    throws ManifoldCFException
+  {
+    if (o instanceof Double)
+      return ((Double)o).doubleValue();
+    if (o instanceof String)
+      return new Double((String)o).doubleValue();
+    if (o instanceof Float)
+      return (double)((Float)o).floatValue();
+    if (o instanceof Long)
+      return (double)((Long)o).longValue();
+    throw new ManifoldCFException("Can't convert to double");
+  }
+
+  /** Convert a JDBC output value to a long.
+  */
+  public static long asLong(Object o)
+    throws ManifoldCFException
+  {
+    if (o instanceof Long)
+      return ((Long)o).longValue();
+    if (o instanceof Double)
+      return (long)((Double)o).doubleValue();
+    if (o instanceof String)
+      return new Long((String)o).longValue();
+    if (o instanceof Float)
+      return (long)((Float)o).floatValue();
+    throw new ManifoldCFException("Can't convert to long");
+  }
+
+}

Propchange: incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/util/Converter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/util/Converter.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: incubator/lcf/trunk/framework/crawler-ui/src/main/webapp/adminHeaders.jsp
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/crawler-ui/src/main/webapp/adminHeaders.jsp?rev=1222233&r1=1222232&r2=1222233&view=diff
==============================================================================
--- incubator/lcf/trunk/framework/crawler-ui/src/main/webapp/adminHeaders.jsp (original)
+++ incubator/lcf/trunk/framework/crawler-ui/src/main/webapp/adminHeaders.jsp Thu Dec 22 13:58:49
2011
@@ -29,6 +29,7 @@ response.setContentType("text/html;chars
 
 <%@ page language="java" %>
 <%@ page import="org.apache.manifoldcf.core.interfaces.*" %>
+<%@ page import="org.apache.manifoldcf.core.util.*" %>
 <%@ page import="org.apache.manifoldcf.agents.interfaces.*" %>
 <%@ page import="org.apache.manifoldcf.crawler.interfaces.*" %>
 <%@ page import="org.apache.manifoldcf.authorities.interfaces.*" %>

Modified: incubator/lcf/trunk/framework/crawler-ui/src/main/webapp/maxactivityreport.jsp
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/crawler-ui/src/main/webapp/maxactivityreport.jsp?rev=1222233&r1=1222232&r2=1222233&view=diff
==============================================================================
--- incubator/lcf/trunk/framework/crawler-ui/src/main/webapp/maxactivityreport.jsp (original)
+++ incubator/lcf/trunk/framework/crawler-ui/src/main/webapp/maxactivityreport.jsp Thu Dec
22 13:58:49 2011
@@ -777,9 +777,9 @@ if (maintenanceUnderway == false)
 			    else
 				idBucketString = idBucketObject.toString();
 
-			    String startTimeString = org.apache.manifoldcf.ui.util.Formatter.formatTime(new Long(row.getValue("starttime").toString()).longValue());
-			    String endTimeString = org.apache.manifoldcf.ui.util.Formatter.formatTime(new Long(row.getValue("endtime").toString()).longValue());
-			    double activityCount = ((Double)row.getValue("activitycount")).doubleValue();
+			    String startTimeString = org.apache.manifoldcf.ui.util.Formatter.formatTime(Converter.asLong(row.getValue("starttime")));
+			    String endTimeString = org.apache.manifoldcf.ui.util.Formatter.formatTime(Converter.asLong(row.getValue("endtime")));
+			    double activityCount = Converter.asDouble(row.getValue("activitycount"));
 			    double activityRate = activityCount * 60000.0 / intervalMilliseconds;
 
 %>

Modified: incubator/lcf/trunk/framework/crawler-ui/src/main/webapp/maxbandwidthreport.jsp
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/crawler-ui/src/main/webapp/maxbandwidthreport.jsp?rev=1222233&r1=1222232&r2=1222233&view=diff
==============================================================================
--- incubator/lcf/trunk/framework/crawler-ui/src/main/webapp/maxbandwidthreport.jsp (original)
+++ incubator/lcf/trunk/framework/crawler-ui/src/main/webapp/maxbandwidthreport.jsp Thu Dec
22 13:58:49 2011
@@ -776,9 +776,9 @@ if (maintenanceUnderway == false)
 				idBucketString = "";
 			    else
 				idBucketString = idBucketObject.toString();
-			    String startTimeString = org.apache.manifoldcf.ui.util.Formatter.formatTime(new Long(row.getValue("starttime").toString()).longValue());
-			    String endTimeString = org.apache.manifoldcf.ui.util.Formatter.formatTime(new Long(row.getValue("endtime").toString()).longValue());
-			    long byteCount = new Long(row.getValue("bytecount").toString()).longValue();
+			    String startTimeString = org.apache.manifoldcf.ui.util.Formatter.formatTime(Converter.asLong(row.getValue("starttime")));
+			    String endTimeString = org.apache.manifoldcf.ui.util.Formatter.formatTime(Converter.asLong(row.getValue("endtime").toString()));
+			    long byteCount = Converter.asLong(row.getValue("bytecount"));
 			    double bandwidth = ((double)byteCount) * 1000.0 / intervalMilliseconds;
 
 %>

Modified: incubator/lcf/trunk/framework/crawler-ui/src/main/webapp/simplereport.jsp
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/crawler-ui/src/main/webapp/simplereport.jsp?rev=1222233&r1=1222232&r2=1222233&view=diff
==============================================================================
--- incubator/lcf/trunk/framework/crawler-ui/src/main/webapp/simplereport.jsp (original)
+++ incubator/lcf/trunk/framework/crawler-ui/src/main/webapp/simplereport.jsp Thu Dec 22 13:58:49
2011
@@ -703,7 +703,7 @@ if (maintenanceUnderway == false)
 		while (zz < iterCount)
 		{
 		    IResultRow row = set.getRow(zz);
-		    String startTimeString = org.apache.manifoldcf.ui.util.Formatter.formatTime(((Long)row.getValue("starttime")).longValue());
+		    String startTimeString = org.apache.manifoldcf.ui.util.Formatter.formatTime(Converter.asLong(row.getValue("starttime")));
 		    String resultCode = "";
 		    Object resultCodeObject = row.getValue("resultcode");
 		    if (resultCodeObject != null)

Modified: incubator/lcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/repository/RepositoryHistoryManager.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/repository/RepositoryHistoryManager.java?rev=1222233&r1=1222232&r2=1222233&view=diff
==============================================================================
--- incubator/lcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/repository/RepositoryHistoryManager.java
(original)
+++ incubator/lcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/repository/RepositoryHistoryManager.java
Thu Dec 22 13:58:49 2011
@@ -369,13 +369,11 @@ public class RepositoryHistoryManager ex
 
     sb.append("t0.bucket AS bucket, t0.").append(startTimeField).append(" AS windowstart,
t0.")
       .append(startTimeField).append("+").append(intervalString).append(" AS windowend, ")
-      .append("CAST(((CASE WHEN t0.")
-      .append(startTimeField).append("+").append(intervalString).append("<t1.").append(endTimeField)
-      .append(" THEN t0.").append(startTimeField).append("+").append(intervalString).append("
ELSE t1.")
-      .append(endTimeField).append(" END) - (CASE WHEN t0.").append(startTimeField).append(">t1.").append(startTimeField)
-      .append(" THEN t0.").append(startTimeField).append(" ELSE t1.").append(startTimeField)
-      .append(" END)) AS DOUBLE PRECISION) / CAST((t1.").append(endTimeField).append("-t1.").append(startTimeField)
-      .append(") AS DOUBLE PRECISION)")
+      .append(constructDoubleCastClause("((CASE WHEN t0."+
+	startTimeField+"+"+intervalString+"<t1."+endTimeField+" THEN t0."+
+        startTimeField+"+"+intervalString+" ELSE t1."+endTimeField+" END) - (CASE WHEN t0."+
+        startTimeField+">t1."+startTimeField+" THEN t0."+startTimeField+" ELSE t1."+startTimeField+"
END))"))
+      .append(" / ").append(constructDoubleCastClause("(t1."+endTimeField+"-t1."+startTimeField+")"))
       .append(" AS activitycount FROM (SELECT DISTINCT ");
     addBucketExtract(sb,list,"",entityIdentifierField,idBucket);
     sb.append(" AS bucket,").append(startTimeField).append(" FROM ").append(getTableName());
@@ -392,15 +390,12 @@ public class RepositoryHistoryManager ex
       .append(" FROM (SELECT ");
     sb.append("t0a.bucket AS bucket, t0a.").append(endTimeField).append("-").append(intervalString).append("
AS windowstart, t0a.")
       .append(endTimeField).append(" AS windowend, ")
-      .append("CAST(((CASE WHEN t0a.")
-      .append(endTimeField).append("<t1a.").append(endTimeField)
-      .append(" THEN t0a.").append(endTimeField).append(" ELSE t1a.")
-      .append(endTimeField).append(" END) - (CASE WHEN t0a.").append(endTimeField).append("-").append(intervalString)
-      .append(">t1a.").append(startTimeField)
-      .append(" THEN t0a.").append(endTimeField).append("-").append(intervalString).append("
ELSE t1a.")
-      .append(startTimeField)
-      .append(" END)) AS DOUBLE PRECISION) / CAST((t1a.").append(endTimeField).append("-t1a.").append(startTimeField)
-      .append(") AS DOUBLE PRECISION)")
+      .append(constructDoubleCastClause("((CASE WHEN t0a."+
+        endTimeField+"<t1a."+endTimeField+" THEN t0a."+endTimeField+
+        " ELSE t1a."+endTimeField+" END) - (CASE WHEN t0a."+
+        endTimeField+"-"+intervalString+">t1a."+startTimeField+
+        " THEN t0a."+endTimeField+"-"+intervalString+" ELSE t1a."+startTimeField+" END))"))
+      .append(" / ").append(constructDoubleCastClause("(t1a."+endTimeField+"-t1a."+startTimeField+")"))
       .append(" AS activitycount FROM (SELECT DISTINCT ");
     addBucketExtract(sb,list,"",entityIdentifierField,idBucket);
     sb.append(" AS bucket,").append(endTimeField).append(" FROM ").append(getTableName());



Mime
View raw message