Variable naming change. Javadocs addded.

This commit is contained in:
damian
2023-06-09 16:56:26 +02:00
parent c6cf19d40c
commit ff504e35d1
11 changed files with 65 additions and 12 deletions

View File

@@ -50,6 +50,12 @@ public class ItemCounter {
*/ */
private Context context; 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; private static ItemCounter instance;
protected ItemService itemService; protected ItemService itemService;
@@ -73,6 +79,13 @@ public class ItemCounter {
this.useCache = configurationService.getBooleanProperty("webui.strengths.cache", true); 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 { public static ItemCounter getInstance() throws ItemCountException {
if (instance == null) { if (instance == null) {
instance = new ItemCounter(ContextUtil.obtainCurrentRequestContext()); instance = new ItemCounter(ContextUtil.obtainCurrentRequestContext());

View File

@@ -337,6 +337,11 @@ public class Collection extends DSpaceObject implements DSpaceObjectLegacySuppor
return collectionService; return collectionService;
} }
/**
* return count of the collection items
*
* @return int
*/
public int countArchivedItem() { public int countArchivedItem() {
try { try {
return collectionService.countArchivedItem(this); return collectionService.countArchivedItem(this);

View File

@@ -1069,6 +1069,13 @@ public class CollectionServiceImpl extends DSpaceObjectServiceImpl<Collection> i
return collectionList; return collectionList;
} }
/**
* Returns total collection archived items
*
* @param collection Collection
* @return total collection archived items
* @throws ItemCountException
*/
@Override @Override
public int countArchivedItem(Collection collection) throws ItemCountException { public int countArchivedItem(Collection collection) throws ItemCountException {
return ItemCounter.getInstance().getCount(collection); return ItemCounter.getInstance().getCount(collection);

View File

@@ -265,6 +265,11 @@ public class Community extends DSpaceObject implements DSpaceObjectLegacySupport
return communityService; return communityService;
} }
/**
* return count of the community items
*
* @return int
*/
public int countArchivedItem() { public int countArchivedItem() {
try { try {
return communityService.getArchivedItems(this); return communityService.getArchivedItems(this);

View File

@@ -711,6 +711,13 @@ public class CommunityServiceImpl extends DSpaceObjectServiceImpl<Community> imp
return communityDAO.countRows(context); return communityDAO.countRows(context);
} }
/**
* Returns total community archived items
*
* @param community Community
* @return total community archived items
* @throws ItemCountException
*/
@Override @Override
public int getArchivedItems(Community community) throws ItemCountException { public int getArchivedItems(Community community) throws ItemCountException {
return ItemCounter.getInstance().getCount(community); return ItemCounter.getInstance().getCount(community);

View File

@@ -470,5 +470,13 @@ public interface CollectionService
*/ */
public List<Collection> findAllCollectionsByEntityType(Context context, String entityType) public List<Collection> findAllCollectionsByEntityType(Context context, String entityType)
throws SearchServiceException; throws SearchServiceException;
/**
* Returns total collection archived items
*
* @param collection Collection
* @return total collection archived items
* @throws ItemCountException
*/
int countArchivedItem(Collection collection) throws ItemCountException; int countArchivedItem(Collection collection) throws ItemCountException;
} }

View File

@@ -294,5 +294,12 @@ public interface CommunityService extends DSpaceObjectService<Community>, DSpace
int countTotal(Context context) throws SQLException; 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; int getArchivedItems(Community community) throws ItemCountException;
} }

View File

@@ -26,9 +26,10 @@ public class CollectionConverter extends DSpaceObjectConverter<Collection, Colle
@Override @Override
public CollectionRest convert(Collection collection, Projection projection) { public CollectionRest convert(Collection collection, Projection projection) {
CollectionRest resource = super.convert(collection, projection); CollectionRest resource = super.convert(collection, projection);
resource.setArchivedItems(collection.countArchivedItem()); resource.setArchivedItemsCount(collection.countArchivedItem());
return resource; return resource;
} }
@Override @Override
protected CollectionRest newInstance() { protected CollectionRest newInstance() {
return new CollectionRest(); return new CollectionRest();

View File

@@ -26,7 +26,7 @@ public class CommunityConverter
public CommunityRest convert(Community community, Projection projection) { public CommunityRest convert(Community community, Projection projection) {
CommunityRest resource = super.convert(community, projection); CommunityRest resource = super.convert(community, projection);
resource.setArchivedItems(community.countArchivedItem()); resource.setArchivedItemsCount(community.countArchivedItem());
return resource; return resource;
} }

View File

@@ -75,14 +75,14 @@ public class CollectionRest extends DSpaceObjectRest {
return NAME; return NAME;
} }
private int archivedItems; private int archivedItemsCount;
public int getArchivedItems() { public int getArchivedItemsCount() {
return archivedItems; return archivedItemsCount;
} }
public void setArchivedItems(int archivedItems) { public void setArchivedItemsCount(int archivedItemsCount) {
this.archivedItems = archivedItems; this.archivedItemsCount = archivedItemsCount;
} }

View File

@@ -59,13 +59,13 @@ public class CommunityRest extends DSpaceObjectRest {
return NAME; return NAME;
} }
private int archivedItems; private int archivedItemsCount;
public int getArchivedItems() { public int getArchivedItemsCount() {
return archivedItems; return archivedItemsCount;
} }
public void setArchivedItems(int archivedItems) { public void setArchivedItemsCount(int archivedItemsCount) {
this.archivedItems = archivedItems; this.archivedItemsCount = archivedItemsCount;
} }
} }