diff --git a/src/main/java/uk/ac/standrews/cs/population_linkage/graph/Query.java b/src/main/java/uk/ac/standrews/cs/population_linkage/graph/Query.java index e8fee8df..08a3fa8b 100644 --- a/src/main/java/uk/ac/standrews/cs/population_linkage/graph/Query.java +++ b/src/main/java/uk/ac/standrews/cs/population_linkage/graph/Query.java @@ -132,8 +132,8 @@ public class Query { private static final String BM_GROOM_MARRIAGE_EXISTS_QUERY = "MATCH (a:Birth)-[r:SIBLING { actors: \"Child-Groom\" }]-(b:Marriage) WHERE a.STANDARDISED_ID = $standard_id_from AND b.STANDARDISED_ID = $standard_id_to AND r.provenance = $prov RETURN r"; private static final String BM_BRIDE_MARRIAGE_EXISTS_QUERY = "MATCH (a:Birth)-[r:SIBLING { actors: \"Child-Bride\" }]-(b:Marriage) WHERE a.STANDARDISED_ID = $standard_id_from AND b.STANDARDISED_ID = $standard_id_to AND r.provenance = $prov RETURN r"; - private static final String MM_BRIDE_BRIDE_EXISTS_QUERY = "MATCH (a:Marriage)-[r:SIBLING { actors: \"Bride-Bride\" }]-(b:Marriage) WHERE a.STANDARDISED_ID = $standard_id_from AND b.STANDARDISED_ID = $standard_id_to AND r.provenance = $prov RETURN r"; - private static final String MM_GROOM_GROOM_EXISTS_QUERY = "MATCH (a:Marriage)-[r:SIBLING { actors: \"Groom-Groom\" }]-(b:Marriage) WHERE a.STANDARDISED_ID = $standard_id_from AND b.STANDARDISED_ID = $standard_id_to AND r.provenance = $prov RETURN r"; + private static final String MM_BRIDE_BRIDE_EXISTS_QUERY = "MATCH (a:Marriage)-[r:ID { actors: \"Bride-Bride\" }]-(b:Marriage) WHERE a.STANDARDISED_ID = $standard_id_from AND b.STANDARDISED_ID = $standard_id_to AND r.provenance = $prov RETURN r"; + private static final String MM_GROOM_GROOM_EXISTS_QUERY = "MATCH (a:Marriage)-[r:ID { actors: \"Groom-Groom\" }]-(b:Marriage) WHERE a.STANDARDISED_ID = $standard_id_from AND b.STANDARDISED_ID = $standard_id_to AND r.provenance = $prov RETURN r"; private static final String DM_DECEASED_BRIDE_EXISTS_QUERY = "MATCH (a:Death)-[r:SIBLING { actors: \"Deceased-Bride\" }]-(b:Marriage) WHERE a.STANDARDISED_ID = $standard_id_from AND b.STANDARDISED_ID = $standard_id_to AND r.provenance = $prov RETURN r"; private static final String DM_DECEASED_GROOM_EXISTS_QUERY = "MATCH (a:Death)-[r:SIBLING { actors: \"Deceased-Groom\" }]-(b:Marriage) WHERE a.STANDARDISED_ID = $standard_id_from AND b.STANDARDISED_ID = $standard_id_to AND r.provenance = $prov RETURN r"; @@ -237,7 +237,7 @@ public static void createMMGroomBrideSiblingReference(NeoDbCypherBridge bridge, * See createReference for param details */ public static void createMMBrideGroomSiblingReference(NeoDbCypherBridge bridge, String standard_id_from, String standard_id_to, String provenance, int fields_populated, double distance) { - createReference(bridge, MM_GB_SIBLING_QUERY, standard_id_to, standard_id_from, provenance, fields_populated, distance); + createReference(bridge, MM_GB_SIBLING_QUERY, standard_id_from, standard_id_to, provenance, fields_populated, distance); } /** @@ -365,43 +365,43 @@ public static boolean MMGroomBrideSiblingReferenceExists(NeoDbCypherBridge bridg } public static boolean MMBrideGroomSiblingReferenceExists(NeoDbCypherBridge bridge, String standard_id_from, String standard_id_to, String provenance) { - return linkExists( bridge, MM_GB_SIBLING_EXISTS_QUERY, standard_id_to, standard_id_from, provenance ); + return linkExists( bridge, MM_GB_SIBLING_EXISTS_QUERY, standard_id_from, standard_id_to, provenance ); } public static boolean DBSiblingReferenceExists(NeoDbCypherBridge bridge, String standard_id_from, String standard_id_to, String provenance) { - return linkExists( bridge, DB_SIBLING_EXISTS_QUERY, standard_id_to, standard_id_from, provenance ); + return linkExists( bridge, DB_SIBLING_EXISTS_QUERY, standard_id_from, standard_id_to, provenance ); } public static boolean MMGroomMarriageParentsMarriageReferenceExists(NeoDbCypherBridge bridge, String standard_id_from, String standard_id_to, String provenance) { - return linkExists( bridge, MM_GROOM_MARRIAGE_EXISTS_QUERY, standard_id_to, standard_id_from, provenance ); + return linkExists( bridge, MM_GROOM_MARRIAGE_EXISTS_QUERY, standard_id_from, standard_id_to, provenance ); } public static boolean MMBrideMarriageParentsMarriageReferenceExists(NeoDbCypherBridge bridge, String standard_id_from, String standard_id_to, String provenance) { - return linkExists( bridge, MM_BRIDE_MARRIAGE_EXISTS_QUERY, standard_id_to, standard_id_from, provenance ); + return linkExists( bridge, MM_BRIDE_MARRIAGE_EXISTS_QUERY, standard_id_from, standard_id_to, provenance ); } public static boolean BMGroomSiblingReferenceExists(NeoDbCypherBridge bridge, String standard_id_from, String standard_id_to, String provenance ){ - return linkExists(bridge, BM_GROOM_MARRIAGE_EXISTS_QUERY, standard_id_to, standard_id_from, provenance); + return linkExists(bridge, BM_GROOM_MARRIAGE_EXISTS_QUERY, standard_id_from, standard_id_to, provenance ); } public static boolean BMBrideSiblingReferenceExists(NeoDbCypherBridge bridge, String standard_id_from, String standard_id_to, String provenance ) { - return linkExists( bridge, BM_BRIDE_MARRIAGE_EXISTS_QUERY, standard_id_to, standard_id_from, provenance ); + return linkExists( bridge, BM_BRIDE_MARRIAGE_EXISTS_QUERY, standard_id_from, standard_id_to, provenance ); } public static boolean MMBrideBrideIdReferenceExists(NeoDbCypherBridge bridge, String standard_id_from, String standard_id_to, String provenance ) { - return linkExists( bridge, MM_BRIDE_BRIDE_EXISTS_QUERY, standard_id_to, standard_id_from, provenance ); + return linkExists( bridge, MM_BRIDE_BRIDE_EXISTS_QUERY, standard_id_from, standard_id_to, provenance ); } public static boolean MMGroomGroomIdReferenceExists(NeoDbCypherBridge bridge, String standard_id_from, String standard_id_to, String provenance ) { - return linkExists( bridge, MM_GROOM_GROOM_EXISTS_QUERY, standard_id_to, standard_id_from, provenance ); + return linkExists( bridge, MM_GROOM_GROOM_EXISTS_QUERY, standard_id_from, standard_id_to, provenance ); } public static boolean DMBrideSiblingReferenceExists(NeoDbCypherBridge bridge, String standard_id_from, String standard_id_to, String provenance ) { - return linkExists( bridge, DM_DECEASED_BRIDE_EXISTS_QUERY, standard_id_to, standard_id_from, provenance ); + return linkExists( bridge, DM_DECEASED_BRIDE_EXISTS_QUERY, standard_id_from, standard_id_to, provenance ); } public static boolean DMGroomSiblingReferenceExists(NeoDbCypherBridge bridge, String standard_id_from, String standard_id_to, String provenance ) { - return linkExists( bridge, DM_DECEASED_GROOM_EXISTS_QUERY, standard_id_to, standard_id_from, provenance ); + return linkExists( bridge, DM_DECEASED_GROOM_EXISTS_QUERY, standard_id_from, standard_id_to, provenance ); } public static List getAllLinkQueries(){ diff --git a/src/main/java/uk/ac/standrews/cs/population_linkage/helpers/CreateIndices.java b/src/main/java/uk/ac/standrews/cs/population_linkage/helpers/CreateIndices.java deleted file mode 100644 index 220f7828..00000000 --- a/src/main/java/uk/ac/standrews/cs/population_linkage/helpers/CreateIndices.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright 2022 Systems Research Group, University of St Andrews: - * - * - * This file is part of the module population-linkage. - * - * population-linkage is free software: you can redistribute it and/or modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later - * version. - * - * population-linkage is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with population-linkage. If not, see - * . - */ -package uk.ac.standrews.cs.population_linkage.helpers; - -import org.neo4j.driver.Session; -import uk.ac.standrews.cs.neoStorr.util.NeoDbCypherBridge; - -import java.time.LocalDateTime; - -public class CreateIndices { - - public static final String BIRTHS_INDEX_NAME = "BirthsIndex"; - public static final String MARRIAGES_INDEX_NAME = "MarriagesIndex"; - public static final String DEATHS_INDEX_NAME = "DeathsIndex"; - - private static final String CREATE_BIRTHS_UNIQUENESS_CONSTRAINT = makeCreateUniquenessConstraintQuery(BIRTHS_INDEX_NAME, "Birth"); - private static final String CREATE_MARRIAGES_UNIQUENESS_CONSTRAINT = makeCreateUniquenessConstraintQuery(MARRIAGES_INDEX_NAME, "Marriage"); - private static final String CREATE_DEATHS_UNIQUENESS_CONSTRAINT = makeCreateUniquenessConstraintQuery(DEATHS_INDEX_NAME, "Death"); - - public static final String BIRTH_RECORD_IDENTITY_INDEX_NAME = "BIRTH_RECORD_IDENTITY_INDEX"; - public static final String BIRTH_CHILD_IDENTITY_INDEX_NAME = "BIRTH_CHILD_IDENTITY_INDEX"; - public static final String BIRTH_MOTHER_IDENTITY_INDEX_NAME = "BIRTH_MOTHER_IDENTITY_INDEX"; - public static final String BIRTH_FATHER_IDENTITY_INDEX_NAME = "BIRTH_FATHER_IDENTITY_INDEX"; - - public static final String DEATH_RECORD_IDENTITY_INDEX_NAME = "DEATH_RECORD_IDENTITY_INDEX"; - public static final String DEATH_DECEASED_IDENTITY_INDEX_NAME = "DEATH_DECEASED_IDENTITY_INDEX"; - public static final String DEATH_MOTHER_IDENTITY_INDEX_NAME = "DEATH_MOTHER_IDENTITY_INDEX"; - public static final String DEATH_FATHER_IDENTITY_INDEX_NAME = "DEATH_FATHER_IDENTITY_INDEX"; - - public static final String MARRIAGE_RECORD_IDENTITY_INDEX_NAME = "MARRIAGE_RECORD_IDENTITY_INDEX"; - public static final String MARRIAGE_BRIDE_IDENTITY_INDEX_NAME = "MARRIAGE_BRIDE_IDENTITY_INDEX"; - public static final String MARRIAGE_GROOM_IDENTITY_INDEX_NAME = "MARRIAGE_GROOM_IDENTITY_INDEX"; - public static final String MARRIAGE_BRIDE_MOTHER_IDENTITY_INDEX_NAME = "MARRIAGE_BRIDE_MOTHER_IDENTITY_INDEX"; - public static final String MARRIAGE_GROOM_MOTHER_IDENTITY_INDEX_NAME = "MARRIAGE_GROOM_MOTHER_IDENTITY_INDEX"; - public static final String MARRIAGE_BRIDE_FATHER_IDENTITY_INDEX_NAME = "MARRIAGE_BRIDE_FATHER_IDENTITY_INDEX"; - public static final String MARRIAGE_GROOM_FATHER_IDENTITY_INDEX_NAME = "MARRIAGE_GROOM_FATHER_IDENTITY_INDEX"; - - private static final String CREATE_BIRTH_RECORD_IDENTITY_INDEX = String.format("CREATE INDEX %s IF NOT EXISTS FOR (b:Birth) on (b.BIRTH_RECORD_IDENTITY)", BIRTH_RECORD_IDENTITY_INDEX_NAME); - private static final String CREATE_BIRTH_CHILD_IDENTITY_INDEX = String.format("CREATE INDEX %s IF NOT EXISTS FOR (b:Birth) on (b.CHILD_IDENTITY)", BIRTH_CHILD_IDENTITY_INDEX_NAME); - private static final String CREATE_BIRTH_MOTHER_IDENTITY_INDEX = String.format("CREATE INDEX %s IF NOT EXISTS FOR (b:Birth) on (b.MOTHER_IDENTITY)", BIRTH_MOTHER_IDENTITY_INDEX_NAME); - private static final String CREATE_BIRTH_FATHER_IDENTITY_INDEX = String.format("CREATE INDEX %s IF NOT EXISTS FOR (b:Birth) on (b.FATHER_IDENTITY)", BIRTH_FATHER_IDENTITY_INDEX_NAME); - - private static final String CREATE_DEATH_RECORD_IDENTITY_INDEX = String.format("CREATE INDEX %s IF NOT EXISTS FOR (d:Death) on (d.DEATH_RECORD_IDENTITY)", DEATH_RECORD_IDENTITY_INDEX_NAME); - private static final String CREATE_DEATH_DECEASED_IDENTITY_INDEX = String.format("CREATE INDEX %s IF NOT EXISTS FOR (d:Death) on (d.DECEASED_IDENTITY)", DEATH_DECEASED_IDENTITY_INDEX_NAME); - private static final String CREATE_DEATH_FATHER_IDENTITY_INDEX = String.format("CREATE INDEX %s IF NOT EXISTS FOR (d:Death) on (d.FATHER_IDENTITY)", DEATH_FATHER_IDENTITY_INDEX_NAME); - private static final String CREATE_DEATH_MOTHER_IDENTITY_INDEX = String.format("CREATE INDEX %s IF NOT EXISTS FOR (d:Death) on (d.MOTHER_IDENTITY)", DEATH_MOTHER_IDENTITY_INDEX_NAME); - - private static final String CREATE_MARRIAGE_RECORD_IDENTITY_INDEX = String.format("CREATE INDEX %s IF NOT EXISTS FOR (m:Marriage) on (m.MARRIAGE_RECORD_IDENTITY)", MARRIAGE_RECORD_IDENTITY_INDEX_NAME); - private static final String CREATE_MARRIAGE_BRIDE_IDENTITY_INDEX = String.format("CREATE INDEX %s IF NOT EXISTS FOR (m:Marriage) on (m.BRIDE_IDENTITY)", MARRIAGE_BRIDE_IDENTITY_INDEX_NAME); - private static final String CREATE_MARRIAGE_GROOM_IDENTITY_INDEX = String.format("CREATE INDEX %s IF NOT EXISTS FOR (m:Marriage) on (m.GROOM_IDENTITY)", MARRIAGE_GROOM_IDENTITY_INDEX_NAME); - private static final String CREATE_MARRIAGE_BRIDE_MOTHER_IDENTITY_INDEX = String.format("CREATE INDEX %s IF NOT EXISTS FOR (m:Marriage) on (m.BRIDE_MOTHER_IDENTITY)", MARRIAGE_BRIDE_MOTHER_IDENTITY_INDEX_NAME); - private static final String CREATE_MARRIAGE_GROOM_MOTHER_IDENTITY_INDEX = String.format("CREATE INDEX %s IF NOT EXISTS FOR (m:Marriage) on (m.GROOM_MOTHER_IDENTITY)", MARRIAGE_GROOM_MOTHER_IDENTITY_INDEX_NAME); - private static final String CREATE_MARRIAGE_BRIDE_FATHER_IDENTITY_INDEX = String.format("CREATE INDEX %s IF NOT EXISTS FOR (m:Marriage) on (m.BRIDE_FATHER_IDENTITY)", MARRIAGE_BRIDE_FATHER_IDENTITY_INDEX_NAME); - private static final String CREATE_MARRIAGE_GROOM_FATHER_IDENTITY_INDEX = String.format("CREATE INDEX %s IF NOT EXISTS FOR (m:Marriage) on (m.GROOM_FATHER_IDENTITY)", MARRIAGE_GROOM_FATHER_IDENTITY_INDEX_NAME); - - public static void main(String[] args) { - - doQueries( - CREATE_BIRTHS_UNIQUENESS_CONSTRAINT, CREATE_MARRIAGES_UNIQUENESS_CONSTRAINT, CREATE_DEATHS_UNIQUENESS_CONSTRAINT, - - CREATE_BIRTH_RECORD_IDENTITY_INDEX, CREATE_BIRTH_CHILD_IDENTITY_INDEX, CREATE_BIRTH_FATHER_IDENTITY_INDEX, CREATE_BIRTH_MOTHER_IDENTITY_INDEX, - - CREATE_DEATH_RECORD_IDENTITY_INDEX, CREATE_DEATH_DECEASED_IDENTITY_INDEX, CREATE_DEATH_FATHER_IDENTITY_INDEX, CREATE_DEATH_MOTHER_IDENTITY_INDEX, - - CREATE_MARRIAGE_RECORD_IDENTITY_INDEX, CREATE_MARRIAGE_BRIDE_IDENTITY_INDEX, CREATE_MARRIAGE_GROOM_IDENTITY_INDEX, CREATE_MARRIAGE_GROOM_FATHER_IDENTITY_INDEX, - CREATE_MARRIAGE_GROOM_MOTHER_IDENTITY_INDEX, CREATE_MARRIAGE_BRIDE_FATHER_IDENTITY_INDEX, CREATE_MARRIAGE_BRIDE_MOTHER_IDENTITY_INDEX - ); - } - - private static void doQueries(String... queries) { - - try (NeoDbCypherBridge bridge = new NeoDbCypherBridge(); Session session = bridge.getNewSession()) { - - System.out.println("Creating indices @ " + LocalDateTime.now()); - - for (String query : queries) { - session.run(query); - } - - System.out.println("Complete @ " + LocalDateTime.now()); - } - } - - private static String makeCreateUniquenessConstraintQuery(String constraint_name, String label_name) { - - return String.format("CALL db.createUniquePropertyConstraint(%s, [%s], [\"STANDARDISED_ID\"], \"native-btree-1.0\")", quote(constraint_name), quote(label_name)); - } - - private static String quote(String s) { - - return "\"" + s + "\""; - } -} diff --git a/src/main/java/uk/ac/standrews/cs/population_linkage/helpers/ImportUmeaRecordsToStore.java b/src/main/java/uk/ac/standrews/cs/population_linkage/helpers/ImportUmeaRecordsToStore.java deleted file mode 100644 index d82e0996..00000000 --- a/src/main/java/uk/ac/standrews/cs/population_linkage/helpers/ImportUmeaRecordsToStore.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2022 Systems Research Group, University of St Andrews: - * - * - * This file is part of the module population-linkage. - * - * population-linkage is free software: you can redistribute it and/or modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later - * version. - * - * population-linkage is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with population-linkage. If not, see - * . - */ -package uk.ac.standrews.cs.population_linkage.helpers; - -import uk.ac.standrews.cs.data.umea.UmeaBirthsDataSet; -import uk.ac.standrews.cs.data.umea.UmeaDeathsDataSet; -import uk.ac.standrews.cs.data.umea.UmeaMarriagesDataSet; -import uk.ac.standrews.cs.population_records.RecordRepository; -import uk.ac.standrews.cs.utilities.dataset.DataSet; - -import java.time.LocalDateTime; - -public class ImportUmeaRecordsToStore { - - public final static String REPOSITORY_NAME = "umea"; - - public void run() throws Exception { - - try (RecordRepository record_repository = new RecordRepository(REPOSITORY_NAME)) { - - DataSet birth_records = new UmeaBirthsDataSet(); - record_repository.importBirthRecords(birth_records); - System.out.println("Imported " + birth_records.getRecords().size() + " birth records"); - - DataSet death_records = new UmeaDeathsDataSet(); - record_repository.importDeathRecords(death_records); - System.out.println("Imported " + death_records.getRecords().size() + " death records"); - - DataSet marriage_records = new UmeaMarriagesDataSet(); - record_repository.importMarriageRecords(marriage_records); - System.out.println("Imported " + marriage_records.getRecords().size() + " marriage records"); - } - } - - public static void main(String[] args) throws Exception { - - System.out.println("Importing Umea records into repository: " + REPOSITORY_NAME + " @ " + LocalDateTime.now()); - new ImportUmeaRecordsToStore().run(); - System.out.println("Complete @ " + LocalDateTime.now()); - } -} diff --git a/src/main/scripts/install/setup_umea_in_storr.sh b/src/main/scripts/install/setup_umea_in_storr.sh index 7559ae66..4399bb1e 100755 --- a/src/main/scripts/install/setup_umea_in_storr.sh +++ b/src/main/scripts/install/setup_umea_in_storr.sh @@ -19,7 +19,7 @@ export MAVEN_OPTS="-Xmx16G" echo "Creating indices" -mvn exec:java -q -Dexec.cleanupDaemonThreads=false -Dexec.mainClass="uk.ac.standrews.cs.population_linkage.helpers.CreateIndices" -e +java -cp ~/Documents/GitHub/data-umea-1.0-SNAPSHOT-jar-with-dependencies.jar uk.ac.standrews.cs.data.umea.store.CreateIndices echo "Loading event records" -mvn exec:java -q -Dexec.cleanupDaemonThreads=false -Dexec.mainClass="uk.ac.standrews.cs.population_linkage.helpers.ImportUmeaRecordsToStore" -e +java -cp ~/Documents/GitHub/data-umea-1.0-SNAPSHOT-jar-with-dependencies.jar uk.ac.standrews.cs.data.umea.store.ImportUmeaRecordsToStore