mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-16 14:33:09 +00:00
DS-4224 Improve paging impl for Entities
This commit is contained in:
@@ -211,7 +211,7 @@ public class InitializeEntities {
|
|||||||
rightCardinalityMaxInteger = null;
|
rightCardinalityMaxInteger = null;
|
||||||
}
|
}
|
||||||
RelationshipType relationshipType = relationshipTypeService
|
RelationshipType relationshipType = relationshipTypeService
|
||||||
.findbyTypesAndLabels(context, leftEntityType, rightEntityType, leftwardType, rightwardType);
|
.findbyTypesAndTypeName(context, leftEntityType, rightEntityType, leftwardType, rightwardType);
|
||||||
if (relationshipType == null) {
|
if (relationshipType == null) {
|
||||||
relationshipTypeService.create(context, leftEntityType, rightEntityType, leftwardType, rightwardType,
|
relationshipTypeService.create(context, leftEntityType, rightEntityType, leftwardType, rightwardType,
|
||||||
leftCardinalityMinInteger, leftCardinalityMaxInteger,
|
leftCardinalityMinInteger, leftCardinalityMaxInteger,
|
||||||
|
@@ -86,25 +86,14 @@ public class EntityServiceImpl implements EntityService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Relationship> getRelationsByLabel(Context context, String label) throws SQLException {
|
public List<Relationship> getRelationsByTypeName(Context context, String typeName) throws SQLException {
|
||||||
|
return getRelationsByTypeName(context, typeName, -1, -1);
|
||||||
return getRelationsByLabel(context, label, -1, -1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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 {
|
throws SQLException {
|
||||||
|
return relationshipService.findByTypeName(context, typeName, limit, offset);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -116,77 +105,42 @@ public class EntityServiceImpl implements EntityService {
|
|||||||
@Override
|
@Override
|
||||||
public List<RelationshipType> getAllRelationshipTypes(Context context, Entity entity, Integer limit, Integer offset)
|
public List<RelationshipType> getAllRelationshipTypes(Context context, Entity entity, Integer limit, Integer offset)
|
||||||
throws SQLException {
|
throws SQLException {
|
||||||
|
return relationshipTypeService.findByEntityType(context, this.getType(context, entity), limit, offset);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@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);
|
return getLeftRelationshipTypes(context, entity, true, -1, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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 {
|
Integer limit, Integer offset) throws SQLException {
|
||||||
|
return relationshipTypeService.findByEntityType(context, this.getType(context, entity), isLeft, limit, offset);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@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);
|
return getRightRelationshipTypes(context, entity, false, -1, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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 {
|
Integer limit, Integer offset) throws SQLException {
|
||||||
|
|
||||||
EntityType entityType = this.getType(context, entity);
|
return relationshipTypeService.findByEntityType(context, this.getType(context, entity), isLeft, limit, offset);
|
||||||
List<RelationshipType> listToReturn = new LinkedList<>();
|
|
||||||
for (RelationshipType relationshipType : relationshipTypeService.findAll(context, limit, offset)) {
|
|
||||||
if (relationshipType.getRightType().getID() == entityType.getID()) {
|
|
||||||
listToReturn.add(relationshipType);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return listToReturn;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<RelationshipType> getRelationshipTypesByTypeName(Context context, String type) throws SQLException {
|
public List<RelationshipType> getRelationshipTypesByTypeName(Context context, String type) throws SQLException {
|
||||||
|
|
||||||
return getRelationshipTypesByTypeName(context, type, -1, -1);
|
return getRelationshipTypesByTypeName(context, type, -1, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<RelationshipType> getRelationshipTypesByTypeName(Context context, String type,
|
public List<RelationshipType> getRelationshipTypesByTypeName(Context context, String typeName,
|
||||||
Integer limit, Integer offset) throws SQLException {
|
Integer limit, Integer offset) throws SQLException {
|
||||||
List<RelationshipType> listToReturn = new LinkedList<>();
|
return relationshipTypeService.findByLeftwardOrRightwardTypeName(context, typeName, limit, offset);
|
||||||
for (RelationshipType relationshipType : relationshipTypeService.findAll(context, limit, offset)) {
|
|
||||||
if (StringUtils.equals(relationshipType.getLeftwardType(),type) ||
|
|
||||||
StringUtils.equals(relationshipType.getRightwardType(),type)) {
|
|
||||||
listToReturn.add(relationshipType);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return listToReturn;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -429,6 +429,19 @@ public class RelationshipServiceImpl implements RelationshipService {
|
|||||||
return relationshipDAO.findByRelationshipType(context, relationshipType, limit, offset);
|
return relationshipDAO.findByRelationshipType(context, relationshipType, limit, offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Relationship> findByTypeName(Context context, String typeName)
|
||||||
|
throws SQLException {
|
||||||
|
return this.findByTypeName(context, typeName, -1, -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Relationship> findByTypeName(Context context, String typeName, Integer limit, Integer offset)
|
||||||
|
throws SQLException {
|
||||||
|
return relationshipDAO.findByTypeName(context, typeName, limit, offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int countTotal(Context context) throws SQLException {
|
public int countTotal(Context context) throws SQLException {
|
||||||
return relationshipDAO.countRows(context);
|
return relationshipDAO.countRows(context);
|
||||||
@@ -449,4 +462,10 @@ public class RelationshipServiceImpl implements RelationshipService {
|
|||||||
throws SQLException {
|
throws SQLException {
|
||||||
return relationshipDAO.countByItemAndRelationshipType(context, item, relationshipType);
|
return relationshipDAO.countByItemAndRelationshipType(context, item, relationshipType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int countByTypeName(Context context, String typeName)
|
||||||
|
throws SQLException {
|
||||||
|
return relationshipDAO.countByTypeName(context, typeName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -47,9 +47,9 @@ public class RelationshipTypeServiceImpl implements RelationshipTypeService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RelationshipType findbyTypesAndLabels(Context context,EntityType leftType,EntityType rightType,
|
public RelationshipType findbyTypesAndTypeName(Context context,EntityType leftType,EntityType rightType,
|
||||||
String leftwardType,String rightwardType) throws SQLException {
|
String leftwardType,String rightwardType) throws SQLException {
|
||||||
return relationshipTypeDAO.findByTypesAndLabels(context, leftType, rightType, leftwardType, rightwardType);
|
return relationshipTypeDAO.findbyTypesAndTypeName(context, leftType, rightType, leftwardType, rightwardType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -64,15 +64,16 @@ public class RelationshipTypeServiceImpl implements RelationshipTypeService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<RelationshipType> findByLeftwardOrRightwardTypeName(Context context, String label) throws SQLException {
|
public List<RelationshipType> findByLeftwardOrRightwardTypeName(Context context, String typeName)
|
||||||
return findByLeftwardOrRightwardTypeName(context, label, -1, -1);
|
throws SQLException {
|
||||||
|
return findByLeftwardOrRightwardTypeName(context, typeName, -1, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<RelationshipType> findByLeftwardOrRightwardTypeName(Context context, String label, Integer limit,
|
public List<RelationshipType> findByLeftwardOrRightwardTypeName(Context context, String typeName, Integer limit,
|
||||||
Integer offset)
|
Integer offset)
|
||||||
throws SQLException {
|
throws SQLException {
|
||||||
return relationshipTypeDAO.findByLeftwardOrRightwardTypeName(context, label, limit, offset);
|
return relationshipTypeDAO.findByLeftwardOrRightwardTypeName(context, typeName, limit, offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -86,6 +87,18 @@ public class RelationshipTypeServiceImpl implements RelationshipTypeService {
|
|||||||
return relationshipTypeDAO.findByEntityType(context, entityType, limit, offset);
|
return relationshipTypeDAO.findByEntityType(context, entityType, limit, offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<RelationshipType> findByEntityType(Context context, EntityType entityType, boolean isLeft)
|
||||||
|
throws SQLException {
|
||||||
|
return findByEntityType(context, entityType, isLeft, -1, -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<RelationshipType> findByEntityType(Context context, EntityType entityType, boolean isLeft,
|
||||||
|
Integer limit, Integer offset) throws SQLException {
|
||||||
|
return relationshipTypeDAO.findByEntityType(context, entityType, isLeft, limit, offset);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RelationshipType create(Context context, EntityType leftEntityType, EntityType rightEntityType,
|
public RelationshipType create(Context context, EntityType leftEntityType, EntityType rightEntityType,
|
||||||
String leftwardType, String rightwardType, Integer leftCardinalityMinInteger,
|
String leftwardType, String rightwardType, Integer leftCardinalityMinInteger,
|
||||||
|
@@ -133,6 +133,31 @@ public interface RelationshipDAO extends GenericDAO<Relationship> {
|
|||||||
boolean isLeft, Integer limit, Integer offset)
|
boolean isLeft, Integer limit, Integer offset)
|
||||||
throws SQLException;
|
throws SQLException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method returns a list of Relationship objects for the given typeName
|
||||||
|
* @param context The relevant DSpace context
|
||||||
|
* @param typeName The leftward or rightward typeName of the relationship type
|
||||||
|
* @return A list of Relationship objects that have the given RelationshipType object as the
|
||||||
|
* relationshipType property
|
||||||
|
* @throws SQLException If something goes wrong
|
||||||
|
*/
|
||||||
|
List<Relationship> findByTypeName(Context context, String typeName)
|
||||||
|
throws SQLException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method returns a list of Relationship objects for the given typeName
|
||||||
|
* @param context The relevant DSpace context
|
||||||
|
* @param typeName The leftward or rightward typeName of the relationship type
|
||||||
|
* @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> findByTypeName(Context context, String typeName, Integer limit, Integer offset)
|
||||||
|
throws SQLException;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Count total number of relationships (rows in relationship table)
|
* Count total number of relationships (rows in relationship table)
|
||||||
*
|
*
|
||||||
@@ -175,4 +200,15 @@ public interface RelationshipDAO extends GenericDAO<Relationship> {
|
|||||||
*/
|
*/
|
||||||
int countByItemAndRelationshipType(Context context, Item item, RelationshipType relationshipType)
|
int countByItemAndRelationshipType(Context context, Item item, RelationshipType relationshipType)
|
||||||
throws SQLException;
|
throws SQLException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Count total number of relationships (rows in relationship table) given a typeName
|
||||||
|
*
|
||||||
|
* @param context context
|
||||||
|
* @param typeName the relationship typeName to filter by
|
||||||
|
* @return total count
|
||||||
|
* @throws SQLException if database error
|
||||||
|
*/
|
||||||
|
int countByTypeName(Context context, String typeName)
|
||||||
|
throws SQLException;
|
||||||
}
|
}
|
||||||
|
@@ -34,7 +34,7 @@ public interface RelationshipTypeDAO extends GenericDAO<RelationshipType> {
|
|||||||
* @return The RelationshipType object that matches all the given parameters
|
* @return The RelationshipType object that matches all the given parameters
|
||||||
* @throws SQLException If something goes wrong
|
* @throws SQLException If something goes wrong
|
||||||
*/
|
*/
|
||||||
RelationshipType findByTypesAndLabels(Context context, EntityType leftType,EntityType rightType,
|
RelationshipType findbyTypesAndTypeName(Context context, EntityType leftType,EntityType rightType,
|
||||||
String leftwardType,
|
String leftwardType,
|
||||||
String rightwardType)
|
String rightwardType)
|
||||||
throws SQLException;
|
throws SQLException;
|
||||||
@@ -88,4 +88,36 @@ public interface RelationshipTypeDAO extends GenericDAO<RelationshipType> {
|
|||||||
*/
|
*/
|
||||||
List<RelationshipType> findByEntityType(Context context, EntityType entityType, Integer limit, Integer offset)
|
List<RelationshipType> findByEntityType(Context context, EntityType entityType, Integer limit, Integer offset)
|
||||||
throws SQLException;
|
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 isLeft Boolean value used to filter by left_type or right_type. If true left_type results only
|
||||||
|
* else right_type results.
|
||||||
|
* @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, Boolean isLeft)
|
||||||
|
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 isLeft Boolean value used to filter by left_type or right_type. If true left_type results only
|
||||||
|
* else right_type results.
|
||||||
|
* @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, Boolean isLeft,
|
||||||
|
Integer limit, Integer offset)
|
||||||
|
throws SQLException;
|
||||||
}
|
}
|
||||||
|
@@ -8,6 +8,7 @@
|
|||||||
package org.dspace.content.dao.impl;
|
package org.dspace.content.dao.impl;
|
||||||
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.persistence.criteria.CriteriaBuilder;
|
import javax.persistence.criteria.CriteriaBuilder;
|
||||||
import javax.persistence.criteria.CriteriaQuery;
|
import javax.persistence.criteria.CriteriaQuery;
|
||||||
@@ -18,6 +19,8 @@ import org.dspace.content.Relationship;
|
|||||||
import org.dspace.content.RelationshipType;
|
import org.dspace.content.RelationshipType;
|
||||||
import org.dspace.content.Relationship_;
|
import org.dspace.content.Relationship_;
|
||||||
import org.dspace.content.dao.RelationshipDAO;
|
import org.dspace.content.dao.RelationshipDAO;
|
||||||
|
import org.dspace.content.factory.ContentServiceFactory;
|
||||||
|
import org.dspace.content.service.RelationshipTypeService;
|
||||||
import org.dspace.core.AbstractHibernateDAO;
|
import org.dspace.core.AbstractHibernateDAO;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
|
|
||||||
@@ -151,6 +154,29 @@ public class RelationshipDAOImpl extends AbstractHibernateDAO<Relationship> impl
|
|||||||
return list(context, criteriaQuery, true, Relationship.class, limit, offset);
|
return list(context, criteriaQuery, true, Relationship.class, limit, offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Relationship> findByTypeName(Context context, String typeName)
|
||||||
|
throws SQLException {
|
||||||
|
return this.findByTypeName(context, typeName, -1, -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Relationship> findByTypeName(Context context, String typeName, Integer limit, Integer offset)
|
||||||
|
throws SQLException {
|
||||||
|
RelationshipTypeService relationshipTypeService = ContentServiceFactory.getInstance()
|
||||||
|
.getRelationshipTypeService();
|
||||||
|
List<RelationshipType> relTypes = relationshipTypeService.findByLeftwardOrRightwardTypeName(context, typeName);
|
||||||
|
List<Integer> ids = new ArrayList<>();
|
||||||
|
for ( RelationshipType relationshipType : relTypes) {
|
||||||
|
ids.add(relationshipType.getID());
|
||||||
|
}
|
||||||
|
CriteriaBuilder criteriaBuilder = getCriteriaBuilder(context);
|
||||||
|
CriteriaQuery criteriaQuery = getCriteriaQuery(criteriaBuilder, Relationship.class);
|
||||||
|
Root<Relationship> relationshipRoot = criteriaQuery.from(Relationship.class);
|
||||||
|
criteriaQuery.where(relationshipRoot.get(Relationship_.relationshipType).in(ids));
|
||||||
|
return list(context, criteriaQuery, true, Relationship.class, limit, offset);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int countByRelationshipType(Context context, RelationshipType relationshipType) throws SQLException {
|
public int countByRelationshipType(Context context, RelationshipType relationshipType) throws SQLException {
|
||||||
|
|
||||||
@@ -188,4 +214,21 @@ public class RelationshipDAOImpl extends AbstractHibernateDAO<Relationship> impl
|
|||||||
return count(context, criteriaQuery, criteriaBuilder, relationshipRoot);
|
return count(context, criteriaQuery, criteriaBuilder, relationshipRoot);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int countByTypeName(Context context, String typeName)
|
||||||
|
throws SQLException {
|
||||||
|
RelationshipTypeService relationshipTypeService = ContentServiceFactory.getInstance()
|
||||||
|
.getRelationshipTypeService();
|
||||||
|
List<RelationshipType> relTypes = relationshipTypeService.findByLeftwardOrRightwardTypeName(context, typeName);
|
||||||
|
List<Integer> ids = new ArrayList<>();
|
||||||
|
for ( RelationshipType relationshipType : relTypes) {
|
||||||
|
ids.add(relationshipType.getID());
|
||||||
|
}
|
||||||
|
CriteriaBuilder criteriaBuilder = getCriteriaBuilder(context);
|
||||||
|
CriteriaQuery criteriaQuery = getCriteriaQuery(criteriaBuilder, Relationship.class);
|
||||||
|
Root<Relationship> relationshipRoot = criteriaQuery.from(Relationship.class);
|
||||||
|
criteriaQuery.where(relationshipRoot.get(Relationship_.relationshipType).in(ids));
|
||||||
|
return count(context, criteriaQuery, criteriaBuilder, relationshipRoot);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -23,7 +23,7 @@ import org.dspace.core.Context;
|
|||||||
public class RelationshipTypeDAOImpl extends AbstractHibernateDAO<RelationshipType> implements RelationshipTypeDAO {
|
public class RelationshipTypeDAOImpl extends AbstractHibernateDAO<RelationshipType> implements RelationshipTypeDAO {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RelationshipType findByTypesAndLabels(Context context, EntityType leftType, EntityType rightType,
|
public RelationshipType findbyTypesAndTypeName(Context context, EntityType leftType, EntityType rightType,
|
||||||
String leftwardType, String rightwardType)
|
String leftwardType, String rightwardType)
|
||||||
throws SQLException {
|
throws SQLException {
|
||||||
CriteriaBuilder criteriaBuilder = getCriteriaBuilder(context);
|
CriteriaBuilder criteriaBuilder = getCriteriaBuilder(context);
|
||||||
@@ -86,4 +86,29 @@ public class RelationshipTypeDAOImpl extends AbstractHibernateDAO<RelationshipTy
|
|||||||
return list(context, criteriaQuery, false, RelationshipType.class, limit, offset);
|
return list(context, criteriaQuery, false, RelationshipType.class, limit, offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<RelationshipType> findByEntityType(Context context, EntityType entityType, Boolean isLeft)
|
||||||
|
throws SQLException {
|
||||||
|
return findByEntityType(context, entityType, isLeft, -1, -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<RelationshipType> findByEntityType(Context context, EntityType entityType, Boolean isLeft,
|
||||||
|
Integer limit, Integer offset) throws SQLException {
|
||||||
|
|
||||||
|
CriteriaBuilder criteriaBuilder = getCriteriaBuilder(context);
|
||||||
|
CriteriaQuery criteriaQuery = getCriteriaQuery(criteriaBuilder, RelationshipType.class);
|
||||||
|
Root<RelationshipType> relationshipTypeRoot = criteriaQuery.from(RelationshipType.class);
|
||||||
|
criteriaQuery.select(relationshipTypeRoot);
|
||||||
|
if (isLeft) {
|
||||||
|
criteriaQuery.where(
|
||||||
|
criteriaBuilder.equal(relationshipTypeRoot.get(RelationshipType_.leftType), entityType)
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
criteriaQuery.where(
|
||||||
|
criteriaBuilder.equal(relationshipTypeRoot.get(RelationshipType_.rightType), entityType)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return list(context, criteriaQuery, false, RelationshipType.class, limit, offset);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -82,25 +82,25 @@ public interface EntityService {
|
|||||||
* Retrieves the list of relationships for which their relationshiptype has a left or right label that is
|
* Retrieves the list of relationships for which their relationshiptype has a left or right label that is
|
||||||
* equal to the passed along label String
|
* equal to the passed along label String
|
||||||
* @param context The relevant DSpace context
|
* @param context The relevant DSpace context
|
||||||
* @param label The label that needs to be in the relationshiptype of the relationship
|
* @param typeName The label that needs to be in the relationshiptype of the relationship
|
||||||
* @return The list of relationships that have a relationshiptype with a left or right label
|
* @return The list of relationships that have a relationshiptype with a left or right label
|
||||||
* that is equal to the label param
|
* that is equal to the label param
|
||||||
* @throws SQLException If something goes wrong
|
* @throws SQLException If something goes wrong
|
||||||
*/
|
*/
|
||||||
List<Relationship> getRelationsByLabel(Context context, String label) throws SQLException;
|
List<Relationship> getRelationsByTypeName(Context context, String typeName) throws SQLException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the list of relationships for which their relationshiptype has a left or right label that is
|
* Retrieves the list of relationships for which their relationshiptype has a left or right label that is
|
||||||
* equal to the passed along label String
|
* equal to the passed along label String
|
||||||
* @param context The relevant DSpace context
|
* @param context The relevant DSpace context
|
||||||
* @param label The label that needs to be in the relationshiptype of the relationship
|
* @param typeName The label that needs to be in the relationshiptype of the relationship
|
||||||
* @param limit paging limit
|
* @param limit paging limit
|
||||||
* @param offset paging offset
|
* @param offset paging offset
|
||||||
* @return The list of relationships that have a relationshiptype with a left or right label
|
* @return The list of relationships that have a relationshiptype with a left or right label
|
||||||
* that is equal to the label param
|
* that is equal to the label param
|
||||||
* @throws SQLException If something goes wrong
|
* @throws SQLException If something goes wrong
|
||||||
*/
|
*/
|
||||||
List<Relationship> getRelationsByLabel(Context context, String label, Integer limit, Integer offset)
|
List<Relationship> getRelationsByTypeName(Context context, String typeName, Integer limit, Integer offset)
|
||||||
throws SQLException;
|
throws SQLException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -150,13 +150,15 @@ public interface EntityService {
|
|||||||
* in the leftEntityType
|
* in the leftEntityType
|
||||||
* @param context The relevant DSpace context
|
* @param context The relevant DSpace context
|
||||||
* @param entity The Entity for which the EntityType should be checked for relationships
|
* @param entity The Entity for which the EntityType should be checked for relationships
|
||||||
|
* @param isLeft Boolean value used to filter by left_type or right_type. If true left_type results only
|
||||||
|
* else right_type results.
|
||||||
* @param limit paging limit
|
* @param limit paging limit
|
||||||
* @param offset paging offset
|
* @param offset paging offset
|
||||||
* @return The list of relationships that each contain a relationshiptype in which there is a left entity type that
|
* @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
|
* is equal to the entity type for the given entity
|
||||||
* @throws SQLException If something goes wrong
|
* @throws SQLException If something goes wrong
|
||||||
*/
|
*/
|
||||||
List<RelationshipType> getLeftRelationshipTypes(Context context, Entity entity,
|
List<RelationshipType> getLeftRelationshipTypes(Context context, Entity entity, boolean isLeft,
|
||||||
Integer limit, Integer offset) throws SQLException;
|
Integer limit, Integer offset) throws SQLException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -177,25 +179,27 @@ public interface EntityService {
|
|||||||
* in the rightEntityType
|
* in the rightEntityType
|
||||||
* @param context The relevant DSpace context
|
* @param context The relevant DSpace context
|
||||||
* @param entity The Entity for which the EntityType should be checked for relationships
|
* @param entity The Entity for which the EntityType should be checked for relationships
|
||||||
|
* @param isLeft Boolean value used to filter by left_type or right_type. If true left_type results only
|
||||||
|
* else right_type results.
|
||||||
* @param limit paging limit
|
* @param limit paging limit
|
||||||
* @param offset paging offset
|
* @param offset paging offset
|
||||||
* @return The list of relationships that each contain a relationshiptype in which there is a right entity type that
|
* @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
|
* is equal to the entity type for the given entity
|
||||||
* @throws SQLException If something goes wrong
|
* @throws SQLException If something goes wrong
|
||||||
*/
|
*/
|
||||||
List<RelationshipType> getRightRelationshipTypes(Context context, Entity entity,
|
List<RelationshipType> getRightRelationshipTypes(Context context, Entity entity, boolean isLeft,
|
||||||
Integer limit, Integer offset) throws SQLException;
|
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
|
||||||
* @param context The relevant DSpace context
|
* @param context The relevant DSpace context
|
||||||
* @param type The label for which the relationshiptype's labels must be checked
|
* @param typeName The typeName for which the relationshiptype's labels must be checked
|
||||||
* @return The list of relationshiptypes that each contain a left or right label that is equal
|
* @return The list of relationshiptypes that each contain a left or right label that is equal
|
||||||
* to the given label parameter
|
* to the given label parameter
|
||||||
* @throws SQLException If something goes wrong
|
* @throws SQLException If something goes wrong
|
||||||
*/
|
*/
|
||||||
List<RelationshipType> getRelationshipTypesByTypeName(Context context, String type) throws SQLException;
|
List<RelationshipType> getRelationshipTypesByTypeName(Context context, String typeName) 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
|
||||||
|
@@ -228,6 +228,30 @@ public interface RelationshipService extends DSpaceCRUDService<Relationship> {
|
|||||||
int leftPlace, int rightPlace)
|
int leftPlace, int rightPlace)
|
||||||
throws AuthorizeException, SQLException;
|
throws AuthorizeException, SQLException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method returns a list of Relationship objects for the given typeName
|
||||||
|
* @param context The relevant DSpace context
|
||||||
|
* @param typeName The leftward or rightward typeName of the relationship type
|
||||||
|
* @return A list of Relationship objects that have the given RelationshipType object as the
|
||||||
|
* relationshipType property
|
||||||
|
* @throws SQLException If something goes wrong
|
||||||
|
*/
|
||||||
|
List<Relationship> findByTypeName(Context context, String typeName) throws SQLException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method returns a list of Relationship objects for the given typeName
|
||||||
|
* @param context The relevant DSpace context
|
||||||
|
* @param typeName The leftward or rightward typeName of the relationship type
|
||||||
|
* @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> findByTypeName(Context context, String typeName, Integer limit, Integer offset)
|
||||||
|
throws SQLException;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* counts all relationships
|
* counts all relationships
|
||||||
*
|
*
|
||||||
@@ -269,4 +293,16 @@ public interface RelationshipService extends DSpaceCRUDService<Relationship> {
|
|||||||
*/
|
*/
|
||||||
int countByItemAndRelationshipType(Context context, Item item, RelationshipType relationshipType)
|
int countByItemAndRelationshipType(Context context, Item item, RelationshipType relationshipType)
|
||||||
throws SQLException;
|
throws SQLException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Count total number of relationships (rows in relationship table)
|
||||||
|
* by a relationship leftward or rightward typeName
|
||||||
|
*
|
||||||
|
* @param context context
|
||||||
|
* @param typeName typeName of relationship
|
||||||
|
* @return total count
|
||||||
|
* @throws SQLException if database error
|
||||||
|
*/
|
||||||
|
int countByTypeName(Context context, String typeName)
|
||||||
|
throws SQLException;
|
||||||
}
|
}
|
@@ -41,7 +41,7 @@ public interface RelationshipTypeService extends DSpaceCRUDService<RelationshipT
|
|||||||
* @return
|
* @return
|
||||||
* @throws SQLException If something goes wrong
|
* @throws SQLException If something goes wrong
|
||||||
*/
|
*/
|
||||||
RelationshipType findbyTypesAndLabels(Context context, EntityType leftType, EntityType rightType,
|
RelationshipType findbyTypesAndTypeName(Context context, EntityType leftType, EntityType rightType,
|
||||||
String leftwardType, String rightwardType)
|
String leftwardType, String rightwardType)
|
||||||
throws SQLException;
|
throws SQLException;
|
||||||
|
|
||||||
@@ -67,12 +67,12 @@ public interface RelationshipTypeService extends DSpaceCRUDService<RelationshipT
|
|||||||
* 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
|
||||||
* @param context The relevant DSpace context
|
* @param context The relevant DSpace context
|
||||||
* @param label The label that has to match
|
* @param typeName The label that has to match
|
||||||
* @return The list of all RelationshipType objects that have a left or right label
|
* @return The list of all RelationshipType objects that have a left or right label
|
||||||
* that is equal to the given label param
|
* that is equal to the given label param
|
||||||
* @throws SQLException If something goes wrong
|
* @throws SQLException If something goes wrong
|
||||||
*/
|
*/
|
||||||
List<RelationshipType> findByLeftwardOrRightwardTypeName(Context context, String label) throws SQLException;
|
List<RelationshipType> findByLeftwardOrRightwardTypeName(Context context, String typeName) throws SQLException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves all RelationshipType objects that have a left or right label that is
|
* Retrieves all RelationshipType objects that have a left or right label that is
|
||||||
@@ -103,6 +103,38 @@ public interface RelationshipTypeService extends DSpaceCRUDService<RelationshipT
|
|||||||
List<RelationshipType> findByEntityType(Context context, EntityType entityType, Integer limit, Integer offset)
|
List<RelationshipType> findByEntityType(Context context, EntityType entityType, Integer limit, Integer offset)
|
||||||
throws SQLException;
|
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 isLeft Boolean value used to filter by left_type or right_type. If true left_type results only
|
||||||
|
* else right_type results.
|
||||||
|
* @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, boolean isLeft)
|
||||||
|
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 isLeft Boolean value used to filter by left_type or right_type. If true left_type results only
|
||||||
|
* else right_type results.
|
||||||
|
* @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, boolean isLeft,
|
||||||
|
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
|
||||||
|
@@ -135,7 +135,7 @@ public class EntityServiceImplTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetRelationsByLabel() throws Exception {
|
public void testGetRelationsByTypeName() throws Exception {
|
||||||
// Declare objects utilized in unit test
|
// Declare objects utilized in unit test
|
||||||
Relationship relationship = mock(Relationship.class);
|
Relationship relationship = mock(Relationship.class);
|
||||||
RelationshipType relationshipType = mock(RelationshipType.class);
|
RelationshipType relationshipType = mock(RelationshipType.class);
|
||||||
@@ -150,10 +150,11 @@ public class EntityServiceImplTest {
|
|||||||
when(relationship.getRelationshipType()).thenReturn(relationshipType);
|
when(relationship.getRelationshipType()).thenReturn(relationshipType);
|
||||||
when(relationshipType.getLeftwardType()).thenReturn("leftwardType");
|
when(relationshipType.getLeftwardType()).thenReturn("leftwardType");
|
||||||
when(relationshipType.getRightwardType()).thenReturn("rightwardType");
|
when(relationshipType.getRightwardType()).thenReturn("rightwardType");
|
||||||
|
when(relationshipService.findByTypeName(context, "leftwardType", -1, -1)).thenReturn(relationshipList);
|
||||||
|
|
||||||
// The relation(s) reported from our defined type should match our relationshipList
|
// The relation(s) reported from our defined type should match our relationshipList
|
||||||
assertEquals("TestGetRelationsByLabel 0", relationshipList,
|
assertEquals("TestGetRelationsByLabel 0", relationshipList,
|
||||||
entityService.getRelationsByLabel(context, "leftwardType"));
|
entityService.getRelationsByTypeName(context, "leftwardType"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -186,6 +187,8 @@ public class EntityServiceImplTest {
|
|||||||
when(leftType.getID()).thenReturn(0);
|
when(leftType.getID()).thenReturn(0);
|
||||||
when(rightType.getID()).thenReturn(1);
|
when(rightType.getID()).thenReturn(1);
|
||||||
when(entityService.getType(context, entity)).thenReturn(leftType); // Mock
|
when(entityService.getType(context, entity)).thenReturn(leftType); // Mock
|
||||||
|
when(relationshipTypeService.findByEntityType(context, entityService.getType(context, entity), -1, -1))
|
||||||
|
.thenReturn(relationshipTypeList);
|
||||||
|
|
||||||
// The relation(s) reported from our mocked Entity should match our relationshipList
|
// The relation(s) reported from our mocked Entity should match our relationshipList
|
||||||
assertEquals("TestGetAllRelationshipTypes 0", relationshipTypeList,
|
assertEquals("TestGetAllRelationshipTypes 0", relationshipTypeList,
|
||||||
@@ -216,6 +219,8 @@ public class EntityServiceImplTest {
|
|||||||
when(relationshipType.getLeftType()).thenReturn(entityType);
|
when(relationshipType.getLeftType()).thenReturn(entityType);
|
||||||
when(entityService.getType(context, entity)).thenReturn(entityType);
|
when(entityService.getType(context, entity)).thenReturn(entityType);
|
||||||
when(entityTypeService.findByEntityType(any(), any())).thenReturn(entityType);
|
when(entityTypeService.findByEntityType(any(), any())).thenReturn(entityType);
|
||||||
|
when(relationshipTypeService.findByEntityType(context, entityService.getType(context, entity), true, -1, -1))
|
||||||
|
.thenReturn(relationshipTypeList);
|
||||||
|
|
||||||
// The left relationshipType(s) reported from our mocked Entity should match our relationshipList
|
// The left relationshipType(s) reported from our mocked Entity should match our relationshipList
|
||||||
assertEquals("TestGetLeftRelationshipTypes 0", relationshipTypeList,
|
assertEquals("TestGetLeftRelationshipTypes 0", relationshipTypeList,
|
||||||
@@ -246,6 +251,8 @@ public class EntityServiceImplTest {
|
|||||||
when(relationshipType.getRightType()).thenReturn(entityType);
|
when(relationshipType.getRightType()).thenReturn(entityType);
|
||||||
when(entityService.getType(context, entity)).thenReturn(entityType);
|
when(entityService.getType(context, entity)).thenReturn(entityType);
|
||||||
when(entityTypeService.findByEntityType(any(), any())).thenReturn(entityType);
|
when(entityTypeService.findByEntityType(any(), any())).thenReturn(entityType);
|
||||||
|
when(relationshipTypeService.findByEntityType(context, entityService.getType(context, entity), false, -1, -1))
|
||||||
|
.thenReturn(relationshipTypeList);
|
||||||
|
|
||||||
// The right relationshipType(s) reported from our mocked Entity should match our relationshipList
|
// The right relationshipType(s) reported from our mocked Entity should match our relationshipList
|
||||||
assertEquals("TestGetRightRelationshipTypes 0", relationshipTypeList,
|
assertEquals("TestGetRightRelationshipTypes 0", relationshipTypeList,
|
||||||
@@ -254,7 +261,7 @@ public class EntityServiceImplTest {
|
|||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetRelationshipTypesByLabel() throws Exception {
|
public void testGetRelationshipTypesByTypeName() throws Exception {
|
||||||
// Declare objects utilized in unit test
|
// Declare objects utilized in unit test
|
||||||
List<RelationshipType> list = new LinkedList<>();
|
List<RelationshipType> list = new LinkedList<>();
|
||||||
RelationshipType relationshipType = mock(RelationshipType.class);
|
RelationshipType relationshipType = mock(RelationshipType.class);
|
||||||
@@ -265,6 +272,8 @@ public class EntityServiceImplTest {
|
|||||||
when(relationshipTypeService.findAll(context, -1, -1)).thenReturn(list);
|
when(relationshipTypeService.findAll(context, -1, -1)).thenReturn(list);
|
||||||
when(relationshipType.getLeftwardType()).thenReturn("leftwardType");
|
when(relationshipType.getLeftwardType()).thenReturn("leftwardType");
|
||||||
when(relationshipType.getRightwardType()).thenReturn("rightwardType");
|
when(relationshipType.getRightwardType()).thenReturn("rightwardType");
|
||||||
|
when(relationshipTypeService.findByLeftwardOrRightwardTypeName(context, "leftwardType", -1, -1))
|
||||||
|
.thenReturn(list);
|
||||||
|
|
||||||
// The RelationshipType(s) reported from our mocked Entity should match our list
|
// The RelationshipType(s) reported from our mocked Entity should match our list
|
||||||
assertEquals("TestGetRelationshipTypesByLabel 0", list,
|
assertEquals("TestGetRelationshipTypesByLabel 0", list,
|
||||||
|
@@ -87,11 +87,11 @@ public class RelationshipTypeTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testRelationshipTypeFindByTypesAndLabels() throws Exception {
|
public void testRelationshipTypeFindByTypesAndLabels() throws Exception {
|
||||||
// Mock DAO to return our firstRelationshipType
|
// Mock DAO to return our firstRelationshipType
|
||||||
when(relationshipTypeDAO.findByTypesAndLabels(any(), any(), any(), any(), any()))
|
when(relationshipTypeDAO.findbyTypesAndTypeName(any(), any(), any(), any(), any()))
|
||||||
.thenReturn(firstRelationshipType);
|
.thenReturn(firstRelationshipType);
|
||||||
|
|
||||||
// Declare objects utilized for this test
|
// Declare objects utilized for this test
|
||||||
RelationshipType found = relationshipTypeService.findbyTypesAndLabels(context, mock(EntityType.class),
|
RelationshipType found = relationshipTypeService.findbyTypesAndTypeName(context, mock(EntityType.class),
|
||||||
mock(EntityType.class),
|
mock(EntityType.class),
|
||||||
"mock", "mock");
|
"mock", "mock");
|
||||||
|
|
||||||
|
@@ -132,7 +132,7 @@ public class RelationshipTypeDAOImplTest extends AbstractIntegrationTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testFindByTypesAndLabels() throws Exception {
|
public void testFindByTypesAndLabels() throws Exception {
|
||||||
assertEquals("TestFindbyTypesAndLabels 0", relationshipType, relationshipTypeService
|
assertEquals("TestFindbyTypesAndLabels 0", relationshipType, relationshipTypeService
|
||||||
.findbyTypesAndLabels(context, entityTypeTwo, entityTypeOne, "isAuthorOfPublication",
|
.findbyTypesAndTypeName(context, entityTypeTwo, entityTypeOne, "isAuthorOfPublication",
|
||||||
"isPublicationOfAuthor"));
|
"isPublicationOfAuthor"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -162,12 +162,12 @@ public class RelationshipRestRepositoryIT extends AbstractEntityIntegrationTest
|
|||||||
.build();
|
.build();
|
||||||
|
|
||||||
isAuthorOfPublicationRelationshipType = relationshipTypeService
|
isAuthorOfPublicationRelationshipType = relationshipTypeService
|
||||||
.findbyTypesAndLabels(context, entityTypeService.findByEntityType(context, "Publication"),
|
.findbyTypesAndTypeName(context, entityTypeService.findByEntityType(context, "Publication"),
|
||||||
entityTypeService.findByEntityType(context, "Person"),
|
entityTypeService.findByEntityType(context, "Person"),
|
||||||
"isAuthorOfPublication", "isPublicationOfAuthor");
|
"isAuthorOfPublication", "isPublicationOfAuthor");
|
||||||
|
|
||||||
isOrgUnitOfPersonRelationshipType = relationshipTypeService
|
isOrgUnitOfPersonRelationshipType = relationshipTypeService
|
||||||
.findbyTypesAndLabels(context, entityTypeService.findByEntityType(context, "Person"),
|
.findbyTypesAndTypeName(context, entityTypeService.findByEntityType(context, "Person"),
|
||||||
entityTypeService.findByEntityType(context, "OrgUnit"),
|
entityTypeService.findByEntityType(context, "OrgUnit"),
|
||||||
"isOrgUnitOfPerson", "isPersonOfOrgUnit");
|
"isOrgUnitOfPerson", "isPersonOfOrgUnit");
|
||||||
|
|
||||||
@@ -188,15 +188,15 @@ public class RelationshipRestRepositoryIT extends AbstractEntityIntegrationTest
|
|||||||
context.turnOffAuthorisationSystem();
|
context.turnOffAuthorisationSystem();
|
||||||
|
|
||||||
RelationshipType isOrgUnitOfPersonRelationshipType = relationshipTypeService
|
RelationshipType isOrgUnitOfPersonRelationshipType = relationshipTypeService
|
||||||
.findbyTypesAndLabels(context, entityTypeService.findByEntityType(context, "Person"),
|
.findbyTypesAndTypeName(context, entityTypeService.findByEntityType(context, "Person"),
|
||||||
entityTypeService.findByEntityType(context, "OrgUnit"),
|
entityTypeService.findByEntityType(context, "OrgUnit"),
|
||||||
"isOrgUnitOfPerson", "isPersonOfOrgUnit");
|
"isOrgUnitOfPerson", "isPersonOfOrgUnit");
|
||||||
RelationshipType isOrgUnitOfProjectRelationshipType = relationshipTypeService
|
RelationshipType isOrgUnitOfProjectRelationshipType = relationshipTypeService
|
||||||
.findbyTypesAndLabels(context, entityTypeService.findByEntityType(context, "Project"),
|
.findbyTypesAndTypeName(context, entityTypeService.findByEntityType(context, "Project"),
|
||||||
entityTypeService.findByEntityType(context, "OrgUnit"),
|
entityTypeService.findByEntityType(context, "OrgUnit"),
|
||||||
"isOrgUnitOfProject", "isProjectOfOrgUnit");
|
"isOrgUnitOfProject", "isProjectOfOrgUnit");
|
||||||
RelationshipType isAuthorOfPublicationRelationshipType = relationshipTypeService
|
RelationshipType isAuthorOfPublicationRelationshipType = relationshipTypeService
|
||||||
.findbyTypesAndLabels(context, entityTypeService.findByEntityType(context, "Publication"),
|
.findbyTypesAndTypeName(context, entityTypeService.findByEntityType(context, "Publication"),
|
||||||
entityTypeService.findByEntityType(context, "Person"),
|
entityTypeService.findByEntityType(context, "Person"),
|
||||||
"isAuthorOfPublication", "isPublicationOfAuthor");
|
"isAuthorOfPublication", "isPublicationOfAuthor");
|
||||||
|
|
||||||
@@ -656,7 +656,7 @@ public class RelationshipRestRepositoryIT extends AbstractEntityIntegrationTest
|
|||||||
.build();
|
.build();
|
||||||
|
|
||||||
RelationshipType isAuthorOfPublicationRelationshipType = relationshipTypeService
|
RelationshipType isAuthorOfPublicationRelationshipType = relationshipTypeService
|
||||||
.findbyTypesAndLabels(context, entityTypeService.findByEntityType(context, "Publication"),
|
.findbyTypesAndTypeName(context, entityTypeService.findByEntityType(context, "Publication"),
|
||||||
entityTypeService.findByEntityType(context, "Person"),
|
entityTypeService.findByEntityType(context, "Person"),
|
||||||
"isAuthorOfPublication", "isPublicationOfAuthor");
|
"isAuthorOfPublication", "isPublicationOfAuthor");
|
||||||
|
|
||||||
@@ -2130,15 +2130,15 @@ public class RelationshipRestRepositoryIT extends AbstractEntityIntegrationTest
|
|||||||
context.turnOffAuthorisationSystem();
|
context.turnOffAuthorisationSystem();
|
||||||
|
|
||||||
RelationshipType isOrgUnitOfPersonRelationshipType = relationshipTypeService
|
RelationshipType isOrgUnitOfPersonRelationshipType = relationshipTypeService
|
||||||
.findbyTypesAndLabels(context, entityTypeService.findByEntityType(context, "Person"),
|
.findbyTypesAndTypeName(context, entityTypeService.findByEntityType(context, "Person"),
|
||||||
entityTypeService.findByEntityType(context, "OrgUnit"),
|
entityTypeService.findByEntityType(context, "OrgUnit"),
|
||||||
"isOrgUnitOfPerson", "isPersonOfOrgUnit");
|
"isOrgUnitOfPerson", "isPersonOfOrgUnit");
|
||||||
RelationshipType isOrgUnitOfProjectRelationshipType = relationshipTypeService
|
RelationshipType isOrgUnitOfProjectRelationshipType = relationshipTypeService
|
||||||
.findbyTypesAndLabels(context, entityTypeService.findByEntityType(context, "Project"),
|
.findbyTypesAndTypeName(context, entityTypeService.findByEntityType(context, "Project"),
|
||||||
entityTypeService.findByEntityType(context, "OrgUnit"),
|
entityTypeService.findByEntityType(context, "OrgUnit"),
|
||||||
"isOrgUnitOfProject", "isProjectOfOrgUnit");
|
"isOrgUnitOfProject", "isProjectOfOrgUnit");
|
||||||
RelationshipType isAuthorOfPublicationRelationshipType = relationshipTypeService
|
RelationshipType isAuthorOfPublicationRelationshipType = relationshipTypeService
|
||||||
.findbyTypesAndLabels(context, entityTypeService.findByEntityType(context, "Publication"),
|
.findbyTypesAndTypeName(context, entityTypeService.findByEntityType(context, "Publication"),
|
||||||
entityTypeService.findByEntityType(context, "Person"),
|
entityTypeService.findByEntityType(context, "Person"),
|
||||||
"isAuthorOfPublication", "isPublicationOfAuthor");
|
"isAuthorOfPublication", "isPublicationOfAuthor");
|
||||||
|
|
||||||
@@ -2261,7 +2261,7 @@ public class RelationshipRestRepositoryIT extends AbstractEntityIntegrationTest
|
|||||||
context.turnOffAuthorisationSystem();
|
context.turnOffAuthorisationSystem();
|
||||||
|
|
||||||
RelationshipType isAuthorOfPublicationRelationshipType = relationshipTypeService
|
RelationshipType isAuthorOfPublicationRelationshipType = relationshipTypeService
|
||||||
.findbyTypesAndLabels(context, entityTypeService.findByEntityType(context, "Publication"),
|
.findbyTypesAndTypeName(context, entityTypeService.findByEntityType(context, "Publication"),
|
||||||
entityTypeService.findByEntityType(context, "Person"),
|
entityTypeService.findByEntityType(context, "Person"),
|
||||||
"isAuthorOfPublication", "isPublicationOfAuthor");
|
"isAuthorOfPublication", "isPublicationOfAuthor");
|
||||||
|
|
||||||
@@ -2298,7 +2298,7 @@ public class RelationshipRestRepositoryIT extends AbstractEntityIntegrationTest
|
|||||||
context.turnOffAuthorisationSystem();
|
context.turnOffAuthorisationSystem();
|
||||||
|
|
||||||
RelationshipType isAuthorOfPublicationRelationshipType = relationshipTypeService
|
RelationshipType isAuthorOfPublicationRelationshipType = relationshipTypeService
|
||||||
.findbyTypesAndLabels(context, entityTypeService.findByEntityType(context, "Publication"),
|
.findbyTypesAndTypeName(context, entityTypeService.findByEntityType(context, "Publication"),
|
||||||
entityTypeService.findByEntityType(context, "Person"),
|
entityTypeService.findByEntityType(context, "Person"),
|
||||||
"isAuthorOfPublication", "isPublicationOfAuthor");
|
"isAuthorOfPublication", "isPublicationOfAuthor");
|
||||||
|
|
||||||
@@ -2338,7 +2338,7 @@ public class RelationshipRestRepositoryIT extends AbstractEntityIntegrationTest
|
|||||||
context.turnOffAuthorisationSystem();
|
context.turnOffAuthorisationSystem();
|
||||||
|
|
||||||
RelationshipType isAuthorOfPublicationRelationshipType = relationshipTypeService
|
RelationshipType isAuthorOfPublicationRelationshipType = relationshipTypeService
|
||||||
.findbyTypesAndLabels(context, entityTypeService.findByEntityType(context, "Publication"),
|
.findbyTypesAndTypeName(context, entityTypeService.findByEntityType(context, "Publication"),
|
||||||
entityTypeService.findByEntityType(context, "Person"),
|
entityTypeService.findByEntityType(context, "Person"),
|
||||||
"isAuthorOfPublication", "isPublicationOfAuthor");
|
"isAuthorOfPublication", "isPublicationOfAuthor");
|
||||||
|
|
||||||
@@ -2393,7 +2393,7 @@ public class RelationshipRestRepositoryIT extends AbstractEntityIntegrationTest
|
|||||||
context.turnOffAuthorisationSystem();
|
context.turnOffAuthorisationSystem();
|
||||||
|
|
||||||
RelationshipType isAuthorOfPublicationRelationshipType = relationshipTypeService
|
RelationshipType isAuthorOfPublicationRelationshipType = relationshipTypeService
|
||||||
.findbyTypesAndLabels(context, entityTypeService.findByEntityType(context, "Publication"),
|
.findbyTypesAndTypeName(context, entityTypeService.findByEntityType(context, "Publication"),
|
||||||
entityTypeService.findByEntityType(context, "Person"),
|
entityTypeService.findByEntityType(context, "Person"),
|
||||||
"isAuthorOfPublication", "isPublicationOfAuthor");
|
"isAuthorOfPublication", "isPublicationOfAuthor");
|
||||||
|
|
||||||
|
@@ -72,19 +72,19 @@ public class RelationshipTypeRestControllerIT extends AbstractEntityIntegrationT
|
|||||||
EntityType journalIssueEntityType = entityTypeService.findByEntityType(context, "journalIssue");
|
EntityType journalIssueEntityType = entityTypeService.findByEntityType(context, "journalIssue");
|
||||||
|
|
||||||
RelationshipType relationshipType1 = relationshipTypeService
|
RelationshipType relationshipType1 = relationshipTypeService
|
||||||
.findbyTypesAndLabels(context, publicationEntityType, personEntityType, "isAuthorOfPublication",
|
.findbyTypesAndTypeName(context, publicationEntityType, personEntityType, "isAuthorOfPublication",
|
||||||
"isPublicationOfAuthor");
|
"isPublicationOfAuthor");
|
||||||
RelationshipType relationshipType2 = relationshipTypeService
|
RelationshipType relationshipType2 = relationshipTypeService
|
||||||
.findbyTypesAndLabels(context, publicationEntityType, projectEntityType, "isProjectOfPublication",
|
.findbyTypesAndTypeName(context, publicationEntityType, projectEntityType, "isProjectOfPublication",
|
||||||
"isPublicationOfProject");
|
"isPublicationOfProject");
|
||||||
RelationshipType relationshipType3 = relationshipTypeService
|
RelationshipType relationshipType3 = relationshipTypeService
|
||||||
.findbyTypesAndLabels(context, publicationEntityType, orgunitEntityType, "isOrgUnitOfPublication",
|
.findbyTypesAndTypeName(context, publicationEntityType, orgunitEntityType, "isOrgUnitOfPublication",
|
||||||
"isPublicationOfOrgUnit");
|
"isPublicationOfOrgUnit");
|
||||||
RelationshipType relationshipType4 = relationshipTypeService
|
RelationshipType relationshipType4 = relationshipTypeService
|
||||||
.findbyTypesAndLabels(context, journalIssueEntityType, publicationEntityType, "isPublicationOfJournalIssue",
|
.findbyTypesAndTypeName(context, journalIssueEntityType, publicationEntityType,
|
||||||
"isJournalIssueOfPublication");
|
"isPublicationOfJournalIssue", "isJournalIssueOfPublication");
|
||||||
RelationshipType relationshipType5 = relationshipTypeService
|
RelationshipType relationshipType5 = relationshipTypeService
|
||||||
.findbyTypesAndLabels(context, publicationEntityType, orgunitEntityType, "isAuthorOfPublication",
|
.findbyTypesAndTypeName(context, publicationEntityType, orgunitEntityType, "isAuthorOfPublication",
|
||||||
"isPublicationOfAuthor");
|
"isPublicationOfAuthor");
|
||||||
getClient().perform(get("/api/core/entitytypes/" + publicationEntityType.getID() + "/relationshiptypes"))
|
getClient().perform(get("/api/core/entitytypes/" + publicationEntityType.getID() + "/relationshiptypes"))
|
||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
@@ -162,15 +162,15 @@ public class RelationshipTypeRestControllerIT extends AbstractEntityIntegrationT
|
|||||||
.build();
|
.build();
|
||||||
|
|
||||||
RelationshipType isOrgUnitOfPersonRelationshipType = relationshipTypeService
|
RelationshipType isOrgUnitOfPersonRelationshipType = relationshipTypeService
|
||||||
.findbyTypesAndLabels(context, entityTypeService.findByEntityType(context, "Person"),
|
.findbyTypesAndTypeName(context, entityTypeService.findByEntityType(context, "Person"),
|
||||||
entityTypeService.findByEntityType(context, "OrgUnit"),
|
entityTypeService.findByEntityType(context, "OrgUnit"),
|
||||||
"isOrgUnitOfPerson", "isPersonOfOrgUnit");
|
"isOrgUnitOfPerson", "isPersonOfOrgUnit");
|
||||||
RelationshipType isOrgUnitOfProjectRelationshipType = relationshipTypeService
|
RelationshipType isOrgUnitOfProjectRelationshipType = relationshipTypeService
|
||||||
.findbyTypesAndLabels(context, entityTypeService.findByEntityType(context, "Project"),
|
.findbyTypesAndTypeName(context, entityTypeService.findByEntityType(context, "Project"),
|
||||||
entityTypeService.findByEntityType(context, "OrgUnit"),
|
entityTypeService.findByEntityType(context, "OrgUnit"),
|
||||||
"isOrgUnitOfProject", "isProjectOfOrgUnit");
|
"isOrgUnitOfProject", "isProjectOfOrgUnit");
|
||||||
RelationshipType isAuthorOfPublicationRelationshipType = relationshipTypeService
|
RelationshipType isAuthorOfPublicationRelationshipType = relationshipTypeService
|
||||||
.findbyTypesAndLabels(context, entityTypeService.findByEntityType(context, "Publication"),
|
.findbyTypesAndTypeName(context, entityTypeService.findByEntityType(context, "Publication"),
|
||||||
entityTypeService.findByEntityType(context, "Person"),
|
entityTypeService.findByEntityType(context, "Person"),
|
||||||
"isAuthorOfPublication", "isPublicationOfAuthor");
|
"isAuthorOfPublication", "isPublicationOfAuthor");
|
||||||
|
|
||||||
|
@@ -120,7 +120,7 @@ public class RelationshipTypeRestRepositoryIT extends AbstractEntityIntegrationT
|
|||||||
private void checkRelationshipType(String leftType, String rightType, String leftwardType, String rightwardType)
|
private void checkRelationshipType(String leftType, String rightType, String leftwardType, String rightwardType)
|
||||||
throws SQLException {
|
throws SQLException {
|
||||||
RelationshipType relationshipType = relationshipTypeService
|
RelationshipType relationshipType = relationshipTypeService
|
||||||
.findbyTypesAndLabels(context, entityTypeService.findByEntityType(context, leftType),
|
.findbyTypesAndTypeName(context, entityTypeService.findByEntityType(context, leftType),
|
||||||
entityTypeService.findByEntityType(context, rightType),
|
entityTypeService.findByEntityType(context, rightType),
|
||||||
leftwardType, rightwardType);
|
leftwardType, rightwardType);
|
||||||
assertNotNull(relationshipType);
|
assertNotNull(relationshipType);
|
||||||
@@ -189,7 +189,7 @@ public class RelationshipTypeRestRepositoryIT extends AbstractEntityIntegrationT
|
|||||||
@Test
|
@Test
|
||||||
public void cardinalityOnAuthorPublicationRelationshipTypesTest() throws Exception {
|
public void cardinalityOnAuthorPublicationRelationshipTypesTest() throws Exception {
|
||||||
RelationshipType relationshipType = relationshipTypeService
|
RelationshipType relationshipType = relationshipTypeService
|
||||||
.findbyTypesAndLabels(context, entityTypeService.findByEntityType(context, "Publication"),
|
.findbyTypesAndTypeName(context, entityTypeService.findByEntityType(context, "Publication"),
|
||||||
entityTypeService.findByEntityType(context, "Person"), "isAuthorOfPublication",
|
entityTypeService.findByEntityType(context, "Person"), "isAuthorOfPublication",
|
||||||
"isPublicationOfAuthor");
|
"isPublicationOfAuthor");
|
||||||
assertEquals(((Integer) 0), relationshipType.getLeftMinCardinality());
|
assertEquals(((Integer) 0), relationshipType.getLeftMinCardinality());
|
||||||
@@ -234,7 +234,7 @@ public class RelationshipTypeRestRepositoryIT extends AbstractEntityIntegrationT
|
|||||||
@Test
|
@Test
|
||||||
public void cardinalityOnIssueJournalJournalVolumeRelationshipTypesTest() throws Exception {
|
public void cardinalityOnIssueJournalJournalVolumeRelationshipTypesTest() throws Exception {
|
||||||
RelationshipType relationshipType = relationshipTypeService
|
RelationshipType relationshipType = relationshipTypeService
|
||||||
.findbyTypesAndLabels(context, entityTypeService.findByEntityType(context, "JournalVolume"),
|
.findbyTypesAndTypeName(context, entityTypeService.findByEntityType(context, "JournalVolume"),
|
||||||
entityTypeService.findByEntityType(context, "JournalIssue"), "isIssueOfJournalVolume",
|
entityTypeService.findByEntityType(context, "JournalIssue"), "isIssueOfJournalVolume",
|
||||||
"isJournalVolumeOfIssue");
|
"isJournalVolumeOfIssue");
|
||||||
assertEquals(((Integer) 0), relationshipType.getLeftMinCardinality());
|
assertEquals(((Integer) 0), relationshipType.getLeftMinCardinality());
|
||||||
|
@@ -131,7 +131,7 @@ public class CsvImportIT extends AbstractEntityIntegrationTest {
|
|||||||
private void assertArticleRelationships(Item article, Item itemB, Item itemC, Item itemF) throws SQLException {
|
private void assertArticleRelationships(Item article, Item itemB, Item itemC, Item itemF) throws SQLException {
|
||||||
List<Relationship> relationshipsForArticle = relationshipService
|
List<Relationship> relationshipsForArticle = relationshipService
|
||||||
.findByItemAndRelationshipType(context, article, relationshipTypeService
|
.findByItemAndRelationshipType(context, article, relationshipTypeService
|
||||||
.findbyTypesAndLabels(context, entityTypeService.findByEntityType(context, "Publication"),
|
.findbyTypesAndTypeName(context, entityTypeService.findByEntityType(context, "Publication"),
|
||||||
entityTypeService.findByEntityType(context, "Person"), "isAuthorOfPublication",
|
entityTypeService.findByEntityType(context, "Person"), "isAuthorOfPublication",
|
||||||
"isPublicationOfAuthor"));
|
"isPublicationOfAuthor"));
|
||||||
assertThat(relationshipsForArticle.size(), is(3));
|
assertThat(relationshipsForArticle.size(), is(3));
|
||||||
|
Reference in New Issue
Block a user