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