You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@roller.apache.org by gm...@apache.org on 2014/06/29 21:09:13 UTC
svn commit: r1606568 [2/2] - in
/roller/trunk/app/src/main/java/org/apache/roller: planet/business/jpa/
weblogger/business/ weblogger/business/jpa/ weblogger/business/pings/
weblogger/pojos/ weblogger/ui/rendering/model/
Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPAWeblogEntryManagerImpl.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPAWeblogEntryManagerImpl.java?rev=1606568&r1=1606567&r2=1606568&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPAWeblogEntryManagerImpl.java (original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPAWeblogEntryManagerImpl.java Sun Jun 29 19:09:13 2014
@@ -23,6 +23,7 @@ import java.text.SimpleDateFormat;
import java.sql.Timestamp;
import javax.persistence.NoResultException;
import javax.persistence.Query;
+import javax.persistence.TypedQuery;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
@@ -69,12 +70,12 @@ public class JPAWeblogEntryManagerImpl i
// cached mapping of entryAnchors -> entryIds
private Map<String, String> entryAnchorToIdMap = new HashMap<String, String>();
- private static final Comparator TAG_STAT_NAME_COMPARATOR = new TagStatComparator();
+ private static final Comparator<TagStat> TAG_STAT_NAME_COMPARATOR = new TagStatComparator();
- private static final Comparator TAG_STAT_COUNT_REVERSE_COMPARATOR =
+ private static final Comparator<TagStat> TAG_STAT_COUNT_REVERSE_COMPARATOR =
Collections.reverseOrder(TagStatCountComparator.getInstance());
- private static final Comparator STAT_COUNT_COUNT_REVERSE_COMPARATOR =
+ private static final Comparator<StatCount> STAT_COUNT_COUNT_REVERSE_COMPARATOR =
Collections.reverseOrder(StatCountCountComparator.getInstance());
@@ -258,9 +259,7 @@ public class JPAWeblogEntryManagerImpl i
this.strategy.remove(att);
}
}
- // TODO: can we eliminate this unnecessary flush with OpenJPA 1.0
- this.strategy.flush();
-
+
// remove entry
this.strategy.remove(entry);
@@ -282,7 +281,7 @@ public class JPAWeblogEntryManagerImpl i
return Collections.emptyList();
}
- Query query;
+ TypedQuery<WeblogEntry> query;
WeblogCategory category;
List<Object> params = new ArrayList<Object>();
@@ -327,7 +326,7 @@ public class JPAWeblogEntryManagerImpl i
} else {
whereClause.append(" ORDER BY e.pubTime DESC");
}
- query = strategy.getDynamicQuery(queryString + whereClause.toString());
+ query = strategy.getDynamicQuery(queryString + whereClause.toString(), WeblogEntry.class);
for (int i=0; i<params.size(); i++) {
query.setParameter(i+1, params.get(i));
}
@@ -346,8 +345,8 @@ public class JPAWeblogEntryManagerImpl i
throw new WebloggerException("website is null");
}
- Query q = strategy.getNamedQuery(
- "WeblogCategory.getByWeblog");
+ TypedQuery<WeblogCategory> q = strategy.getNamedQuery(
+ "WeblogCategory.getByWeblog", WeblogCategory.class);
q.setParameter(1, website);
return q.getResultList();
}
@@ -442,7 +441,7 @@ public class JPAWeblogEntryManagerImpl i
}
- Query query = strategy.getDynamicQuery(queryString.toString());
+ TypedQuery<WeblogEntry> query = strategy.getDynamicQuery(queryString.toString(), WeblogEntry.class);
for (int i=0; i<params.size(); i++) {
query.setParameter(i+1, params.get(i));
}
@@ -462,8 +461,8 @@ public class JPAWeblogEntryManagerImpl i
*/
public List<WeblogEntry> getWeblogEntriesPinnedToMain(Integer max)
throws WebloggerException {
- Query query = strategy.getNamedQuery(
- "WeblogEntry.getByPinnedToMain&statusOrderByPubTimeDesc");
+ TypedQuery<WeblogEntry> query = strategy.getNamedQuery(
+ "WeblogEntry.getByPinnedToMain&statusOrderByPubTimeDesc", WeblogEntry.class);
query.setParameter(1, Boolean.TRUE);
query.setParameter(2, PubStatus.PUBLISHED);
if (max != null) {
@@ -527,13 +526,13 @@ public class JPAWeblogEntryManagerImpl i
}
// mapping key is combo of weblog + anchor
- String mappingKey = website.getHandle()+":"+anchor;
+ String mappingKey = website.getHandle() + ":" + anchor;
// check cache first
// NOTE: if we ever allow changing anchors then this needs updating
if(this.entryAnchorToIdMap.containsKey(mappingKey)) {
- WeblogEntry entry = this.getWeblogEntry((String) this.entryAnchorToIdMap.get(mappingKey));
+ WeblogEntry entry = this.getWeblogEntry(this.entryAnchorToIdMap.get(mappingKey));
if(entry != null) {
LOG.debug("entryAnchorToIdMap CACHE HIT - " + mappingKey);
return entry;
@@ -544,13 +543,13 @@ public class JPAWeblogEntryManagerImpl i
}
// cache failed, do lookup
- Query q = strategy.getNamedQuery(
- "WeblogEntry.getByWebsite&AnchorOrderByPubTimeDesc");
+ TypedQuery<WeblogEntry> q = strategy.getNamedQuery(
+ "WeblogEntry.getByWebsite&AnchorOrderByPubTimeDesc", WeblogEntry.class);
q.setParameter(1, website);
q.setParameter(2, anchor);
WeblogEntry entry;
try {
- entry = (WeblogEntry)q.getSingleResult();
+ entry = q.getSingleResult();
} catch (NoResultException e) {
entry = null;
}
@@ -577,8 +576,8 @@ public class JPAWeblogEntryManagerImpl i
name = base + count;
}
- Query q = strategy.getNamedQuery(
- "WeblogEntry.getByWebsite&Anchor");
+ TypedQuery<WeblogEntry> q = strategy.getNamedQuery(
+ "WeblogEntry.getByWebsite&Anchor", WeblogEntry.class);
q.setParameter(1, entry.getWebsite());
q.setParameter(2, name);
List results = q.getResultList();
@@ -609,7 +608,7 @@ public class JPAWeblogEntryManagerImpl i
if (cat.getWeblog().getBloggerCategory().equals(cat)) {
return true;
}
- Query q = strategy.getNamedQuery("WeblogEntry.getByCategory");
+ TypedQuery<WeblogEntry> q = strategy.getNamedQuery("WeblogEntry.getByCategory", WeblogEntry.class);
q.setParameter(1, cat);
int entryCount = q.getResultList().size();
return entryCount > 0;
@@ -666,7 +665,7 @@ public class JPAWeblogEntryManagerImpl i
queryString.append(" ORDER BY c.postTime ASC");
}
- Query query = strategy.getDynamicQuery(queryString.toString());
+ TypedQuery<WeblogEntryComment> query = strategy.getDynamicQuery(queryString.toString(), WeblogEntryComment.class);
if (csc.getOffset() != 0) {
query.setFirstResult(csc.getOffset());
}
@@ -730,12 +729,12 @@ public class JPAWeblogEntryManagerImpl i
*/
public WeblogCategory getWeblogCategoryByName(Weblog weblog,
String categoryName) throws WebloggerException {
- Query q = strategy.getNamedQuery(
- "WeblogCategory.getByWeblog&Name");
+ TypedQuery<WeblogCategory> q = strategy.getNamedQuery(
+ "WeblogCategory.getByWeblog&Name", WeblogCategory.class);
q.setParameter(1, weblog);
q.setParameter(2, categoryName);
try {
- return (WeblogCategory)q.getSingleResult();
+ return q.getSingleResult();
} catch (NoResultException e) {
return null;
}
@@ -759,19 +758,32 @@ public class JPAWeblogEntryManagerImpl i
* @inheritDoc
*/
public Map<Date, List<WeblogEntry>> getWeblogEntryObjectMap(WeblogEntrySearchCriteria wesc) throws WebloggerException {
- return getWeblogEntryMap(wesc, false);
+ TreeMap<Date, List<WeblogEntry>> map = new TreeMap<Date, List<WeblogEntry>>(Collections.reverseOrder());
+
+ List<WeblogEntry> entries = getWeblogEntries(wesc);
+
+ Calendar cal = Calendar.getInstance();
+ if (wesc.getWeblog() != null) {
+ cal.setTimeZone(wesc.getWeblog().getTimeZoneInstance());
+ }
+
+ for (WeblogEntry entry : entries) {
+ Date sDate = DateUtil.getNoonOfDay(entry.getPubTime(), cal);
+ List<WeblogEntry> dayEntries = map.get(sDate);
+ if (dayEntries == null) {
+ dayEntries = new ArrayList<WeblogEntry>();
+ map.put(sDate, dayEntries);
+ }
+ dayEntries.add(entry);
+ }
+ return map;
}
/**
* @inheritDoc
*/
public Map<Date, String> getWeblogEntryStringMap(WeblogEntrySearchCriteria wesc) throws WebloggerException {
- return getWeblogEntryMap(wesc, true);
- }
-
- private Map getWeblogEntryMap(WeblogEntrySearchCriteria wesc, boolean stringsOnly) throws WebloggerException {
-
- TreeMap map = new TreeMap(Collections.reverseOrder());
+ TreeMap<Date, String> map = new TreeMap<Date, String>(Collections.reverseOrder());
List<WeblogEntry> entries = getWeblogEntries(wesc);
@@ -779,33 +791,24 @@ public class JPAWeblogEntryManagerImpl i
if (wesc.getWeblog() != null) {
cal.setTimeZone(wesc.getWeblog().getTimeZoneInstance());
}
-
+
SimpleDateFormat formatter = DateUtil.get8charDateFormat();
for (WeblogEntry entry : entries) {
Date sDate = DateUtil.getNoonOfDay(entry.getPubTime(), cal);
- if (stringsOnly) {
- if (map.get(sDate) == null) {
- map.put(sDate, formatter.format(sDate));
- }
- } else {
- List dayEntries = (List) map.get(sDate);
- if (dayEntries == null) {
- dayEntries = new ArrayList();
- map.put(sDate, dayEntries);
- }
- dayEntries.add(entry);
+ if (map.get(sDate) == null) {
+ map.put(sDate, formatter.format(sDate));
}
}
return map;
}
-
+
/**
* @inheritDoc
*/
public List<StatCount> getMostCommentedWeblogEntries(Weblog website,
Date startDate, Date endDate, int offset,
int length) throws WebloggerException {
- Query query;
+ TypedQuery<WeblogEntryComment> query;
List queryResults;
Timestamp end = new Timestamp(endDate != null? endDate.getTime() : new Date().getTime());
@@ -814,13 +817,14 @@ public class JPAWeblogEntryManagerImpl i
if (startDate != null) {
Timestamp start = new Timestamp(startDate.getTime());
query = strategy.getNamedQuery(
- "WeblogEntryComment.getMostCommentedWeblogEntryByWebsite&EndDate&StartDate");
+ "WeblogEntryComment.getMostCommentedWeblogEntryByWebsite&EndDate&StartDate",
+ WeblogEntryComment.class);
query.setParameter(1, website);
query.setParameter(2, end);
query.setParameter(3, start);
} else {
query = strategy.getNamedQuery(
- "WeblogEntryComment.getMostCommentedWeblogEntryByWebsite&EndDate");
+ "WeblogEntryComment.getMostCommentedWeblogEntryByWebsite&EndDate", WeblogEntryComment.class);
query.setParameter(1, website);
query.setParameter(2, end);
}
@@ -828,12 +832,12 @@ public class JPAWeblogEntryManagerImpl i
if (startDate != null) {
Timestamp start = new Timestamp(startDate.getTime());
query = strategy.getNamedQuery(
- "WeblogEntryComment.getMostCommentedWeblogEntryByEndDate&StartDate");
+ "WeblogEntryComment.getMostCommentedWeblogEntryByEndDate&StartDate", WeblogEntryComment.class);
query.setParameter(1, end);
query.setParameter(2, start);
} else {
query = strategy.getNamedQuery(
- "WeblogEntryComment.getMostCommentedWeblogEntryByEndDate");
+ "WeblogEntryComment.getMostCommentedWeblogEntryByEndDate", WeblogEntryComment.class);
query.setParameter(1, end);
}
}
@@ -845,16 +849,18 @@ public class JPAWeblogEntryManagerImpl i
}
queryResults = query.getResultList();
List<StatCount> results = new ArrayList<StatCount>();
- for (Iterator iter = queryResults.iterator(); iter.hasNext();) {
- Object[] row = (Object[]) iter.next();
- StatCount sc = new StatCount(
- (String)row[1], // weblog handle
- (String)row[2], // entry anchor
- (String)row[3], // entry title
- "statCount.weblogEntryCommentCountType", // stat desc
- ((Long)row[0])); // count
- sc.setWeblogHandle((String)row[1]);
- results.add(sc);
+ if (queryResults != null) {
+ for (Object obj : queryResults) {
+ Object[] row = (Object[]) obj;
+ StatCount sc = new StatCount(
+ (String)row[1], // weblog handle
+ (String)row[2], // entry anchor
+ (String)row[3], // entry title
+ "statCount.weblogEntryCommentCountType", // stat desc
+ ((Long)row[0])); // count
+ sc.setWeblogHandle((String)row[1]);
+ results.add(sc);
+ }
}
// Original query ordered by desc count.
// JPA QL doesn't allow queries to be ordered by agregates; do it in memory
@@ -917,30 +923,30 @@ public class JPAWeblogEntryManagerImpl i
*/
public List<TagStat> getPopularTags(Weblog website, Date startDate, int offset, int limit)
throws WebloggerException {
- Query query;
+ TypedQuery<TagStat> query;
List queryResults;
if (website != null) {
if (startDate != null) {
Timestamp start = new Timestamp(startDate.getTime());
query = strategy.getNamedQuery(
- "WeblogEntryTagAggregate.getPopularTagsByWebsite&StartDate");
+ "WeblogEntryTagAggregate.getPopularTagsByWebsite&StartDate", TagStat.class);
query.setParameter(1, website);
query.setParameter(2, start);
} else {
query = strategy.getNamedQuery(
- "WeblogEntryTagAggregate.getPopularTagsByWebsite");
+ "WeblogEntryTagAggregate.getPopularTagsByWebsite", TagStat.class);
query.setParameter(1, website);
}
} else {
if (startDate != null) {
Timestamp start = new Timestamp(startDate.getTime());
query = strategy.getNamedQuery(
- "WeblogEntryTagAggregate.getPopularTagsByWebsiteNull&StartDate");
+ "WeblogEntryTagAggregate.getPopularTagsByWebsiteNull&StartDate", TagStat.class);
query.setParameter(1, start);
} else {
query = strategy.getNamedQuery(
- "WeblogEntryTagAggregate.getPopularTagsByWebsiteNull");
+ "WeblogEntryTagAggregate.getPopularTagsByWebsiteNull", TagStat.class);
}
}
if (offset != 0) {
@@ -956,17 +962,19 @@ public class JPAWeblogEntryManagerImpl i
List<TagStat> results = new ArrayList<TagStat>(limit >= 0 ? limit : 25);
- for (Iterator iter = queryResults.iterator(); iter.hasNext();) {
- Object[] row = (Object[]) iter.next();
- TagStat t = new TagStat();
- t.setName((String) row[0]);
- t.setCount(((Number) row[1]).intValue());
-
- min = Math.min(min, t.getCount());
- max = Math.max(max, t.getCount());
- results.add(t);
+ if (queryResults != null) {
+ for (Object obj : queryResults) {
+ Object[] row = (Object[]) obj;
+ TagStat t = new TagStat();
+ t.setName((String) row[0]);
+ t.setCount(((Number) row[1]).intValue());
+
+ min = Math.min(min, t.getCount());
+ max = Math.max(max, t.getCount());
+ results.add(t);
+ }
}
-
+
min = Math.log(1+min);
max = Math.log(1+max);
@@ -1005,7 +1013,7 @@ public class JPAWeblogEntryManagerImpl i
if (startsWith != null && startsWith.length() > 0) {
params.add(size++, startsWith + '%');
- queryString.append(" AND w.name LIKE ?" + size);
+ queryString.append(" AND w.name LIKE ?").append(size);
}
if (sortBy != null && sortBy.equals("count")) {
@@ -1028,13 +1036,15 @@ public class JPAWeblogEntryManagerImpl i
queryResults = query.getResultList();
List<TagStat> results = new ArrayList<TagStat>();
- for (Iterator iter = queryResults.iterator(); iter.hasNext();) {
- Object[] row = (Object[]) iter.next();
- TagStat ce = new TagStat();
- ce.setName((String) row[0]);
- // The JPA query retrieves SUM(w.total) always as long
- ce.setCount(((Long) row[1]).intValue());
- results.add(ce);
+ if (queryResults != null) {
+ for (Object obj : queryResults) {
+ Object[] row = (Object[]) obj;
+ TagStat ce = new TagStat();
+ ce.setName((String) row[0]);
+ // The JPA query retrieves SUM(w.total) always as long
+ ce.setCount(((Long) row[1]).intValue());
+ results.add(ce);
+ }
}
if (sortByName) {
@@ -1082,11 +1092,11 @@ public class JPAWeblogEntryManagerImpl i
queryString.append(" AND w.weblog IS NULL");
}
- Query q = strategy.getDynamicQuery(queryString.toString());
+ TypedQuery<String> q = strategy.getDynamicQuery(queryString.toString(), String.class);
for (int j=0; j<params.size(); j++) {
q.setParameter(j+1, params.get(j));
}
- List results = q.getResultList();
+ List<String> results = q.getResultList();
//TODO: DatamapperPort: Since we are only interested in knowing whether
//results.size() == tags.size(). This query can be optimized to just fetch COUNT
@@ -1111,23 +1121,23 @@ public class JPAWeblogEntryManagerImpl i
// one in the case where we have multiple rows (clustered environment)
// eventually that second entry will have a very low total (most likely 1) and
// won't matter
- Query weblogQuery = strategy.getNamedQuery(
- "WeblogEntryTagAggregate.getByName&WebsiteOrderByLastUsedDesc");
+ TypedQuery<WeblogEntryTagAggregate> weblogQuery = strategy.getNamedQuery(
+ "WeblogEntryTagAggregate.getByName&WebsiteOrderByLastUsedDesc", WeblogEntryTagAggregate.class);
weblogQuery.setParameter(1, name);
weblogQuery.setParameter(2, website);
WeblogEntryTagAggregate weblogTagData;
try {
- weblogTagData = (WeblogEntryTagAggregate)weblogQuery.getSingleResult();
+ weblogTagData = weblogQuery.getSingleResult();
} catch (NoResultException e) {
weblogTagData = null;
}
-
- Query siteQuery = strategy.getNamedQuery(
- "WeblogEntryTagAggregate.getByName&WebsiteNullOrderByLastUsedDesc");
+
+ TypedQuery<WeblogEntryTagAggregate> siteQuery = strategy.getNamedQuery(
+ "WeblogEntryTagAggregate.getByName&WebsiteNullOrderByLastUsedDesc", WeblogEntryTagAggregate.class);
siteQuery.setParameter(1, name);
WeblogEntryTagAggregate siteTagData;
try {
- siteTagData = (WeblogEntryTagAggregate)siteQuery.getSingleResult();
+ siteTagData = siteQuery.getSingleResult();
} catch (NoResultException e) {
siteTagData = null;
}
@@ -1178,10 +1188,10 @@ public class JPAWeblogEntryManagerImpl i
*/
public WeblogHitCount getHitCountByWeblog(Weblog weblog)
throws WebloggerException {
- Query q = strategy.getNamedQuery("WeblogHitCount.getByWeblog");
+ TypedQuery<WeblogHitCount> q = strategy.getNamedQuery("WeblogHitCount.getByWeblog", WeblogHitCount.class);
q.setParameter(1, weblog);
try {
- return (WeblogHitCount)q.getSingleResult();
+ return q.getSingleResult();
} catch (NoResultException e) {
return null;
}
@@ -1198,13 +1208,12 @@ public class JPAWeblogEntryManagerImpl i
cal.setTime(new Date());
cal.add(Calendar.DATE, -1 * sinceDays);
Date startDate = cal.getTime();
-
- Query query = strategy.getNamedQuery(
- "WeblogHitCount.getByWeblogEnabledTrueAndActiveTrue&DailyHitsGreaterThenZero&WeblogLastModifiedGreaterOrderByDailyHitsDesc");
+
+ TypedQuery<WeblogHitCount> query = strategy.getNamedQuery(
+ "WeblogHitCount.getByWeblogEnabledTrueAndActiveTrue&DailyHitsGreaterThenZero&WeblogLastModifiedGreaterOrderByDailyHitsDesc",
+ WeblogHitCount.class);
query.setParameter(1, startDate);
- // Was commented out due to https://glassfish.dev.java.net/issues/show_bug.cgi?id=2084
- // TODO: determine if this is still an issue. Is it a problem with other JPA implementations?
if (offset != 0) {
query.setFirstResult(offset);
}
@@ -1244,12 +1253,12 @@ public class JPAWeblogEntryManagerImpl i
if(weblog == null) {
throw new WebloggerException("Website cannot be NULL.");
}
-
- Query q = strategy.getNamedQuery("WeblogHitCount.getByWeblog");
+
+ TypedQuery<WeblogHitCount> q = strategy.getNamedQuery("WeblogHitCount.getByWeblog", WeblogHitCount.class);
q.setParameter(1, weblog);
WeblogHitCount hitCount;
try {
- hitCount = (WeblogHitCount)q.getSingleResult();
+ hitCount = q.getSingleResult();
} catch (NoResultException e) {
hitCount = null;
}
@@ -1278,11 +1287,11 @@ public class JPAWeblogEntryManagerImpl i
* @inheritDoc
*/
public void resetHitCount(Weblog weblog) throws WebloggerException {
- Query q = strategy.getNamedQuery("WeblogHitCount.getByWeblog");
+ TypedQuery<WeblogHitCount> q = strategy.getNamedQuery("WeblogHitCount.getByWeblog", WeblogHitCount.class);
q.setParameter(1, weblog);
WeblogHitCount hitCount;
try {
- hitCount = (WeblogHitCount)q.getSingleResult();
+ hitCount = q.getSingleResult();
hitCount.setDailyHits(0);
strategy.store(hitCount);
} catch (NoResultException e) {
@@ -1295,46 +1304,42 @@ public class JPAWeblogEntryManagerImpl i
* @inheritDoc
*/
public long getCommentCount() throws WebloggerException {
- Query q = strategy.getNamedQuery(
- "WeblogEntryComment.getCountAllDistinctByStatus");
+ TypedQuery<Long> q = strategy.getNamedQuery(
+ "WeblogEntryComment.getCountAllDistinctByStatus", Long.class);
q.setParameter(1, ApprovalStatus.APPROVED);
- List results = q.getResultList();
- return ((Long)results.get(0));
+ return q.getResultList().get(0);
}
/**
* @inheritDoc
*/
public long getCommentCount(Weblog website) throws WebloggerException {
- Query q = strategy.getNamedQuery(
- "WeblogEntryComment.getCountDistinctByWebsite&Status");
+ TypedQuery<Long> q = strategy.getNamedQuery(
+ "WeblogEntryComment.getCountDistinctByWebsite&Status", Long.class);
q.setParameter(1, website);
q.setParameter(2, ApprovalStatus.APPROVED);
- List results = q.getResultList();
- return ((Long)results.get(0));
+ return q.getResultList().get(0);
}
/**
* @inheritDoc
*/
public long getEntryCount() throws WebloggerException {
- Query q = strategy.getNamedQuery(
- "WeblogEntry.getCountDistinctByStatus");
+ TypedQuery<Long> q = strategy.getNamedQuery(
+ "WeblogEntry.getCountDistinctByStatus", Long.class);
q.setParameter(1, PubStatus.PUBLISHED);
- List results = q.getResultList();
- return ((Long)results.get(0));
+ return q.getResultList().get(0);
}
/**
* @inheritDoc
*/
public long getEntryCount(Weblog website) throws WebloggerException {
- Query q = strategy.getNamedQuery(
- "WeblogEntry.getCountDistinctByStatus&Website");
+ TypedQuery<Long> q = strategy.getNamedQuery(
+ "WeblogEntry.getCountDistinctByStatus&Website", Long.class);
q.setParameter(1, PubStatus.PUBLISHED);
q.setParameter(2, website);
- List results = q.getResultList();
- return ((Long)results.get(0));
+ return q.getResultList().get(0);
}
/**
@@ -1347,7 +1352,7 @@ public class JPAWeblogEntryManagerImpl i
*/
private static StringBuilder appendConjuctionToWhereclause(StringBuilder whereClause,
String expression) {
- if(whereClause.length() != 0 && expression.length() != 0) {
+ if (whereClause.length() != 0 && expression.length() != 0) {
whereClause.append(" AND ");
}
return whereClause.append(expression);
Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPAWeblogManagerImpl.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPAWeblogManagerImpl.java?rev=1606568&r1=1606567&r2=1606568&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPAWeblogManagerImpl.java (original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPAWeblogManagerImpl.java Sun Jun 29 19:09:13 2014
@@ -28,6 +28,7 @@ import org.apache.roller.weblogger.confi
import javax.persistence.NoResultException;
import javax.persistence.Query;
+import javax.persistence.TypedQuery;
import java.sql.Timestamp;
import java.util.*;
import org.apache.roller.weblogger.business.MediaFileManager;
@@ -37,6 +38,7 @@ import org.apache.roller.weblogger.busin
import org.apache.roller.weblogger.business.Weblogger;
import org.apache.roller.weblogger.business.WebloggerFactory;
import org.apache.roller.weblogger.pojos.AutoPing;
+import org.apache.roller.weblogger.pojos.PingQueueEntry;
import org.apache.roller.weblogger.pojos.PingTarget;
import org.apache.roller.weblogger.pojos.StatCount;
import org.apache.roller.weblogger.pojos.StatCountCountComparator;
@@ -66,7 +68,7 @@ public class JPAWeblogManagerImpl implem
/** The logger instance for this class. */
private static Log log = LogFactory.getLog(JPAWeblogManagerImpl.class);
- private static final Comparator STAT_COUNT_COUNT_REVERSE_COMPARATOR =
+ private static final Comparator<StatCount> STAT_COUNT_COUNT_REVERSE_COMPARATOR =
Collections.reverseOrder(StatCountCountComparator.getInstance());
private final Weblogger roller;
@@ -116,7 +118,8 @@ public class JPAWeblogManagerImpl implem
WeblogEntryManager emgr = roller.getWeblogEntryManager();
//remove theme Assocs
- Query themeAssocQuery = strategy.getNamedQuery("WeblogThemeAssoc.getThemeAssocsByWeblog");
+ TypedQuery<WeblogThemeAssoc> themeAssocQuery = strategy.getNamedQuery("WeblogThemeAssoc.getThemeAssocsByWeblog",
+ WeblogThemeAssoc.class);
themeAssocQuery.setParameter(1,website);
List<WeblogThemeAssoc> assocResults = themeAssocQuery.getResultList();
for (WeblogThemeAssoc themeAssoc : assocResults) {
@@ -124,7 +127,8 @@ public class JPAWeblogManagerImpl implem
}
// remove tags
- Query tagQuery = strategy.getNamedQuery("WeblogEntryTag.getByWeblog");
+ TypedQuery<WeblogEntryTag> tagQuery = strategy.getNamedQuery("WeblogEntryTag.getByWeblog",
+ WeblogEntryTag.class);
tagQuery.setParameter(1, website);
List<WeblogEntryTag> results = tagQuery.getResultList();
@@ -136,7 +140,7 @@ public class JPAWeblogManagerImpl implem
}
// remove site tag aggregates
- List tags = emgr.getTags(website, null, null, 0, -1);
+ List<TagStat> tags = emgr.getTags(website, null, null, 0, -1);
updateTagAggregates(tags);
// delete all weblog tag aggregates
@@ -152,7 +156,7 @@ public class JPAWeblogManagerImpl implem
removeCounts.executeUpdate();
// Remove the website's ping queue entries
- Query q = strategy.getNamedQuery("PingQueueEntry.getByWebsite");
+ TypedQuery<PingQueueEntry> q = strategy.getNamedQuery("PingQueueEntry.getByWebsite", PingQueueEntry.class);
q.setParameter(1, website);
List queueEntries = q.getResultList();
for (Object obj : queueEntries) {
@@ -166,24 +170,21 @@ public class JPAWeblogManagerImpl implem
this.strategy.remove(autoPing);
}
- // TODO: can we eliminate this unnecessary flush with OpenJPA 1.0
- this.strategy.flush();
-
// remove associated pages
- Query pageQuery = strategy.getNamedQuery("WeblogTemplate.getByWebsite");
+ TypedQuery<WeblogTemplate> pageQuery = strategy.getNamedQuery("WeblogTemplate.getByWebsite",
+ WeblogTemplate.class);
pageQuery.setParameter(1, website);
- List pages = pageQuery.getResultList();
- for (Object obj : pages) {
- WeblogTemplate page = (WeblogTemplate) obj;
+ List<WeblogTemplate> pages = pageQuery.getResultList();
- //remove associated templateCode objects
+ for (WeblogTemplate page : pages) {
+ // remove associated templateCode objects
this.removeTemplateCodeObjs(page);
-
this.strategy.remove(page);
}
// remove folders (including bookmarks)
- Query folderQuery = strategy.getNamedQuery("WeblogBookmarkFolder.getByWebsite");
+ TypedQuery<WeblogBookmarkFolder> folderQuery = strategy.getNamedQuery("WeblogBookmarkFolder.getByWebsite",
+ WeblogBookmarkFolder.class);
folderQuery.setParameter(1, website);
List<WeblogBookmarkFolder> folders = folderQuery.getResultList();
for (WeblogBookmarkFolder wbf : folders) {
@@ -201,7 +202,7 @@ public class JPAWeblogManagerImpl implem
this.strategy.flush();
// remove entries
- Query refQuery = strategy.getNamedQuery("WeblogEntry.getByWebsite");
+ TypedQuery<WeblogEntry> refQuery = strategy.getNamedQuery("WeblogEntry.getByWebsite", WeblogEntry.class);
refQuery.setParameter(1, website);
List<WeblogEntry> entries = refQuery.getResultList();
for (WeblogEntry entry : entries) {
@@ -210,8 +211,7 @@ public class JPAWeblogManagerImpl implem
this.strategy.flush();
// delete all weblog categories
- Query removeCategories= strategy.getNamedUpdate(
- "WeblogCategory.removeByWeblog");
+ Query removeCategories= strategy.getNamedUpdate("WeblogCategory.removeByWeblog");
removeCategories.setParameter(1, website);
removeCategories.executeUpdate();
@@ -227,11 +227,11 @@ public class JPAWeblogManagerImpl implem
protected void updateTagAggregates(List<TagStat> tags) throws WebloggerException {
for (TagStat stat : tags) {
- Query query = strategy.getNamedUpdate(
- "WeblogEntryTagAggregate.getByName&WebsiteNullOrderByLastUsedDesc");
+ TypedQuery<WeblogEntryTagAggregate> query = strategy.getNamedQueryCommitFirst(
+ "WeblogEntryTagAggregate.getByName&WebsiteNullOrderByLastUsedDesc", WeblogEntryTagAggregate.class);
query.setParameter(1, stat.getName());
try {
- WeblogEntryTagAggregate agg = (WeblogEntryTagAggregate)query.getSingleResult();
+ WeblogEntryTagAggregate agg = query.getSingleResult();
agg.setTotal(agg.getTotal() - stat.getCount());
} catch (NoResultException ignored) {
// nothing to update
@@ -264,7 +264,6 @@ public class JPAWeblogManagerImpl implem
}
public void addWeblog(Weblog newWeblog) throws WebloggerException {
-
this.strategy.store(newWeblog);
this.strategy.flush();
this.addWeblogContents(newWeblog);
@@ -281,20 +280,22 @@ public class JPAWeblogManagerImpl implem
String cats = WebloggerConfig.getProperty("newuser.categories");
WeblogCategory firstCat = null;
- String[] splitcats = cats.split(",");
- for (int i=0; i<splitcats.length; i++) {
- if (splitcats[i].trim().length() == 0) {
- continue;
- }
- WeblogCategory c = new WeblogCategory(
- newWeblog,
- splitcats[i],
- null,
- null );
- if (firstCat == null) {
- firstCat = c;
+ if (cats != null) {
+ String[] splitcats = cats.split(",");
+ for (String split : splitcats) {
+ if (split.trim().length() == 0) {
+ continue;
+ }
+ WeblogCategory c = new WeblogCategory(
+ newWeblog,
+ split,
+ null,
+ null );
+ if (firstCat == null) {
+ firstCat = c;
+ }
+ this.strategy.store(c);
}
- this.strategy.store(c);
}
// Use first category as default for Blogger API
@@ -314,7 +315,7 @@ public class JPAWeblogManagerImpl implem
String[] splitroll = blogroll.split(",");
for (String splitItem : splitroll) {
String[] rollitems = splitItem.split("\\|");
- if (rollitems != null && rollitems.length > 1) {
+ if (rollitems.length > 1) {
WeblogBookmark b = new WeblogBookmark(
defaultFolder,
rollitems[0],
@@ -369,7 +370,7 @@ public class JPAWeblogManagerImpl implem
if(this.weblogHandleToIdMap.containsKey(handle)) {
Weblog weblog = this.getWeblog(
- (String) this.weblogHandleToIdMap.get(handle));
+ this.weblogHandleToIdMap.get(handle));
if(weblog != null) {
// only return weblog if enabled status matches
if(enabled == null || enabled.equals(weblog.getEnabled())) {
@@ -382,11 +383,11 @@ public class JPAWeblogManagerImpl implem
}
}
- Query query = strategy.getNamedQuery("Weblog.getByHandle");
+ TypedQuery<Weblog> query = strategy.getNamedQuery("Weblog.getByHandle", Weblog.class);
query.setParameter(1, handle);
Weblog website;
try {
- website = (Weblog)query.getSingleResult();
+ website = query.getSingleResult();
} catch (NoResultException e) {
website = null;
}
@@ -414,7 +415,7 @@ public class JPAWeblogManagerImpl implem
//if (endDate == null) endDate = new Date();
- List params = new ArrayList();
+ List<Object> params = new ArrayList<Object>();
int size = 0;
String queryString;
StringBuilder whereClause = new StringBuilder();
@@ -427,7 +428,7 @@ public class JPAWeblogManagerImpl implem
whereClause.append(" AND ");
}
params.add(size++, start);
- whereClause.append(" w.dateCreated > ?" + size);
+ whereClause.append(" w.dateCreated > ?").append(size);
}
if (endDate != null) {
Timestamp end = new Timestamp(endDate.getTime());
@@ -435,26 +436,26 @@ public class JPAWeblogManagerImpl implem
whereClause.append(" AND ");
}
params.add(size++, end);
- whereClause.append(" w.dateCreated < ?" + size);
+ whereClause.append(" w.dateCreated < ?").append(size);
}
if (enabled != null) {
if (whereClause.length() > 0) {
whereClause.append(" AND ");
}
params.add(size++, enabled);
- whereClause.append(" w.enabled = ?" + size);
+ whereClause.append(" w.enabled = ?").append(size);
}
if (active != null) {
if (whereClause.length() > 0) {
whereClause.append(" AND ");
}
params.add(size++, active);
- whereClause.append(" w.active = ?" + size);
+ whereClause.append(" w.active = ?").append(size);
}
whereClause.append(" ORDER BY w.dateCreated DESC");
- Query query = strategy.getDynamicQuery(queryString + whereClause.toString());
+ TypedQuery<Weblog> query = strategy.getDynamicQuery(queryString + whereClause.toString(), Weblog.class);
if (offset != 0) {
query.setFirstResult(offset);
}
@@ -470,21 +471,22 @@ public class JPAWeblogManagerImpl implem
public WeblogThemeAssoc getThemeAssoc(Weblog weblog , String type) throws WebloggerException {
- if(weblog == null){
+ if (weblog == null) {
throw new WebloggerException("Weblog is null");
}
- if(type == null){
+ if (type == null) {
throw new WebloggerException("Type is null");
}
- Query query = strategy.getNamedQuery("WeblogThemeAssoc.getThemeAssocByType") ;
+ TypedQuery<WeblogThemeAssoc> query = strategy.getNamedQuery("WeblogThemeAssoc.getThemeAssocByType",
+ WeblogThemeAssoc.class);
query.setParameter(1,weblog);
query.setParameter(2,type);
- return (WeblogThemeAssoc) query.getSingleResult();
+ return query.getSingleResult();
}
public void saveThemeAssoc(WeblogThemeAssoc themeAssoc) throws WebloggerException {
- this.strategy.store(themeAssoc);
+ this.strategy.store(themeAssoc);
// update weblog last modified date. date updated by saveWebsite()
roller.getWeblogManager().saveWeblog(themeAssoc.getWeblog());
@@ -544,11 +546,12 @@ public class JPAWeblogManagerImpl implem
throw new WebloggerException("Pagelink is null");
}
- Query query = strategy.getNamedQuery("WeblogTemplate.getByWebsite&Link");
+ TypedQuery<WeblogTemplate> query = strategy.getNamedQuery("WeblogTemplate.getByWebsite&Link",
+ WeblogTemplate.class);
query.setParameter(1, website);
query.setParameter(2, pagelink);
try {
- return (WeblogTemplate) query.getSingleResult();
+ return query.getSingleResult();
} catch (NoResultException e) {
return null;
}
@@ -568,11 +571,12 @@ public class JPAWeblogManagerImpl implem
throw new WebloggerException("Action name is null");
}
- Query query = strategy.getNamedQuery("WeblogTemplate.getByAction");
+ TypedQuery<WeblogTemplate> query = strategy.getNamedQuery("WeblogTemplate.getByAction",
+ WeblogTemplate.class);
query.setParameter(1, website);
query.setParameter(2, action);
try {
- return (WeblogTemplate)query.getSingleResult();
+ return query.getSingleResult();
} catch (NoResultException e) {
return null;
}
@@ -592,11 +596,12 @@ public class JPAWeblogManagerImpl implem
throw new WebloggerException("Page name is null");
}
- Query query = strategy.getNamedQuery("WeblogTemplate.getByWebsite&Name");
+ TypedQuery<WeblogTemplate> query = strategy.getNamedQuery("WeblogTemplate.getByWebsite&Name",
+ WeblogTemplate.class);
query.setParameter(1, website);
query.setParameter(2, pagename);
try {
- return (WeblogTemplate)query.getSingleResult();
+ return query.getSingleResult();
} catch (NoResultException e) {
return null;
}
@@ -611,11 +616,12 @@ public class JPAWeblogManagerImpl implem
throw new WebloggerException("Type is null");
}
- Query query = strategy.getNamedQuery("WeblogThemeTemplateCode.getTemplateCodeByType");
+ TypedQuery<WeblogThemeTemplateCode> query = strategy.getNamedQuery("WeblogThemeTemplateCode.getTemplateCodeByType",
+ WeblogThemeTemplateCode.class);
query.setParameter(1, templateId);
query.setParameter(2, type);
try {
- return (WeblogThemeTemplateCode)query.getSingleResult();
+ return query.getSingleResult();
} catch (NoResultException e) {
return null;
}
@@ -628,18 +634,18 @@ public class JPAWeblogManagerImpl implem
if (website == null) {
throw new WebloggerException("website is null");
}
- Query q = strategy.getNamedQuery(
- "WeblogTemplate.getByWebsiteOrderByName");
+ TypedQuery<WeblogTemplate> q = strategy.getNamedQuery(
+ "WeblogTemplate.getByWebsiteOrderByName", WeblogTemplate.class);
q.setParameter(1, website);
return q.getResultList();
}
- public Map getWeblogHandleLetterMap() throws WebloggerException {
+ public Map<String, Long> getWeblogHandleLetterMap() throws WebloggerException {
String lc = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
- Map results = new TreeMap();
- Query query = strategy.getNamedQuery(
- "Weblog.getCountByHandleLike");
+ Map<String, Long> results = new TreeMap<String, Long>();
+ TypedQuery<Long> query = strategy.getNamedQuery(
+ "Weblog.getCountByHandleLike", Long.class);
for (int i=0; i<26; i++) {
char currentChar = lc.charAt(i);
query.setParameter(1, currentChar + "%");
@@ -652,8 +658,8 @@ public class JPAWeblogManagerImpl implem
public List<Weblog> getWeblogsByLetter(char letter, int offset, int length)
throws WebloggerException {
- Query query = strategy.getNamedQuery(
- "Weblog.getByLetterOrderByHandle");
+ TypedQuery<Weblog> query = strategy.getNamedQuery(
+ "Weblog.getByLetterOrderByHandle", Weblog.class);
query.setParameter(1, letter + "%");
if (offset != 0) {
query.setFirstResult(offset);
@@ -668,7 +674,7 @@ public class JPAWeblogManagerImpl implem
int offset, int length)
throws WebloggerException {
- Query query = null;
+ Query query;
if (endDate == null) {
endDate = new Date();
@@ -695,19 +701,22 @@ public class JPAWeblogManagerImpl implem
}
List queryResults = query.getResultList();
List<StatCount> results = new ArrayList<StatCount>();
- for (Iterator iter = queryResults.iterator(); iter.hasNext();) {
- Object[] row = (Object[]) iter.next();
- StatCount sc = new StatCount(
- (String)row[1], // website id
- (String)row[2], // website handle
- (String)row[3], // website name
- "statCount.weblogCommentCountType", // stat type
- ((Long)row[0])); // # comments
- sc.setWeblogHandle((String)row[2]);
- results.add(sc);
+ if (queryResults != null) {
+ for (Object obj : queryResults) {
+ Object[] row = (Object[]) obj;
+ StatCount sc = new StatCount(
+ (String)row[1], // website id
+ (String)row[2], // website handle
+ (String)row[3], // website name
+ "statCount.weblogCommentCountType", // stat type
+ ((Long)row[0])); // # comments
+ sc.setWeblogHandle((String)row[2]);
+ results.add(sc);
+ }
}
+
// Original query ordered by desc # comments.
- // JPA QL doesn't allow queries to be ordered by agregates; do it in memory
+ // JPA QL doesn't allow queries to be ordered by aggregates; do it in memory
Collections.sort(results, STAT_COUNT_COUNT_REVERSE_COMPARATOR);
return results;
@@ -717,22 +726,19 @@ public class JPAWeblogManagerImpl implem
* Get count of weblogs, active and inactive
*/
public long getWeblogCount() throws WebloggerException {
- long ret = 0;
- List results = strategy.getNamedQuery(
- "Weblog.getCountAllDistinct").getResultList();
-
- ret = (Long)results.get(0);
-
- return ret;
+ List<Long> results = strategy.getNamedQuery(
+ "Weblog.getCountAllDistinct", Long.class).getResultList();
+ return results.get(0);
}
private void removeTemplateCodeObjs(WeblogTemplate page) throws WebloggerException {
- Query codeQuery = strategy.getNamedQuery("WeblogThemeTemplateCode.getTemplateCodesByTemplateId");
+ TypedQuery<WeblogThemeTemplateCode> codeQuery = strategy.getNamedQuery(
+ "WeblogThemeTemplateCode.getTemplateCodesByTemplateId", WeblogThemeTemplateCode.class);
codeQuery.setParameter(1, page.getId());
- List codeList = codeQuery.getResultList();
+ List<WeblogThemeTemplateCode> codeList = codeQuery.getResultList();
- for (Object obj : codeList) {
- this.strategy.remove(obj);
+ for (WeblogThemeTemplateCode code : codeList) {
+ this.strategy.remove(code);
}
}
Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPAWebloggerImpl.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPAWebloggerImpl.java?rev=1606568&r1=1606567&r2=1606568&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPAWebloggerImpl.java (original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPAWebloggerImpl.java Sun Jun 29 19:09:13 2014
@@ -45,8 +45,6 @@ import org.apache.roller.weblogger.busin
@com.google.inject.Singleton
public class JPAWebloggerImpl extends WebloggerImpl {
- static final long serialVersionUID = 5256135928578074652L;
-
// a persistence utility class
private final JPAPersistenceStrategy strategy;
Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/pings/AutoPingManager.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/pings/AutoPingManager.java?rev=1606568&r1=1606567&r2=1606568&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/pings/AutoPingManager.java (original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/pings/AutoPingManager.java Sun Jun 29 19:09:13 2014
@@ -68,7 +68,7 @@ public interface AutoPingManager {
* @param autopings a <code>Collection</code> of <code>AAutoPing/code> objects
* @throws WebloggerException
*/
- void removeAutoPings(Collection autopings) throws WebloggerException;
+ void removeAutoPings(Collection<AutoPing> autopings) throws WebloggerException;
/**
Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/pojos/StatCountCountComparator.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/pojos/StatCountCountComparator.java?rev=1606568&r1=1606567&r2=1606568&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/pojos/StatCountCountComparator.java (original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/pojos/StatCountCountComparator.java Sun Jun 29 19:09:13 2014
@@ -24,7 +24,7 @@ import java.io.Serializable;
/**
* @author Markus Fuchs
*/
-public final class StatCountCountComparator implements Comparator, Serializable {
+public final class StatCountCountComparator implements Comparator<StatCount>, Serializable {
private static final long serialVersionUID = 4811314286365625712L;
@@ -38,9 +38,7 @@ public final class StatCountCountCompara
* @throws ClassCastException if arguments are not instances of <em>StatCount</em>
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
*/
- public int compare(Object obj1, Object obj2) {
- StatCount sc1 = (StatCount) obj1;
- StatCount sc2 = (StatCount) obj2;
+ public int compare(StatCount sc1, StatCount sc2) {
int compVal = sc1.getCount() < sc2.getCount() ? -1 :
(sc1.getCount() == sc2.getCount() ? 0 : 1);
Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/pojos/TagStatComparator.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/pojos/TagStatComparator.java?rev=1606568&r1=1606567&r2=1606568&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/pojos/TagStatComparator.java (original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/pojos/TagStatComparator.java Sun Jun 29 19:09:13 2014
@@ -24,7 +24,7 @@ import java.util.Comparator;
* @author Elias Torres (<a href="mailto:eliast@us.ibm.com">eliast@us.ibm.com</a>)
*
*/
-public class TagStatComparator implements Comparator, Serializable {
+public class TagStatComparator implements Comparator<TagStat>, Serializable {
private static final long serialVersionUID = -3272396777374523757L;
@@ -39,10 +39,8 @@ public class TagStatComparator implement
* @throws ClassCastException if arguments are not instances of <em>TagStat</em>
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
*/
- public int compare(Object obj1, Object obj2) {
- TagStat st1 = (TagStat) obj1;
- TagStat st2 = (TagStat) obj2;
- return st1.getName().compareToIgnoreCase(st2.getName());
+ public int compare(TagStat ts1, TagStat ts2) {
+ return ts1.getName().compareToIgnoreCase(ts2.getName());
}
}
Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/pojos/TagStatCountComparator.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/pojos/TagStatCountComparator.java?rev=1606568&r1=1606567&r2=1606568&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/pojos/TagStatCountComparator.java (original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/pojos/TagStatCountComparator.java Sun Jun 29 19:09:13 2014
@@ -24,7 +24,7 @@ import java.io.Serializable;
/**
* @author Markus Fuchs
*/
-public class TagStatCountComparator implements Comparator, Serializable {
+public class TagStatCountComparator implements Comparator<TagStat>, Serializable {
private static final long serialVersionUID = 1155112837815739929L;
@@ -43,9 +43,7 @@ public class TagStatCountComparator impl
* @throws ClassCastException if arguments are not instances of <em>TagStat</em>
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
*/
- public int compare(Object obj1, Object obj2) {
- TagStat st1 = (TagStat) obj1;
- TagStat st2 = (TagStat) obj2;
+ public int compare(TagStat st1, TagStat st2) {
int compVal = st1.getCount() < st2.getCount() ? -1 :
(st1.getCount() == st2.getCount() ? 0 : 1);
Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/model/PlanetModel.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/model/PlanetModel.java?rev=1606568&r1=1606567&r2=1606568&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/model/PlanetModel.java (original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/model/PlanetModel.java Sun Jun 29 19:09:13 2014
@@ -201,7 +201,7 @@ public class PlanetModel implements Mode
try {
PlanetManager planetManager = WebloggerFactory.getWeblogger().getPlanetManager();
Planet defaultPlanet = planetManager.getWeblogger(DEFAULT_PLANET_HANDLE);
- Set<PlanetGroup> groups = (Set<PlanetGroup>)defaultPlanet.getGroups();
+ Set<PlanetGroup> groups = defaultPlanet.getGroups();
for (PlanetGroup group : groups) {
// TODO needs pojo wrapping from planet
list.add(group);