diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/predicate/BasePredicateBuilder.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/predicate/BasePredicateBuilder.java index 7e3d2a96f85..4db7ae264a5 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/predicate/BasePredicateBuilder.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/predicate/BasePredicateBuilder.java @@ -126,14 +126,14 @@ abstract class BasePredicateBuilder { } Predicate createPredicateNumeric(String theResourceName, - String theParamName, - From theFrom, - CriteriaBuilder builder, - IQueryParameterType theParam, - ParamPrefixEnum thePrefix, - BigDecimal theValue, - final Expression thePath, - String invalidMessageName) { + String theParamName, + From theFrom, + CriteriaBuilder builder, + IQueryParameterType theParam, + ParamPrefixEnum thePrefix, + BigDecimal theValue, + final Expression thePath, + String invalidMessageName) { Predicate num; // Per discussions with Grahame Grieve and James Agnew on 11/13/19, modified logic for EQUAL and NOT_EQUAL operators below so as to // use exact value matching. The "fuzz amount" matching is still used with the APPROXIMATE operator. @@ -157,7 +157,7 @@ abstract class BasePredicateBuilder { num = builder.notEqual(thePath, theValue); break; case APPROXIMATE: - BigDecimal mul = FuzzCalculator.calculateFuzzAmount(thePrefix, theValue); + BigDecimal mul = SearchFuzzUtil.calculateFuzzAmount(thePrefix, theValue); BigDecimal low = theValue.subtract(mul, MathContext.DECIMAL64); BigDecimal high = theValue.add(mul, MathContext.DECIMAL64); Predicate lowPred; diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/predicate/FuzzCalculator.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/predicate/SearchFuzzUtil.java similarity index 96% rename from hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/predicate/FuzzCalculator.java rename to hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/predicate/SearchFuzzUtil.java index 5ad21b22ace..ac7ce66c493 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/predicate/FuzzCalculator.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/predicate/SearchFuzzUtil.java @@ -4,7 +4,7 @@ import ca.uhn.fhir.rest.param.ParamPrefixEnum; import java.math.BigDecimal; -public interface FuzzCalculator { +public interface SearchFuzzUtil { /** * Figures out the tolerance for a search. For example, if the user is searching for 4.00, this method * returns 0.005 because we shold actually match values which are diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/predicate/FuzzCalculatorTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/predicate/SearchFuzzUtilTest.java similarity index 82% rename from hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/predicate/FuzzCalculatorTest.java rename to hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/predicate/SearchFuzzUtilTest.java index 558e3e7a051..0ea02794e22 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/predicate/FuzzCalculatorTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/predicate/SearchFuzzUtilTest.java @@ -13,13 +13,13 @@ import static org.hamcrest.Matchers.startsWith; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat; -public class FuzzCalculatorTest { +public class SearchFuzzUtilTest { private static final Logger ourLog = LoggerFactory.getLogger(SearchBuilderTest.class); @Test public void testCalculateMultiplierEqualNoDecimal() { BigDecimal in = new BigDecimal("200"); - BigDecimal out = FuzzCalculator.calculateFuzzAmount(ParamPrefixEnum.EQUAL, in); + BigDecimal out = SearchFuzzUtil.calculateFuzzAmount(ParamPrefixEnum.EQUAL, in); ourLog.info(out.toPlainString()); assertEquals("0.5", out.toPlainString()); } @@ -27,7 +27,7 @@ public class FuzzCalculatorTest { @Test public void testCalculateMultiplierEqualDecimalPrecision200_() { BigDecimal in = new BigDecimal("200."); - BigDecimal out = FuzzCalculator.calculateFuzzAmount(ParamPrefixEnum.EQUAL, in); + BigDecimal out = SearchFuzzUtil.calculateFuzzAmount(ParamPrefixEnum.EQUAL, in); ourLog.info(out.toPlainString()); assertEquals("0.5", out.toPlainString()); } @@ -35,7 +35,7 @@ public class FuzzCalculatorTest { @Test public void testCalculateMultiplierEqualDecimalPrecision123_010() { BigDecimal in = new BigDecimal("123.010"); - BigDecimal out = FuzzCalculator.calculateFuzzAmount(ParamPrefixEnum.EQUAL, in); + BigDecimal out = SearchFuzzUtil.calculateFuzzAmount(ParamPrefixEnum.EQUAL, in); ourLog.info(out.toPlainString()); assertThat(out.toPlainString(), startsWith("0.0005")); @@ -47,7 +47,7 @@ public class FuzzCalculatorTest { @Test public void testCalculateMultiplierEqualDecimalPrecision200_0() { BigDecimal in = new BigDecimal("200.0"); - BigDecimal out = FuzzCalculator.calculateFuzzAmount(ParamPrefixEnum.EQUAL, in); + BigDecimal out = SearchFuzzUtil.calculateFuzzAmount(ParamPrefixEnum.EQUAL, in); ourLog.info(out.toPlainString()); assertThat(out.toPlainString(), startsWith("0.05000000")); } @@ -55,7 +55,7 @@ public class FuzzCalculatorTest { @Test public void testCalculateMultiplierEqualDecimalPrecision200_3() { BigDecimal in = new BigDecimal("200.3"); - BigDecimal out = FuzzCalculator.calculateFuzzAmount(ParamPrefixEnum.EQUAL, in); + BigDecimal out = SearchFuzzUtil.calculateFuzzAmount(ParamPrefixEnum.EQUAL, in); ourLog.info(out.toPlainString()); assertThat(out.toPlainString(), startsWith("0.05000000")); } @@ -63,7 +63,7 @@ public class FuzzCalculatorTest { @Test public void testCalculateMultiplierEqualDecimalPrecision200_300() { BigDecimal in = new BigDecimal("200.300"); - BigDecimal out = FuzzCalculator.calculateFuzzAmount(ParamPrefixEnum.EQUAL, in); + BigDecimal out = SearchFuzzUtil.calculateFuzzAmount(ParamPrefixEnum.EQUAL, in); ourLog.info(out.toPlainString()); assertThat(out.toPlainString(), startsWith("0.0005000000")); } @@ -71,7 +71,7 @@ public class FuzzCalculatorTest { @Test public void testCalculateMultiplierEqualDecimalPrecision200_30000000() { BigDecimal in = new BigDecimal("200.30000000"); - BigDecimal out = FuzzCalculator.calculateFuzzAmount(ParamPrefixEnum.EQUAL, in); + BigDecimal out = SearchFuzzUtil.calculateFuzzAmount(ParamPrefixEnum.EQUAL, in); ourLog.info(out.toPlainString()); assertThat(out.toPlainString(), startsWith("0.000000005000000")); } @@ -79,7 +79,7 @@ public class FuzzCalculatorTest { @Test public void testCalculateMultiplierEqualDecimalPrecision200_300000001() { BigDecimal in = new BigDecimal("200.300000001"); - BigDecimal out = FuzzCalculator.calculateFuzzAmount(ParamPrefixEnum.EQUAL, in); + BigDecimal out = SearchFuzzUtil.calculateFuzzAmount(ParamPrefixEnum.EQUAL, in); ourLog.info(out.toPlainString()); assertThat(out.toPlainString(), startsWith("0.0000000005000000")); } @@ -87,7 +87,7 @@ public class FuzzCalculatorTest { @Test public void testCalculateMultiplierApprox() { BigDecimal in = new BigDecimal("200"); - BigDecimal out = FuzzCalculator.calculateFuzzAmount(ParamPrefixEnum.APPROXIMATE, in); + BigDecimal out = SearchFuzzUtil.calculateFuzzAmount(ParamPrefixEnum.APPROXIMATE, in); ourLog.info(out.toPlainString()); assertThat(out.toPlainString(), startsWith("20.000")); }