Update of /cvsroot/roller/roller/src/org/roller/business
In directory
sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18546/src/org/roller/business
Modified Files:
WeblogManagerImpl.java BookmarkManagerImpl.java
Log Message:
Rewritten 0.9.8 to 0.9.9 database upgrade method and some fixes
Index: WeblogManagerImpl.java
===================================================================
RCS file:
/cvsroot/roller/roller/src/org/roller/business/WeblogManagerImpl.java,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -d -r1.24 -r1.25
*** WeblogManagerImpl.java 22 May 2004 22:18:59 -0000 1.24
--- WeblogManagerImpl.java 29 May 2004 04:01:56 -0000 1.25
***************
*** 909,987 ****
}
- /**
- * If WeblogCategoryAssoc table is empty, populate it.
- * @see org.roller.model.Roller#upgradeIfNeeded()
- */
- public void repairIfNeeded() throws RollerException
- {
- QueryFactory factory = mStrategy.getQueryFactory();
- //PersistenceStrategy pstrategy =
- //RollerFactory.getRoller().getPersistenceStrategy();
- WeblogManager wmgr = mRoller.getWeblogManager();
-
- // iterate through websites
- Query websiteQuery =
- factory.createQuery(WebsiteData.class.getName());
- Iterator websites = websiteQuery.execute().iterator();
- while (websites.hasNext())
- {
- WebsiteData wd = (WebsiteData) websites.next();
-
- // Ensure that website has a root category
- Query rootQuery = factory.createQuery(
- WeblogCategoryAssoc.class.getName());
- rootQuery.setWhere( factory.createCondition(
- Query.AND,
- factory.createCondition("category.website", Query.EQ, wd),
- factory.createCondition("ancestorCategory", Query.IS_NULL),
- factory.createCondition("relation", Query.EQ,
WeblogCategoryAssoc.PARENT)));
- List assocs = rootQuery.execute();
-
- WeblogCategoryData rootCat = null;
- if (assocs.size() == 0)
- {
- // create root cat
- rootCat =
wmgr.createWeblogCategory(wd,null,"root","root",null);
- rootCat.save();
- }
- else
- {
- rootCat = ((WeblogCategoryAssoc)assocs.get(0)).getCategory();
- }
-
- if (wd.getBloggerCategory() == null)
- {
- wd.setBloggerCategory(rootCat);
- }
-
- if (wd.getDefaultCategory() == null)
- {
- wd.setDefaultCategory(rootCat);
- }
-
- // ensure that every non-root cat has a parent
- Query allCats =
- factory.createQuery(WeblogCategoryData.class.getName());
- allCats.setWhere(factory.createCondition(
- factory.createCondition("website", Query.EQ, wd),
- Query.AND,
- factory.createCondition("name", Query.NE, "root")));
- Iterator cats = allCats.execute().iterator();
- while (cats.hasNext())
- {
- WeblogCategoryData cat = (WeblogCategoryData) cats.next();
-
- if (null == cat.getParent())
- {
- WeblogCategoryAssoc parentAssoc =
- wmgr.createWeblogCategoryAssoc(
- cat, rootCat, WeblogCategoryAssoc.PARENT);
- parentAssoc.save();
-
- cat.setParent(rootCat);
- rootCat.save();
- }
- }
- }
- }
}
--- 909,911 ----
Index: BookmarkManagerImpl.java
===================================================================
RCS file:
/cvsroot/roller/roller/src/org/roller/business/BookmarkManagerImpl.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** BookmarkManagerImpl.java 9 Feb 2004 14:47:18 -0000 1.11
--- BookmarkManagerImpl.java 29 May 2004 04:01:56 -0000 1.12
***************
*** 23,26 ****
--- 23,27 ----
import java.io.StringReader;
+ import java.sql.Connection;
import java.util.Iterator;
import java.util.LinkedList;
***************
*** 392,458 ****
}
- public void repairIfNeeded() throws RollerException
- {
- QueryFactory factory = mStrategy.getQueryFactory();
- PersistenceStrategy pstrategy =
- RollerFactory.getRoller().getPersistenceStrategy();
- BookmarkManager wmgr = mRoller.getBookmarkManager();
-
- // iterate through websites
- Query websiteQuery =
- factory.createQuery(WebsiteData.class.getName());
- Iterator websites = websiteQuery.execute().iterator();
- while (websites.hasNext())
- {
-
- // ensure that website has a root folder
- WebsiteData wd = (WebsiteData) websites.next();
- Query rootQuery = factory.createQuery(
- FolderAssoc.class.getName());
- rootQuery.setWhere( factory.createCondition(
- Query.AND,
- factory.createCondition("folder.website", Query.EQ, wd),
- factory.createCondition("ancestorFolder", Query.IS_NULL),
- factory.createCondition("relation", Query.EQ,
FolderAssoc.PARENT)));
- List assocs = rootQuery.execute();
-
- FolderData rootFolder = null;
- if (assocs.size() == 0)
- {
- // create root
- rootFolder = wmgr.createFolder(null, "root", "root", wd);
- rootFolder.save();
- }
- else
- {
- rootFolder = ((FolderAssoc)assocs.get(0)).getFolder();
- }
-
- // ensure all non-root folders have a parent
- Query allFolders =
- factory.createQuery(FolderData.class.getName());
- allFolders.setWhere(factory.createCondition(
- factory.createCondition("website", Query.EQ, wd),
- Query.AND,
- factory.createCondition("name", Query.NE, "root")));
- Iterator folders = allFolders.execute().iterator();
- while (folders.hasNext())
- {
- FolderData folder = (FolderData) folders.next();
-
- if (null == folder.getParent())
- {
- FolderAssoc parentAssoc =
- (FolderAssoc)wmgr.createFolderAssoc(
- folder, rootFolder, FolderAssoc.PARENT);
- parentAssoc.save();
-
- folder.setParent(rootFolder);
- folder.save();
- }
- }
- }
- }
-
/**
* @see
org.roller.model.BookmarkManager#retrieveBookmarks(org.roller.pojos.FolderData,
boolean)
--- 393,396 ----
-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g.
Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click
|