mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 01:54:22 +00:00
Enabling Community/Collection Item Counts (i.e. strengths) for XMLUI. These counts are stored in the "dc.format.extent" DIM field of the METS document generated for Communities/Collections. By default these counts are NOT displayed by the out-of-the-box themes. However, now they are available for custom themes. After talking with Scott Phillips, it was decided they should only be enabled when the "webui.strengths.cache" flag is enabled in dspace.cfg. Added a note to dspace.cfg to document this.
git-svn-id: http://scm.dspace.org/svn/repo/trunk@3016 9c30dcfa-912a-0410-8fc2-9e0234be79fd
This commit is contained in:
@@ -177,7 +177,7 @@ public class DSpaceMETSGenerator extends AbstractGenerator
|
||||
if (dso instanceof Item)
|
||||
adapter = new ItemAdapter((Item) dso, contextPath);
|
||||
else if (dso instanceof Collection || dso instanceof Community)
|
||||
adapter = new ContainerAdapter(dso, contextPath);
|
||||
adapter = new ContainerAdapter(context, dso, contextPath);
|
||||
}
|
||||
else if (internal != null)
|
||||
{
|
||||
@@ -199,13 +199,13 @@ public class DSpaceMETSGenerator extends AbstractGenerator
|
||||
{
|
||||
Collection collection = Collection.find(context,id);
|
||||
if (collection != null)
|
||||
adapter = new ContainerAdapter(collection,contextPath);
|
||||
adapter = new ContainerAdapter(context, collection,contextPath);
|
||||
}
|
||||
else if ("community".equals(type))
|
||||
{
|
||||
Community community = Community.find(context,id);
|
||||
if (community != null)
|
||||
adapter = new ContainerAdapter(community,contextPath);
|
||||
adapter = new ContainerAdapter(context, community,contextPath);
|
||||
}
|
||||
else if ("repository".equals(type))
|
||||
{
|
||||
|
@@ -43,13 +43,17 @@ package org.dspace.app.xmlui.objectmanager;
|
||||
import org.dspace.app.xmlui.wing.AttributeMap;
|
||||
import org.dspace.app.xmlui.wing.WingException;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.browse.ItemCounter;
|
||||
import org.dspace.browse.ItemCountException;
|
||||
import org.dspace.content.Bitstream;
|
||||
import org.dspace.content.Collection;
|
||||
import org.dspace.content.Community;
|
||||
import org.dspace.content.DSpaceObject;
|
||||
import org.dspace.content.crosswalk.CrosswalkException;
|
||||
import org.dspace.content.crosswalk.DisseminationCrosswalk;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.core.Constants;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.uri.IdentifierService;
|
||||
import org.jdom.Document;
|
||||
import org.jdom.Element;
|
||||
@@ -89,6 +93,9 @@ public class ContainerAdapter extends AbstractAdapter
|
||||
/** A space seperated list of descriptive metadata sections */
|
||||
private StringBuffer dmdSecIDS;
|
||||
|
||||
/** Current DSpace context **/
|
||||
private Context dspaceContext;
|
||||
|
||||
/**
|
||||
* Construct a new CommunityCollectionMETSAdapter.
|
||||
*
|
||||
@@ -97,10 +104,11 @@ public class ContainerAdapter extends AbstractAdapter
|
||||
* @param contextPath
|
||||
* The contextPath of this webapplication.
|
||||
*/
|
||||
public ContainerAdapter(DSpaceObject dso,String contextPath)
|
||||
public ContainerAdapter(Context context, DSpaceObject dso,String contextPath)
|
||||
{
|
||||
super(contextPath);
|
||||
this.dso = dso;
|
||||
this.dspaceContext = context;
|
||||
}
|
||||
|
||||
/** Return the container, community or collection, object */
|
||||
@@ -275,6 +283,22 @@ public class ContainerAdapter extends AbstractAdapter
|
||||
createField("dc","rights",null,null,rights);
|
||||
createField("dc","rights","license",null,rights_license);
|
||||
createField("dc","title",null,null,title);
|
||||
|
||||
boolean useCache = ConfigurationManager.getBooleanProperty("webui.strengths.cache");
|
||||
|
||||
//To improve scalability, XMLUI only adds item counts if they are cached
|
||||
if (useCache)
|
||||
{
|
||||
try
|
||||
{ //try to determine Collection size (i.e. # of items)
|
||||
int size = new ItemCounter(this.dspaceContext).getCount(collection);
|
||||
createField("dc","format","extent",null, String.valueOf(size));
|
||||
}
|
||||
catch(ItemCountException e)
|
||||
{
|
||||
throw new IOException("Could not obtain Collection item-count: ", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (dso.getType() == Constants.COMMUNITY)
|
||||
{
|
||||
@@ -294,6 +318,22 @@ public class ContainerAdapter extends AbstractAdapter
|
||||
createField("dc","identifier","uri",null,identifier_uri);
|
||||
createField("dc","rights",null,null,rights);
|
||||
createField("dc","title",null,null,title);
|
||||
|
||||
boolean useCache = ConfigurationManager.getBooleanProperty("webui.strengths.cache");
|
||||
|
||||
//To improve scalability, XMLUI only adds item counts if they are cached
|
||||
if (useCache)
|
||||
{
|
||||
try
|
||||
{ //try to determine Community size (i.e. # of items)
|
||||
int size = new ItemCounter(this.dspaceContext).getCount(community);
|
||||
createField("dc","format","extent",null, String.valueOf(size));
|
||||
}
|
||||
catch(ItemCountException e)
|
||||
{
|
||||
throw new IOException("Could not obtain Community item-count: ", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ///////////////////////////////
|
||||
|
@@ -759,7 +759,8 @@ webui.preview.brand.fontpoint = 12
|
||||
webui.strengths.show = false
|
||||
|
||||
# if showing the strengths, should they be counted in real time or
|
||||
# fetched from cache?
|
||||
# fetched from cache? NOTE: To improve scaling/performance,
|
||||
# the XMLUI only makes strengths available to themes if they are CACHED!
|
||||
#
|
||||
# Counts fetched in real time will perform an actual count of the
|
||||
# database contents every time a page with this feature is requested,
|
||||
|
Reference in New Issue
Block a user