mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-15 05:53:08 +00:00
Variable naming change. Javadocs addded.
This commit is contained in:
@@ -50,6 +50,12 @@ public class ItemCounter {
|
||||
*/
|
||||
private Context context;
|
||||
|
||||
/**
|
||||
* This field is used to hold singular instance of a class.
|
||||
* Singleton pattern is used but this class should be
|
||||
* refactored to modern DSpace approach (injectible service).
|
||||
*/
|
||||
|
||||
private static ItemCounter instance;
|
||||
|
||||
protected ItemService itemService;
|
||||
@@ -73,6 +79,13 @@ public class ItemCounter {
|
||||
this.useCache = configurationService.getBooleanProperty("webui.strengths.cache", true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the singular instance of a class.
|
||||
* It creates a new instance at the first usage of this method.
|
||||
*
|
||||
* @return instance af a class
|
||||
* @throws ItemCountException when error occurs
|
||||
*/
|
||||
public static ItemCounter getInstance() throws ItemCountException {
|
||||
if (instance == null) {
|
||||
instance = new ItemCounter(ContextUtil.obtainCurrentRequestContext());
|
||||
|
@@ -337,6 +337,11 @@ public class Collection extends DSpaceObject implements DSpaceObjectLegacySuppor
|
||||
return collectionService;
|
||||
}
|
||||
|
||||
/**
|
||||
* return count of the collection items
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public int countArchivedItem() {
|
||||
try {
|
||||
return collectionService.countArchivedItem(this);
|
||||
|
@@ -1069,6 +1069,13 @@ public class CollectionServiceImpl extends DSpaceObjectServiceImpl<Collection> i
|
||||
return collectionList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns total collection archived items
|
||||
*
|
||||
* @param collection Collection
|
||||
* @return total collection archived items
|
||||
* @throws ItemCountException
|
||||
*/
|
||||
@Override
|
||||
public int countArchivedItem(Collection collection) throws ItemCountException {
|
||||
return ItemCounter.getInstance().getCount(collection);
|
||||
|
@@ -265,6 +265,11 @@ public class Community extends DSpaceObject implements DSpaceObjectLegacySupport
|
||||
return communityService;
|
||||
}
|
||||
|
||||
/**
|
||||
* return count of the community items
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public int countArchivedItem() {
|
||||
try {
|
||||
return communityService.getArchivedItems(this);
|
||||
|
@@ -711,6 +711,13 @@ public class CommunityServiceImpl extends DSpaceObjectServiceImpl<Community> imp
|
||||
return communityDAO.countRows(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns total community archived items
|
||||
*
|
||||
* @param community Community
|
||||
* @return total community archived items
|
||||
* @throws ItemCountException
|
||||
*/
|
||||
@Override
|
||||
public int getArchivedItems(Community community) throws ItemCountException {
|
||||
return ItemCounter.getInstance().getCount(community);
|
||||
|
@@ -470,5 +470,13 @@ public interface CollectionService
|
||||
*/
|
||||
public List<Collection> findAllCollectionsByEntityType(Context context, String entityType)
|
||||
throws SearchServiceException;
|
||||
|
||||
/**
|
||||
* Returns total collection archived items
|
||||
*
|
||||
* @param collection Collection
|
||||
* @return total collection archived items
|
||||
* @throws ItemCountException
|
||||
*/
|
||||
int countArchivedItem(Collection collection) throws ItemCountException;
|
||||
}
|
||||
|
@@ -294,5 +294,12 @@ public interface CommunityService extends DSpaceObjectService<Community>, DSpace
|
||||
|
||||
int countTotal(Context context) throws SQLException;
|
||||
|
||||
/**
|
||||
* Returns total community archived items
|
||||
*
|
||||
* @param community Community
|
||||
* @return total community archived items
|
||||
* @throws ItemCountException
|
||||
*/
|
||||
int getArchivedItems(Community community) throws ItemCountException;
|
||||
}
|
||||
|
@@ -26,9 +26,10 @@ public class CollectionConverter extends DSpaceObjectConverter<Collection, Colle
|
||||
@Override
|
||||
public CollectionRest convert(Collection collection, Projection projection) {
|
||||
CollectionRest resource = super.convert(collection, projection);
|
||||
resource.setArchivedItems(collection.countArchivedItem());
|
||||
resource.setArchivedItemsCount(collection.countArchivedItem());
|
||||
return resource;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CollectionRest newInstance() {
|
||||
return new CollectionRest();
|
||||
|
@@ -26,7 +26,7 @@ public class CommunityConverter
|
||||
|
||||
public CommunityRest convert(Community community, Projection projection) {
|
||||
CommunityRest resource = super.convert(community, projection);
|
||||
resource.setArchivedItems(community.countArchivedItem());
|
||||
resource.setArchivedItemsCount(community.countArchivedItem());
|
||||
return resource;
|
||||
}
|
||||
|
||||
|
@@ -75,14 +75,14 @@ public class CollectionRest extends DSpaceObjectRest {
|
||||
return NAME;
|
||||
}
|
||||
|
||||
private int archivedItems;
|
||||
private int archivedItemsCount;
|
||||
|
||||
public int getArchivedItems() {
|
||||
return archivedItems;
|
||||
public int getArchivedItemsCount() {
|
||||
return archivedItemsCount;
|
||||
}
|
||||
|
||||
public void setArchivedItems(int archivedItems) {
|
||||
this.archivedItems = archivedItems;
|
||||
public void setArchivedItemsCount(int archivedItemsCount) {
|
||||
this.archivedItemsCount = archivedItemsCount;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -59,13 +59,13 @@ public class CommunityRest extends DSpaceObjectRest {
|
||||
return NAME;
|
||||
}
|
||||
|
||||
private int archivedItems;
|
||||
private int archivedItemsCount;
|
||||
|
||||
public int getArchivedItems() {
|
||||
return archivedItems;
|
||||
public int getArchivedItemsCount() {
|
||||
return archivedItemsCount;
|
||||
}
|
||||
|
||||
public void setArchivedItems(int archivedItems) {
|
||||
this.archivedItems = archivedItems;
|
||||
public void setArchivedItemsCount(int archivedItemsCount) {
|
||||
this.archivedItemsCount = archivedItemsCount;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user