mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 01:54:22 +00:00
Entities performance improvement in RelationshipServiceImpl
If there's no max on the relationships, don't bother trying to verify whether the max would be exceeded Don't get virtual metadata for retrieving the relationship type
This commit is contained in:
@@ -244,6 +244,10 @@ public class RelationshipServiceImpl implements RelationshipService {
|
||||
Integer maxCardinality,
|
||||
RelationshipType relationshipType,
|
||||
boolean isLeft) throws SQLException {
|
||||
if (maxCardinality == null) {
|
||||
//no need to check the relationships
|
||||
return true;
|
||||
}
|
||||
List<Relationship> rightRelationships = findByItemAndRelationshipType(context, itemToProcess, relationshipType,
|
||||
isLeft);
|
||||
if (maxCardinality != null && rightRelationships.size() >= maxCardinality) {
|
||||
@@ -253,7 +257,8 @@ public class RelationshipServiceImpl implements RelationshipService {
|
||||
}
|
||||
|
||||
private boolean verifyEntityTypes(Item itemToProcess, EntityType entityTypeToProcess) {
|
||||
List<MetadataValue> list = itemService.getMetadata(itemToProcess, "relationship", "type", null, Item.ANY);
|
||||
List<MetadataValue> list = itemService.getMetadata(itemToProcess, "relationship", "type",
|
||||
null, Item.ANY, false);
|
||||
if (list.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
@@ -227,8 +227,8 @@ public class RelationshipServiceImplTest {
|
||||
when(metsList.get(0).getValue()).thenReturn("Entitylabel");
|
||||
when(relationshipService
|
||||
.findByItemAndRelationshipType(context, leftItem, testRel, true)).thenReturn(leftTypelist);
|
||||
when(itemService.getMetadata(leftItem, "relationship", "type", null, Item.ANY)).thenReturn(metsList);
|
||||
when(itemService.getMetadata(rightItem, "relationship", "type", null, Item.ANY)).thenReturn(metsList);
|
||||
when(itemService.getMetadata(leftItem, "relationship", "type", null, Item.ANY, false)).thenReturn(metsList);
|
||||
when(itemService.getMetadata(rightItem, "relationship", "type", null, Item.ANY, false)).thenReturn(metsList);
|
||||
when(relationshipDAO.create(any(), any())).thenReturn(relationship);
|
||||
|
||||
// The reported Relationship should match our defined relationship
|
||||
@@ -305,8 +305,8 @@ public class RelationshipServiceImplTest {
|
||||
relationship = getRelationship(leftItem, rightItem, testRel, 0,0);
|
||||
|
||||
// Mock the state of objects utilized in update() to meet the success criteria of the invocation
|
||||
when(itemService.getMetadata(leftItem, "relationship", "type", null, Item.ANY)).thenReturn(metsList);
|
||||
when(itemService.getMetadata(rightItem, "relationship", "type", null, Item.ANY)).thenReturn(metsList);
|
||||
when(itemService.getMetadata(leftItem, "relationship", "type", null, Item.ANY, false)).thenReturn(metsList);
|
||||
when(itemService.getMetadata(rightItem, "relationship", "type", null, Item.ANY, false)).thenReturn(metsList);
|
||||
when(authorizeService.authorizeActionBoolean(context, relationship.getLeftItem(),
|
||||
Constants.WRITE)).thenReturn(true);
|
||||
|
||||
|
Reference in New Issue
Block a user