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 = ""
|
private static final String LOCATE_PARTNERS_WITHOUT_RESTRICTION = ""
|
||||||
+ "SELECT ?partner \n" //
|
+ "SELECT ?partner \n" //
|
||||||
+ "WHERE { \n" //
|
+ "WHERE { \n" //
|
||||||
+ " ?uri ?incoming ?contextNode . \n" //
|
+ " ?partner ?incoming ?contextNode . \n" //
|
||||||
+ " ?contextNode ?outgoing ?partner . \n" //
|
+ " ?contextNode ?outgoing ?uri . \n" //
|
||||||
+ " FILTER( ?uri != ?partner ) \n" //
|
+ " FILTER( ?uri != ?partner ) \n" //
|
||||||
+ "} \n";
|
+ "} \n";
|
||||||
private static final String LOCATE_PARTNERS_ON_CONTEXT_NODE_TYPE = ""
|
private static final String LOCATE_PARTNERS_ON_CONTEXT_NODE_TYPE = ""
|
||||||
+ "SELECT ?partner \n" //
|
+ "SELECT ?partner \n" //
|
||||||
+ "WHERE { \n" //
|
+ "WHERE { \n" //
|
||||||
+ " ?uri ?incoming ?contextNode . \n" //
|
+ " ?partner ?incoming ?contextNode . \n" //
|
||||||
+ " ?contextNode ?outgoing ?partner . \n" //
|
+ " ?contextNode ?outgoing ?uri . \n" //
|
||||||
+ " ?contextNode a ?nodeType . \n" //
|
+ " ?contextNode a ?nodeType . \n" //
|
||||||
+ " FILTER( ?uri != ?partner ) \n" //
|
+ " FILTER( ?uri != ?partner ) \n" //
|
||||||
+ "} \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
|
* If this is a "label" statement, check to see if the subject has any
|
||||||
* acceptable partners across acceptable context nodes.
|
* acceptable partners across acceptable context nodes.
|
||||||
*
|
*
|
||||||
* If this is a statement that involves the specified outgoing property on
|
* If this is a statement that involves the specified incoming property on
|
||||||
* an acceptable context node, check to see if there are any other
|
* an acceptable context node, check to see if there are any acceptable
|
||||||
* acceptable partners on this node.
|
* 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.
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<String> findAdditionalURIsToIndex(Statement stmt) {
|
public List<String> findAdditionalURIsToIndex(Statement stmt) {
|
||||||
if (isLabelStatement(stmt)) {
|
if (isLabelStatement(stmt)) {
|
||||||
return filterByType(locatePartners(stmt));
|
return filterByType(locatePartners(stmt));
|
||||||
} else if (isOutgoingStatementOnAcceptableContextNode(stmt)) {
|
} else if (isIncomingStatementOnAcceptableContextNode(stmt)) {
|
||||||
return filterByType(locateOtherPartners(stmt));
|
return filterByType(locateOtherPartners(stmt));
|
||||||
}
|
}
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
|
@ -371,11 +368,11 @@ public class LabelsAcrossContextNodes implements IndexingUriFinder,
|
||||||
.getStringFields("partner").flattenToSet();
|
.getStringFields("partner").flattenToSet();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isOutgoingStatementOnAcceptableContextNode(Statement stmt) {
|
private boolean isIncomingStatementOnAcceptableContextNode(Statement stmt) {
|
||||||
String subjectUri = stmt.getSubject().getURI();
|
String subjectUri = stmt.getSubject().getURI();
|
||||||
String predicateUri = stmt.getPredicate().getURI();
|
String predicateUri = stmt.getPredicate().getURI();
|
||||||
|
|
||||||
if (outgoingPropertyUri.equals(predicateUri)
|
if (incomingPropertyUri.equals(predicateUri)
|
||||||
&& (contextNodeClasses.isEmpty() || isAnyMatch(
|
&& (contextNodeClasses.isEmpty() || isAnyMatch(
|
||||||
contextNodeClasses, getTypes(subjectUri)))) {
|
contextNodeClasses, getTypes(subjectUri)))) {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -278,42 +278,42 @@ public class LabelsAcrossContextNodesTest extends AbstractTestClass {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void relates_returnsPartner() {
|
public void relatedBy_returnsPartner() {
|
||||||
setTypeRestrictions();
|
setTypeRestrictions();
|
||||||
setContextNodeTypes();
|
setContextNodeTypes();
|
||||||
exerciseUriFinder(stmt(URI_POSITION1, CORE_RELATES, URI_PERSON1));
|
exerciseUriFinder(stmt(URI_POSITION1, CORE_RELATED_BY, URI_PERSON1));
|
||||||
assertExpectedUris(URI_ORGANIZATION1);
|
assertExpectedUris(URI_ORGANIZATION1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void relates_inclusiveTypeRestriction_returnsPartner() {
|
public void relatedBy_inclusiveTypeRestriction_returnsPartner() {
|
||||||
setTypeRestrictions(FOAF_ORGANIZATION);
|
setTypeRestrictions(FOAF_ORGANIZATION);
|
||||||
setContextNodeTypes();
|
setContextNodeTypes();
|
||||||
exerciseUriFinder(stmt(URI_POSITION1, CORE_RELATES, URI_PERSON1));
|
exerciseUriFinder(stmt(URI_POSITION1, CORE_RELATED_BY, URI_PERSON1));
|
||||||
assertExpectedUris(URI_ORGANIZATION1);
|
assertExpectedUris(URI_ORGANIZATION1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void relates_exclusiveTypeRestriction_returnsNothing() {
|
public void relatedBy_exclusiveTypeRestriction_returnsNothing() {
|
||||||
setTypeRestrictions(CORE_ADVISING_RELATIONSHIP);
|
setTypeRestrictions(CORE_ADVISING_RELATIONSHIP);
|
||||||
setContextNodeTypes();
|
setContextNodeTypes();
|
||||||
exerciseUriFinder(stmt(URI_POSITION1, CORE_RELATES, URI_PERSON1));
|
exerciseUriFinder(stmt(URI_POSITION1, CORE_RELATED_BY, URI_PERSON1));
|
||||||
assertExpectedUris();
|
assertExpectedUris();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void relates_inclusiveContextType_returnsPartner() {
|
public void relatedBy_inclusiveContextType_returnsPartner() {
|
||||||
setTypeRestrictions();
|
setTypeRestrictions();
|
||||||
setContextNodeTypes(CORE_POSITION);
|
setContextNodeTypes(CORE_POSITION);
|
||||||
exerciseUriFinder(stmt(URI_POSITION1, CORE_RELATES, URI_PERSON1));
|
exerciseUriFinder(stmt(URI_POSITION1, CORE_RELATED_BY, URI_PERSON1));
|
||||||
assertExpectedUris(URI_ORGANIZATION1);
|
assertExpectedUris(URI_ORGANIZATION1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void relates_exclusiveContextType_returnsNothing() {
|
public void relatedBy_exclusiveContextType_returnsNothing() {
|
||||||
setTypeRestrictions();
|
setTypeRestrictions();
|
||||||
setContextNodeTypes(CORE_ADVISING_RELATIONSHIP);
|
setContextNodeTypes(CORE_ADVISING_RELATIONSHIP);
|
||||||
exerciseUriFinder(stmt(URI_POSITION1, CORE_RELATES, URI_PERSON1));
|
exerciseUriFinder(stmt(URI_POSITION1, CORE_RELATED_BY, URI_PERSON1));
|
||||||
assertExpectedUris();
|
assertExpectedUris();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue