logo       

roller/src/org/roller/business/hibernate BookmarkManagerImpl.java,1.8,1.9 H: msg#00119

Subject: roller/src/org/roller/business/hibernate BookmarkManagerImpl.java,1.8,1.9 HibernateStrategy.java,1.1,1.2 NewsfeedManagerImpl.java,1.9,1.10 RefererManagerImpl.java,1.25,1.26 UserManagerImpl.java,1.20,1.21 WeblogManagerImpl.java,1.25,1.26
Update of /cvsroot/roller/roller/src/org/roller/business/hibernate
In directory sc8-pr-cvs1:/tmp/cvs-serv4958/src/org/roller/business/hibernate

Modified Files:
        BookmarkManagerImpl.java HibernateStrategy.java 
        NewsfeedManagerImpl.java RefererManagerImpl.java 
        UserManagerImpl.java WeblogManagerImpl.java 
Log Message:
Extracting queries ("OQL") from the implementations.  Some further work is 
needed, but this proves the concept and improves performance.

Index: BookmarkManagerImpl.java
===================================================================
RCS file: 
/cvsroot/roller/roller/src/org/roller/business/hibernate/BookmarkManagerImpl.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** BookmarkManagerImpl.java    14 Aug 2003 21:09:49 -0000      1.8
--- BookmarkManagerImpl.java    20 Aug 2003 16:37:30 -0000      1.9
***************
*** 5,11 ****
  
  import java.io.Serializable;
- import java.util.Iterator;
  import java.util.List;
- import java.util.Vector;
  
  import net.sf.hibernate.Hibernate;
--- 5,9 ----
***************
*** 20,26 ****
  import org.roller.model.PersistenceStrategy;
  import org.roller.model.UserManager;
- import org.roller.pojos.BookmarkData;
  import org.roller.pojos.FolderData;
- import org.roller.pojos.WebsiteData;
  
  /**
--- 18,22 ----
***************
*** 45,115 ****
      //----------------------------------------------------------------- Folder
  
-     /** Remove folder optionally retrieve the bookmarks that it contains */
-     public FolderData retrieveFolder( String id, boolean bookmarks )
-         throws RollerException
-     {
-         String msg = "retrieveFolder";
-         FolderData fd = (FolderData)
-             mSupport.retrievePersistentObject( id, FolderData.class );
-         if (bookmarks) populateBookmarks(fd);            
-         return fd;
-     }
- 
-     // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-     
-     public FolderData[] getFolders(WebsiteData website) throws RollerException
-     {
-               Object[] args = {website.getId()};
-               Type[] types = {Hibernate.STRING};
-               String query = 
-                       "SELECT p FROM org.roller.pojos.FolderData p WHERE 
p.website.id=?";
- 
-               List folders = mSupport.query(query, args, types);
-               Iterator iter = folders.iterator();
-               while (iter.hasNext())
-               {
-                       FolderData folder = (FolderData) iter.next();
-                       populateBookmarks(  folder );
-                       //folders.add( folder );
-               }
- 
-               return (FolderData[]) folders.toArray(
-                                       new FolderData[ folders.size() ] );
-     }
-     
-     public FolderData[] getFolders(
-         String parentId, boolean bookmarks ) throws RollerException
-     {
-         Object[] args = {parentId};
-         Type[] types = {Hibernate.STRING};
-         List folders = mSupport.query(
-             "select f from f in class org.roller.pojos.FolderData "+
-             "where f.parentId=?",
-             args, types);
-         
-         Iterator iter = folders.iterator();
-         while (iter.hasNext())
-         {
-             FolderData folder = (FolderData) iter.next();
-             populateBookmarks( folder );
-         }
- 
-         return (FolderData[]) folders.toArray(
-                     new FolderData[ folders.size() ] );
-     }
- 
-     // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- 
-     public FolderData[] getTopLevelFolders(
-         String userName, boolean bookmarks ) throws RollerException
-     {
-         // Return folders in top level folder
-         FolderData topFolder = getTopLevelFolder( userName );
-         if (topFolder == null) return new FolderData[]{};
-         return getFolders( topFolder.getId(), bookmarks );
-     }
- 
-     // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- 
      public FolderData getTopLevelFolder( String userName )
          throws RollerException
--- 41,44 ----
***************
*** 131,184 ****
      }
  
-     // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- 
-     public FolderData getFolder( String userName, String folderName )
-         throws RollerException
-     {
-         if ( userName==null )
-             throw new RollerException("Username is null");
-             
-         if ( folderName==null )
-             throw new RollerException("Folder name is null");
- 
-         Object[] args = { userName, folderName };
-         Type[] types = { Hibernate.STRING, Hibernate.STRING };
-    
-         List list = mSupport.query(
-             "select f from f in class org.roller.pojos.FolderData "
-           + "where f.website.user.userName=? and f.name=?", args, types );
-         
-         FolderData fd = list.size()!=0 ? (FolderData)list.get(0) : null;
-         if ( fd != null )
-         {
-             populateBookmarks(fd);
-         }
-         return fd;
-     }
- 
      //---------------------------------------------------------------- 
Privates
- 
-     protected void populateBookmarks( FolderData folder )
-         throws RollerException
-     {
-         String msg = "populateBookmarks";
-         if (  folder != null ) 
-         {
-             // Query for bookmarks in folder
-             Object args[] = {folder.getId()};
-             Type types[] = {Hibernate.STRING};
-             List bookmarks = mSupport.query( 
-                 "select b from b in class org.roller.pojos.BookmarkData "
-                +"where b.folder.id=?",args,types);
- 
-             Vector bv = new Vector();
-             Iterator iter = bookmarks.iterator();
-             while (iter.hasNext())
-             {
-                 BookmarkData bd = (BookmarkData) iter.next();
-                 bv.addElement(bd);
-             }
-             folder.setBookmarks( bv );
-         }
-     }
  }
--- 60,63 ----

Index: HibernateStrategy.java
===================================================================
RCS file: 
/cvsroot/roller/roller/src/org/roller/business/hibernate/HibernateStrategy.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** HibernateStrategy.java      14 Aug 2003 21:09:49 -0000      1.1
--- HibernateStrategy.java      20 Aug 2003 16:37:30 -0000      1.2
***************
*** 230,234 ****
          
                  try
!                 {            
                          return getSession().find(query,args,types);
                  }
--- 230,238 ----
          
                  try
!                 {    
!               if (query.indexOf("$") > -1)
!               {
!                   query = query.replaceAll("\\$\\d+", "\\?");
!               }        
                          return getSession().find(query,args,types);
                  }
***************
*** 244,248 ****
        {
                try
!               {            
                        return getSession().find(query);
                }
--- 248,256 ----
        {
                try
!               {   
!             if (query.indexOf("$") > -1)
!             {
!                 query = query.replaceAll("\\$\\d+", "\\?");
!             }
                        return getSession().find(query);
                }

Index: NewsfeedManagerImpl.java
===================================================================
RCS file: 
/cvsroot/roller/roller/src/org/roller/business/hibernate/NewsfeedManagerImpl.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** NewsfeedManagerImpl.java    14 Aug 2003 21:09:49 -0000      1.9
--- NewsfeedManagerImpl.java    20 Aug 2003 16:37:30 -0000      1.10
***************
*** 5,12 ****
  
  import java.io.Serializable;
- import java.util.List;
- 
- import net.sf.hibernate.Hibernate;
- import net.sf.hibernate.type.Type;
  
  import org.apache.commons.logging.Log;
--- 5,8 ----
***************
*** 14,20 ****
  import org.roller.RollerException;
  import org.roller.business.NewsfeedManagerBase;
- import org.roller.model.PersistenceStrategy;
  import org.roller.model.NewsfeedManager;
! import org.roller.pojos.NewsfeedData;
  
  /**
--- 10,15 ----
  import org.roller.RollerException;
  import org.roller.business.NewsfeedManagerBase;
  import org.roller.model.NewsfeedManager;
! import org.roller.model.PersistenceStrategy;
  
  /**
***************
*** 31,71 ****
                mSupport = (HibernateStrategy)support;
      }
- 
-     /** 
-      * @see org.roller.pojos.NewsfeedManager#getNewsfeeds(java.lang.String)
-      */
-     public NewsfeedData[] getNewsfeeds(String userName) throws RollerException
-     {
-         List feeds = null;
- 
-         Object[] args = {userName};
-         Type[] types = {Hibernate.STRING};
-         feeds = mSupport.query(
-             "select n from n in class org.roller.pojos.NewsfeedData "+
-             "where n.website.user.userName=?",
-             args, types);
- 
-         return (NewsfeedData[])feeds.toArray(new NewsfeedData[feeds.size()]);
-     }
- 
-     /** 
-      * @see org.roller.pojos.NewsfeedManager#getNewsfeeds(java.lang.String, 
java.lang.String)
-      */
-     public NewsfeedData getNewsfeed(String userName, String feedName)
-         throws RollerException
-     {
-         NewsfeedData feed = null;
- 
-         Object[] args = {userName, feedName};
-         Type[] types = {Hibernate.STRING,Hibernate.STRING};
-         List feeds = mSupport.query(
-            "select n from n in class org.roller.pojos.NewsfeedData "+
-            "where n.website.user.userName=? and n.name=?",
-            args, types);
-          
-         if ( feeds.size()>0 ) feed = (NewsfeedData)feeds.get(0);         
- 
-         return feed;
-     }
- 
  }
--- 26,28 ----

Index: RefererManagerImpl.java
===================================================================
RCS file: 
/cvsroot/roller/roller/src/org/roller/business/hibernate/RefererManagerImpl.java,v
retrieving revision 1.25
retrieving revision 1.26
diff -C2 -d -r1.25 -r1.26
*** RefererManagerImpl.java     16 Aug 2003 23:28:59 -0000      1.25
--- RefererManagerImpl.java     20 Aug 2003 16:37:30 -0000      1.26
***************
*** 225,282 ****
  
      /**
-      * @see org.roller.pojos.RefererManager#getReferers(java.lang.String)
-      */
-     public List getReferers(String username) throws RollerException
-     {
-         Object[] args = { Boolean.TRUE, username };
-         Type[] types = { Hibernate.BOOLEAN, Hibernate.STRING };
-         String query = 
-             "select p from p in class org.roller.pojos.RefererData " + 
-             "where p.website.user.userEnabled=? and p.website.user.userName=? 
order by p.totalHits desc";
- 
-         return getReferers(query, args, types);
-     }
- 
-     //----------------------------------------------------------------------- 
   
- 
-     /**
-      * @see org.roller.pojos.RefererManager#getTodaysReferers(String)
-      */
-     public List getTodaysReferers(String username)
-                                     throws RollerException
-     {
-               Object[] args = { Boolean.TRUE, username };
-               Type[] types = { Hibernate.BOOLEAN, Hibernate.STRING };
-         String query ="select p from p in class org.roller.pojos.RefererData 
"+ 
-                       "where p.website.user.userEnabled=? and 
p.website.user.userName=? " + 
-                        "and p.dayHits>0 order by p.dayHits desc";
- 
-         return getReferers(query, args, types);
-     }
- 
-     //----------------------------------------------------------------------- 
   
- 
-     /**
-      * Returns referers for a specified day. Duplicate enties are not
-      * included in this list so the hit counts may not be accurate.
-      * @see org.roller.pojos.RefererManager#getReferersToDay(
-      * java.lang.String, java.lang.String)
-      */
-     public List getReferersToDate(String username, String date)
-                                     throws RollerException
-     {
-         Object[] args = { username, date, Boolean.FALSE };
-         Type[] types = {Hibernate.STRING,Hibernate.STRING,Hibernate.BOOLEAN};
-         String query = 
-             "select p from p in class org.roller.pojos.RefererData "+ 
-             "where p.website.user.userName=? " + 
-             "and p.dateString=? and p.duplicate=? ";
- 
-         return getReferers(query, args, types);
-     }
- 
-     //----------------------------------------------------------------------- 
   
- 
-     /**
       * @see org.roller.pojos.RefererManager#getReferersToEntry(
       * java.lang.String, java.lang.String)
--- 225,228 ----
***************
*** 295,376 ****
      }
  
-     //----------------------------------------------------------------------- 
   
- 
-     /**
-      * Query for collection of referers.
-      */
-     protected List getMatchingReferers(Object[] args)
-                                          throws RollerException
-     {
-         Type[] types = { Hibernate.STRING, Hibernate.STRING, Hibernate.STRING 
};
-         String query = "select p from p in class org.roller.pojos.RefererData 
"+ 
-                   "where p.website.id=? and p.requestUrl=? and 
p.refererUrl=?";
- 
-         return getReferers(query, args, types);
-     }
- 
-     //----------------------------------------------------------------------- 
   
- 
-     /**
-      * Query for collection of referers.
-      */
-     protected List getExistingReferers(Object[] args)
-                                          throws RollerException
-     {
-         Type[] types = { Hibernate.STRING, Hibernate.STRING, Hibernate.STRING 
};
-         String query = 
-             "select p from p in class org.roller.pojos.RefererData where " + 
-             "p.website.id=? and p.dateString=? and p.refererPermalink=?";
- 
-         return getReferers(query, args, types);
-     }
- 
-     //----------------------------------------------------------------------- 
   
- 
-     /**
-      * Query for collection of referers.
-      */
-     protected List getReferersToWebsite(Object[] args)
-                                           throws RollerException
-     {
-         Type[] types = { Hibernate.STRING, Hibernate.STRING };
-         String query = "select p from p in class org.roller.pojos.RefererData 
"+ 
-                        "where p.website.id=? and p.refererUrl=?";
- 
-         return getReferers(query, args, types);
-     }
- 
-     //----------------------------------------------------------------------- 
   
- 
-     /**
-      * Query for collection of referers. 
-      */
-     protected List getReferersWithSameTitle(Object[] args)
-                                               throws RollerException
-     {
-         Type[] types = { Hibernate.STRING, Hibernate.STRING, 
-                          Hibernate.STRING, Hibernate.STRING };
-         String query = "select p from p in class org.roller.pojos.RefererData 
"+ 
-                        "where p.website.id=? AND p.requestUrl=? " + 
-                        "and ( p.title=? OR p.excerpt=? )";
- 
-         return getReferers(query, args, types);
-     }
- 
-     //----------------------------------------------------------------------- 
   
- 
-     /**
-      * Query for collection of referers.
-      */
-     private List getReferers(String query, Object[] args, Type[] types)
-                                throws RollerException
-     {
-         String msg = "getReferers";
- 
-         List refs = mSupport.query(query, args, types);
- 
-         return refs;
- 
-     }
  
  }
--- 241,244 ----

Index: UserManagerImpl.java
===================================================================
RCS file: 
/cvsroot/roller/roller/src/org/roller/business/hibernate/UserManagerImpl.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** UserManagerImpl.java        14 Aug 2003 21:09:49 -0000      1.20
--- UserManagerImpl.java        20 Aug 2003 16:37:30 -0000      1.21
***************
*** 5,12 ****
  
  import java.io.Serializable;
- import java.util.List;
- 
- import net.sf.hibernate.Hibernate;
- import net.sf.hibernate.type.Type;
  
  import org.apache.commons.logging.Log;
--- 5,8 ----
***************
*** 17,23 ****
  import org.roller.model.UserManager;
  import org.roller.pojos.PageData;
- import org.roller.pojos.RoleData;
- import org.roller.pojos.UserData;
- import org.roller.pojos.WebsiteData;
  
  /**
--- 13,16 ----
***************
*** 30,35 ****
      private static Log mLogger = 
          LogFactory.getFactory().getInstance(UserManagerImpl.class);
- 
-     //private RollerImpl mRoller;
      
      public UserManagerImpl( RollerImpl roller, PersistenceStrategy support) 
throws RollerException
--- 23,26 ----
***************
*** 38,151 ****
                mSupport = (HibernateStrategy)support;
      }
! 
!     
//------------------------------------------------------------------------    
!     /** 
!      * @see org.roller.model.UserManager#getUsers()
!      */
!     public UserData[] getUsers() throws RollerException
!       {
!               return getUsers(true);
!       }
!       
!       public UserData[] getUsers(boolean enabledOnly) throws RollerException
!     {
!         String msg = "getUsers"; 
!         String query = "select f from f in class org.roller.pojos.UserData ";
!         if (enabledOnly) query += " where f.userEnabled=?";                   
               
!         Object[] args = {};
!         if (enabledOnly) args = new Object[]{Boolean.TRUE};
!         Type[] types = {};
!         if (enabledOnly) types = new Type[]{Hibernate.BOOLEAN};
!         List list = mSupport.query( query,args,types );            
!         return (UserData[]) list.toArray(new UserData[list.size()]);
!     }
! 
!     
//------------------------------------------------------------------------    
!     /** 
!      * @see org.roller.model.UserManager#getUser(java.lang.String)
!      */
!     public UserData getUser(String userName) throws RollerException
!       {
!               return getUser(userName, true);
!       }
!       
!       public UserData getUser(String userName, boolean enabledOnly) throws 
RollerException
!     {
!         String msg = "getUser";
!         
!         if ( userName==null )
!             throw new RollerException("Username is null");
!                                    
!         Object[] args = { userName };
!         if (enabledOnly) args = new Object[]{userName, Boolean.TRUE };
!         Type[] types = { Hibernate.STRING };
!         if (enabledOnly) types = new Type[]{ Hibernate.STRING, 
Hibernate.BOOLEAN };
! 
!               String query = "select u from u in class 
org.roller.pojos.UserData where u.userName=?";
!               if (enabledOnly) query += " and u.userEnabled=?";
!         List list = mSupport.query(query, args, types);
!             
!         return list.size()!=0 ? (UserData)list.get(0) : null;
!     }
! 
!     
//------------------------------------------------------------------------    
!     /** 
!      * @see org.roller.model.UserManager#getUserById(java.lang.String)
!      */
!     public UserData getUserById(String userId) throws RollerException
!       {
!               return getUserById(userId, true);
!       }
!       
!       public UserData getUserById(String userId, boolean enabledOnly) throws 
RollerException
!     {
!         if (!enabledOnly) return retrieveUser(userId);
! 
!               String msg = "getUserById";
!         
!               if ( userId==null )
!                       throw new RollerException("Username is null");
!                                    
!               Object[] args = { userId };
!               if (enabledOnly) args = new Object[]{userId, Boolean.TRUE };
!               Type[] types = { Hibernate.STRING };
!               if (enabledOnly) types = new Type[]{ Hibernate.STRING, 
Hibernate.BOOLEAN };
! 
!               String query = "select u from u in class 
org.roller.pojos.UserData where u.id=?";
!               if (enabledOnly) query += " and u.userEnabled=?";
!               List list = mSupport.query(query, args, types);
!             
!               return list.size()!=0 ? (UserData)list.get(0) : null;
!         
!     }
! 
!     
//------------------------------------------------------------------------    
! 
!       /* (non-Javadoc)
!        * @see org.roller.model.UserManager#getWebsite(java.lang.String, 
boolean)
!        */
!       public WebsiteData getWebsite(String userName, boolean enabledOnly) 
throws RollerException
!       {
!               String msg = "getWebsite";
!         
!               if ( userName==null )
!                       throw new RollerException("Username is null");
!                                    
!               Object[] args = { userName };
!               Type[] types = { Hibernate.STRING };
!               String query = "select w from w in class 
org.roller.pojos.WebsiteData " +
!                                               "where w.user.userName=? ";
!               if (enabledOnly)
!               {
!                       query += "and w.user.userEnabled=?";
!                       args = new Object[]{ userName, Boolean.TRUE };
!                       types = new Type[]{ Hibernate.STRING, Hibernate.BOOLEAN 
};
!               }
!         
!               List list = mSupport.query( query, args,types);
!             
!               return list.size()!=0 ? (WebsiteData)list.get(0) : null;
!       }
! 
      
//------------------------------------------------------------------------    
      /** 
--- 29,33 ----
                mSupport = (HibernateStrategy)support;
      }
!     
      
//------------------------------------------------------------------------    
      /** 
***************
*** 169,253 ****
  
      
//------------------------------------------------------------------------    
-     /** 
-      * @see org.roller.model.UserManager#getPageByName(java.lang.String, 
java.lang.String)
-      */
-     public PageData getPageByName(String u, String p) throws RollerException
-     {
-         String msg = "getPageByName";
-         
-         if ( u==null )
-             throw new RollerException("Username is null");
-                                    
-         if ( p==null )
-             throw new RollerException("Page name is null");
-                                    
-         Object[] args = { u,p, Boolean.TRUE };
-         Type[] types = { Hibernate.STRING,Hibernate.STRING,Hibernate.BOOLEAN 
};
-         
-         List list = mSupport.query(
-             "select p from p in class org.roller.pojos.PageData " +
-             "where p.website.user.userName=? and p.name=? and 
p.website.user.userEnabled=?",
-             args,types);
-             
-         return list.size()!=0 ? (PageData)list.get(0) : null;
-     }
- 
-     
//------------------------------------------------------------------------    
-     /** 
-      * @see org.roller.model.UserManager#getPageByLink(java.lang.String, 
java.lang.String)
-      */
-     public PageData getPageByLink(String u, String p) throws RollerException
-     {
-         String msg = "getPageByLink";
-         
-         if ( u==null )
-             throw new RollerException("Username is null");
-                                    
-         if ( p==null )
-             throw new RollerException("Pagelink is null");
-                                    
-         Object[] args = { u,p, Boolean.TRUE};
-         Type[] types = { Hibernate.STRING,Hibernate.STRING,Hibernate.BOOLEAN 
};
-         
-         List list = mSupport.query(
-             "select p from p in class org.roller.pojos.PageData " +
-             "where p.website.user.userName=? and p.link=? and 
p.website.user.userEnabled=?",
-             args,types);
-             
-         return list.size()!=0 ? (PageData)list.get(0) : null;
-     }
- 
-     
//------------------------------------------------------------------------    
-     /** 
-      * @see org.roller.model.UserManager#getPages(java.lang.String)
-      */
-     public PageData[] getPages(String userName) throws RollerException
-     {
-         if ( userName == null )
-             throw new RollerException("Username is null");
-             
-         String msg = "getPages";                                   
-         Object[] args = {userName, Boolean.TRUE};
-         Type[] types = {Hibernate.STRING,Hibernate.BOOLEAN};       
-         List list = mSupport.query(
-             "select p from p in class org.roller.pojos.PageData "
-            +"where p.website.user.userName=? and 
p.website.user.userEnabled=?",args,types);
-                         
-         return (PageData[]) list.toArray(new PageData[list.size()]);
-     }
  
-     /* (non-Javadoc)
-      * @see 
org.roller.business.UserManagerBase#getRoles(org.roller.pojos.UserData)
-      */
-     protected RoleData[] getRoles(UserData user) throws RollerException
-     {
-               String query =
-                       "SELECT r FROM org.roller.pojos.RoleData r WHERE 
userId=?";
-               Object[] args = { user.getId() };
-               Type[] types = { Hibernate.STRING };
-               List roles = mSupport.query(query, args, types);
- 
-               return (RoleData[]) roles.toArray(new RoleData[roles.size()]);
-     }
  
  }
--- 51,55 ----

Index: WeblogManagerImpl.java
===================================================================
RCS file: 
/cvsroot/roller/roller/src/org/roller/business/hibernate/WeblogManagerImpl.java,v
retrieving revision 1.25
retrieving revision 1.26
diff -C2 -d -r1.25 -r1.26
*** WeblogManagerImpl.java      16 Aug 2003 00:07:46 -0000      1.25
--- WeblogManagerImpl.java      20 Aug 2003 16:37:30 -0000      1.26
***************
*** 6,10 ****
  import java.io.Serializable;
  import java.util.ArrayList;
- import java.util.Collections;
  import java.util.Date;
  import java.util.Iterator;
--- 6,9 ----
***************
*** 12,16 ****
  
  import net.sf.hibernate.Hibernate;
- import net.sf.hibernate.Session;
  import net.sf.hibernate.type.Type;
  
--- 11,14 ----
***************
*** 20,27 ****
  import org.roller.business.WeblogManagerBase;
  import org.roller.model.WeblogManager;
- import org.roller.pojos.CommentData;
- import org.roller.pojos.WeblogCategoryData;
  import org.roller.pojos.WeblogEntryData;
- import org.roller.pojos.WebsiteData;
  import org.roller.util.DateUtil;
  
--- 18,22 ----
***************
*** 49,154 ****
  
      //------------------------------------------------------------------------
- 
-     public WeblogEntryData retrieveWeblogEntry(String id)
-         throws RollerException
-     {
-         return (WeblogEntryData)
-             mSupport.retrievePersistentObject(id,WeblogEntryData.class);
-     }
- 
-     //------------------------------------------------------------------------
      
      public void storeWeblogEntry(WeblogEntryData data) throws RollerException
      {
- //        String msg = "storeWeblogEntry";
- 
          // If no anchor then create one
          if (data.getAnchor()==null || data.getAnchor().trim().equals(""))
          {
!             data.setAnchor(createAnchor(null, data));
          }
  
          mSupport.storePersistentObject(data);          
      }
- 
-     //------------------------------------------------------------------------
-     
-     /** Create anchor for weblog entry, based on title or text */
-     private String createAnchor(Session ses, WeblogEntryData entry)
-         throws RollerException
-     {
-         // Check for uniqueness of anchor
-         String base = createAnchor(entry);
-         String name = base;
-         int count = 0;
-         while (true)
-         {
-             if (count > 0) name = base + count;
-             
-             Object[] args = {entry.getWebsite().getId(),name};
-             Type[] types = {Hibernate.STRING,Hibernate.STRING};
-             List list = mSupport.query(
-                 "select w from w in class org.roller.pojos.WeblogEntryData "
-                +"where w.website.id=? and w.anchor=?",
-                args,types);
- 
-             Iterator iter = list.iterator();
-             if (!iter.hasNext())
-             {
-                 break;
-             }
-             else
-             {
-                 count++;
-             }
-         }
-         return name;
-     }
- 
-     //------------------------------------------------------------------------
-     
-     public void removeWeblogEntry(String id) throws RollerException
-     {
-         mSupport.removePersistentObject(id,WeblogEntryData.class);
-     }
- 
-     //------------------------------------------------------------------------
- 
-     public WeblogEntryData getWeblogEntryByAnchor(
-         String userName,
-         String anchor)
-         throws RollerException
-     {
- //        String msg = "getWeblogEntryByAnchor";
- //        WeblogEntryData entry = null;
- 
-         Object[] args = {Boolean.TRUE, userName, anchor};
-         Type[] types = {Hibernate.BOOLEAN, Hibernate.STRING, 
Hibernate.STRING};
-         List list = mSupport.query(
-             "select w from w in class org.roller.pojos.WeblogEntryData "
-            +"where w.website.user.userEnabled=? and w.website.user.userName=? 
and w.anchor=?",args,types);
-            
-         return (list.size()!=0 ? (WeblogEntryData)list.get(0) : null);
- 
-     }
- 
-     //------------------------------------------------------------------------
- 
-     public List getAllRecentWeblogEntries(Date endDate, int max)
-         throws RollerException
-     {
- //        String msg = "getAllRecentWeblogEntries";
- 
-         Object[] args = 
-             { Boolean.TRUE, endDate, Boolean.TRUE, new Integer(max) };
-         Type[] types  = 
-             { Hibernate.BOOLEAN, Hibernate.TIMESTAMP, Hibernate.BOOLEAN, 
Hibernate.INTEGER };
-         String query =  
-             "select w from w in class org.roller.pojos.WeblogEntryData "+
-             "where w.website.user.userEnabled=? and w.pubTime<? and 
w.publishEntry=? "+
-             "order by w.pubTime desc limit ?";
-                         
-         return mSupport.query(query,args,types);
-     }
      
      //------------------------------------------------------------------------
--- 44,58 ----
  
      //------------------------------------------------------------------------
      
      public void storeWeblogEntry(WeblogEntryData data) throws RollerException
      {
          // If no anchor then create one
          if (data.getAnchor()==null || data.getAnchor().trim().equals(""))
          {
!             data.setAnchor(createAnchor(data));
          }
  
          mSupport.storePersistentObject(data);          
      }
      
      //------------------------------------------------------------------------
***************
*** 352,530 ****
      }
  
-     //------------------------------------------------------------------------
- 
-     public boolean isWeblogCategoryInUse(String catId) throws RollerException
-     {
-         boolean ret = false;
-         
-         if ( catId==null )
-             throw new RollerException("catId is null");
-                                    
-         Object[] args = { catId, new Integer(1) };
-         Type[] types = { Hibernate.STRING, Hibernate.INTEGER };        
-         List results = mSupport.query(
-            "select p from p in class org.roller.pojos.WeblogEntryData "
-           +"where p.category.id=? order by p.id limit ?",args,types);
-             
-         if ( results.size() > 0 ) ret = true;
-         return ret;
-     }
- 
-     //------------------------------------------------------------------------
- 
-     public WeblogCategoryData retrieveWeblogCategory(String id)
-         throws RollerException
-     {
-         return (WeblogCategoryData)
-             mSupport.retrievePersistentObject(id,WeblogCategoryData.class);
-     }
- 
-     //------------------------------------------------------------------------
- 
-     public void storeWeblogCategory(WeblogCategoryData data)
-         throws RollerException
-     {
-         mSupport.storePersistentObject(data);
-     }
- 
-     //------------------------------------------------------------------------
- 
-     public void removeWeblogCategory(String id) throws RollerException
-     {
-         mSupport.removePersistentObject(id,WeblogCategoryData.class);
-     }
- 
-     // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- 
-       /* (non-Javadoc)
-        * @see 
org.roller.model.WeblogManager#getWeblogCategories(org.roller.pojos.WebsiteData)
-        */
-       public List getWeblogCategories(WebsiteData website) throws 
RollerException
-       {
-               if (website == null) return Collections.EMPTY_LIST;
-         
-               String query =
-                  "SELECT p FROM org.roller.pojos.WeblogCategoryData p " +
-                  "WHERE p.website.id=? and p.website.user.userEnabled=?";
-                  
-               Object[] args = {website.getId(), Boolean.TRUE};
-               Type[] types = {Hibernate.STRING, Hibernate.BOOLEAN};
- 
-               List cats = mSupport.query(query, args, types);
-               return cats;
-       }
- 
-       // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- 
-     public List getWeblogCategories(String userName)
-         throws RollerException
-     {
-         Object[] args = { userName, Boolean.TRUE };
-         Type[] types = { Hibernate.STRING, Hibernate.BOOLEAN };
-                 
-         List results = mSupport.query(
-            "select c from c in class org.roller.pojos.WeblogCategoryData "
-           +"where c.website.user.userName=? and 
c.website.user.userEnabled=?",args,types);
-           
-         return results;
-     }
- 
-     // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- 
-     public WeblogCategoryData getWeblogCategory(
-         String catName,
-         String user)
-         throws RollerException
-     {
-         Object[] args = { user, catName, Boolean.TRUE };
-         Type[] types = { Hibernate.STRING, Hibernate.STRING, 
Hibernate.BOOLEAN };
-         
-         String query = 
-            "select c from c in class org.roller.pojos.WeblogCategoryData "
-            +"where c.website.user.userName=? and c.name=? and 
c.website.user.userEnabled=?";
-                 
-         List results = mSupport.query( query, args,types);
-           
-         return results.size()!=0 ? (WeblogCategoryData)results.get(0) : null;
-     }
- 
-     // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- 
-     public void moveWeblogCategoryContents(String srcId, String destId)
-         throws RollerException
-     {
- //        String msg = "moveWeblogCategoryContents";
- 
- //        WeblogCategoryData srcCd =
- //            (WeblogCategoryData) mSupport.retrievePersistentObject(
- //                srcId, WeblogCategoryData.class);
- 
-         WeblogCategoryData destCd =
-             (WeblogCategoryData) mSupport.retrievePersistentObject(
-                 destId, WeblogCategoryData.class);
- 
-         // Loop through entries in src cat, assign them to dest cat
-               Object[] args = { srcId };
-               Type[] types = { Hibernate.STRING };
-         List list = ((HibernateStrategy)mSupport).query(
-               "select p from p in class org.roller.pojos.WeblogEntryData "
-             + "where p.category.id=?",args,types);
-         
-         Iterator iter = list.iterator();
-         while (iter.hasNext())
-         {
-             WeblogEntryData entry = (WeblogEntryData) iter.next();
-             entry.setCategory(destCd);
-             mSupport.storePersistentObject( entry );
-         }
-     }
- 
-     //---------------------------------------------------------- CommentData
- 
-     public void storeComment(CommentData data) throws RollerException
-     {
-         mSupport.storePersistentObject(data);
-     }
- 
-     // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- 
-     public List getComments(String entryId)
-         throws RollerException
-     {
-         ArrayList comments = new ArrayList();
- //        String msg = "getComments";
- 
-         // Loop through entries in src cat, assign them to dest cat
-         Object[] args = {entryId};
-         Type[] types = {Hibernate.STRING};
-         List results = mSupport.query(
-           "select c from c in class org.roller.pojos.CommentData "
-           +"where c.entry.id=? order by c.postTime asc",args,types);
-           
-         Iterator iter = results.iterator();
-         while (iter.hasNext())
-         {
-             CommentData comment = (CommentData) iter.next();
-             comments.add(comment);
-         }
- 
-         return comments;
-     }
- 
-     // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-     public void removeComment(String id) throws RollerException
-     {
-         mSupport.removePersistentObject(id,CommentData.class);
-     }
- 
-     // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-     public void removeComments(String[] ids) throws RollerException
-     {
- //        String msg = "removeComments";
- 
-         for (int i = 0; i < ids.length; i++)
-         {
-             removeComment(ids[i]);
-         }
-     }
  }
--- 256,258 ----




-------------------------------------------------------
This SF.net email is sponsored by Dice.com.
Did you know that Dice has over 25,000 tech jobs available today? From
careers in IT to Engineering to Tech Sales, Dice has tech jobs from the
best hiring companies. http://www.dice.com/index.epl?rel_code=104


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
web.pylons.gene...    hurd.l4/2002-10...    kernel.commits....    user-groups.lin...    yellowdog.gener...    java.drools.use...    security.openva...    package-managem...    linux.debian.us...    qnx.openqnx.dev...    genealogy.gramp...    file-systems.if...    voip.wengophone...    tex.context/200...    ietf.smime/2003...    audio.csound.de...    culture.region....    xfree86.devel/2...    mobile.kannel.u...    distributed.con...    education.engli...    org.user-groups...    bug-tracking.gn...    recreation.bicy...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe