Fixed ALF-9591: Integrity check: Association source multiplicity checking is incorrect

- Drop checks for source multiplicity when no associations are pointing to a type/aspect instance


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@31018 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2011-10-06 17:36:03 +00:00
parent def158f1e6
commit e0483f9b36
2 changed files with 29 additions and 7 deletions

View File

@@ -169,13 +169,11 @@ public class AssocSourceMultiplicityIntegrityEvent extends AbstractIntegrityEven
{
if (actualSize == 0)
{
// Double check that the association source is still present
ClassDefinition classDef = assocDef.getTargetClass();
if (classDef.isAspect() && !nodeService.hasAspect(targetNodeRef, classDef.getName()))
{
// The target is an aspect but the aspect is not present
return;
}
// ALF-9591: Integrity check: Association source multiplicity checking is incorrect
// At this point, there is no point worrying. There are no more associations
// pointing *to* this node and therefore the checking of the source
// multiplicity (a feature of the source type/aspect) is not relevant
return;
}
String parentOrSourceStr = (assocDef.isChild() ? "parent" : "source");

View File

@@ -448,4 +448,28 @@ public class IntegrityTest extends TestCase
checkIntegrityExpectFailure("Failed to detect excess source cardinality for one-to-many assocs", 1);
}
public void testSourceAssocAfterDeletion() throws Exception
{
NodeRef source1 = createNode("abc", TEST_TYPE_WITH_ASSOCS, null);
NodeRef source2 = createNode("abc", TEST_TYPE_WITH_ASSOCS, null);
NodeRef target1 = createNode("target1", TEST_TYPE_WITHOUT_ANYTHING, null);
NodeRef target2 = createNode("target1", TEST_TYPE_WITHOUT_ANYTHING, null);
nodeService.createAssociation(source1, target1, TEST_ASSOC_NODE_ONE_ONE);
nodeService.createAssociation(source2, target2, TEST_ASSOC_NODE_ONE_ONE);
checkIntegrityNoFailure();
nodeService.createAssociation(source1, target1, TEST_ASSOC_NODE_ONE_MANY);
nodeService.createAssociation(source2, target1, TEST_ASSOC_NODE_ONE_MANY);
// Both (or either of) the associations are in violation
checkIntegrityExpectFailure("Failed to detect excess source cardinality for one-to-many assocs", 1);
// Now remove one of the associations
nodeService.removeAssociation(source2, target1, TEST_ASSOC_NODE_ONE_MANY);
checkIntegrityNoFailure();
// Now remove the last association
nodeService.removeAssociation(source1, target1, TEST_ASSOC_NODE_ONE_MANY);
checkIntegrityNoFailure();
}
}