@Test public void matchCitationsIndirectly() throws Exception { String mainEntityIdType = "pmc"; String referenceIdType = "pmid"; doReturn(idMappingRdd).when(idMappingExtractor).extractIdMapping(documentsMetadataRdd, mainEntityIdType, pickOneDocumentMetadataFunction); doReturn(externalIdReferencesRdd).when(referencePicker).extractExternalIdReferences(documentsMetadataRdd, referenceIdType); doReturn(externalIdReferencesJoinedWithReferenceIdMappingRdd).when(externalIdReferencesRdd).join(referenceIdMappingRdd); doReturn(externalIdReferencesJoinedWithReferenceIdMappingMappedToPairRdd).when(externalIdReferencesJoinedWithReferenceIdMappingRdd).mapToPair(any()); doReturn(joinedRdd).when(externalIdReferencesJoinedWithReferenceIdMappingMappedToPairRdd).join(idMappingRdd); doReturn(citationsRdd).when(joinedRdd).map(any()); JavaRDD<Citation> retCitationsRdd = externalIdCitationMatcher.matchCitations(documentsMetadataRdd, referenceIdMappingRdd, mainEntityIdType, referenceIdType, pickOneDocumentMetadataFunction); assertTrue(retCitationsRdd == citationsRdd); verify(idMappingExtractor).extractIdMapping(documentsMetadataRdd, mainEntityIdType, pickOneDocumentMetadataFunction); verify(referencePicker).extractExternalIdReferences(documentsMetadataRdd, referenceIdType); verify(externalIdReferencesRdd).join(referenceIdMappingRdd); verify(externalIdReferencesJoinedWithReferenceIdMappingRdd).mapToPair(mapToPairFunctionArg.capture()); assertMaptoPairFunction(mapToPairFunctionArg.getValue()); verify(externalIdReferencesJoinedWithReferenceIdMappingMappedToPairRdd).join(idMappingRdd); verify(joinedRdd).map(fillCitationFunctionArg.capture()); assertFillCitationFunction(fillCitationFunctionArg.getValue()); }
public JavaRDD<Citation> matchCitations(JavaRDD<DocumentMetadata> documents, String idType, Function<Iterable<DocumentMetadata>, DocumentMetadata> pickSingle) { Preconditions.checkNotNull(documents); Preconditions.checkNotNull(idType); Preconditions.checkNotNull(pickSingle); JavaPairRDD<String, String> externalIdToIdMapping = idMappingExtractor.extractIdMapping(documents, idType, pickSingle); JavaPairRDD<String, Citation> externalIdReferences = referencePicker.extractExternalIdReferences(documents, idType); JavaRDD<Citation> externalIdCitation = externalIdReferences.join(externalIdToIdMapping) .map(x -> { Citation partialCitation = x._2._1; String destinationDocumentId = x._2._2; return Citation.newBuilder(partialCitation) .setDestinationDocumentId(destinationDocumentId) .build(); }); return externalIdCitation; }
ExternalIdCitationMatcher implements Serializable { public JavaRDD<Citation> matchCitations(JavaRDD<DocumentMetadata> documents, String idType, Function<Iterable<DocumentMetadata>, DocumentMetadata> pickSingle) { Preconditions.checkNotNull(documents); Preconditions.checkNotNull(idType); Preconditions.checkNotNull(pickSingle); JavaPairRDD<String, String> externalIdToIdMapping = idMappingExtractor.extractIdMapping(documents, idType, pickSingle); JavaPairRDD<String, Citation> externalIdReferences = referencePicker.extractExternalIdReferences(documents, idType); JavaRDD<Citation> externalIdCitation = externalIdReferences.join(externalIdToIdMapping) .map(x -> { Citation partialCitation = x._2._1; String destinationDocumentId = x._2._2; return Citation.newBuilder(partialCitation) .setDestinationDocumentId(destinationDocumentId) .build(); }); return externalIdCitation; } }
ExternalIdCitationMatcher implements Serializable { public JavaRDD<Citation> matchCitations(JavaRDD<DocumentMetadata> documents, String idType, Function<Iterable<DocumentMetadata>, DocumentMetadata> pickSingle) { Preconditions.checkNotNull(documents); Preconditions.checkNotNull(idType); Preconditions.checkNotNull(pickSingle); JavaPairRDD<String, String> externalIdToIdMapping = idMappingExtractor.extractIdMapping(documents, idType, pickSingle); JavaPairRDD<String, Citation> externalIdReferences = referencePicker.extractExternalIdReferences(documents, idType); JavaRDD<Citation> externalIdCitation = externalIdReferences.join(externalIdToIdMapping) .map(x -> { Citation partialCitation = x._2._1; String destinationDocumentId = x._2._2; return Citation.newBuilder(partialCitation) .setDestinationDocumentId(destinationDocumentId) .build(); }); return externalIdCitation; }  }
ExternalIdCitationMatcher implements Serializable { public JavaRDD<Citation> matchCitations(JavaRDD<DocumentMetadata> documents, String idType, Function<Iterable<DocumentMetadata>, DocumentMetadata> pickSingle) { Preconditions.checkNotNull(documents); Preconditions.checkNotNull(idType); Preconditions.checkNotNull(pickSingle); JavaPairRDD<String, String> externalIdToIdMapping = idMappingExtractor.extractIdMapping(documents, idType, pickSingle); JavaPairRDD<String, Citation> externalIdReferences = referencePicker.extractExternalIdReferences(documents, idType); JavaRDD<Citation> externalIdCitation = externalIdReferences.join(externalIdToIdMapping) .map(x -> { Citation partialCitation = x._2._1; String destinationDocumentId = x._2._2; return Citation.newBuilder(partialCitation) .setDestinationDocumentId(destinationDocumentId) .build(); }); return externalIdCitation; }  JavaRDD<Citation> matchCitations(JavaRDD<DocumentMetadata> documents, String idType, Function<Iterable<DocumentMetadata>, DocumentMetadata> pickSingle); JavaRDD<Citation> matchCitations(JavaRDD<DocumentMetadata> documents, JavaPairRDD<String, String> referenceIdMappings, 
            String mainIdType, String referenceIdType, Function<Iterable<DocumentMetadata>, DocumentMetadata> pickSingle); }
ExternalIdCitationMatcher implements Serializable { public JavaRDD<Citation> matchCitations(JavaRDD<DocumentMetadata> documents, String idType, Function<Iterable<DocumentMetadata>, DocumentMetadata> pickSingle) { Preconditions.checkNotNull(documents); Preconditions.checkNotNull(idType); Preconditions.checkNotNull(pickSingle); JavaPairRDD<String, String> externalIdToIdMapping = idMappingExtractor.extractIdMapping(documents, idType, pickSingle); JavaPairRDD<String, Citation> externalIdReferences = referencePicker.extractExternalIdReferences(documents, idType); JavaRDD<Citation> externalIdCitation = externalIdReferences.join(externalIdToIdMapping) .map(x -> { Citation partialCitation = x._2._1; String destinationDocumentId = x._2._2; return Citation.newBuilder(partialCitation) .setDestinationDocumentId(destinationDocumentId) .build(); }); return externalIdCitation; }  JavaRDD<Citation> matchCitations(JavaRDD<DocumentMetadata> documents, String idType, Function<Iterable<DocumentMetadata>, DocumentMetadata> pickSingle); JavaRDD<Citation> matchCitations(JavaRDD<DocumentMetadata> documents, JavaPairRDD<String, String> referenceIdMappings, 
            String mainIdType, String referenceIdType, Function<Iterable<DocumentMetadata>, DocumentMetadata> pickSingle);  }