VIVO-946 Add labels of objects across Role nodes.
This commit is contained in:
parent
6166b48357
commit
731642491c
2 changed files with 20 additions and 23 deletions
|
@ -283,15 +283,15 @@ public class LabelsAcrossContextNodes implements IndexingUriFinder,
|
|||
private static final String LOCATE_PARTNERS_WITHOUT_RESTRICTION = ""
|
||||
+ "SELECT ?partner \n" //
|
||||
+ "WHERE { \n" //
|
||||
+ " ?uri ?incoming ?contextNode . \n" //
|
||||
+ " ?contextNode ?outgoing ?partner . \n" //
|
||||
+ " ?partner ?incoming ?contextNode . \n" //
|
||||
+ " ?contextNode ?outgoing ?uri . \n" //
|
||||
+ " FILTER( ?uri != ?partner ) \n" //
|
||||
+ "} \n";
|
||||
private static final String LOCATE_PARTNERS_ON_CONTEXT_NODE_TYPE = ""
|
||||
+ "SELECT ?partner \n" //
|
||||
+ "WHERE { \n" //
|
||||
+ " ?uri ?incoming ?contextNode . \n" //
|
||||
+ " ?contextNode ?outgoing ?partner . \n" //
|
||||
+ " ?partner ?incoming ?contextNode . \n" //
|
||||
+ " ?contextNode ?outgoing ?uri . \n" //
|
||||
+ " ?contextNode a ?nodeType . \n" //
|
||||
+ " FILTER( ?uri != ?partner ) \n" //
|
||||
+ "} \n";
|
||||
|
@ -316,18 +316,15 @@ public class LabelsAcrossContextNodes implements IndexingUriFinder,
|
|||
* If this is a "label" statement, check to see if the subject has any
|
||||
* acceptable partners across acceptable context nodes.
|
||||
*
|
||||
* If this is a statement that involves the specified outgoing property on
|
||||
* an acceptable context node, check to see if there are any other
|
||||
* acceptable partners on this node.
|
||||
*
|
||||
* We could also check for statements that involve the specified incoming
|
||||
* property, but they should happen in pairs with the "outgoing" statements.
|
||||
* If this is a statement that involves the specified incoming property on
|
||||
* an acceptable context node, check to see if there are any acceptable
|
||||
* partners on this node.
|
||||
*/
|
||||
@Override
|
||||
public List<String> findAdditionalURIsToIndex(Statement stmt) {
|
||||
if (isLabelStatement(stmt)) {
|
||||
return filterByType(locatePartners(stmt));
|
||||
} else if (isOutgoingStatementOnAcceptableContextNode(stmt)) {
|
||||
} else if (isIncomingStatementOnAcceptableContextNode(stmt)) {
|
||||
return filterByType(locateOtherPartners(stmt));
|
||||
}
|
||||
return Collections.emptyList();
|
||||
|
@ -371,11 +368,11 @@ public class LabelsAcrossContextNodes implements IndexingUriFinder,
|
|||
.getStringFields("partner").flattenToSet();
|
||||
}
|
||||
|
||||
private boolean isOutgoingStatementOnAcceptableContextNode(Statement stmt) {
|
||||
private boolean isIncomingStatementOnAcceptableContextNode(Statement stmt) {
|
||||
String subjectUri = stmt.getSubject().getURI();
|
||||
String predicateUri = stmt.getPredicate().getURI();
|
||||
|
||||
if (outgoingPropertyUri.equals(predicateUri)
|
||||
if (incomingPropertyUri.equals(predicateUri)
|
||||
&& (contextNodeClasses.isEmpty() || isAnyMatch(
|
||||
contextNodeClasses, getTypes(subjectUri)))) {
|
||||
return true;
|
||||
|
|
|
@ -278,42 +278,42 @@ public class LabelsAcrossContextNodesTest extends AbstractTestClass {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void relates_returnsPartner() {
|
||||
public void relatedBy_returnsPartner() {
|
||||
setTypeRestrictions();
|
||||
setContextNodeTypes();
|
||||
exerciseUriFinder(stmt(URI_POSITION1, CORE_RELATES, URI_PERSON1));
|
||||
exerciseUriFinder(stmt(URI_POSITION1, CORE_RELATED_BY, URI_PERSON1));
|
||||
assertExpectedUris(URI_ORGANIZATION1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void relates_inclusiveTypeRestriction_returnsPartner() {
|
||||
public void relatedBy_inclusiveTypeRestriction_returnsPartner() {
|
||||
setTypeRestrictions(FOAF_ORGANIZATION);
|
||||
setContextNodeTypes();
|
||||
exerciseUriFinder(stmt(URI_POSITION1, CORE_RELATES, URI_PERSON1));
|
||||
exerciseUriFinder(stmt(URI_POSITION1, CORE_RELATED_BY, URI_PERSON1));
|
||||
assertExpectedUris(URI_ORGANIZATION1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void relates_exclusiveTypeRestriction_returnsNothing() {
|
||||
public void relatedBy_exclusiveTypeRestriction_returnsNothing() {
|
||||
setTypeRestrictions(CORE_ADVISING_RELATIONSHIP);
|
||||
setContextNodeTypes();
|
||||
exerciseUriFinder(stmt(URI_POSITION1, CORE_RELATES, URI_PERSON1));
|
||||
exerciseUriFinder(stmt(URI_POSITION1, CORE_RELATED_BY, URI_PERSON1));
|
||||
assertExpectedUris();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void relates_inclusiveContextType_returnsPartner() {
|
||||
public void relatedBy_inclusiveContextType_returnsPartner() {
|
||||
setTypeRestrictions();
|
||||
setContextNodeTypes(CORE_POSITION);
|
||||
exerciseUriFinder(stmt(URI_POSITION1, CORE_RELATES, URI_PERSON1));
|
||||
exerciseUriFinder(stmt(URI_POSITION1, CORE_RELATED_BY, URI_PERSON1));
|
||||
assertExpectedUris(URI_ORGANIZATION1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void relates_exclusiveContextType_returnsNothing() {
|
||||
public void relatedBy_exclusiveContextType_returnsNothing() {
|
||||
setTypeRestrictions();
|
||||
setContextNodeTypes(CORE_ADVISING_RELATIONSHIP);
|
||||
exerciseUriFinder(stmt(URI_POSITION1, CORE_RELATES, URI_PERSON1));
|
||||
exerciseUriFinder(stmt(URI_POSITION1, CORE_RELATED_BY, URI_PERSON1));
|
||||
assertExpectedUris();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue