From 568cab79e26f22ab705572a34101981b5be30dd5 Mon Sep 17 00:00:00 2001 From: Josh Lagrimas Date: Thu, 7 Apr 2022 14:11:25 +0100 Subject: [PATCH] issue-550: fix duplicate Individuals issue (#574) * issue-550: fix indexing duplicate Individuals fix for #550 * issue-550: display anonymous type for individuals related fix for #550 * issue-550: fix indexing duplication for related Individuals fix for #550 * issue-550: rename anonymous type key related fix for #550 * issue-550: fix indexing duplicate Individuals fix for #550 * issue-550: display anonymous type for individuals related fix for #550 * issue-550: fix indexing duplication for related Individuals fix for #550 * issue-550: rename anonymous type key related fix for #550 Co-authored-by: Josh Lagrimas --- .../spot/ols/loader/BatchNeo4JIndexer.java | 77 +- .../ac/ebi/spot/ols/loader/NodeCreator.java | 592 ++++++------ .../ebi/spot/ols/neo4j/model/Individual.java | 43 +- .../model/Neo4JNodePropertyNameConstants.java | 1 + .../controller/ui/IndividualControllerUI.java | 31 +- .../main/resources/templates/individual.html | 19 +- .../src/main/resources/templates/term.html | 210 ++--- .../ols/loader/AbstractOWLOntologyLoader.java | 842 +++++++++--------- .../ebi/spot/ols/loader/OntologyLoader.java | 46 +- 9 files changed, 952 insertions(+), 909 deletions(-) diff --git a/ols-neo4j/src/main/java/uk/ac/ebi/spot/ols/loader/BatchNeo4JIndexer.java b/ols-neo4j/src/main/java/uk/ac/ebi/spot/ols/loader/BatchNeo4JIndexer.java index 473815e9..cef5bde4 100644 --- a/ols-neo4j/src/main/java/uk/ac/ebi/spot/ols/loader/BatchNeo4JIndexer.java +++ b/ols-neo4j/src/main/java/uk/ac/ebi/spot/ols/loader/BatchNeo4JIndexer.java @@ -1,21 +1,6 @@ package uk.ac.ebi.spot.ols.loader; -import static uk.ac.ebi.spot.ols.loader.Neo4JIndexerConstants.*; -import static uk.ac.ebi.spot.ols.config.OntologyDefaults.THING; - -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.Map; -import java.util.concurrent.TimeUnit; - -import org.neo4j.graphdb.DynamicLabel; -import org.neo4j.graphdb.GraphDatabaseService; -import org.neo4j.graphdb.Label; -import org.neo4j.graphdb.Result; -import org.neo4j.graphdb.Transaction; +import org.neo4j.graphdb.*; import org.neo4j.graphdb.factory.GraphDatabaseFactory; import org.neo4j.graphdb.index.IndexHits; import org.neo4j.graphdb.schema.IndexDefinition; @@ -30,12 +15,17 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; - import uk.ac.ebi.spot.ols.config.OlsNeo4jConfiguration; import uk.ac.ebi.spot.ols.exception.IndexingException; import uk.ac.ebi.spot.ols.model.OntologyIndexer; import uk.ac.ebi.spot.ols.util.LocalizedStrings; +import java.util.*; +import java.util.concurrent.TimeUnit; + +import static uk.ac.ebi.spot.ols.config.OntologyDefaults.THING; +import static uk.ac.ebi.spot.ols.loader.Neo4JIndexerConstants.*; + /** * @author Simon Jupp * @date 17/06/2015 @@ -110,7 +100,7 @@ private Long getOrCreateMergedNode(BatchInserter inserter, Map mer } } - properties.put("label", labels.getFirstString("en")); + properties.put("label", labels.getFirstString("en")); Long hit = inserter.createNode(properties, nodeLabel); index.add(hit, properties); @@ -220,6 +210,11 @@ private void indexIndividuals(BatchInserter inserter, OntologyLoader loader, for (IRI individualIri : loader.getAllIndividualIRIs()) { + // avoid duplicating individuals already related to a class + if (classNodeMap.containsKey(individualIri.toString())) { + nodeMap.put(individualIri.toString(), classNodeMap.get(individualIri.toString())); + } + Long node = NodeCreator.getOrCreateNode(inserter, nodeMap, loader, individualIri, new LinkedList