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:
Ben Bosman
2021-01-26 15:04:15 +01:00
parent 12ffc78452
commit fa90057203
2 changed files with 10 additions and 5 deletions

View File

@@ -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;
}