Add support for symmetric constraint
This commit is contained in:
parent
9cb4a46277
commit
3c181c9070
@ -59,6 +59,9 @@ public class InverseConstraintScrutinizer extends StatementScrutinizer {
|
|||||||
return _inverse.get(pid);
|
return _inverse.get(pid);
|
||||||
} else {
|
} else {
|
||||||
PropertyIdValue inversePid = _fetcher.getInversePid(pid);
|
PropertyIdValue inversePid = _fetcher.getInversePid(pid);
|
||||||
|
if (inversePid == null && _fetcher.isSymmetric(pid)) {
|
||||||
|
inversePid = pid;
|
||||||
|
}
|
||||||
_inverse.put(pid, inversePid);
|
_inverse.put(pid, inversePid);
|
||||||
_statements.put(pid, new HashMap<EntityIdValue, Set<EntityIdValue>>());
|
_statements.put(pid, new HashMap<EntityIdValue, Set<EntityIdValue>>());
|
||||||
|
|
||||||
|
@ -37,6 +37,7 @@ public class InverseConstaintScrutinizerTest extends StatementScrutinizerTest {
|
|||||||
private ItemIdValue idB = TestingData.newIdB;
|
private ItemIdValue idB = TestingData.newIdB;
|
||||||
private PropertyIdValue pidWithInverse = MockConstraintFetcher.pidWithInverse;
|
private PropertyIdValue pidWithInverse = MockConstraintFetcher.pidWithInverse;
|
||||||
private PropertyIdValue inversePid = MockConstraintFetcher.inversePid;
|
private PropertyIdValue inversePid = MockConstraintFetcher.inversePid;
|
||||||
|
private PropertyIdValue symmetricPid = MockConstraintFetcher.symmetricPid;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EditScrutinizer getScrutinizer() {
|
public EditScrutinizer getScrutinizer() {
|
||||||
@ -51,6 +52,14 @@ public class InverseConstaintScrutinizerTest extends StatementScrutinizerTest {
|
|||||||
assertWarningsRaised(InverseConstraintScrutinizer.type);
|
assertWarningsRaised(InverseConstraintScrutinizer.type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSymmetric() {
|
||||||
|
ItemUpdate update = new ItemUpdateBuilder(idA)
|
||||||
|
.addStatement(TestingData.generateStatement(idA, symmetricPid, idB)).build();
|
||||||
|
scrutinize(update);
|
||||||
|
assertWarningsRaised(InverseConstraintScrutinizer.type);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNoSymmetricClosure() {
|
public void testNoSymmetricClosure() {
|
||||||
ItemUpdate update = new ItemUpdateBuilder(idA).addStatement(TestingData.generateStatement(idA, inversePid, idB))
|
ItemUpdate update = new ItemUpdateBuilder(idA).addStatement(TestingData.generateStatement(idA, inversePid, idB))
|
||||||
|
Loading…
Reference in New Issue
Block a user