Skip to content

Commit

Permalink
Renamed 'MetaData' => 'Metadata' for consistency (#703)
Browse files Browse the repository at this point in the history
  • Loading branch information
basiliskus authored Dec 4, 2023
1 parent 1f9cb5f commit 8f09de4
Show file tree
Hide file tree
Showing 15 changed files with 57 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import gov.hhs.cdc.trustedintermediary.external.azure.AzureSecrets;
import gov.hhs.cdc.trustedintermediary.external.hapi.HapiFhirImplementation;
import gov.hhs.cdc.trustedintermediary.external.inmemory.KeyCache;
import gov.hhs.cdc.trustedintermediary.external.inmemory.LoggingMetricMetaData;
import gov.hhs.cdc.trustedintermediary.external.inmemory.LoggingMetricMetadata;
import gov.hhs.cdc.trustedintermediary.external.jackson.Jackson;
import gov.hhs.cdc.trustedintermediary.external.jjwt.JjwtEngine;
import gov.hhs.cdc.trustedintermediary.external.localfile.LocalSecrets;
Expand All @@ -22,7 +22,7 @@
import gov.hhs.cdc.trustedintermediary.wrappers.HapiFhir;
import gov.hhs.cdc.trustedintermediary.wrappers.HttpClient;
import gov.hhs.cdc.trustedintermediary.wrappers.Logger;
import gov.hhs.cdc.trustedintermediary.wrappers.MetricMetaData;
import gov.hhs.cdc.trustedintermediary.wrappers.MetricMetadata;
import gov.hhs.cdc.trustedintermediary.wrappers.Secrets;
import gov.hhs.cdc.trustedintermediary.wrappers.YamlCombiner;
import gov.hhs.cdc.trustedintermediary.wrappers.formatter.Formatter;
Expand Down Expand Up @@ -86,6 +86,6 @@ private static void registerClasses() {
: AzureSecrets.getInstance());
ApplicationContext.register(
OrganizationsSettings.class, OrganizationsSettings.getInstance());
ApplicationContext.register(MetricMetaData.class, LoggingMetricMetaData.getInstance());
ApplicationContext.register(MetricMetadata.class, LoggingMetricMetadata.getInstance());
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package gov.hhs.cdc.trustedintermediary.etor.metadata;

/** Etor specific steps from the general shared metadata steps */
public enum EtorMetaDataStep {
public enum EtorMetadataStep {
RECEIVED_FROM_REPORT_STREAM,

ORDER_CONVERTED_TO_OML,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package gov.hhs.cdc.trustedintermediary.etor.orders;

import gov.hhs.cdc.trustedintermediary.domainconnector.DomainRequest;
import gov.hhs.cdc.trustedintermediary.etor.metadata.EtorMetaDataStep;
import gov.hhs.cdc.trustedintermediary.etor.metadata.EtorMetadataStep;
import gov.hhs.cdc.trustedintermediary.external.hapi.HapiOrder;
import gov.hhs.cdc.trustedintermediary.wrappers.FhirParseException;
import gov.hhs.cdc.trustedintermediary.wrappers.HapiFhir;
import gov.hhs.cdc.trustedintermediary.wrappers.Logger;
import gov.hhs.cdc.trustedintermediary.wrappers.MetricMetaData;
import gov.hhs.cdc.trustedintermediary.wrappers.MetricMetadata;
import javax.inject.Inject;
import org.hl7.fhir.r4.model.Bundle;

Expand All @@ -17,7 +17,7 @@ public class OrderController {

@Inject HapiFhir fhir;
@Inject Logger logger;
@Inject MetricMetaData metaData;
@Inject MetricMetadata metadata;

private OrderController() {}

Expand All @@ -28,7 +28,7 @@ public static OrderController getInstance() {
public Order<?> parseOrders(DomainRequest request) throws FhirParseException {
logger.logInfo("Parsing orders");
var fhirBundle = fhir.parseResource(request.getBody(), Bundle.class);
metaData.put(fhirBundle.getId(), EtorMetaDataStep.RECEIVED_FROM_REPORT_STREAM);
metadata.put(fhirBundle.getId(), EtorMetadataStep.RECEIVED_FROM_REPORT_STREAM);
return new HapiOrder(fhirBundle);
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package gov.hhs.cdc.trustedintermediary.etor.orders;

import gov.hhs.cdc.trustedintermediary.etor.metadata.EtorMetaDataStep;
import gov.hhs.cdc.trustedintermediary.etor.metadata.EtorMetadataStep;
import gov.hhs.cdc.trustedintermediary.etor.metadata.PartnerMetadata;
import gov.hhs.cdc.trustedintermediary.etor.metadata.PartnerMetadataStorage;
import gov.hhs.cdc.trustedintermediary.wrappers.MetricMetaData;
import gov.hhs.cdc.trustedintermediary.wrappers.MetricMetadata;
import java.time.Instant;
import javax.inject.Inject;

Expand All @@ -12,7 +12,7 @@ public class SendOrderUseCase {
private static final SendOrderUseCase INSTANCE = new SendOrderUseCase();
@Inject OrderConverter converter;
@Inject OrderSender sender;
@Inject MetricMetaData metaData;
@Inject MetricMetadata metadata;
@Inject PartnerMetadataStorage partnerMetadataStorage;

private SendOrderUseCase() {}
Expand All @@ -28,9 +28,9 @@ public void convertAndSend(final Order<?> order) throws UnableToSendOrderExcepti
partnerMetadataStorage.saveMetadata(partnerMetadata);

var omlOrder = converter.convertMetadataToOmlOrder(order);
metaData.put(order.getFhirResourceId(), EtorMetaDataStep.ORDER_CONVERTED_TO_OML);
metadata.put(order.getFhirResourceId(), EtorMetadataStep.ORDER_CONVERTED_TO_OML);
omlOrder = converter.addContactSectionToPatientResource(omlOrder);
metaData.put(order.getFhirResourceId(), EtorMetaDataStep.CONTACT_SECTION_ADDED_TO_PATIENT);
metadata.put(order.getFhirResourceId(), EtorMetadataStep.CONTACT_SECTION_ADDED_TO_PATIENT);
sender.sendOrder(omlOrder);
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package gov.hhs.cdc.trustedintermediary.external.localfile;

import gov.hhs.cdc.trustedintermediary.etor.metadata.EtorMetaDataStep;
import gov.hhs.cdc.trustedintermediary.etor.metadata.EtorMetadataStep;
import gov.hhs.cdc.trustedintermediary.etor.orders.Order;
import gov.hhs.cdc.trustedintermediary.etor.orders.OrderSender;
import gov.hhs.cdc.trustedintermediary.etor.orders.UnableToSendOrderException;
import gov.hhs.cdc.trustedintermediary.wrappers.HapiFhir;
import gov.hhs.cdc.trustedintermediary.wrappers.Logger;
import gov.hhs.cdc.trustedintermediary.wrappers.MetricMetaData;
import gov.hhs.cdc.trustedintermediary.wrappers.MetricMetadata;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
Expand All @@ -21,7 +21,7 @@ public class LocalFileOrderSender implements OrderSender {
@Inject HapiFhir fhir;
@Inject Logger logger;

@Inject MetricMetaData metaData;
@Inject MetricMetadata metadata;

public static LocalFileOrderSender getInstance() {
return INSTANCE;
Expand All @@ -35,7 +35,7 @@ public void sendOrder(final Order<?> order) throws UnableToSendOrderException {
logger.logInfo("Sending the order to the hard drive at {}", fileLocation.toAbsolutePath());

try {
metaData.put(order.getFhirResourceId(), EtorMetaDataStep.SENT_TO_REPORT_STREAM);
metadata.put(order.getFhirResourceId(), EtorMetadataStep.SENT_TO_REPORT_STREAM);
String serialized = fhir.encodeResourceToJson(order.getUnderlyingOrder());
Files.writeString(fileLocation, serialized, StandardCharsets.UTF_8);
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package gov.hhs.cdc.trustedintermediary.external.reportstream;

import gov.hhs.cdc.trustedintermediary.context.ApplicationContext;
import gov.hhs.cdc.trustedintermediary.etor.metadata.EtorMetaDataStep;
import gov.hhs.cdc.trustedintermediary.etor.metadata.EtorMetadataStep;
import gov.hhs.cdc.trustedintermediary.etor.orders.Order;
import gov.hhs.cdc.trustedintermediary.etor.orders.OrderSender;
import gov.hhs.cdc.trustedintermediary.etor.orders.UnableToSendOrderException;
Expand All @@ -11,7 +11,7 @@
import gov.hhs.cdc.trustedintermediary.wrappers.HttpClient;
import gov.hhs.cdc.trustedintermediary.wrappers.HttpClientException;
import gov.hhs.cdc.trustedintermediary.wrappers.Logger;
import gov.hhs.cdc.trustedintermediary.wrappers.MetricMetaData;
import gov.hhs.cdc.trustedintermediary.wrappers.MetricMetadata;
import gov.hhs.cdc.trustedintermediary.wrappers.SecretRetrievalException;
import gov.hhs.cdc.trustedintermediary.wrappers.Secrets;
import gov.hhs.cdc.trustedintermediary.wrappers.formatter.Formatter;
Expand Down Expand Up @@ -55,7 +55,7 @@ public class ReportStreamOrderSender implements OrderSender {
@Inject private Secrets secrets;
@Inject private Cache cache;

@Inject MetricMetaData metaData;
@Inject MetricMetadata metadata;

public static ReportStreamOrderSender getInstance() {
return INSTANCE;
Expand All @@ -70,7 +70,7 @@ public void sendOrder(final Order<?> order) throws UnableToSendOrderException {
String bearerToken = getRsToken();
String rsResponseBody = sendRequestBody(json, bearerToken);
logRsSubmissionId(rsResponseBody);
metaData.put(order.getFhirResourceId(), EtorMetaDataStep.SENT_TO_REPORT_STREAM);
metadata.put(order.getFhirResourceId(), EtorMetadataStep.SENT_TO_REPORT_STREAM);
}

protected void logRsSubmissionId(String rsResponseBody) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package gov.hhs.cdc.trustedintermediary.etor.orders

import gov.hhs.cdc.trustedintermediary.context.TestApplicationContext
import gov.hhs.cdc.trustedintermediary.domainconnector.DomainRequest
import gov.hhs.cdc.trustedintermediary.etor.metadata.EtorMetaDataStep
import gov.hhs.cdc.trustedintermediary.etor.metadata.EtorMetadataStep
import gov.hhs.cdc.trustedintermediary.wrappers.FhirParseException
import gov.hhs.cdc.trustedintermediary.wrappers.HapiFhir
import gov.hhs.cdc.trustedintermediary.wrappers.MetricMetaData
import gov.hhs.cdc.trustedintermediary.wrappers.MetricMetadata
import org.hl7.fhir.r4.model.Bundle
import spock.lang.Specification

Expand All @@ -15,7 +15,7 @@ class OrderControllerTest extends Specification {
TestApplicationContext.reset()
TestApplicationContext.init()
TestApplicationContext.register(OrderController, OrderController.getInstance())
TestApplicationContext.register(MetricMetaData, Mock(MetricMetaData))
TestApplicationContext.register(MetricMetadata, Mock(MetricMetadata))
}

def "parseOrders happy path works"() {
Expand Down Expand Up @@ -47,7 +47,7 @@ class OrderControllerTest extends Specification {
OrderController.getInstance().parseOrders(new DomainRequest())

then:
1 * OrderController.getInstance().metaData.put(_, EtorMetaDataStep.RECEIVED_FROM_REPORT_STREAM)
1 * OrderController.getInstance().metadata.put(_, EtorMetadataStep.RECEIVED_FROM_REPORT_STREAM)
}

def "parseOrders throws an exception when unable to parse de request"() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ package gov.hhs.cdc.trustedintermediary.etor.orders

import gov.hhs.cdc.trustedintermediary.OrderMock
import gov.hhs.cdc.trustedintermediary.context.TestApplicationContext
import gov.hhs.cdc.trustedintermediary.etor.metadata.EtorMetaDataStep
import gov.hhs.cdc.trustedintermediary.etor.metadata.EtorMetadataStep
import gov.hhs.cdc.trustedintermediary.etor.metadata.PartnerMetadataStorage
import gov.hhs.cdc.trustedintermediary.wrappers.MetricMetaData
import gov.hhs.cdc.trustedintermediary.wrappers.MetricMetadata
import spock.lang.Specification

class SendOrderUsecaseTest extends Specification {
Expand All @@ -13,7 +13,7 @@ class SendOrderUsecaseTest extends Specification {
TestApplicationContext.reset()
TestApplicationContext.init()
TestApplicationContext.register(SendOrderUseCase, SendOrderUseCase.getInstance())
TestApplicationContext.register(MetricMetaData, Mock(MetricMetaData))
TestApplicationContext.register(MetricMetadata, Mock(MetricMetadata))
TestApplicationContext.register(PartnerMetadataStorage, Mock(PartnerMetadataStorage))
}

Expand Down Expand Up @@ -45,7 +45,7 @@ class SendOrderUsecaseTest extends Specification {
SendOrderUseCase.getInstance().convertAndSend(new OrderMock(null, null, null))

then:
1 * SendOrderUseCase.getInstance().metaData.put(_, EtorMetaDataStep.ORDER_CONVERTED_TO_OML)
1 * SendOrderUseCase.getInstance().metadata.put(_, EtorMetadataStep.ORDER_CONVERTED_TO_OML)
}

def "metadata is registered for adding the contact section to an order"() {
Expand All @@ -58,7 +58,7 @@ class SendOrderUsecaseTest extends Specification {
SendOrderUseCase.getInstance().convertAndSend(new OrderMock(null, null, null))

then:
1 * SendOrderUseCase.getInstance().metaData.put(_, EtorMetaDataStep.CONTACT_SECTION_ADDED_TO_PATIENT)
1 * SendOrderUseCase.getInstance().metadata.put(_, EtorMetadataStep.CONTACT_SECTION_ADDED_TO_PATIENT)
}

def "send fails to send"() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package gov.hhs.cdc.trustedintermediary.external.localfile

import gov.hhs.cdc.trustedintermediary.OrderMock
import gov.hhs.cdc.trustedintermediary.context.TestApplicationContext
import gov.hhs.cdc.trustedintermediary.etor.metadata.EtorMetaDataStep
import gov.hhs.cdc.trustedintermediary.etor.metadata.EtorMetadataStep
import gov.hhs.cdc.trustedintermediary.etor.orders.UnableToSendOrderException
import gov.hhs.cdc.trustedintermediary.wrappers.HapiFhir
import gov.hhs.cdc.trustedintermediary.wrappers.MetricMetaData
import gov.hhs.cdc.trustedintermediary.wrappers.MetricMetadata
import java.nio.file.Files
import java.nio.file.Paths
import spock.lang.Specification
Expand All @@ -15,7 +15,7 @@ class LocalFileOrderSenderTest extends Specification{
def setup() {
TestApplicationContext.reset()
TestApplicationContext.init()
TestApplicationContext.register(MetricMetaData, Mock(MetricMetaData))
TestApplicationContext.register(MetricMetadata, Mock(MetricMetadata))
TestApplicationContext.register(LocalFileOrderSender, LocalFileOrderSender.getInstance())
}

Expand Down Expand Up @@ -79,6 +79,6 @@ class LocalFileOrderSenderTest extends Specification{
LocalFileOrderSender.getInstance().sendOrder(mockOrder)

then:
1 * LocalFileOrderSender.getInstance().metaData.put(_ as String, EtorMetaDataStep.SENT_TO_REPORT_STREAM)
1 * LocalFileOrderSender.getInstance().metadata.put(_ as String, EtorMetadataStep.SENT_TO_REPORT_STREAM)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package gov.hhs.cdc.trustedintermediary.external.reportstream

import gov.hhs.cdc.trustedintermediary.OrderMock
import gov.hhs.cdc.trustedintermediary.context.TestApplicationContext
import gov.hhs.cdc.trustedintermediary.etor.metadata.EtorMetaDataStep
import gov.hhs.cdc.trustedintermediary.etor.metadata.EtorMetadataStep
import gov.hhs.cdc.trustedintermediary.etor.orders.OrderSender
import gov.hhs.cdc.trustedintermediary.etor.orders.UnableToSendOrderException
import gov.hhs.cdc.trustedintermediary.external.inmemory.KeyCache
Expand All @@ -13,7 +13,7 @@ import gov.hhs.cdc.trustedintermediary.wrappers.HapiFhir
import gov.hhs.cdc.trustedintermediary.wrappers.HttpClient
import gov.hhs.cdc.trustedintermediary.wrappers.HttpClientException
import gov.hhs.cdc.trustedintermediary.wrappers.Logger
import gov.hhs.cdc.trustedintermediary.wrappers.MetricMetaData
import gov.hhs.cdc.trustedintermediary.wrappers.MetricMetadata
import gov.hhs.cdc.trustedintermediary.wrappers.Secrets
import gov.hhs.cdc.trustedintermediary.wrappers.formatter.Formatter
import gov.hhs.cdc.trustedintermediary.wrappers.formatter.FormatterProcessingException
Expand All @@ -28,7 +28,7 @@ class ReportStreamOrderSenderTest extends Specification {
TestApplicationContext.reset()
TestApplicationContext.init()
TestApplicationContext.register(OrderSender, ReportStreamOrderSender.getInstance())
TestApplicationContext.register(MetricMetaData, Mock(MetricMetaData))
TestApplicationContext.register(MetricMetadata, Mock(MetricMetadata))
}

def "sendRequestBody works"() {
Expand Down Expand Up @@ -304,7 +304,7 @@ class ReportStreamOrderSenderTest extends Specification {
ReportStreamOrderSender.getInstance().sendOrder(new OrderMock(null, null, "Mock order"))

then:
1 * ReportStreamOrderSender.getInstance().metaData.put(_, EtorMetaDataStep.SENT_TO_REPORT_STREAM)
1 * ReportStreamOrderSender.getInstance().metadata.put(_, EtorMetadataStep.SENT_TO_REPORT_STREAM)
}

def "retrievePrivateKey works when cache is empty" () {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
package gov.hhs.cdc.trustedintermediary.external.inmemory;

import gov.hhs.cdc.trustedintermediary.metadata.MetaDataEntry;
import gov.hhs.cdc.trustedintermediary.metadata.MetadataEntry;
import gov.hhs.cdc.trustedintermediary.wrappers.Logger;
import gov.hhs.cdc.trustedintermediary.wrappers.MetricMetaData;
import gov.hhs.cdc.trustedintermediary.wrappers.MetricMetadata;
import java.util.Map;
import javax.inject.Inject;

/**
* Implementation of a class that can be used throughout the project to collect a list of metadata
* events
*/
public class LoggingMetricMetaData implements MetricMetaData {
private static final LoggingMetricMetaData INSTANCE = new LoggingMetricMetaData();
public class LoggingMetricMetadata implements MetricMetadata {
private static final LoggingMetricMetadata INSTANCE = new LoggingMetricMetadata();

@Inject Logger logger;

public static LoggingMetricMetaData getInstance() {
public static LoggingMetricMetadata getInstance() {
return INSTANCE;
}

private LoggingMetricMetaData() {}
private LoggingMetricMetadata() {}

@Override
public <T> void put(String bundleId, T step) {
MetaDataEntry<T> entry = extractMetricsFromBundle(bundleId, step);
MetadataEntry<T> entry = extractMetricsFromBundle(bundleId, step);
var metadataMap =
Map.of(
"BundleId",
Expand All @@ -33,10 +33,10 @@ public <T> void put(String bundleId, T step) {
"Entry Step",
entry.entryStep());

logger.logMap("MetaData Event Occurred:", metadataMap);
logger.logMap("Metadata Event Occurred:", metadataMap);
}

private <T> MetaDataEntry<T> extractMetricsFromBundle(String bundleId, T step) {
return new MetaDataEntry<>(bundleId, step);
private <T> MetadataEntry<T> extractMetricsFromBundle(String bundleId, T step) {
return new MetadataEntry<>(bundleId, step);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import java.time.Instant;

/** An instance of a metadata event to be used for internal troubleshooting of messages */
public record MetaDataEntry<T>(String bundleId, T entryStep, Instant entryTime) {
public record MetadataEntry<T>(String bundleId, T entryStep, Instant entryTime) {

public MetaDataEntry(String bundleId, T entryStep) {
public MetadataEntry(String bundleId, T entryStep) {
this(bundleId, entryStep, Instant.now());
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package gov.hhs.cdc.trustedintermediary.wrappers;

/** Interface to provide a blueprint for working with metadate */
public interface MetricMetaData {
public interface MetricMetadata {

<T> void put(String value, T step);
}
Loading

0 comments on commit 8f09de4

Please sign in to comment.