mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-11 20:13:17 +00:00
DS-4224 Improve paging impl for Entities
This commit is contained in:
@@ -86,25 +86,14 @@ public class EntityServiceImpl implements EntityService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Relationship> getRelationsByLabel(Context context, String label) throws SQLException {
|
||||
|
||||
return getRelationsByLabel(context, label, -1, -1);
|
||||
public List<Relationship> getRelationsByTypeName(Context context, String typeName) throws SQLException {
|
||||
return getRelationsByTypeName(context, typeName, -1, -1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Relationship> getRelationsByLabel(Context context, String label, Integer limit, Integer offset)
|
||||
public List<Relationship> getRelationsByTypeName(Context context, String typeName, Integer limit, Integer offset)
|
||||
throws SQLException {
|
||||
|
||||
List<Relationship> listToReturn = new LinkedList<>();
|
||||
List<Relationship> relationshipList = relationshipService.findAll(context, limit, offset);
|
||||
for (Relationship relationship : relationshipList) {
|
||||
RelationshipType relationshipType = relationship.getRelationshipType();
|
||||
if (StringUtils.equals(relationshipType.getLeftwardType(),label) ||
|
||||
StringUtils.equals(relationshipType.getRightwardType(),label)) {
|
||||
listToReturn.add(relationship);
|
||||
}
|
||||
}
|
||||
return listToReturn;
|
||||
return relationshipService.findByTypeName(context, typeName, limit, offset);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -116,77 +105,42 @@ public class EntityServiceImpl implements EntityService {
|
||||
@Override
|
||||
public List<RelationshipType> getAllRelationshipTypes(Context context, Entity entity, Integer limit, Integer offset)
|
||||
throws SQLException {
|
||||
|
||||
EntityType entityType = this.getType(context, entity);
|
||||
if (entityType == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<RelationshipType> listToReturn = new LinkedList<>();
|
||||
for (RelationshipType relationshipType : relationshipTypeService.findAll(context, limit, offset)) {
|
||||
if (relationshipType.getLeftType().getID() == entityType.getID() ||
|
||||
relationshipType.getRightType().getID() == entityType.getID()) {
|
||||
listToReturn.add(relationshipType);
|
||||
}
|
||||
}
|
||||
return listToReturn;
|
||||
return relationshipTypeService.findByEntityType(context, this.getType(context, entity), limit, offset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RelationshipType> getLeftRelationshipTypes(Context context, Entity entity) throws SQLException {
|
||||
|
||||
return getLeftRelationshipTypes(context, entity, -1, -1);
|
||||
return getLeftRelationshipTypes(context, entity, true, -1, -1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RelationshipType> getLeftRelationshipTypes(Context context, Entity entity,
|
||||
public List<RelationshipType> getLeftRelationshipTypes(Context context, Entity entity, boolean isLeft,
|
||||
Integer limit, Integer offset) throws SQLException {
|
||||
|
||||
EntityType entityType = this.getType(context, entity);
|
||||
List<RelationshipType> listToReturn = new LinkedList<>();
|
||||
for (RelationshipType relationshipType : relationshipTypeService.findAll(context, limit, offset)) {
|
||||
if (relationshipType.getLeftType().getID() == entityType.getID()) {
|
||||
listToReturn.add(relationshipType);
|
||||
}
|
||||
}
|
||||
return listToReturn;
|
||||
return relationshipTypeService.findByEntityType(context, this.getType(context, entity), isLeft, limit, offset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RelationshipType> getRightRelationshipTypes(Context context, Entity entity) throws SQLException {
|
||||
|
||||
return getRightRelationshipTypes(context, entity, -1, -1);
|
||||
return getRightRelationshipTypes(context, entity, false, -1, -1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RelationshipType> getRightRelationshipTypes(Context context, Entity entity,
|
||||
public List<RelationshipType> getRightRelationshipTypes(Context context, Entity entity, boolean isLeft,
|
||||
Integer limit, Integer offset) throws SQLException {
|
||||
|
||||
EntityType entityType = this.getType(context, entity);
|
||||
List<RelationshipType> listToReturn = new LinkedList<>();
|
||||
for (RelationshipType relationshipType : relationshipTypeService.findAll(context, limit, offset)) {
|
||||
if (relationshipType.getRightType().getID() == entityType.getID()) {
|
||||
listToReturn.add(relationshipType);
|
||||
}
|
||||
}
|
||||
return listToReturn;
|
||||
return relationshipTypeService.findByEntityType(context, this.getType(context, entity), isLeft, limit, offset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RelationshipType> getRelationshipTypesByTypeName(Context context, String type) throws SQLException {
|
||||
|
||||
return getRelationshipTypesByTypeName(context, type, -1, -1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RelationshipType> getRelationshipTypesByTypeName(Context context, String type,
|
||||
public List<RelationshipType> getRelationshipTypesByTypeName(Context context, String typeName,
|
||||
Integer limit, Integer offset) throws SQLException {
|
||||
List<RelationshipType> listToReturn = new LinkedList<>();
|
||||
for (RelationshipType relationshipType : relationshipTypeService.findAll(context, limit, offset)) {
|
||||
if (StringUtils.equals(relationshipType.getLeftwardType(),type) ||
|
||||
StringUtils.equals(relationshipType.getRightwardType(),type)) {
|
||||
listToReturn.add(relationshipType);
|
||||
}
|
||||
}
|
||||
return listToReturn;
|
||||
return relationshipTypeService.findByLeftwardOrRightwardTypeName(context, typeName, limit, offset);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user