Refactor other classes affected by move of item counting from CommunityService to ItemService. Also cleanup horrible spacing/alignment in ItemCounter

This commit is contained in:
Tim Donohue
2016-02-04 15:33:07 -06:00
parent 3587661b6c
commit 1e174972e0
3 changed files with 169 additions and 166 deletions

View File

@@ -15,10 +15,11 @@ import org.dspace.content.service.CommunityService;
import org.dspace.content.service.ItemService;
import org.dspace.core.Context;
import org.dspace.content.DSpaceObject;
import org.dspace.core.ConfigurationManager;
import java.sql.SQLException;
import java.util.List;
import org.dspace.services.ConfigurationService;
import org.dspace.services.factory.DSpaceServicesFactory;
/**
* This class provides a standard interface to all item counting
@@ -48,6 +49,7 @@ public class ItemCounter
protected CommunityService communityService;
protected ItemService itemService;
protected ConfigurationService configurationService;
/**
* method invoked by CLI which will result in the number of items
@@ -79,6 +81,7 @@ public class ItemCounter
this.dao = ItemCountDAOFactory.getInstance(this.context);
this.communityService = ContentServiceFactory.getInstance().getCommunityService();
this.itemService = ContentServiceFactory.getInstance().getItemService();
this.configurationService = DSpaceServicesFactory.getInstance().getConfigurationService();
}
/**
@@ -118,7 +121,7 @@ public class ItemCounter
public int getCount(DSpaceObject dso)
throws ItemCountException
{
boolean useCache = ConfigurationManager.getBooleanProperty(
boolean useCache = configurationService.getBooleanProperty(
"webui.strengths.cache", true);
if (useCache)
@@ -140,7 +143,7 @@ public class ItemCounter
if (dso instanceof Community)
{
try {
return communityService.countItems(context, ((Community) dso));
return itemService.countItems(context, ((Community) dso));
} catch (SQLException e) {
log.error("caught exception: ", e);
throw new ItemCountException(e);
@@ -180,7 +183,7 @@ public class ItemCounter
try
{
// first count the community we are in
int count = communityService.countItems(context, community);
int count = itemService.countItems(context, community);
dao.communityCount(community, count);
// now get the sub-communities

View File

@@ -74,7 +74,7 @@ public class ItemCheck extends Check {
"Withdrawn items: %d\n", itemService.countWithdrawnItems(context));
ret += String.format(
"Not published items (in workspace or workflow mode): %d\n",
itemService.getNotArchivedItemsCount(context));
itemService.countNotArchivedItems(context));
for (Map.Entry<Integer, Long> row : workspaceItemService.getStageReachedCounts(context)) {
ret += String.format("\tIn Stage %s: %s\n",

View File

@@ -21,7 +21,7 @@ import org.dspace.authorize.AuthorizeException;
import org.dspace.content.Community;
import org.dspace.content.DSpaceObject;
import org.dspace.content.factory.ContentServiceFactory;
import org.dspace.content.service.CommunityService;
import org.dspace.content.service.ItemService;
import org.xml.sax.SAXException;
/**
@@ -36,7 +36,7 @@ public class CommunityRecentSubmissions extends AbstractRecentSubmissionTransfor
private static final Message T_head_recent_submissions =
message("xmlui.ArtifactBrowser.CommunityViewer.head_recent_submissions");
protected CommunityService communityService = ContentServiceFactory.getInstance().getCommunityService();
protected ItemService itemService = ContentServiceFactory.getInstance().getItemService();
/**
* Displays the recent submissions for this community
@@ -80,7 +80,7 @@ public class CommunityRecentSubmissions extends AbstractRecentSubmissionTransfor
Community community = (Community) dso;
if (communityService.countItems(context, community) > maxRecentSubmissions)
if (itemService.countItems(context, community) > maxRecentSubmissions)
addViewMoreLink(lastSubmittedDiv, dso);
}
}