DS-4096 paginated methods for relationships

This commit is contained in:
Samuel
2019-06-20 14:45:57 +02:00
committed by Andrew Wood
parent f8e42eb5e5
commit 6da844941d
14 changed files with 389 additions and 31 deletions

View File

@@ -38,8 +38,15 @@ public class EntityServiceImpl implements EntityService {
@Override @Override
public Entity findByItemId(Context context, UUID itemId) throws SQLException { 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); Item item = itemService.find(context, itemId);
List<Relationship> relationshipList = relationshipService.findByItem(context, item); List<Relationship> relationshipList = relationshipService.findByItem(context, item, limit, offset);
return new Entity(item, relationshipList); return new Entity(item, relationshipList);
} }
@@ -80,8 +87,16 @@ public class EntityServiceImpl implements EntityService {
@Override @Override
public List<Relationship> getRelationsByLabel(Context context, String label) throws SQLException { public List<Relationship> getRelationsByLabel(Context context, String label) throws SQLException {
return getRelationsByLabel(context, label, -1, -1);
}
@Override
public List<Relationship> getRelationsByLabel(Context context, String label, Integer limit, Integer offset)
throws SQLException {
List<Relationship> listToReturn = new LinkedList<>(); List<Relationship> listToReturn = new LinkedList<>();
List<Relationship> relationshipList = relationshipService.findAll(context); List<Relationship> relationshipList = relationshipService.findAll(context, limit, offset);
for (Relationship relationship : relationshipList) { for (Relationship relationship : relationshipList) {
RelationshipType relationshipType = relationship.getRelationshipType(); RelationshipType relationshipType = relationship.getRelationshipType();
if (StringUtils.equals(relationshipType.getLeftwardType(),label) || if (StringUtils.equals(relationshipType.getLeftwardType(),label) ||
@@ -94,12 +109,20 @@ public class EntityServiceImpl implements EntityService {
@Override @Override
public List<RelationshipType> getAllRelationshipTypes(Context context, Entity entity) throws SQLException { public List<RelationshipType> getAllRelationshipTypes(Context context, Entity entity) throws SQLException {
return getAllRelationshipTypes(context, entity, -1, -1);
}
@Override
public List<RelationshipType> getAllRelationshipTypes(Context context, Entity entity, Integer limit, Integer offset)
throws SQLException {
EntityType entityType = this.getType(context, entity); EntityType entityType = this.getType(context, entity);
if (entityType == null) { if (entityType == null) {
return Collections.emptyList(); return Collections.emptyList();
} }
List<RelationshipType> listToReturn = new LinkedList<>(); List<RelationshipType> listToReturn = new LinkedList<>();
for (RelationshipType relationshipType : relationshipTypeService.findAll(context)) { for (RelationshipType relationshipType : relationshipTypeService.findAll(context, limit, offset)) {
if (relationshipType.getLeftType().getID() == entityType.getID() || if (relationshipType.getLeftType().getID() == entityType.getID() ||
relationshipType.getRightType().getID() == entityType.getID()) { relationshipType.getRightType().getID() == entityType.getID()) {
listToReturn.add(relationshipType); listToReturn.add(relationshipType);
@@ -110,9 +133,17 @@ public class EntityServiceImpl implements EntityService {
@Override @Override
public List<RelationshipType> getLeftRelationshipTypes(Context context, Entity entity) throws SQLException { public List<RelationshipType> getLeftRelationshipTypes(Context context, Entity entity) throws SQLException {
return getLeftRelationshipTypes(context, entity, -1, -1);
}
@Override
public List<RelationshipType> getLeftRelationshipTypes(Context context, Entity entity,
Integer limit, Integer offset) throws SQLException {
EntityType entityType = this.getType(context, entity); EntityType entityType = this.getType(context, entity);
List<RelationshipType> listToReturn = new LinkedList<>(); List<RelationshipType> listToReturn = new LinkedList<>();
for (RelationshipType relationshipType : relationshipTypeService.findAll(context)) { for (RelationshipType relationshipType : relationshipTypeService.findAll(context, limit, offset)) {
if (relationshipType.getLeftType().getID() == entityType.getID()) { if (relationshipType.getLeftType().getID() == entityType.getID()) {
listToReturn.add(relationshipType); listToReturn.add(relationshipType);
} }
@@ -122,9 +153,17 @@ public class EntityServiceImpl implements EntityService {
@Override @Override
public List<RelationshipType> getRightRelationshipTypes(Context context, Entity entity) throws SQLException { public List<RelationshipType> getRightRelationshipTypes(Context context, Entity entity) throws SQLException {
return getRightRelationshipTypes(context, entity, -1, -1);
}
@Override
public List<RelationshipType> getRightRelationshipTypes(Context context, Entity entity,
Integer limit, Integer offset) throws SQLException {
EntityType entityType = this.getType(context, entity); EntityType entityType = this.getType(context, entity);
List<RelationshipType> listToReturn = new LinkedList<>(); List<RelationshipType> listToReturn = new LinkedList<>();
for (RelationshipType relationshipType : relationshipTypeService.findAll(context)) { for (RelationshipType relationshipType : relationshipTypeService.findAll(context, limit, offset)) {
if (relationshipType.getRightType().getID() == entityType.getID()) { if (relationshipType.getRightType().getID() == entityType.getID()) {
listToReturn.add(relationshipType); listToReturn.add(relationshipType);
} }
@@ -133,9 +172,16 @@ public class EntityServiceImpl implements EntityService {
} }
@Override @Override
public List<RelationshipType> getRelationshipTypesByTypeName(Context context, String label) throws SQLException { public List<RelationshipType> getRelationshipTypesByLabel(Context context, String label) throws SQLException {
return getRelationshipTypesByLabel(context, label, -1, -1);
}
@Override
public List<RelationshipType> getRelationshipTypesByTypeName(Context context, String label,
Integer limit, Integer offset) throws SQLException {
List<RelationshipType> listToReturn = new LinkedList<>(); List<RelationshipType> listToReturn = new LinkedList<>();
for (RelationshipType relationshipType : relationshipTypeService.findAll(context)) { for (RelationshipType relationshipType : relationshipTypeService.findAll(context, limit, offset)) {
if (StringUtils.equals(relationshipType.getLeftwardType(),label) || if (StringUtils.equals(relationshipType.getLeftwardType(),label) ||
StringUtils.equals(relationshipType.getRightwardType(),label)) { StringUtils.equals(relationshipType.getRightwardType(),label)) {
listToReturn.add(relationshipType); listToReturn.add(relationshipType);

View File

@@ -28,13 +28,20 @@ public class EntityTypeServiceImpl implements EntityTypeService {
protected AuthorizeService authorizeService; protected AuthorizeService authorizeService;
@Override @Override
public EntityType findByEntityType(Context context,String entityType) throws SQLException { public EntityType findByEntityType(Context context, String entityType) throws SQLException {
return entityTypeDAO.findByEntityType(context, entityType); return entityTypeDAO.findByEntityType(context, entityType);
} }
@Override @Override
public List<EntityType> findAll(Context context) throws SQLException { public List<EntityType> findAll(Context context) throws SQLException {
return entityTypeDAO.findAll(context, EntityType.class);
return findAll(context, -1, -1);
}
@Override
public List<EntityType> findAll(Context context, Integer limit, Integer offset) throws SQLException {
return entityTypeDAO.findAll(context, EntityType.class, limit, offset);
} }
@Override @Override

View File

@@ -268,7 +268,14 @@ public class RelationshipServiceImpl implements RelationshipService {
@Override @Override
public List<Relationship> findByItem(Context context, Item item) throws SQLException { public List<Relationship> findByItem(Context context, Item item) throws SQLException {
List<Relationship> list = relationshipDAO.findByItem(context, item); return findByItem(context, item, -1, -1);
}
@Override
public List<Relationship> findByItem(Context context, Item item, Integer limit, Integer offset)
throws SQLException {
List<Relationship> list = relationshipDAO.findByItem(context, item, limit, offset);
list.sort((o1, o2) -> { list.sort((o1, o2) -> {
int relationshipType = o1.getRelationshipType().getLeftwardType() int relationshipType = o1.getRelationshipType().getLeftwardType()
@@ -288,7 +295,14 @@ public class RelationshipServiceImpl implements RelationshipService {
@Override @Override
public List<Relationship> findAll(Context context) throws SQLException { public List<Relationship> findAll(Context context) throws SQLException {
return relationshipDAO.findAll(context, Relationship.class);
return findAll(context, -1, -1);
}
@Override
public List<Relationship> findAll(Context context, Integer limit, Integer offset) throws SQLException {
return relationshipDAO.findAll(context, Relationship.class, limit, offset);
} }
@Override @Override
@@ -420,7 +434,15 @@ public class RelationshipServiceImpl implements RelationshipService {
@Override @Override
public List<Relationship> findByRelationshipType(Context context, RelationshipType relationshipType) public List<Relationship> findByRelationshipType(Context context, RelationshipType relationshipType)
throws SQLException { throws SQLException {
return relationshipDAO.findByRelationshipType(context, relationshipType);
return findByRelationshipType(context, relationshipType, -1, -1);
}
@Override
public List<Relationship> findByRelationshipType(Context context, RelationshipType relationshipType, Integer limit,
Integer offset)
throws SQLException {
return relationshipDAO.findByRelationshipType(context, relationshipType, limit, offset);
} }

View File

@@ -54,17 +54,35 @@ public class RelationshipTypeServiceImpl implements RelationshipTypeService {
@Override @Override
public List<RelationshipType> findAll(Context context) throws SQLException { public List<RelationshipType> findAll(Context context) throws SQLException {
return relationshipTypeDAO.findAll(context, RelationshipType.class); return findAll(context, -1, -1);
}
@Override
public List<RelationshipType> findAll(Context context, Integer limit, Integer offset) throws SQLException {
return relationshipTypeDAO.findAll(context, RelationshipType.class, limit, offset);
} }
@Override @Override
public List<RelationshipType> findByLeftwardOrRightwardTypeName(Context context, String label) throws SQLException { public List<RelationshipType> findByLeftwardOrRightwardTypeName(Context context, String label) throws SQLException {
return relationshipTypeDAO.findByLeftwardOrRightwardTypeName(context, label); return findByLeftOrRightLabel(context, label, -1, -1);
}
@Override
public List<RelationshipType> findByLeftwardOrRightwardTypeName(Context context, String label, Integer limit, Integer offset)
throws SQLException {
return relationshipTypeDAO.findByLeftOrRightLabel(context, label, limit, offset);
} }
@Override @Override
public List<RelationshipType> findByEntityType(Context context, EntityType entityType) throws SQLException { public List<RelationshipType> findByEntityType(Context context, EntityType entityType) throws SQLException {
return relationshipTypeDAO.findByEntityType(context, entityType); return findByEntityType(context, entityType, -1, -1);
}
@Override
public List<RelationshipType> findByEntityType(Context context, EntityType entityType,
Integer limit, Integer offset) throws SQLException {
return relationshipTypeDAO.findByEntityType(context, entityType, limit, offset);
} }
@Override @Override

View File

@@ -36,6 +36,20 @@ public interface RelationshipDAO extends GenericDAO<Relationship> {
*/ */
List<Relationship> findByItem(Context context,Item item) throws SQLException; List<Relationship> 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<Relationship> findByItem(Context context, Item item, Integer limit, Integer offset) throws SQLException;
/** /**
* This method returns the highest leftplace integer for all the relationships where this * 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 * 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<Relationship> {
* @throws SQLException If something goes wrong * @throws SQLException If something goes wrong
*/ */
List<Relationship> findByRelationshipType(Context context, RelationshipType relationshipType) throws SQLException; List<Relationship> 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<Relationship> findByRelationshipType(Context context, RelationshipType relationshipType,
Integer limit, Integer offset) throws SQLException;
} }

View File

@@ -50,6 +50,19 @@ public interface RelationshipTypeDAO extends GenericDAO<RelationshipType> {
*/ */
List<RelationshipType> findByLeftwardOrRightwardTypeName(Context context, String type) throws SQLException; List<RelationshipType> 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<RelationshipType> 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 * This method will return a list of RelationshipType objects for which the given EntityType object is equal
* to the leftType or rightType * to the leftType or rightType
@@ -60,4 +73,18 @@ public interface RelationshipTypeDAO extends GenericDAO<RelationshipType> {
* @throws SQLException If something goes wrong * @throws SQLException If something goes wrong
*/ */
List<RelationshipType> findByEntityType(Context context, EntityType entityType) throws SQLException; List<RelationshipType> 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<RelationshipType> findByEntityType(Context context, EntityType entityType, Integer limit, Integer offset)
throws SQLException;
} }

View File

@@ -25,6 +25,14 @@ public class RelationshipDAOImpl extends AbstractHibernateDAO<Relationship> impl
@Override @Override
public List<Relationship> findByItem(Context context, Item item) throws SQLException { public List<Relationship> findByItem(Context context, Item item) throws SQLException {
return findByItem(context, item, -1, -1);
}
@Override
public List<Relationship> findByItem(Context context, Item item, Integer limit, Integer offset)
throws SQLException {
CriteriaBuilder criteriaBuilder = getCriteriaBuilder(context); CriteriaBuilder criteriaBuilder = getCriteriaBuilder(context);
CriteriaQuery criteriaQuery = getCriteriaQuery(criteriaBuilder, Relationship.class); CriteriaQuery criteriaQuery = getCriteriaQuery(criteriaBuilder, Relationship.class);
Root<Relationship> relationshipRoot = criteriaQuery.from(Relationship.class); Root<Relationship> relationshipRoot = criteriaQuery.from(Relationship.class);
@@ -32,7 +40,7 @@ public class RelationshipDAOImpl extends AbstractHibernateDAO<Relationship> impl
criteriaQuery criteriaQuery
.where(criteriaBuilder.or(criteriaBuilder.equal(relationshipRoot.get(Relationship_.leftItem), item), .where(criteriaBuilder.or(criteriaBuilder.equal(relationshipRoot.get(Relationship_.leftItem), item),
criteriaBuilder.equal(relationshipRoot.get(Relationship_.rightItem), 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 @Override
@@ -70,13 +78,21 @@ public class RelationshipDAOImpl extends AbstractHibernateDAO<Relationship> impl
@Override @Override
public List<Relationship> findByRelationshipType(Context context, RelationshipType relationshipType) public List<Relationship> findByRelationshipType(Context context, RelationshipType relationshipType)
throws SQLException { throws SQLException {
return findByRelationshipType(context, relationshipType, -1, -1);
}
@Override
public List<Relationship> findByRelationshipType(Context context, RelationshipType relationshipType,
Integer limit, Integer offset) throws SQLException {
CriteriaBuilder criteriaBuilder = getCriteriaBuilder(context); CriteriaBuilder criteriaBuilder = getCriteriaBuilder(context);
CriteriaQuery criteriaQuery = getCriteriaQuery(criteriaBuilder, Relationship.class); CriteriaQuery criteriaQuery = getCriteriaQuery(criteriaBuilder, Relationship.class);
Root<Relationship> relationshipRoot = criteriaQuery.from(Relationship.class); Root<Relationship> relationshipRoot = criteriaQuery.from(Relationship.class);
criteriaQuery.select(relationshipRoot); criteriaQuery.select(relationshipRoot);
criteriaQuery criteriaQuery
.where(criteriaBuilder.equal(relationshipRoot.get(Relationship_.relationshipType), relationshipType)); .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);
} }

View File

@@ -41,6 +41,14 @@ public class RelationshipTypeDAOImpl extends AbstractHibernateDAO<RelationshipTy
@Override @Override
public List<RelationshipType> findByLeftwardOrRightwardTypeName(Context context, String type) throws SQLException { public List<RelationshipType> findByLeftwardOrRightwardTypeName(Context context, String type) throws SQLException {
return findByLeftwardOrRightwardTypeName(context, type, -1, -1);
}
@Override
public List<RelationshipType> findByLeftwardOrRightwardTypeName(Context context, String type, Integer limit, Integer offset)
throws SQLException {
CriteriaBuilder criteriaBuilder = getCriteriaBuilder(context); CriteriaBuilder criteriaBuilder = getCriteriaBuilder(context);
CriteriaQuery criteriaQuery = getCriteriaQuery(criteriaBuilder, RelationshipType.class); CriteriaQuery criteriaQuery = getCriteriaQuery(criteriaBuilder, RelationshipType.class);
Root<RelationshipType> relationshipTypeRoot = criteriaQuery.from(RelationshipType.class); Root<RelationshipType> relationshipTypeRoot = criteriaQuery.from(RelationshipType.class);
@@ -51,11 +59,18 @@ public class RelationshipTypeDAOImpl extends AbstractHibernateDAO<RelationshipTy
criteriaBuilder.equal(relationshipTypeRoot.get(RelationshipType_.rightwardType), type) criteriaBuilder.equal(relationshipTypeRoot.get(RelationshipType_.rightwardType), type)
) )
); );
return list(context, criteriaQuery, true, RelationshipType.class, -1, -1); return list(context, criteriaQuery, true, RelationshipType.class, limit, offset);
} }
@Override @Override
public List<RelationshipType> findByEntityType(Context context, EntityType entityType) throws SQLException { public List<RelationshipType> findByEntityType(Context context, EntityType entityType) throws SQLException {
return findByEntityType(context, entityType, -1, -1);
}
@Override
public List<RelationshipType> findByEntityType(Context context, EntityType entityType,
Integer limit, Integer offset) throws SQLException {
CriteriaBuilder criteriaBuilder = getCriteriaBuilder(context); CriteriaBuilder criteriaBuilder = getCriteriaBuilder(context);
CriteriaQuery criteriaQuery = getCriteriaQuery(criteriaBuilder, RelationshipType.class); CriteriaQuery criteriaQuery = getCriteriaQuery(criteriaBuilder, RelationshipType.class);
Root<RelationshipType> relationshipTypeRoot = criteriaQuery.from(RelationshipType.class); Root<RelationshipType> relationshipTypeRoot = criteriaQuery.from(RelationshipType.class);
@@ -67,7 +82,7 @@ public class RelationshipTypeDAOImpl extends AbstractHibernateDAO<RelationshipTy
.equal(relationshipTypeRoot.get(RelationshipType_.rightType), entityType) .equal(relationshipTypeRoot.get(RelationshipType_.rightType), entityType)
) )
); );
return list(context, criteriaQuery, false, RelationshipType.class, -1, -1); return list(context, criteriaQuery, false, RelationshipType.class, limit, offset);
} }
} }

View File

@@ -36,6 +36,19 @@ public interface EntityService {
*/ */
Entity findByItemId(Context context, UUID itemId) throws SQLException; Entity findByItemId(Context context, UUID itemId) throws SQLException;
/**
* This will construct an Entity object that will be returned with the Item that matches the ItemID that was
* passed along
* as well as a list of relationships for that Item.
* @param context The relevant DSpace context
* @param itemId The ItemID for the Item that is to be used in the Entity object
* @param limit paging limit
* @param offset paging offset
* @return The constructed Entity object with the Item and the list of relationships
* @throws SQLException If something goes wrong
*/
Entity findByItemId(Context context, UUID itemId, Integer limit, Integer offset) throws SQLException;
/** /**
* Returns the EntityType for the Item that is attached to the Entity that is passed along to this method. * Returns the EntityType for the Item that is attached to the Entity that is passed along to this method.
* The EntityType String logic is in the Metadata for that Item and will be searched on in the EntityTypeService * The EntityType String logic is in the Metadata for that Item and will be searched on in the EntityTypeService
@@ -76,6 +89,20 @@ public interface EntityService {
*/ */
List<Relationship> getRelationsByLabel(Context context, String label) throws SQLException; List<Relationship> 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<Relationship> 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 * Retrieves the list of relationships that have a relationshiptype that contains the EntityType for the given
* Entity * Entity
@@ -89,6 +116,22 @@ public interface EntityService {
*/ */
List<RelationshipType> getAllRelationshipTypes(Context context, Entity entity) throws SQLException; List<RelationshipType> 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<RelationshipType> 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 * Retrieves the list of relationships that have a relationshiptype that contains the EntityType for the given
* Entity * Entity
@@ -101,6 +144,21 @@ public interface EntityService {
*/ */
List<RelationshipType> getLeftRelationshipTypes(Context context, Entity entity) throws SQLException; List<RelationshipType> 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<RelationshipType> 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 * Retrieves the list of relationships that have a relationshiptype that contains the EntityType for the given
* Entity * Entity
@@ -113,6 +171,21 @@ public interface EntityService {
*/ */
List<RelationshipType> getRightRelationshipTypes(Context context, Entity entity) throws SQLException; List<RelationshipType> 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<RelationshipType> 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 * 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 * label parameter that's being passed along
@@ -124,4 +197,18 @@ public interface EntityService {
*/ */
List<RelationshipType> getRelationshipTypesByTypeName(Context context, String label) throws SQLException; List<RelationshipType> 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<RelationshipType> getRelationshipTypesByLabel(Context context, String label,
Integer limit, Integer offset) throws SQLException;
} }

View File

@@ -37,6 +37,16 @@ public interface EntityTypeService extends DSpaceCRUDService<EntityType> {
*/ */
public List<EntityType> findAll(Context context) throws SQLException; public List<EntityType> 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<EntityType> 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 * This method creates an EntityType object in the database with the given entityTypeString as it's label
* @param context The relevant DSpace context * @param context The relevant DSpace context

View File

@@ -32,6 +32,18 @@ public interface RelationshipService extends DSpaceCRUDService<Relationship> {
*/ */
public List<Relationship> findByItem(Context context,Item item) throws SQLException; public List<Relationship> 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<Relationship> findByItem(Context context, Item item, Integer limit, Integer offset) throws SQLException;
/** /**
* Retrieves the full list of relationships currently in the system * Retrieves the full list of relationships currently in the system
* @param context The relevant DSpace context * @param context The relevant DSpace context
@@ -40,6 +52,16 @@ public interface RelationshipService extends DSpaceCRUDService<Relationship> {
*/ */
public List<Relationship> findAll(Context context) throws SQLException; public List<Relationship> 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<Relationship> findAll(Context context, Integer limit, Integer offset) throws SQLException;
/** /**
* This method creates a relationship object in the database equal to the given relationship param * This method creates a relationship object in the database equal to the given relationship param
* if this is a valid relationship * if this is a valid relationship
@@ -126,6 +148,20 @@ public interface RelationshipService extends DSpaceCRUDService<Relationship> {
*/ */
List<Relationship> findByRelationshipType(Context context, RelationshipType relationshipType) throws SQLException; List<Relationship> 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<Relationship> 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 * This method is used to construct a Relationship object with all it's variables
* @param c The relevant DSpace context * @param c The relevant DSpace context

View File

@@ -23,26 +23,26 @@ public interface RelationshipTypeService extends DSpaceCRUDService<RelationshipT
/** /**
* This method creates the given RelationshipType object in the database and returns it * This method creates the given RelationshipType object in the database and returns it
* @param context The relevant DSpace context * @param context The relevant DSpace context
* @param relationshipType The RelationshipType to be created in the database * @param relationshipType The RelationshipType to be created in the database
* @return The newly created RelationshipType * @return The newly created RelationshipType
* @throws SQLException If something goes wrong * @throws SQLException If something goes wrong
* @throws AuthorizeException If something goes wrong with authorizations * @throws AuthorizeException If something goes wrong with authorizations
*/ */
RelationshipType create(Context context,RelationshipType relationshipType) throws SQLException, AuthorizeException; RelationshipType create(Context context, RelationshipType relationshipType) throws SQLException, AuthorizeException;
/** /**
* Retrieves a RelationshipType for which the given parameters all match the one in the returned RelationshipType * Retrieves a RelationshipType for which the given parameters all match the one in the returned RelationshipType
* @param context The relevant DSpace context * @param context The relevant DSpace context
* @param leftType The rightType EntityType that needs to match for the returned RelationshipType * @param leftType The rightType EntityType that needs to match for the returned RelationshipType
* @param rightType The rightType EntityType that needs to match for the returned RelationshipType * @param rightType The rightType EntityType that needs to match for the returned RelationshipType
* @param leftwardType The leftwardType String that needs to match for the returned RelationshipType * @param leftwardType The leftLabel String that needs to match for the returned RelationshipType
* @param rightwardType The rightwardType String that needs to match for the returned RelationshipType * @param rightwardType The rightLabel String that needs to match for the returned RelationshipType
* @return * @return
* @throws SQLException If something goes wrong * @throws SQLException If something goes wrong
*/ */
RelationshipType findbyTypesAndLabels(Context context,EntityType leftType,EntityType rightType, RelationshipType findbyTypesAndLabels(Context context, EntityType leftType, EntityType rightType,
String leftwardType,String rightwardType) String leftwardType, String rightwardType)
throws SQLException; throws SQLException;
/** /**
@@ -53,6 +53,16 @@ public interface RelationshipTypeService extends DSpaceCRUDService<RelationshipT
*/ */
List<RelationshipType> findAll(Context context) throws SQLException; List<RelationshipType> 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<RelationshipType> findAll(Context context, Integer limit, Integer offset) throws SQLException;
/** /**
* Retrieves all RelationshipType objects that have a left or right type that is * Retrieves all RelationshipType objects that have a left or right type that is
* equal to the given String * equal to the given String
@@ -64,6 +74,20 @@ public interface RelationshipTypeService extends DSpaceCRUDService<RelationshipT
*/ */
List<RelationshipType> findByLeftwardOrRightwardTypeName(Context context, String label) throws SQLException; List<RelationshipType> 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<RelationshipType> 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 * Returns a list of RelationshipType objects for which the given EntityType is equal to either the leftType
* or the rightType * or the rightType
@@ -75,6 +99,9 @@ public interface RelationshipTypeService extends DSpaceCRUDService<RelationshipT
*/ */
List<RelationshipType> findByEntityType(Context context, EntityType entityType) throws SQLException; List<RelationshipType> findByEntityType(Context context, EntityType entityType) throws SQLException;
List<RelationshipType> 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 * This method will support the creation of a RelationshipType object with the given parameters
* @param context The relevant DSpace context * @param context The relevant DSpace context

View File

@@ -66,10 +66,16 @@ public abstract class AbstractHibernateDAO<T> implements GenericDAO<T> {
@Override @Override
public List<T> findAll(Context context, Class<T> clazz) throws SQLException { public List<T> findAll(Context context, Class<T> clazz) throws SQLException {
return findAll(context, clazz, -1, -1);
}
@Override
public List<T> findAll(Context context, Class<T> clazz, Integer limit, Integer offset) throws SQLException {
CriteriaQuery criteriaQuery = getCriteriaQuery(getCriteriaBuilder(context), clazz); CriteriaQuery criteriaQuery = getCriteriaQuery(getCriteriaBuilder(context), clazz);
Root<T> root = criteriaQuery.from(clazz); Root<T> root = criteriaQuery.from(clazz);
criteriaQuery.select(root); criteriaQuery.select(root);
return executeCriteriaQuery(context, criteriaQuery, false, -1, -1); return executeCriteriaQuery(context, criteriaQuery, false, limit, offset);
} }
@Override @Override

View File

@@ -58,6 +58,18 @@ public interface GenericDAO<T> {
*/ */
public List<T> findAll(Context context, Class<T> clazz) throws SQLException; public List<T> findAll(Context context, Class<T> 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<T> findAll(Context context, Class<T> clazz, Integer limit, Integer offset) throws SQLException;
/** /**
* Execute a JPQL query returning a unique result. * Execute a JPQL query returning a unique result.
* *