Skip to content

Commit

Permalink
Renamed TransformationRuleException to RuleExecutionException
Browse files Browse the repository at this point in the history
  • Loading branch information
basiliskus committed May 7, 2024
1 parent 74d2c03 commit 81364d8
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import gov.hhs.cdc.trustedintermediary.etor.messages.UnableToSendMessageException;
import gov.hhs.cdc.trustedintermediary.etor.orders.OrderSender;
import gov.hhs.cdc.trustedintermediary.etor.ruleengine.RuleExecutionException;
import gov.hhs.cdc.trustedintermediary.etor.ruleengine.transformation.TransformationRuleEngine;
import gov.hhs.cdc.trustedintermediary.etor.ruleengine.transformation.TransformationRuleException;
import gov.hhs.cdc.trustedintermediary.external.hapi.HapiOrder;
import javax.inject.Inject;
import org.hl7.fhir.r4.model.Bundle;
Expand All @@ -30,7 +30,7 @@ private ConvertAndSendDemographicsUsecase() {}
public void convertAndSend(Demographics<?> demographics) throws UnableToSendMessageException {
try {
transformationEngine.runRules(demographics);
} catch (TransformationRuleException e) {
} catch (RuleExecutionException e) {
throw new UnableToSendMessageException("Error running transformation rules", e);
}
var order = new HapiOrder((Bundle) demographics.getUnderlyingResource());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import gov.hhs.cdc.trustedintermediary.etor.messages.UnableToSendMessageException;
import gov.hhs.cdc.trustedintermediary.etor.metadata.partner.PartnerMetadata;
import gov.hhs.cdc.trustedintermediary.etor.metadata.partner.PartnerMetadataMessageType;
import gov.hhs.cdc.trustedintermediary.etor.ruleengine.RuleExecutionException;
import gov.hhs.cdc.trustedintermediary.etor.ruleengine.transformation.TransformationRuleEngine;
import gov.hhs.cdc.trustedintermediary.etor.ruleengine.transformation.TransformationRuleException;
import gov.hhs.cdc.trustedintermediary.wrappers.Logger;
import gov.hhs.cdc.trustedintermediary.wrappers.MetricMetadata;
import javax.inject.Inject;
Expand Down Expand Up @@ -45,7 +45,7 @@ public void convertAndSend(final Order<?> order, String receivedSubmissionId)

try {
transformationEngine.runRules(order);
} catch (TransformationRuleException e) {
} catch (RuleExecutionException e) {
throw new UnableToSendMessageException("Error running transformation rules", e);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import gov.hhs.cdc.trustedintermediary.etor.messages.UnableToSendMessageException;
import gov.hhs.cdc.trustedintermediary.etor.metadata.partner.PartnerMetadata;
import gov.hhs.cdc.trustedintermediary.etor.metadata.partner.PartnerMetadataMessageType;
import gov.hhs.cdc.trustedintermediary.etor.ruleengine.RuleExecutionException;
import gov.hhs.cdc.trustedintermediary.etor.ruleengine.transformation.TransformationRuleEngine;
import gov.hhs.cdc.trustedintermediary.etor.ruleengine.transformation.TransformationRuleException;
import gov.hhs.cdc.trustedintermediary.wrappers.Logger;
import javax.inject.Inject;

Expand Down Expand Up @@ -46,7 +46,7 @@ public void convertAndSend(Result<?> result, String receivedSubmissionId)

try {
transformationEngine.runRules(result);
} catch (TransformationRuleException e) {
} catch (RuleExecutionException e) {
throw new UnableToSendMessageException("Error running transformation rules", e);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public boolean shouldRun(FhirResource<?> resource) {
});
}

public void runRule(FhirResource<?> resource) {
public void runRule(FhirResource<?> resource) throws RuleExecutionException {
throw new UnsupportedOperationException("This method must be implemented by subclasses.");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package gov.hhs.cdc.trustedintermediary.etor.ruleengine;

public class RuleExecutionException extends Exception {
public RuleExecutionException(String message, Throwable cause) {
super(message, cause);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import gov.hhs.cdc.trustedintermediary.etor.ruleengine.FhirResource;
import gov.hhs.cdc.trustedintermediary.etor.ruleengine.Rule;
import gov.hhs.cdc.trustedintermediary.etor.ruleengine.RuleExecutionException;
import java.lang.reflect.InvocationTargetException;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -34,15 +35,15 @@ public TransformationRule(
}

@Override
public void runRule(FhirResource<?> resource) throws TransformationRuleException {
public void runRule(FhirResource<?> resource) throws RuleExecutionException {
for (TransformationRuleMethod transformation : this.getRules()) {
applyTransformation(transformation, resource);
}
}

private void applyTransformation(
TransformationRuleMethod transformation, FhirResource<?> resource)
throws TransformationRuleException {
throws RuleExecutionException {
String name = transformation.name();
Map<String, String> args = transformation.args();
logger.logInfo("Applying transformation: ", name);
Expand All @@ -54,7 +55,7 @@ private void applyTransformation(
| IllegalAccessException
| InvocationTargetException
| InstantiationException e) {
throw new TransformationRuleException("Error invoking method: " + name, e);
throw new RuleExecutionException("Error invoking method: " + name, e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import gov.hhs.cdc.trustedintermediary.etor.ruleengine.FhirResource;
import gov.hhs.cdc.trustedintermediary.etor.ruleengine.RuleEngine;
import gov.hhs.cdc.trustedintermediary.etor.ruleengine.RuleExecutionException;
import gov.hhs.cdc.trustedintermediary.etor.ruleengine.RuleLoader;
import gov.hhs.cdc.trustedintermediary.etor.ruleengine.RuleLoaderException;
import gov.hhs.cdc.trustedintermediary.wrappers.Logger;
Expand Down Expand Up @@ -53,7 +54,7 @@ public void ensureRulesLoaded() throws RuleLoaderException {
}

@Override
public void runRules(FhirResource<?> resource) throws TransformationRuleException {
public void runRules(FhirResource<?> resource) throws RuleExecutionException {
try {
ensureRulesLoaded();
} catch (RuleLoaderException e) {
Expand Down

This file was deleted.

0 comments on commit 81364d8

Please sign in to comment.