Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,29 @@ synchronized AvroConverter getConverter(String resourceType) throws ProfileExcep
return converterMap.get(resourceType);
}

/*
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this older version.

@VisibleForTesting
@Nullable GenericRecord convertToAvro(Resource resource) throws ProfileException {
AvroConverter converter = getConverter(resource.getResourceType().name());
// TODO: Check why Bunsen returns IndexedRecord instead of GenericRecord.
return (GenericRecord) converter.resourceToAvro(resource);
}
*/

// Catch any RuntimeException and log the error instead of crashing the whole pipeline for an issue with one FHIR resource.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move this comment inside the function; this does not really document what the function does.

@VisibleForTesting
@Nullable GenericRecord convertToAvro(Resource resource) throws ProfileException {
AvroConverter converter = getConverter(resource.getResourceType().name());
// TODO: Check why Bunsen returns IndexedRecord instead of GenericRecord.
GenericRecord gr = null;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make sure that you run mvn clean package and include the formatting changes after that in the PR. There are some style issues in these lines which should be fixed by that.

try {
gr = (GenericRecord) converter.resourceToAvro(resource);
} catch (RuntimeException e) {
String errorMsg = "Unable to process resource " + resource.getResourceType().name() + "/" + resource.getId() + ": " + e.toString();
log.error(errorMsg);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
log.error(errorMsg);
log.error(errorMsg, e);

}
return gr;
}

@VisibleForTesting
Resource convertToHapi(GenericRecord record, String resourceType) throws ProfileException {
Expand Down