You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@roller.apache.org by ag...@apache.org on 2006/07/15 01:26:50 UTC
svn commit: r422095 - in /incubator/roller/branches/roller_3.0:
src/org/apache/roller/business/hibernate/ src/org/apache/roller/model/
src/org/apache/roller/ui/rendering/model/
src/org/apache/roller/ui/rendering/velocity/deprecated/
tests/org/apache/ro...
Author: agilliland
Date: Fri Jul 14 16:26:49 2006
New Revision: 422095
URL: http://svn.apache.org/viewvc?rev=422095&view=rev
Log:
next/previous functionality now takes locale into consideration.
Modified:
incubator/roller/branches/roller_3.0/src/org/apache/roller/business/hibernate/HibernateWeblogManagerImpl.java
incubator/roller/branches/roller_3.0/src/org/apache/roller/model/WeblogManager.java
incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/WeblogEntriesPagerImpl.java
incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/velocity/deprecated/OldWeblogPageModel.java
incubator/roller/branches/roller_3.0/tests/org/apache/roller/business/WeblogEntryTest.java
Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/business/hibernate/HibernateWeblogManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/business/hibernate/HibernateWeblogManagerImpl.java?rev=422095&r1=422094&r2=422095&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/business/hibernate/HibernateWeblogManagerImpl.java (original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/business/hibernate/HibernateWeblogManagerImpl.java Fri Jul 14 16:26:49 2006
@@ -1,23 +1,21 @@
/*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements. 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. For additional information regarding
-* copyright in this work, please see the NOTICE file in the top level
-* directory of this distribution.
-*/
-/*
- * Created on Jun 16, 2004
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. 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. For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
*/
+
package org.apache.roller.business.hibernate;
import java.text.SimpleDateFormat;
@@ -31,7 +29,6 @@
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
-
import org.apache.commons.collections.comparators.ReverseComparator;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.logging.Log;
@@ -61,6 +58,7 @@
import org.hibernate.criterion.MatchMode;
import org.hibernate.criterion.Order;
+
/**
* Hibernate implementation of the WeblogManager.
*/
@@ -293,12 +291,10 @@
}
- public List getNextPrevEntries(
- WeblogEntryData current, String catName, int maxEntries, boolean next)
+ public List getNextPrevEntries(WeblogEntryData current, String catName,
+ String locale, int maxEntries, boolean next)
throws RollerException {
- if (catName != null && catName.trim().equals("/")) {
- catName = null;
- }
+
Junction conjunction = Expression.conjunction();
conjunction.add(Expression.eq("website", current.getWebsite()));
conjunction.add(Expression.eq("status", WeblogEntryData.PUBLISHED));
@@ -309,7 +305,7 @@
conjunction.add(Expression.lt("pubTime", current.getPubTime()));
}
- if (catName != null) {
+ if (catName != null && !catName.trim().equals("/")) {
WeblogCategoryData category =
getWeblogCategoryByPath(current.getWebsite(), null, catName);
if (category != null) {
@@ -319,6 +315,10 @@
}
}
+ if(locale != null) {
+ conjunction.add(Expression.eq("locale", locale));
+ }
+
try {
Session session = ((HibernatePersistenceStrategy)this.strategy).getSession();
Criteria criteria = session.createCriteria(WeblogEntryData.class);
@@ -1103,38 +1103,49 @@
}
}
- public List getNextEntries(
- WeblogEntryData current, String catName, int maxEntries)
+
+ public List getNextEntries(WeblogEntryData current, String catName,
+ String locale, int maxEntries)
throws RollerException {
- return getNextPrevEntries(current, catName, maxEntries, true);
+
+ return getNextPrevEntries(current, catName, locale, maxEntries, true);
}
- public List getPreviousEntries(
- WeblogEntryData current, String catName, int maxEntries)
+
+ public List getPreviousEntries(WeblogEntryData current, String catName,
+ String locale, int maxEntries)
throws RollerException {
- return getNextPrevEntries(current, catName, maxEntries, false);
+
+ return getNextPrevEntries(current, catName, locale, maxEntries, false);
}
- public WeblogEntryData getNextEntry(WeblogEntryData current, String catName)
- throws RollerException {
+
+ public WeblogEntryData getNextEntry(WeblogEntryData current, String catName,
+ String locale)
+ throws RollerException {
+
WeblogEntryData entry = null;
- List entryList = getNextEntries(current, catName, 1);
+ List entryList = getNextEntries(current, catName, locale, 1);
if (entryList != null && entryList.size() > 0) {
entry = (WeblogEntryData)entryList.get(0);
}
return entry;
}
- public WeblogEntryData getPreviousEntry(WeblogEntryData current, String catName)
- throws RollerException {
+
+ public WeblogEntryData getPreviousEntry(WeblogEntryData current, String catName,
+ String locale)
+ throws RollerException {
+
WeblogEntryData entry = null;
- List entryList = getPreviousEntries(current, catName, 1);
+ List entryList = getPreviousEntries(current, catName, locale, 1);
if (entryList != null && entryList.size() > 0) {
entry = (WeblogEntryData)entryList.get(0);
}
return entry;
}
-
+
+
public void release() {}
/**
Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/model/WeblogManager.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/model/WeblogManager.java?rev=422095&r1=422094&r2=422095&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/model/WeblogManager.java (original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/model/WeblogManager.java Fri Jul 14 16:26:49 2006
@@ -1,20 +1,20 @@
/*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements. 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. For additional information regarding
-* copyright in this work, please see the NOTICE file in the top level
-* directory of this distribution.
-*/
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. 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. For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
package org.apache.roller.model;
@@ -29,6 +29,7 @@
import org.apache.roller.pojos.WeblogEntryData;
import org.apache.roller.pojos.WebsiteData;
+
/**
* Interface to weblog entry, category and comment management.
*/
@@ -168,8 +169,8 @@
* @param current The "current" WeblogEntryData
* @param catName The value of the requested Category Name
*/
- public WeblogEntryData getNextEntry(WeblogEntryData current, String catName)
- throws RollerException;
+ public WeblogEntryData getNextEntry(WeblogEntryData current,
+ String catName, String locale) throws RollerException;
/**
* Get the WeblogEntry prior to, chronologically, the current entry.
@@ -178,7 +179,7 @@
* @param catName The value of the requested Category Name.
*/
public WeblogEntryData getPreviousEntry(WeblogEntryData current,
- String catName) throws RollerException;
+ String catName, String locale) throws RollerException;
/**
* Get entries next after current entry.
@@ -187,7 +188,7 @@
* @param maxEntries Maximum number of entries to return.
*/
public List getNextEntries(WeblogEntryData entry,
- String catName, int maxEntries) throws RollerException;
+ String catName, String locale, int maxEntries) throws RollerException;
/**
* Get entries previous to current entry.
@@ -196,7 +197,7 @@
* @param maxEntries Maximum number of entries to return.
*/
public List getPreviousEntries(WeblogEntryData entry,
- String catName, int maxEntries) throws RollerException;
+ String catName, String locale, int maxEntries) throws RollerException;
/**
* Get specified number of most recent pinned and published Weblog Entries.
Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/WeblogEntriesPagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/WeblogEntriesPagerImpl.java?rev=422095&r1=422094&r2=422095&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/WeblogEntriesPagerImpl.java (original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/WeblogEntriesPagerImpl.java Fri Jul 14 16:26:49 2006
@@ -314,7 +314,7 @@
if (nextEntry == null) try {
Roller roller = RollerFactory.getRoller();
WeblogManager wmgr = roller.getWeblogManager();
- nextEntry = wmgr.getNextEntry(entry, cat != null ? cat.getPath() : null);
+ nextEntry = wmgr.getNextEntry(entry, cat != null ? cat.getPath() : null, locale);
// make sure that entry is published and not to future
if (nextEntry != null && nextEntry.getPubTime().after(new Date())
&& nextEntry.getStatus().equals(WeblogEntryData.PUBLISHED)) {
@@ -330,7 +330,7 @@
if (prevEntry == null) try {
Roller roller = RollerFactory.getRoller();
WeblogManager wmgr = roller.getWeblogManager();
- prevEntry = wmgr.getPreviousEntry(entry, cat != null ? cat.getPath() : null);
+ prevEntry = wmgr.getPreviousEntry(entry, cat != null ? cat.getPath() : null, locale);
// make sure that entry is published and not to future
if (prevEntry != null && prevEntry.getPubTime().after(new Date())
&& prevEntry.getStatus().equals(WeblogEntryData.PUBLISHED)) {
Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/velocity/deprecated/OldWeblogPageModel.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/velocity/deprecated/OldWeblogPageModel.java?rev=422095&r1=422094&r2=422095&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/velocity/deprecated/OldWeblogPageModel.java (original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/velocity/deprecated/OldWeblogPageModel.java Fri Jul 14 16:26:49 2006
@@ -689,7 +689,7 @@
}
try {
WeblogEntryData nextEntry =
- mWeblogMgr.getNextEntry(currentEntry.getPojo(), catName);
+ mWeblogMgr.getNextEntry(currentEntry.getPojo(), catName, mLocale);
if(nextEntry != null)
mNextEntry = WeblogEntryDataWrapper.wrap(nextEntry);
@@ -721,7 +721,7 @@
}
try {
WeblogEntryData prevEntry =
- mWeblogMgr.getPreviousEntry(currentEntry.getPojo(), catName);
+ mWeblogMgr.getPreviousEntry(currentEntry.getPojo(), catName, mLocale);
if(prevEntry != null)
mPreviousEntry = WeblogEntryDataWrapper.wrap(prevEntry);
Modified: incubator/roller/branches/roller_3.0/tests/org/apache/roller/business/WeblogEntryTest.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/tests/org/apache/roller/business/WeblogEntryTest.java?rev=422095&r1=422094&r2=422095&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/tests/org/apache/roller/business/WeblogEntryTest.java (original)
+++ incubator/roller/branches/roller_3.0/tests/org/apache/roller/business/WeblogEntryTest.java Fri Jul 14 16:26:49 2006
@@ -245,27 +245,27 @@
// get next entries
entries = null;
- entries = mgr.getNextEntries(entry1, null, 5);
+ entries = mgr.getNextEntries(entry1, null, null, 5);
assertNotNull(entries);
assertEquals(1, entries.size());
assertEquals(entry2, entries.get(0));
// get next entry
entry = null;
- entry = mgr.getNextEntry(entry1, null);
+ entry = mgr.getNextEntry(entry1, null, null);
assertNotNull(entry);
assertEquals(entry2, entry);
// get previous entries
entries = null;
- entries = mgr.getPreviousEntries(entry2, null, 5);
+ entries = mgr.getPreviousEntries(entry2, null, null, 5);
assertNotNull(entries);
assertEquals(1, entries.size());
assertEquals(entry1, entries.get(0));
// get previous entry
entry = null;
- entry = mgr.getPreviousEntry(entry2, null);
+ entry = mgr.getPreviousEntry(entry2, null, null);
assertNotNull(entry);
assertEquals(entry1, entry);