@Test public void parseAssociations() throws IOException, StudyImporterException { String someAssociationRows = "Oid\tOccurrenceA\tOccurrenceB\tRoleA\tRoleB\tCountA\tCountB\tCountUnitB\tCountUnitA\tScoreBPrefA\tScoreBPrefAStage\tReference\tOptimisticLockField\tGCRecord\n" + "{505B49F3-1798-451C-99B0-00011BE9614D}\t{8F0B633B-C7B0-43C3-B210-8E6488B42405}\t{E3A0CB88-26EF-46DF-9BED-0AF88231C050}\t{8613FD4F-784D-4818-9E26-92B648B1C733}\t{93D3102F-5CC8-48CF-88E7-FEE74F8E54AD}\t0\t0\t\t\tx\t\t{DF56D217-13B1-42B1-81A6-64553F91F7B6}\t0\t\n" + "{EAB80A48-DE82-454E-8A90-000157CE4E29}\t{D255447F-A514-4901-9C68-1B027AF67CEE}\t{575D9556-BE91-4E85-8BCC-85A159F5FCD3}\t{EC69560A-C33B-4D45-97D2-8D6AE8365B3C}\t{93D3102F-5CC8-48CF-88E7-FEE74F8E54AD}\t0\t0\t\t\tx\t\t{F90595F4-6872-4B42-B1B2-6F5D392A44F0}\t0\t"; final TreeSet<Triple<String, String, String>> triples = new TreeSet<>(); DatasetImporterForSaproxylic.parseAssociations(triples::add, IOUtils.toInputStream(someAssociationRows, StandardCharsets.UTF_8)); assertThat(triples.size(), is(10)); assertThat(triples, hasItem(DatasetImporterForSaproxylic.asTriple("{505B49F3-1798-451C-99B0-00011BE9614D}", "mentioned_by", "{DF56D217-13B1-42B1-81A6-64553F91F7B6}"))); }
static void parseAssociations(Tripler tripler, InputStream is) throws IOException, StudyImporterException { LineListener listener = parser -> { String sourceOccurrenceId = parser.getValueByLabel("OccurrenceA"); String targetOccurrenceId = parser.getValueByLabel("OccurrenceB"); String interactionTypeIdAB = parser.getValueByLabel("RoleA"); String interactionTypeIdBA = parser.getValueByLabel("RoleB"); tripler.on(asTriple(sourceOccurrenceId, interactionTypeIdAB, targetOccurrenceId)); tripler.on(asTriple(targetOccurrenceId, interactionTypeIdBA, sourceOccurrenceId)); String interactionId = parser.getValueByLabel("Oid"); tripler.on(asTriple(targetOccurrenceId, PARTICIPATES_IN, interactionId)); tripler.on(asTriple(sourceOccurrenceId, PARTICIPATES_IN, interactionId)); String referenceId = parser.getValueByLabel("Reference"); tripler.on(asTriple(interactionId, MENTIONED_BY, referenceId)); }; handleLines(listener, is); }
DatasetImporterForSaproxylic extends DatasetImporterWithListener { static void parseAssociations(Tripler tripler, InputStream is) throws IOException, StudyImporterException { LineListener listener = parser -> { String sourceOccurrenceId = parser.getValueByLabel("OccurrenceA"); String targetOccurrenceId = parser.getValueByLabel("OccurrenceB"); String interactionTypeIdAB = parser.getValueByLabel("RoleA"); String interactionTypeIdBA = parser.getValueByLabel("RoleB"); tripler.on(asTriple(sourceOccurrenceId, interactionTypeIdAB, targetOccurrenceId)); tripler.on(asTriple(targetOccurrenceId, interactionTypeIdBA, sourceOccurrenceId)); String interactionId = parser.getValueByLabel("Oid"); tripler.on(asTriple(targetOccurrenceId, PARTICIPATES_IN, interactionId)); tripler.on(asTriple(sourceOccurrenceId, PARTICIPATES_IN, interactionId)); String referenceId = parser.getValueByLabel("Reference"); tripler.on(asTriple(interactionId, MENTIONED_BY, referenceId)); }; handleLines(listener, is); } }
DatasetImporterForSaproxylic extends DatasetImporterWithListener { static void parseAssociations(Tripler tripler, InputStream is) throws IOException, StudyImporterException { LineListener listener = parser -> { String sourceOccurrenceId = parser.getValueByLabel("OccurrenceA"); String targetOccurrenceId = parser.getValueByLabel("OccurrenceB"); String interactionTypeIdAB = parser.getValueByLabel("RoleA"); String interactionTypeIdBA = parser.getValueByLabel("RoleB"); tripler.on(asTriple(sourceOccurrenceId, interactionTypeIdAB, targetOccurrenceId)); tripler.on(asTriple(targetOccurrenceId, interactionTypeIdBA, sourceOccurrenceId)); String interactionId = parser.getValueByLabel("Oid"); tripler.on(asTriple(targetOccurrenceId, PARTICIPATES_IN, interactionId)); tripler.on(asTriple(sourceOccurrenceId, PARTICIPATES_IN, interactionId)); String referenceId = parser.getValueByLabel("Reference"); tripler.on(asTriple(interactionId, MENTIONED_BY, referenceId)); }; handleLines(listener, is); } DatasetImporterForSaproxylic(ParserFactory parserFactory, NodeFactory nodeFactory); }
DatasetImporterForSaproxylic extends DatasetImporterWithListener { static void parseAssociations(Tripler tripler, InputStream is) throws IOException, StudyImporterException { LineListener listener = parser -> { String sourceOccurrenceId = parser.getValueByLabel("OccurrenceA"); String targetOccurrenceId = parser.getValueByLabel("OccurrenceB"); String interactionTypeIdAB = parser.getValueByLabel("RoleA"); String interactionTypeIdBA = parser.getValueByLabel("RoleB"); tripler.on(asTriple(sourceOccurrenceId, interactionTypeIdAB, targetOccurrenceId)); tripler.on(asTriple(targetOccurrenceId, interactionTypeIdBA, sourceOccurrenceId)); String interactionId = parser.getValueByLabel("Oid"); tripler.on(asTriple(targetOccurrenceId, PARTICIPATES_IN, interactionId)); tripler.on(asTriple(sourceOccurrenceId, PARTICIPATES_IN, interactionId)); String referenceId = parser.getValueByLabel("Reference"); tripler.on(asTriple(interactionId, MENTIONED_BY, referenceId)); }; handleLines(listener, is); } DatasetImporterForSaproxylic(ParserFactory parserFactory, NodeFactory nodeFactory); @Override void importStudy(); void toInteractions(ResultSet results); }
DatasetImporterForSaproxylic extends DatasetImporterWithListener { static void parseAssociations(Tripler tripler, InputStream is) throws IOException, StudyImporterException { LineListener listener = parser -> { String sourceOccurrenceId = parser.getValueByLabel("OccurrenceA"); String targetOccurrenceId = parser.getValueByLabel("OccurrenceB"); String interactionTypeIdAB = parser.getValueByLabel("RoleA"); String interactionTypeIdBA = parser.getValueByLabel("RoleB"); tripler.on(asTriple(sourceOccurrenceId, interactionTypeIdAB, targetOccurrenceId)); tripler.on(asTriple(targetOccurrenceId, interactionTypeIdBA, sourceOccurrenceId)); String interactionId = parser.getValueByLabel("Oid"); tripler.on(asTriple(targetOccurrenceId, PARTICIPATES_IN, interactionId)); tripler.on(asTriple(sourceOccurrenceId, PARTICIPATES_IN, interactionId)); String referenceId = parser.getValueByLabel("Reference"); tripler.on(asTriple(interactionId, MENTIONED_BY, referenceId)); }; handleLines(listener, is); } DatasetImporterForSaproxylic(ParserFactory parserFactory, NodeFactory nodeFactory); @Override void importStudy(); void toInteractions(ResultSet results); static final String CLASSIFIED_AS; static final String IN_STAGE; static final String FOUND_AT; static final String MENTIONED_BY; static final String PARTICIPATES_IN; static final String HAS_NAME; static final String HAS_RANK; static final String HAS_PATH_IDS; static final String HAS_PATH_NAMES; }