From 4ed88b81e3738fccbf3beef677bc165bcaa37179 Mon Sep 17 00:00:00 2001 From: Georgy Litvinov Date: Tue, 6 Apr 2021 12:23:21 +0200 Subject: [PATCH] Add subject to reindex in AdditionalURIsForObjectProperties (#216) Resolve https://jira.lyrasis.org/browse/VIVO-1966 --- .../AdditionalURIsForObjectProperties.java | 16 ++++++++-------- .../AdditionalURIsForObjectPropertiesTest.java | 3 ++- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/searchindex/indexing/AdditionalURIsForObjectProperties.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/searchindex/indexing/AdditionalURIsForObjectProperties.java index d8b2233fc..6462cd3fc 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/searchindex/indexing/AdditionalURIsForObjectProperties.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/searchindex/indexing/AdditionalURIsForObjectProperties.java @@ -59,16 +59,16 @@ public class AdditionalURIsForObjectProperties implements IndexingUriFinder, Con public void endIndexing() { /* nothing to do */ } protected List doObjectPropertyStmt(Statement stmt) { - // Only need to consider the object since the subject - // will already be updated in search index as part of - // SearchReindexingListener. - // Also, context nodes are not handled here. They are // taken care of in AdditionalURIsForContextNodex. - if( stmt.getObject().isURIResource() ) - return Collections.singletonList( stmt.getObject().as(Resource.class).getURI() ); - else - return Collections.emptyList(); + List uris = new ArrayList(); + if( stmt.getObject().isURIResource() ) { + uris.add(stmt.getObject().as(Resource.class).getURI() ); + } + if( stmt.getSubject().isURIResource() ) { + uris.add(stmt.getSubject().as(Resource.class).getURI() ); + } + return uris; } protected List doDataPropertyStmt(Statement stmt) { diff --git a/api/src/test/java/edu/cornell/mannlib/vitro/webapp/searchindex/indexing/AdditionalURIsForObjectPropertiesTest.java b/api/src/test/java/edu/cornell/mannlib/vitro/webapp/searchindex/indexing/AdditionalURIsForObjectPropertiesTest.java index 038c25453..7257f1ad7 100644 --- a/api/src/test/java/edu/cornell/mannlib/vitro/webapp/searchindex/indexing/AdditionalURIsForObjectPropertiesTest.java +++ b/api/src/test/java/edu/cornell/mannlib/vitro/webapp/searchindex/indexing/AdditionalURIsForObjectPropertiesTest.java @@ -90,13 +90,14 @@ public class AdditionalURIsForObjectPropertiesTest { Assert.assertTrue("uris was empty", uris.size() > 0 ); Assert.assertTrue("uris didn't not contain test:cheese", uris.contains(testNS+"cheese")); + Assert.assertTrue("uris didn't not contain test:bob", uris.contains(testNS+"bob")); Assert.assertTrue("uris contained test:Person", !uris.contains(testNS+"Person")); Assert.assertTrue("uris contained owl:Thing", !uris.contains( OWL.Thing.getURI() )); Assert.assertTrue("uris contained test:onions", !uris.contains(testNS+"onions")); Assert.assertTrue("uris contained test:icecream", !uris.contains(testNS+"icecream")); - Assert.assertEquals(1, uris.size()); + Assert.assertEquals(2, uris.size()); } @Test