diff --git a/dspace-api/src/main/java/org/dspace/content/EntityServiceImpl.java b/dspace-api/src/main/java/org/dspace/content/EntityServiceImpl.java index 6c97820ac6..98665a94dd 100644 --- a/dspace-api/src/main/java/org/dspace/content/EntityServiceImpl.java +++ b/dspace-api/src/main/java/org/dspace/content/EntityServiceImpl.java @@ -38,8 +38,15 @@ public class EntityServiceImpl implements EntityService { @Override public Entity findByItemId(Context context, UUID itemId) throws SQLException { + + return findByItemId(context, itemId, -1, -1); + } + + @Override + public Entity findByItemId(Context context, UUID itemId, Integer limit, Integer offset) throws SQLException { + Item item = itemService.find(context, itemId); - List relationshipList = relationshipService.findByItem(context, item); + List relationshipList = relationshipService.findByItem(context, item, limit, offset); return new Entity(item, relationshipList); } @@ -80,8 +87,16 @@ public class EntityServiceImpl implements EntityService { @Override public List getRelationsByLabel(Context context, String label) throws SQLException { + + return getRelationsByLabel(context, label, -1, -1); + } + + @Override + public List getRelationsByLabel(Context context, String label, Integer limit, Integer offset) + throws SQLException { + List listToReturn = new LinkedList<>(); - List relationshipList = relationshipService.findAll(context); + List relationshipList = relationshipService.findAll(context, limit, offset); for (Relationship relationship : relationshipList) { RelationshipType relationshipType = relationship.getRelationshipType(); if (StringUtils.equals(relationshipType.getLeftwardType(),label) || @@ -94,12 +109,20 @@ public class EntityServiceImpl implements EntityService { @Override public List getAllRelationshipTypes(Context context, Entity entity) throws SQLException { + + return getAllRelationshipTypes(context, entity, -1, -1); + } + + @Override + public List getAllRelationshipTypes(Context context, Entity entity, Integer limit, Integer offset) + throws SQLException { + EntityType entityType = this.getType(context, entity); if (entityType == null) { return Collections.emptyList(); } List listToReturn = new LinkedList<>(); - for (RelationshipType relationshipType : relationshipTypeService.findAll(context)) { + for (RelationshipType relationshipType : relationshipTypeService.findAll(context, limit, offset)) { if (relationshipType.getLeftType().getID() == entityType.getID() || relationshipType.getRightType().getID() == entityType.getID()) { listToReturn.add(relationshipType); @@ -110,9 +133,17 @@ public class EntityServiceImpl implements EntityService { @Override public List getLeftRelationshipTypes(Context context, Entity entity) throws SQLException { + + return getLeftRelationshipTypes(context, entity, -1, -1); + } + + @Override + public List getLeftRelationshipTypes(Context context, Entity entity, + Integer limit, Integer offset) throws SQLException { + EntityType entityType = this.getType(context, entity); List listToReturn = new LinkedList<>(); - for (RelationshipType relationshipType : relationshipTypeService.findAll(context)) { + for (RelationshipType relationshipType : relationshipTypeService.findAll(context, limit, offset)) { if (relationshipType.getLeftType().getID() == entityType.getID()) { listToReturn.add(relationshipType); } @@ -122,9 +153,17 @@ public class EntityServiceImpl implements EntityService { @Override public List getRightRelationshipTypes(Context context, Entity entity) throws SQLException { + + return getRightRelationshipTypes(context, entity, -1, -1); + } + + @Override + public List getRightRelationshipTypes(Context context, Entity entity, + Integer limit, Integer offset) throws SQLException { + EntityType entityType = this.getType(context, entity); List listToReturn = new LinkedList<>(); - for (RelationshipType relationshipType : relationshipTypeService.findAll(context)) { + for (RelationshipType relationshipType : relationshipTypeService.findAll(context, limit, offset)) { if (relationshipType.getRightType().getID() == entityType.getID()) { listToReturn.add(relationshipType); } @@ -133,9 +172,16 @@ public class EntityServiceImpl implements EntityService { } @Override - public List getRelationshipTypesByTypeName(Context context, String label) throws SQLException { + public List getRelationshipTypesByLabel(Context context, String label) throws SQLException { + + return getRelationshipTypesByLabel(context, label, -1, -1); + } + + @Override + public List getRelationshipTypesByTypeName(Context context, String label, + Integer limit, Integer offset) throws SQLException { List listToReturn = new LinkedList<>(); - for (RelationshipType relationshipType : relationshipTypeService.findAll(context)) { + for (RelationshipType relationshipType : relationshipTypeService.findAll(context, limit, offset)) { if (StringUtils.equals(relationshipType.getLeftwardType(),label) || StringUtils.equals(relationshipType.getRightwardType(),label)) { listToReturn.add(relationshipType); diff --git a/dspace-api/src/main/java/org/dspace/content/EntityTypeServiceImpl.java b/dspace-api/src/main/java/org/dspace/content/EntityTypeServiceImpl.java index e35a8a20e4..4577054ff0 100644 --- a/dspace-api/src/main/java/org/dspace/content/EntityTypeServiceImpl.java +++ b/dspace-api/src/main/java/org/dspace/content/EntityTypeServiceImpl.java @@ -28,13 +28,20 @@ public class EntityTypeServiceImpl implements EntityTypeService { protected AuthorizeService authorizeService; @Override - public EntityType findByEntityType(Context context,String entityType) throws SQLException { + public EntityType findByEntityType(Context context, String entityType) throws SQLException { return entityTypeDAO.findByEntityType(context, entityType); } @Override public List findAll(Context context) throws SQLException { - return entityTypeDAO.findAll(context, EntityType.class); + + return findAll(context, -1, -1); + } + + @Override + public List findAll(Context context, Integer limit, Integer offset) throws SQLException { + + return entityTypeDAO.findAll(context, EntityType.class, limit, offset); } @Override diff --git a/dspace-api/src/main/java/org/dspace/content/RelationshipServiceImpl.java b/dspace-api/src/main/java/org/dspace/content/RelationshipServiceImpl.java index 8e3c944966..c00367ac0c 100644 --- a/dspace-api/src/main/java/org/dspace/content/RelationshipServiceImpl.java +++ b/dspace-api/src/main/java/org/dspace/content/RelationshipServiceImpl.java @@ -268,7 +268,14 @@ public class RelationshipServiceImpl implements RelationshipService { @Override public List findByItem(Context context, Item item) throws SQLException { - List list = relationshipDAO.findByItem(context, item); + return findByItem(context, item, -1, -1); + } + + @Override + public List findByItem(Context context, Item item, Integer limit, Integer offset) + throws SQLException { + + List list = relationshipDAO.findByItem(context, item, limit, offset); list.sort((o1, o2) -> { int relationshipType = o1.getRelationshipType().getLeftwardType() @@ -288,7 +295,14 @@ public class RelationshipServiceImpl implements RelationshipService { @Override public List findAll(Context context) throws SQLException { - return relationshipDAO.findAll(context, Relationship.class); + + return findAll(context, -1, -1); + } + + @Override + public List findAll(Context context, Integer limit, Integer offset) throws SQLException { + + return relationshipDAO.findAll(context, Relationship.class, limit, offset); } @Override @@ -420,7 +434,15 @@ public class RelationshipServiceImpl implements RelationshipService { @Override public List findByRelationshipType(Context context, RelationshipType relationshipType) throws SQLException { - return relationshipDAO.findByRelationshipType(context, relationshipType); + + return findByRelationshipType(context, relationshipType, -1, -1); + } + + @Override + public List findByRelationshipType(Context context, RelationshipType relationshipType, Integer limit, + Integer offset) + throws SQLException { + return relationshipDAO.findByRelationshipType(context, relationshipType, limit, offset); } diff --git a/dspace-api/src/main/java/org/dspace/content/RelationshipTypeServiceImpl.java b/dspace-api/src/main/java/org/dspace/content/RelationshipTypeServiceImpl.java index a9ecabc9d4..31564b1eee 100644 --- a/dspace-api/src/main/java/org/dspace/content/RelationshipTypeServiceImpl.java +++ b/dspace-api/src/main/java/org/dspace/content/RelationshipTypeServiceImpl.java @@ -54,17 +54,35 @@ public class RelationshipTypeServiceImpl implements RelationshipTypeService { @Override public List findAll(Context context) throws SQLException { - return relationshipTypeDAO.findAll(context, RelationshipType.class); + return findAll(context, -1, -1); + } + + @Override + public List findAll(Context context, Integer limit, Integer offset) throws SQLException { + + return relationshipTypeDAO.findAll(context, RelationshipType.class, limit, offset); } @Override public List findByLeftwardOrRightwardTypeName(Context context, String label) throws SQLException { - return relationshipTypeDAO.findByLeftwardOrRightwardTypeName(context, label); + return findByLeftOrRightLabel(context, label, -1, -1); + } + + @Override + public List findByLeftwardOrRightwardTypeName(Context context, String label, Integer limit, Integer offset) + throws SQLException { + return relationshipTypeDAO.findByLeftOrRightLabel(context, label, limit, offset); } @Override public List findByEntityType(Context context, EntityType entityType) throws SQLException { - return relationshipTypeDAO.findByEntityType(context, entityType); + return findByEntityType(context, entityType, -1, -1); + } + + @Override + public List findByEntityType(Context context, EntityType entityType, + Integer limit, Integer offset) throws SQLException { + return relationshipTypeDAO.findByEntityType(context, entityType, limit, offset); } @Override diff --git a/dspace-api/src/main/java/org/dspace/content/dao/RelationshipDAO.java b/dspace-api/src/main/java/org/dspace/content/dao/RelationshipDAO.java index 5352e39680..7c3d1f5bd1 100644 --- a/dspace-api/src/main/java/org/dspace/content/dao/RelationshipDAO.java +++ b/dspace-api/src/main/java/org/dspace/content/dao/RelationshipDAO.java @@ -36,6 +36,20 @@ public interface RelationshipDAO extends GenericDAO { */ List findByItem(Context context,Item item) throws SQLException; + /** + * This method returns a list of Relationship objects that have the given Item object + * as a leftItem or a rightItem + * @param context The relevant DSpace context + * @param item The item that should be either a leftItem or a rightItem of all + * the Relationship objects in the returned list + * @param limit paging limit + * @param offset paging offset + * @return The list of Relationship objects that contain either a left or a + * right item that is equal to the given item + * @throws SQLException If something goes wrong + */ + List findByItem(Context context, Item item, Integer limit, Integer offset) throws SQLException; + /** * This method returns the highest leftplace integer for all the relationships where this * item is the leftitem so that we can set a proper leftplace attribute on the next relationship @@ -69,4 +83,19 @@ public interface RelationshipDAO extends GenericDAO { * @throws SQLException If something goes wrong */ List findByRelationshipType(Context context, RelationshipType relationshipType) throws SQLException; + + /** + * This method returns a list of Relationship objects for the given RelationshipType object. + * It will construct a list of all Relationship objects that have the given RelationshipType object + * as the relationshipType property + * @param context The relevant DSpace context + * @param relationshipType The RelationshipType object to be checked on + * @param limit paging limit + * @param offset paging offset + * @return A list of Relationship objects that have the given RelationshipType object as the + * relationshipType property + * @throws SQLException If something goes wrong + */ + List findByRelationshipType(Context context, RelationshipType relationshipType, + Integer limit, Integer offset) throws SQLException; } diff --git a/dspace-api/src/main/java/org/dspace/content/dao/RelationshipTypeDAO.java b/dspace-api/src/main/java/org/dspace/content/dao/RelationshipTypeDAO.java index 500b9449f5..02b55e1614 100644 --- a/dspace-api/src/main/java/org/dspace/content/dao/RelationshipTypeDAO.java +++ b/dspace-api/src/main/java/org/dspace/content/dao/RelationshipTypeDAO.java @@ -50,6 +50,19 @@ public interface RelationshipTypeDAO extends GenericDAO { */ List findByLeftwardOrRightwardTypeName(Context context, String type) throws SQLException; + /** + * This method will return a list of RelationshipType objects for which the given label is equal to + * either the leftLabel or rightLabel. + * @param context The relevant DSpace context + * @param label The label that will be used to check on + * @param limit paging limit + * @param offset paging offset + * @return A list of RelationshipType objects that have the given label as either the leftLabel or rightLabel + * @throws SQLException If something goes wrong + */ + List findByLeftwardOrRightwardTypeName(Context context, String label, Integer limit, Integer offset) + throws SQLException; + /** * This method will return a list of RelationshipType objects for which the given EntityType object is equal * to the leftType or rightType @@ -60,4 +73,18 @@ public interface RelationshipTypeDAO extends GenericDAO { * @throws SQLException If something goes wrong */ List findByEntityType(Context context, EntityType entityType) throws SQLException; + + /** + * This method will return a list of RelationshipType objects for which the given EntityType object is equal + * to the leftType or rightType + * @param context The relevant DSpace context + * @param entityType The EntityType object that will be used to check on + * @param limit paging limit + * @param offset paging offset + * @return The list of RelationshipType objects that have the given EntityType object + * as either a leftType or rightType + * @throws SQLException If something goes wrong + */ + List findByEntityType(Context context, EntityType entityType, Integer limit, Integer offset) + throws SQLException; } diff --git a/dspace-api/src/main/java/org/dspace/content/dao/impl/RelationshipDAOImpl.java b/dspace-api/src/main/java/org/dspace/content/dao/impl/RelationshipDAOImpl.java index 2df8ed0a2e..e90772d368 100644 --- a/dspace-api/src/main/java/org/dspace/content/dao/impl/RelationshipDAOImpl.java +++ b/dspace-api/src/main/java/org/dspace/content/dao/impl/RelationshipDAOImpl.java @@ -25,6 +25,14 @@ public class RelationshipDAOImpl extends AbstractHibernateDAO impl @Override public List findByItem(Context context, Item item) throws SQLException { + + return findByItem(context, item, -1, -1); + } + + @Override + public List findByItem(Context context, Item item, Integer limit, Integer offset) + throws SQLException { + CriteriaBuilder criteriaBuilder = getCriteriaBuilder(context); CriteriaQuery criteriaQuery = getCriteriaQuery(criteriaBuilder, Relationship.class); Root relationshipRoot = criteriaQuery.from(Relationship.class); @@ -32,7 +40,7 @@ public class RelationshipDAOImpl extends AbstractHibernateDAO impl criteriaQuery .where(criteriaBuilder.or(criteriaBuilder.equal(relationshipRoot.get(Relationship_.leftItem), item), criteriaBuilder.equal(relationshipRoot.get(Relationship_.rightItem), item))); - return list(context, criteriaQuery, false, Relationship.class, -1, -1); + return list(context, criteriaQuery, false, Relationship.class, limit, offset); } @Override @@ -70,13 +78,21 @@ public class RelationshipDAOImpl extends AbstractHibernateDAO impl @Override public List findByRelationshipType(Context context, RelationshipType relationshipType) throws SQLException { + + return findByRelationshipType(context, relationshipType, -1, -1); + } + + @Override + public List findByRelationshipType(Context context, RelationshipType relationshipType, + Integer limit, Integer offset) throws SQLException { + CriteriaBuilder criteriaBuilder = getCriteriaBuilder(context); CriteriaQuery criteriaQuery = getCriteriaQuery(criteriaBuilder, Relationship.class); Root relationshipRoot = criteriaQuery.from(Relationship.class); criteriaQuery.select(relationshipRoot); criteriaQuery .where(criteriaBuilder.equal(relationshipRoot.get(Relationship_.relationshipType), relationshipType)); - return list(context, criteriaQuery, true, Relationship.class, -1, -1); + return list(context, criteriaQuery, true, Relationship.class, limit, offset); } diff --git a/dspace-api/src/main/java/org/dspace/content/dao/impl/RelationshipTypeDAOImpl.java b/dspace-api/src/main/java/org/dspace/content/dao/impl/RelationshipTypeDAOImpl.java index 6a7a829d73..df4d5e613b 100644 --- a/dspace-api/src/main/java/org/dspace/content/dao/impl/RelationshipTypeDAOImpl.java +++ b/dspace-api/src/main/java/org/dspace/content/dao/impl/RelationshipTypeDAOImpl.java @@ -41,6 +41,14 @@ public class RelationshipTypeDAOImpl extends AbstractHibernateDAO findByLeftwardOrRightwardTypeName(Context context, String type) throws SQLException { + + return findByLeftwardOrRightwardTypeName(context, type, -1, -1); + } + + @Override + public List findByLeftwardOrRightwardTypeName(Context context, String type, Integer limit, Integer offset) + throws SQLException { + CriteriaBuilder criteriaBuilder = getCriteriaBuilder(context); CriteriaQuery criteriaQuery = getCriteriaQuery(criteriaBuilder, RelationshipType.class); Root relationshipTypeRoot = criteriaQuery.from(RelationshipType.class); @@ -51,11 +59,18 @@ public class RelationshipTypeDAOImpl extends AbstractHibernateDAO findByEntityType(Context context, EntityType entityType) throws SQLException { + return findByEntityType(context, entityType, -1, -1); + } + + @Override + public List findByEntityType(Context context, EntityType entityType, + Integer limit, Integer offset) throws SQLException { + CriteriaBuilder criteriaBuilder = getCriteriaBuilder(context); CriteriaQuery criteriaQuery = getCriteriaQuery(criteriaBuilder, RelationshipType.class); Root relationshipTypeRoot = criteriaQuery.from(RelationshipType.class); @@ -67,7 +82,7 @@ public class RelationshipTypeDAOImpl extends AbstractHibernateDAO getRelationsByLabel(Context context, String label) throws SQLException; + /** + * Retrieves the list of relationships for which their relationshiptype has a left or right label that is + * equal to the passed along label String + * @param context The relevant DSpace context + * @param label The label that needs to be in the relationshiptype of the relationship + * @param limit paging limit + * @param offset paging offset + * @return The list of relationships that have a relationshiptype with a left or right label + * that is equal to the label param + * @throws SQLException If something goes wrong + */ + List getRelationsByLabel(Context context, String label, Integer limit, Integer offset) + throws SQLException; + /** * Retrieves the list of relationships that have a relationshiptype that contains the EntityType for the given * Entity @@ -89,6 +116,22 @@ public interface EntityService { */ List getAllRelationshipTypes(Context context, Entity entity) throws SQLException; + /** + * Retrieves the list of relationships that have a relationshiptype that contains the EntityType for the given + * Entity + * in either the leftEntityType or the rightEntityType variables + * @param context The relevant DSpace context + * @param entity The Entity for which the EntityType should be checked for relationships + * @param limit paging limit + * @param offset paging offset + * @return The list of relationships that each contain a relationshiptype in which there is a right or left + * entity type that + * is equal to the entity type for the given entity + * @throws SQLException If something goes wrong + */ + List getAllRelationshipTypes(Context context, Entity entity, Integer limit, Integer offset) + throws SQLException; + /** * Retrieves the list of relationships that have a relationshiptype that contains the EntityType for the given * Entity @@ -101,6 +144,21 @@ public interface EntityService { */ List getLeftRelationshipTypes(Context context, Entity entity) throws SQLException; + /** + * Retrieves the list of relationships that have a relationshiptype that contains the EntityType for the given + * Entity + * in the leftEntityType + * @param context The relevant DSpace context + * @param entity The Entity for which the EntityType should be checked for relationships + * @param limit paging limit + * @param offset paging offset + * @return The list of relationships that each contain a relationshiptype in which there is a left entity type that + * is equal to the entity type for the given entity + * @throws SQLException If something goes wrong + */ + List getLeftRelationshipTypes(Context context, Entity entity, + Integer limit, Integer offset) throws SQLException; + /** * Retrieves the list of relationships that have a relationshiptype that contains the EntityType for the given * Entity @@ -113,6 +171,21 @@ public interface EntityService { */ List getRightRelationshipTypes(Context context, Entity entity) throws SQLException; + /** + * Retrieves the list of relationships that have a relationshiptype that contains the EntityType for the given + * Entity + * in the rightEntityType + * @param context The relevant DSpace context + * @param entity The Entity for which the EntityType should be checked for relationships + * @param limit paging limit + * @param offset paging offset + * @return The list of relationships that each contain a relationshiptype in which there is a right entity type that + * is equal to the entity type for the given entity + * @throws SQLException If something goes wrong + */ + List getRightRelationshipTypes(Context context, Entity entity, + Integer limit, Integer offset) throws SQLException; + /** * Retrieves a list of RelationshipType objects for which either their left or right label is equal to the * label parameter that's being passed along @@ -124,4 +197,18 @@ public interface EntityService { */ List getRelationshipTypesByTypeName(Context context, String label) throws SQLException; + /** + * Retrieves a list of RelationshipType objects for which either their left or right label is equal to the + * label parameter that's being passed along + * @param context The relevant DSpace context + * @param label The label for which the relationshiptype's labels must be checked + * @param limit paging limit + * @param offset paging offset + * @return The list of relationshiptypes that each contain a left or right label that is equal + * to the given label parameter + * @throws SQLException If something goes wrong + */ + List getRelationshipTypesByLabel(Context context, String label, + Integer limit, Integer offset) throws SQLException; + } diff --git a/dspace-api/src/main/java/org/dspace/content/service/EntityTypeService.java b/dspace-api/src/main/java/org/dspace/content/service/EntityTypeService.java index 32c86848f8..f4d9a15bb2 100644 --- a/dspace-api/src/main/java/org/dspace/content/service/EntityTypeService.java +++ b/dspace-api/src/main/java/org/dspace/content/service/EntityTypeService.java @@ -37,6 +37,16 @@ public interface EntityTypeService extends DSpaceCRUDService { */ public List findAll(Context context) throws SQLException; + /** + * Retrieves all the EntityType objects currently in the system + * @param context The relevant DSpace context + * @param limit paging limit + * @param offset paging offset + * @return A list of all EntityType objects + * @throws SQLException If something goes wrong + */ + List findAll(Context context, Integer limit, Integer offset) throws SQLException; + /** * This method creates an EntityType object in the database with the given entityTypeString as it's label * @param context The relevant DSpace context diff --git a/dspace-api/src/main/java/org/dspace/content/service/RelationshipService.java b/dspace-api/src/main/java/org/dspace/content/service/RelationshipService.java index aff6140935..270bf7f940 100644 --- a/dspace-api/src/main/java/org/dspace/content/service/RelationshipService.java +++ b/dspace-api/src/main/java/org/dspace/content/service/RelationshipService.java @@ -32,6 +32,18 @@ public interface RelationshipService extends DSpaceCRUDService { */ public List findByItem(Context context,Item item) throws SQLException; + /** + * Retrieves the list of Relationships currently in the system for which the given Item is either + * a leftItem or a rightItem object + * @param context The relevant DSpace context + * @param item The Item that has to be the left or right item for the relationship to be included in the list + * @param limit paging limit + * @param offset paging offset + * @return The list of relationships for which each relationship adheres to the above listed constraint + * @throws SQLException If something goes wrong + */ + List findByItem(Context context, Item item, Integer limit, Integer offset) throws SQLException; + /** * Retrieves the full list of relationships currently in the system * @param context The relevant DSpace context @@ -40,6 +52,16 @@ public interface RelationshipService extends DSpaceCRUDService { */ public List findAll(Context context) throws SQLException; + /** + * Retrieves the full list of relationships currently in the system + * @param context The relevant DSpace context + * @param limit paging limit + * @param offset paging offset + * @return The list of all relationships currently in the system + * @throws SQLException If something goes wrong + */ + List findAll(Context context, Integer limit, Integer offset) throws SQLException; + /** * This method creates a relationship object in the database equal to the given relationship param * if this is a valid relationship @@ -126,6 +148,20 @@ public interface RelationshipService extends DSpaceCRUDService { */ List findByRelationshipType(Context context, RelationshipType relationshipType) throws SQLException; + /** + * This method returns a list of Relationship objets for which the relationshipType property is equal to the given + * RelationshipType object + * @param context The relevant DSpace context + * @param relationshipType The RelationshipType object that will be used to check the Relationship on + * @param limit paging limit + * @param offset paging offset + * @return The list of Relationship objects for which the given RelationshipType object is equal + * to the relationshipType property + * @throws SQLException If something goes wrong + */ + List findByRelationshipType(Context context, RelationshipType relationshipType, Integer limit, + Integer offset) throws SQLException; + /** * This method is used to construct a Relationship object with all it's variables * @param c The relevant DSpace context diff --git a/dspace-api/src/main/java/org/dspace/content/service/RelationshipTypeService.java b/dspace-api/src/main/java/org/dspace/content/service/RelationshipTypeService.java index d5afafdb8b..f60abfb88b 100644 --- a/dspace-api/src/main/java/org/dspace/content/service/RelationshipTypeService.java +++ b/dspace-api/src/main/java/org/dspace/content/service/RelationshipTypeService.java @@ -23,26 +23,26 @@ public interface RelationshipTypeService extends DSpaceCRUDService findAll(Context context) throws SQLException; + /** + * Retrieves all RelationshipType objects currently in the system + * @param context The relevant DSpace context + * @param limit paging limit + * @param offset paging offset + * @return The list of all RelationshipType objects currently in the system + * @throws SQLException If something goes wrong + */ + List findAll(Context context, Integer limit, Integer offset) throws SQLException; + /** * Retrieves all RelationshipType objects that have a left or right type that is * equal to the given String @@ -64,6 +74,20 @@ public interface RelationshipTypeService extends DSpaceCRUDService findByLeftwardOrRightwardTypeName(Context context, String label) throws SQLException; + /** + * Retrieves all RelationshipType objects that have a left or right label that is + * equal to the given String + * @param context The relevant DSpace context + * @param label The label that has to match + * @param limit paging limit + * @param offset paging offset + * @return The list of all RelationshipType objects that have a left or right label + * that is equal to the given label param + * @throws SQLException If something goes wrong + */ + List findByLeftOrRightLabel(Context context, String label, Integer limit, Integer offset) + throws SQLException; + /** * Returns a list of RelationshipType objects for which the given EntityType is equal to either the leftType * or the rightType @@ -75,6 +99,9 @@ public interface RelationshipTypeService extends DSpaceCRUDService findByEntityType(Context context, EntityType entityType) throws SQLException; + List findByEntityType(Context context, EntityType entityType, Integer limit, Integer offset) + throws SQLException; + /** * This method will support the creation of a RelationshipType object with the given parameters * @param context The relevant DSpace context diff --git a/dspace-api/src/main/java/org/dspace/core/AbstractHibernateDAO.java b/dspace-api/src/main/java/org/dspace/core/AbstractHibernateDAO.java index 1064017222..c8e64e0ad9 100644 --- a/dspace-api/src/main/java/org/dspace/core/AbstractHibernateDAO.java +++ b/dspace-api/src/main/java/org/dspace/core/AbstractHibernateDAO.java @@ -66,10 +66,16 @@ public abstract class AbstractHibernateDAO implements GenericDAO { @Override public List findAll(Context context, Class clazz) throws SQLException { + + return findAll(context, clazz, -1, -1); + } + + @Override + public List findAll(Context context, Class clazz, Integer limit, Integer offset) throws SQLException { CriteriaQuery criteriaQuery = getCriteriaQuery(getCriteriaBuilder(context), clazz); Root root = criteriaQuery.from(clazz); criteriaQuery.select(root); - return executeCriteriaQuery(context, criteriaQuery, false, -1, -1); + return executeCriteriaQuery(context, criteriaQuery, false, limit, offset); } @Override diff --git a/dspace-api/src/main/java/org/dspace/core/GenericDAO.java b/dspace-api/src/main/java/org/dspace/core/GenericDAO.java index ba17499a67..a04a0ccbdc 100644 --- a/dspace-api/src/main/java/org/dspace/core/GenericDAO.java +++ b/dspace-api/src/main/java/org/dspace/core/GenericDAO.java @@ -58,6 +58,18 @@ public interface GenericDAO { */ public List findAll(Context context, Class clazz) throws SQLException; + /** + * Fetch all persisted instances of a given object type. + * + * @param context The relevant DSpace Context. + * @param clazz the desired type. + * @param limit paging limit + * @param offset paging offset + * @return list of DAOs of the same type as clazz + * @throws SQLException if database error + */ + List findAll(Context context, Class clazz, Integer limit, Integer offset) throws SQLException; + /** * Execute a JPQL query returning a unique result. *