roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c..@apache.org
Subject svn commit: r483601 - in /incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business: datamapper/ jdo/ jpa/
Date Thu, 07 Dec 2006 18:41:03 GMT
Author: clr
Date: Thu Dec  7 10:41:02 2006
New Revision: 483601

URL: http://svn.apache.org/viewvc?view=rev&rev=483601
Log:
Updates for jpa datamapper

Added:
    incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/jpa/JPAUserManagerImpl.java
      - copied, changed from r483598, incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/datamapper/JPAUserManagerImpl.java
    incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/jpa/JPAWeblogManagerImpl.java
      - copied, changed from r483598, incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/datamapper/JPAWeblogManagerImpl.java
Removed:
    incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/datamapper/JPAUserManagerImpl.java
    incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/datamapper/JPAWeblogManagerImpl.java
Modified:
    incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/datamapper/DatamapperReferrerManagerImpl.java
    incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/datamapper/DatamapperRemoveQuery.java
    incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/datamapper/DatamapperUserManagerImpl.java
    incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/datamapper/DatamapperWeblogManagerImpl.java
    incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/jdo/JDORemoveQueryImpl.java
    incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/jpa/JPADynamicQueryImpl.java
    incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/jpa/JPANamedQueryImpl.java
    incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/jpa/JPAQueryImpl.java
    incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/jpa/JPARemoveQueryImpl.java
    incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/jpa/JPARollerImpl.java
    incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/jpa/JPAUpdateQuery.java

Modified: incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/datamapper/DatamapperReferrerManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/datamapper/DatamapperReferrerManagerImpl.java?view=diff&rev=483601&r1=483600&r2=483601
==============================================================================
--- incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/datamapper/DatamapperReferrerManagerImpl.java
(original)
+++ incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/datamapper/DatamapperReferrerManagerImpl.java
Thu Dec  7 10:41:02 2006
@@ -68,16 +68,10 @@
         this.strategy = strategy;
     }
 
-    /**
-     * Store the referer.
-     */
     public void saveReferer(RefererData referer) throws RollerException {
         strategy.store(referer);
     }
 
-    /**
-     * Remove a single referer.
-     */
     public void removeReferer(RefererData referer) throws RollerException {
         strategy.remove(referer);
     }

Modified: incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/datamapper/DatamapperRemoveQuery.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/datamapper/DatamapperRemoveQuery.java?view=diff&rev=483601&r1=483600&r2=483601
==============================================================================
--- incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/datamapper/DatamapperRemoveQuery.java
(original)
+++ incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/datamapper/DatamapperRemoveQuery.java
Thu Dec  7 10:41:02 2006
@@ -38,9 +38,4 @@
      */
     void removeAll(Object[] params);
 
-    /** Set the result to be a single instance (not a List).
-     * @return the instance on which this method is called
-     */
-    DatamapperRemoveQuery setUnique();
-
 }

Modified: incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/datamapper/DatamapperUserManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/datamapper/DatamapperUserManagerImpl.java?view=diff&rev=483601&r1=483600&r2=483601
==============================================================================
--- incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/datamapper/DatamapperUserManagerImpl.java
(original)
+++ incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/datamapper/DatamapperUserManagerImpl.java
Thu Dec  7 10:41:02 2006
@@ -45,6 +45,7 @@
 import org.apache.roller.pojos.CommentData;
 import org.apache.roller.pojos.WeblogEntryTagData;
 import org.apache.roller.pojos.TagStat;
+import org.apache.roller.pojos.WeblogEntryTagAggregateData;
 
 import java.util.ArrayList;
 import java.util.Collections;
@@ -66,7 +67,7 @@
     /** The logger instance for this class. */
     private static Log log = LogFactory.getLog(DatamapperUserManagerImpl.class);    
 
-    private DatamapperPersistenceStrategy strategy;
+    protected DatamapperPersistenceStrategy strategy;
     
 
     // cached mapping of weblogHandles -> weblogIds
@@ -123,6 +124,17 @@
         List tags = wmgr.getTags(website, null, null, -1);
         updateTagAggregates(tags);
 
+        // delete all weblog tag aggregates
+        strategy.newRemoveQuery(
+                WeblogEntryTagAggregateData.class,
+                "WeblogEntryTagAggregateData.deleteByWeblog").removeAll(website);
+
+        // delete all bad counts
+        strategy.newRemoveQuery(
+                WeblogEntryTagAggregateData.class,
+                "WeblogEntryTagAggregateData.deleteByTotalLEZero").removeAll(website);
+
+
         // Remove the website's ping queue entries
         List queueEntries = (List)strategy.newQuery(PingQueueEntryData.class,
                 "PingQueueEntryData.getByWebsite").execute(website);
@@ -222,7 +234,7 @@
     }
 
     /**
-     * @see org.apache.roller.business.UserManager#savePage(org.apache.roller.pojos.WeblogTemplate)
+     * @see org.apache.roller.model.UserManager#storePage(org.apache.roller.pojos.WeblogTemplate)
      */
     public void savePage(WeblogTemplate page) throws RollerException {
         this.strategy.store(page);
@@ -243,7 +255,7 @@
 
         // TODO BACKEND: we must do this in a better fashion, like getUserCnt()?
         boolean adminUser = false;
-        List existingUsers = this.getUsers(0, 1);
+        List existingUsers = this.getUsers(null, Boolean.TRUE, null, null, 0, 1);
         if(existingUsers.size() == 0) {
             // Make first user an admin
             adminUser = true;
@@ -279,7 +291,7 @@
         perms.setPermissionMask(PermissionsData.ADMIN);
         this.strategy.store(perms);
 
-        // add default categories
+        // add default category
         WeblogCategoryData rootCat = new WeblogCategoryData(
                 newWeblog, // newWeblog
                 null,      // parent
@@ -290,7 +302,7 @@
 
         String cats = RollerConfig.getProperty("newuser.categories");
         WeblogCategoryData firstCat = rootCat;
-        if (cats != null) {
+        if (cats != null && cats.trim().length() > 0) {
             String[] splitcats = cats.split(",");
             for (int i=0; i<splitcats.length; i++) {
                 WeblogCategoryData c = new WeblogCategoryData(
@@ -303,6 +315,7 @@
                 this.strategy.store(c);
             }
         }
+        
         // Use first category as default for Blogger API
         newWeblog.setBloggerCategory(firstCat);
 
@@ -860,7 +873,7 @@
     }
 
     /**
-     * @see org.apache.roller.business.UserManager#getPageByName(WebsiteData, java.lang.String)
+     * @see org.apache.roller.model.UserManager#getPageByName(WebsiteData, java.lang.String)
      */
     public WeblogTemplate getPageByName(WebsiteData website, String pagename)
             throws RollerException {
@@ -879,7 +892,7 @@
     }
 
     /**
-     * @see org.apache.roller.business.UserManager#getPages(WebsiteData)
+     * @see org.apache.roller.model.UserManager#getPages(WebsiteData)
      */
     public List getPages(WebsiteData website) throws RollerException {
         if (website == null)
@@ -1034,11 +1047,11 @@
         for (Iterator iter = queryResults.iterator(); iter.hasNext();) {
             Object[] row = (Object[]) iter.next();
             results.add(new StatCount(
-                (String)row[1],
-                (String)row[2],
-                (String)row[3],
-                "statCount.weblogCommentCountType",
-                new Long(((Integer)row[0]).intValue()).longValue()));
+                    (String)row[1],                     // website id
+                    (String)row[2],                     // website handle
+                    (String)row[3],                     // website name
+                    "statCount.weblogCommentCountType", // stat type 
+                    new Long(((Integer)row[0]).intValue()).longValue())); // # comments
         }
         //TODO Uncomment following once integrated with code
         //Collections.sort(results, StatCount.getComparator());

Modified: incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/datamapper/DatamapperWeblogManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/datamapper/DatamapperWeblogManagerImpl.java?view=diff&rev=483601&r1=483600&r2=483601
==============================================================================
--- incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/datamapper/DatamapperWeblogManagerImpl.java
(original)
+++ incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/datamapper/DatamapperWeblogManagerImpl.java
Thu Dec  7 10:41:02 2006
@@ -61,7 +61,7 @@
     private static Log log = LogFactory.getLog(
         DatamapperWeblogManagerImpl.class);
     
-    private DatamapperPersistenceStrategy strategy;
+    protected DatamapperPersistenceStrategy strategy;
 
     /* inline creation of reverse comparator, anonymous inner class */
     private Comparator reverseComparator = new ReverseComparator();

Modified: incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/jdo/JDORemoveQueryImpl.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/jdo/JDORemoveQueryImpl.java?view=diff&rev=483601&r1=483600&r2=483601
==============================================================================
--- incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/jdo/JDORemoveQueryImpl.java
(original)
+++ incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/jdo/JDORemoveQueryImpl.java
Thu Dec  7 10:41:02 2006
@@ -53,9 +53,4 @@
         q.deletePersistentAll(params);
     }
 
-    public DatamapperRemoveQuery setUnique() {
-        q.setUnique(true);
-        return this;
-    }
-
 }

Modified: incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/jpa/JPADynamicQueryImpl.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/jpa/JPADynamicQueryImpl.java?view=diff&rev=483601&r1=483600&r2=483601
==============================================================================
--- incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/jpa/JPADynamicQueryImpl.java
(original)
+++ incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/jpa/JPADynamicQueryImpl.java
Thu Dec  7 10:41:02 2006
@@ -27,20 +27,17 @@
  */
 public class JPADynamicQueryImpl extends JPAQueryImpl {
 
-    String queryString;
-
     /**
      * Creates a new instance of JPADynamicQueryImpl
      */
     public JPADynamicQueryImpl(EntityManager em, String queryString) {
-        super(em);
-        this.queryString = queryString;
+        super(em, queryString);
     }
 
     /**
      * Create a Query for this instance
      */
-    protected Query createQuery() {
+    protected Query createQuery(String queryString) {
         return em.createQuery(queryString);
     }
 }

Modified: incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/jpa/JPANamedQueryImpl.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/jpa/JPANamedQueryImpl.java?view=diff&rev=483601&r1=483600&r2=483601
==============================================================================
--- incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/jpa/JPANamedQueryImpl.java
(original)
+++ incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/jpa/JPANamedQueryImpl.java
Thu Dec  7 10:41:02 2006
@@ -27,20 +27,17 @@
  */
 public class JPANamedQueryImpl extends JPAQueryImpl {
 
-    String queryName;
-
     /**
      * Creates a new instance of JPANamedQueryImpl
      */
     public JPANamedQueryImpl(EntityManager em, String queryName) {
-        super(em);
-        this.queryName = queryName;
+        super(em, queryName);
     }
 
     /**
      * Create a Query for this instance
      */
-    protected Query createQuery() {
+    protected Query createQuery(String queryName) {
         return em.createNamedQuery(queryName);
     }
 }

Modified: incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/jpa/JPAQueryImpl.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/jpa/JPAQueryImpl.java?view=diff&rev=483601&r1=483600&r2=483601
==============================================================================
--- incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/jpa/JPAQueryImpl.java
(original)
+++ incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/jpa/JPAQueryImpl.java
Thu Dec  7 10:41:02 2006
@@ -40,13 +40,18 @@
     /**
      * Creates a new instance of JPAQueryImpl
      */
-    public JPAQueryImpl(EntityManager em) {
+    protected JPAQueryImpl(EntityManager em, String arg) {
         this.em = em;
-        q = createQuery();
+        q = createQuery(arg);
     }
 
-    /** Create a Query for this instance*/
-    protected abstract Query createQuery();
+    /**
+     * Create a Query for this instance.
+     * @param arg Can be the name of a named query or the actual query string
+     * for a dynamic query.
+     * @return Query object
+     */
+    protected abstract Query createQuery(String arg);
 
     public Object execute() {
         return executeQuery();

Modified: incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/jpa/JPARemoveQueryImpl.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/jpa/JPARemoveQueryImpl.java?view=diff&rev=483601&r1=483600&r2=483601
==============================================================================
--- incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/jpa/JPARemoveQueryImpl.java
(original)
+++ incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/jpa/JPARemoveQueryImpl.java
Thu Dec  7 10:41:02 2006
@@ -59,12 +59,6 @@
         q.executeUpdate();
     }
 
-    public DatamapperRemoveQuery setUnique() {
-        // TODO - Craig, what does setUnique mean on a RemoveQuery?
-        //q.setUnique(true);
-        return this;
-    }
-
     public DatamapperRemoveQuery setTypes(Object[] types) {
         return this;
     }

Modified: incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/jpa/JPARollerImpl.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/jpa/JPARollerImpl.java?view=diff&rev=483601&r1=483600&r2=483601
==============================================================================
--- incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/jpa/JPARollerImpl.java
(original)
+++ incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/jpa/JPARollerImpl.java
Thu Dec  7 10:41:02 2006
@@ -23,7 +23,7 @@
 import org.apache.roller.RollerException;
 import org.apache.roller.business.datamapper.DatamapperRollerImpl;
 import org.apache.roller.business.datamapper.DatamapperPersistenceStrategy;
-import org.apache.roller.business.datamapper.JPAUserManagerImpl;
+import org.apache.roller.business.jpa.JPAUserManagerImpl;
 import org.apache.roller.business.Roller;
 import org.apache.roller.business.UserManager;
 import org.apache.roller.business.WeblogManager;

Modified: incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/jpa/JPAUpdateQuery.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/jpa/JPAUpdateQuery.java?view=diff&rev=483601&r1=483600&r2=483601
==============================================================================
--- incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/jpa/JPAUpdateQuery.java
(original)
+++ incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/jpa/JPAUpdateQuery.java
Thu Dec  7 10:41:02 2006
@@ -55,5 +55,4 @@
         return q.executeUpdate();
     }
 
-
 }

Copied: incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/jpa/JPAUserManagerImpl.java
(from r483598, incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/datamapper/JPAUserManagerImpl.java)
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/jpa/JPAUserManagerImpl.java?view=diff&rev=483601&p1=incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/datamapper/JPAUserManagerImpl.java&r1=483598&p2=incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/jpa/JPAUserManagerImpl.java&r2=483601
==============================================================================
--- incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/datamapper/JPAUserManagerImpl.java
(original)
+++ incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/jpa/JPAUserManagerImpl.java
Thu Dec  7 10:41:02 2006
@@ -17,11 +17,12 @@
  */
 
 
-package org.apache.roller.business.datamapper;
+package org.apache.roller.business.jpa;
 
 import org.apache.roller.pojos.TagStat;
 import org.apache.roller.business.jpa.JPAPersistenceStrategy;
 import org.apache.roller.business.jpa.JPAUpdateQuery;
+import org.apache.roller.business.datamapper.DatamapperUserManagerImpl;
 import org.apache.roller.RollerException;
 
 import java.util.List;
@@ -32,17 +33,14 @@
  */
 public class JPAUserManagerImpl extends DatamapperUserManagerImpl {
 
-    private JPAPersistenceStrategy strategy;
-    
-    public JPAUserManagerImpl(JPAPersistenceStrategy strat) {
-        super(strat);
-        this.strategy = strat;
+    public JPAUserManagerImpl(JPAPersistenceStrategy strategy) {
+        super(strategy);
     }
 
     protected void updateTagAggregates(List tags) throws RollerException {
         for(Iterator iter = tags.iterator(); iter.hasNext();) {
                 TagStat stat = (TagStat) iter.next();
-                JPAUpdateQuery query = strategy.newUpdateQuery(
+                JPAUpdateQuery query = ((JPAPersistenceStrategy)strategy).newUpdateQuery(
                     "WeblogEntryTagAggregateData.updateTotalByName&ampWeblogNull");
                 query.updateAll(
                     new Object[] {Integer.valueOf(stat.getCount()), 

Copied: incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/jpa/JPAWeblogManagerImpl.java
(from r483598, incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/datamapper/JPAWeblogManagerImpl.java)
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/jpa/JPAWeblogManagerImpl.java?view=diff&rev=483601&p1=incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/datamapper/JPAWeblogManagerImpl.java&r1=483598&p2=incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/jpa/JPAWeblogManagerImpl.java&r2=483601
==============================================================================
--- incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/datamapper/JPAWeblogManagerImpl.java
(original)
+++ incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/jpa/JPAWeblogManagerImpl.java
Thu Dec  7 10:41:02 2006
@@ -17,20 +17,17 @@
  */
 
 
-package org.apache.roller.business.datamapper;
+package org.apache.roller.business.jpa;
 
 import org.apache.roller.business.jpa.JPAPersistenceStrategy;
-
+import org.apache.roller.business.datamapper.DatamapperWeblogManagerImpl;
 
 /**
  * @author Mitesh Meswani
  */
-public class JPAWeblogManagerImpl extends DatamapperWeblogManagerImpl{
-
-    private JPAPersistenceStrategy strategy;
+public class JPAWeblogManagerImpl extends DatamapperWeblogManagerImpl {
 
-    public JPAWeblogManagerImpl(JPAPersistenceStrategy strat) {
-        super(strat);
-        this.strategy = strat;
+    public JPAWeblogManagerImpl(JPAPersistenceStrategy strategy) {
+        super(strategy);
     }
 }



Mime
View raw message