Merge remote-tracking branch 'community/main' into w2p-71502_deleting-items-with-min-relationship

This commit is contained in:
Ben Bosman
2021-01-15 11:39:07 +01:00
431 changed files with 11667 additions and 15151 deletions

View File

@@ -202,14 +202,14 @@ public class RelationshipServiceImpl implements RelationshipService {
return false;
}
if (!verifyMaxCardinality(context, relationship.getLeftItem(),
relationshipType.getLeftMaxCardinality(), relationshipType)) {
relationshipType.getLeftMaxCardinality(), relationshipType, true)) {
log.warn("The relationship has been deemed invalid since the left item has more" +
" relationships than the left max cardinality allows after we'd store this relationship");
logRelationshipTypeDetailsForError(relationshipType);
return false;
}
if (!verifyMaxCardinality(context, relationship.getRightItem(),
relationshipType.getRightMaxCardinality(), relationshipType)) {
relationshipType.getRightMaxCardinality(), relationshipType, false)) {
log.warn("The relationship has been deemed invalid since the right item has more" +
" relationships than the right max cardinality allows after we'd store this relationship");
logRelationshipTypeDetailsForError(relationshipType);
@@ -232,9 +232,10 @@ public class RelationshipServiceImpl implements RelationshipService {
private boolean verifyMaxCardinality(Context context, Item itemToProcess,
Integer maxCardinality,
RelationshipType relationshipType) throws SQLException {
RelationshipType relationshipType,
boolean isLeft) throws SQLException {
List<Relationship> rightRelationships = findByItemAndRelationshipType(context, itemToProcess, relationshipType,
false);
isLeft);
if (maxCardinality != null && rightRelationships.size() >= maxCardinality) {
return false;
}
@@ -559,9 +560,9 @@ public class RelationshipServiceImpl implements RelationshipService {
}
@Override
public int countByItemAndRelationshipType(Context context, Item item, RelationshipType relationshipType)
throws SQLException {
return relationshipDAO.countByItemAndRelationshipType(context, item, relationshipType);
public int countByItemAndRelationshipType(Context context, Item item, RelationshipType relationshipType,
boolean isLeft) throws SQLException {
return relationshipDAO.countByItemAndRelationshipType(context, item, relationshipType, isLeft);
}
@Override