[jboss-svn-commits] JBL Code SVN: r35703 - labs/jbosslabs/labs-3.0-build/integration/sbs/reports/trunk/src/main/java/org/jboss/community/sbs/plugin/reports/monthly/valuesource.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Mon Oct 25 04:51:45 EDT 2010


Author: lkrzyzanek
Date: 2010-10-25 04:51:44 -0400 (Mon, 25 Oct 2010)
New Revision: 35703

Modified:
   labs/jbosslabs/labs-3.0-build/integration/sbs/reports/trunk/src/main/java/org/jboss/community/sbs/plugin/reports/monthly/valuesource/SBSValueSource.java
Log:
Added SQL queries for SBS

Modified: labs/jbosslabs/labs-3.0-build/integration/sbs/reports/trunk/src/main/java/org/jboss/community/sbs/plugin/reports/monthly/valuesource/SBSValueSource.java
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/sbs/reports/trunk/src/main/java/org/jboss/community/sbs/plugin/reports/monthly/valuesource/SBSValueSource.java	2010-10-25 05:16:05 UTC (rev 35702)
+++ labs/jbosslabs/labs-3.0-build/integration/sbs/reports/trunk/src/main/java/org/jboss/community/sbs/plugin/reports/monthly/valuesource/SBSValueSource.java	2010-10-25 08:51:44 UTC (rev 35703)
@@ -73,8 +73,6 @@
    * </ul>
    */
   protected void initSqlStatements() {
-    // TODO LIBOR define correct SQL statements!
-
     // WIKI related values
     sqlStatements.put(SBSValueType.WIKI_NEW_ARTICLE_RH, "SELECT d.containerId, count(d.internalDocID)"
         + " FROM jiveDocument d" + " WHERE d.userID IN (SELECT userId from reportsRedHatUsers where created = ?)"
@@ -84,10 +82,16 @@
         + " FROM jiveDocument d" + " WHERE d.userID NOT IN (SELECT userId from reportsRedHatUsers where created = ?)"
         + " and d.creationDate > ? and d.creationDate < ? group by d.containerId");
 
-    sqlStatements.put(SBSValueType.WIKI_EDIT_ARTICLE_RH,
-        "select 1, 1 from reportsRedHatUsers where created = ? and created = ? and created = ?");
-    sqlStatements.put(SBSValueType.WIKI_EDIT_ARTICLE_CM,
-        "select 1, 1 from reportsRedHatUsers where created = ? and created = ? and created = ?");
+    sqlStatements.put(SBSValueType.WIKI_EDIT_ARTICLE_RH, "SELECT d.containerId, count(dv.internalDocID)"
+        + " FROM jiveDocVersion dv, jiveDocument d"
+        + " WHERE dv.internalDocID = d.internalDocID and dv.modificationDate != 0 and dv.versionID != 1"
+        + " and dv.userID IN (SELECT userId from reportsRedHatUsers where created = ?)"
+        + " and dv.modificationDate > ? and dv.modificationDate < ? group by d.containerId");
+    sqlStatements.put(SBSValueType.WIKI_EDIT_ARTICLE_CM, "SELECT d.containerId, count(dv.internalDocID)"
+        + " FROM jiveDocVersion dv, jiveDocument d"
+        + " WHERE dv.internalDocID = d.internalDocID and dv.modificationDate != 0 and dv.versionID != 1"
+        + " and dv.userID NOT IN (SELECT userId from reportsRedHatUsers where created = ?)"
+        + " and dv.modificationDate > ? and dv.modificationDate < ? group by d.containerId");
 
     sqlStatements.put(SBSValueType.WIKI_COMMENT_RH, "SELECT d.containerId, count(c.commentID)"
         + " FROM jiveComment c, jiveDocument d" + " WHERE c.objectID = d.internalDocID and c.objectType = 102"
@@ -99,30 +103,53 @@
         + " and c.creationDate > ? and c.creationDate < ? group by d.containerId");
 
     // forum related values
-    sqlStatements.put(SBSValueType.FORUM_QUESTION_RH,
-        "select 1, 1 from reportsRedHatUsers where created = ? and created = ? and created = ?");
-    sqlStatements.put(SBSValueType.FORUM_QUESTION_CM,
-        "select 1, 1 from reportsRedHatUsers where created = ? and created = ? and created = ?");
+    sqlStatements.put(SBSValueType.FORUM_QUESTION_RH, "SELECT m.containerId, count(m.messageId) "
+        + "FROM jiveQuestion q, jiveMessage m " + "WHERE q.threadID = m.threadID "
+        + "and m.userID IN (SELECT userId from reportsRedHatUsers where created = ?) "
+        + "and m.creationDate > ? and m.creationDate < ? and m.containerType = 14 group by m.containerId");
+    sqlStatements.put(SBSValueType.FORUM_QUESTION_CM, "SELECT m.containerId, count(m.messageId) "
+        + "FROM jiveQuestion q, jiveMessage m " + "WHERE q.threadID = m.threadID "
+        + "and m.userID NOT IN (SELECT userId from reportsRedHatUsers where created = ?) "
+        + "and m.creationDate > ? and m.creationDate < ? and m.containerType = 14 group by m.containerId");
 
-    sqlStatements.put(SBSValueType.FORUM_ANSWER_HELPFUL_RH,
-        "select 1, 1 from reportsRedHatUsers where created = ? and created = ? and created = ?");
-    sqlStatements.put(SBSValueType.FORUM_ANSWER_CORRECT_RH,
-        "select 1, 1 from reportsRedHatUsers where created = ? and created = ? and created = ?");
-    sqlStatements.put(SBSValueType.FORUM_ANSWER_HELPFUL_CM,
-        "select 1, 1 from reportsRedHatUsers where created = ? and created = ? and created = ?");
-    sqlStatements.put(SBSValueType.FORUM_ANSWER_CORRECT_CM,
-        "select 1, 1 from reportsRedHatUsers where created = ? and created = ? and created = ?");
+    sqlStatements.put(SBSValueType.FORUM_ANSWER_HELPFUL_RH, "SELECT m.containerId, count(m.messageId) "
+        + "FROM jiveAnswer a, jiveMessage m " + "WHERE a.messageID = m.messageID "
+        + "and m.userID IN (SELECT userId from reportsRedHatUsers where created = ?) "
+        + "and m.creationDate > ? and m.creationDate < ? and m.containerType = 14 and "
+        + "a.helpfulAnswer = 1 group by m.containerId");
+    sqlStatements.put(SBSValueType.FORUM_ANSWER_CORRECT_RH, "SELECT m.containerId, count(m.messageId) "
+        + "FROM jiveAnswer a, jiveMessage m " + "WHERE a.messageID = m.messageID "
+        + "and m.userID IN (SELECT userId from reportsRedHatUsers where created = ?) "
+        + "and m.creationDate > ? and m.creationDate < ? and m.containerType = 14 and "
+        + "a.correctAnswer = 1 group by m.containerId");
+    sqlStatements.put(SBSValueType.FORUM_ANSWER_HELPFUL_CM, "SELECT m.containerId, count(m.messageId) "
+        + "FROM jiveAnswer a, jiveMessage m " + "WHERE a.messageID = m.messageID "
+        + "and m.userID NOT IN (SELECT userId from reportsRedHatUsers where created = ?) "
+        + "and m.creationDate > ? and m.creationDate < ? and m.containerType = 14 and "
+        + "a.helpfulAnswer = 1 group by m.containerId");
+    sqlStatements.put(SBSValueType.FORUM_ANSWER_CORRECT_CM, "SELECT m.containerId, count(m.messageId) "
+        + "FROM jiveAnswer a, jiveMessage m " + "WHERE a.messageID = m.messageID "
+        + "and m.userID NOT IN (SELECT userId from reportsRedHatUsers where created = ?) "
+        + "and m.creationDate > ? and m.creationDate < ? and m.containerType = 14 and "
+        + "a.correctAnswer = 1 group by m.containerId");
 
-    sqlStatements.put(SBSValueType.FORUM_THREAD_RH,
-        "select 1, 1 from reportsRedHatUsers where created = ? and created = ? and created = ?");
-    sqlStatements.put(SBSValueType.FORUM_THREAD_CM,
-        "select 1, 1 from reportsRedHatUsers where created = ? and created = ? and created = ?");
+    sqlStatements.put(SBSValueType.FORUM_THREAD_RH, "SELECT m.containerId, count(m.messageId) " + "FROM jiveMessage m "
+        + "WHERE m.parentMessageId is null "
+        + "and m.userID IN (SELECT userId from reportsRedHatUsers where created = ?) "
+        + "and m.creationDate > ? and m.creationDate < ? group by m.containerId");
+    sqlStatements.put(SBSValueType.FORUM_THREAD_CM, "SELECT m.containerId, count(m.messageId) " + "FROM jiveMessage m "
+        + "WHERE m.parentMessageId is null "
+        + "and m.userID NOT IN (SELECT userId from reportsRedHatUsers where created = ?) "
+        + "and m.creationDate > ? and m.creationDate < ? group by m.containerId");
 
-    sqlStatements.put(SBSValueType.FORUM_REPLY_RH,
-        "select 1, 1 from reportsRedHatUsers where created = ? and created = ? and created = ?");
-    sqlStatements.put(SBSValueType.FORUM_REPLY_CM,
-        "select 1, 1 from reportsRedHatUsers where created = ? and created = ? and created = ?");
-
+    sqlStatements.put(SBSValueType.FORUM_REPLY_RH, "SELECT m.containerId, count(m.messageId) " + "FROM jiveMessage m "
+        + "WHERE m.parentMessageId is not null "
+        + "and m.userID IN (SELECT userId from reportsRedHatUsers where created = ?) "
+        + "and  m.creationDate > ? and m.creationDate < ? group by m.containerId");
+    sqlStatements.put(SBSValueType.FORUM_REPLY_CM, "SELECT m.containerId, count(m.messageId) " + "FROM jiveMessage m "
+        + "WHERE m.parentMessageId is not null "
+        + "and m.userID NOT IN (SELECT userId from reportsRedHatUsers where created = ?) "
+        + "and  m.creationDate > ? and m.creationDate < ? group by m.containerId");
   }
 
   @Override
@@ -152,7 +179,8 @@
       throw new IllegalArgumentException("No SQL statement defined for value type " + valueType);
     }
 
-    // TODO: Consider usage of Spring DAO Templates instead of Prepared Statements
+    // TODO: Consider usage of Spring DAO Templates instead of Prepared
+    // Statements
 
     Connection conn = dataSource.getConnection();
     PreparedStatement ps = null;



More information about the jboss-svn-commits mailing list