Skip to content

Commit 4d73c97

Browse files
committed
Updated dependencies
1 parent aac5d46 commit 4d73c97

21 files changed

+178
-128
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
## Validation Framework Version History
22

3-
**Version 4.7 (not released yet)**
3+
**Version 4.7**
44

5+
- Added new differenceInDays methods to the edits context.
56
- Changed the minimum Java language for this library from Java 11 to Java 21.
67
- Updated dependencies.
78

build.gradle

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ import com.vanniktech.maven.publish.*
33
plugins {
44
id 'java-library'
55
id 'jacoco'
6-
id 'com.vanniktech.maven.publish' version '0.34.0' // publish to Maven Central
7-
id 'com.github.ben-manes.versions' version '0.52.0' // check for out-of-date dependencies (run 'dependencyUpdates' manually)
8-
id 'com.github.spotbugs' version '6.4.2' // spotbugs code analysis
9-
id 'org.sonarqube' version '6.3.1.5724' // sonarQube analysis
6+
id 'com.vanniktech.maven.publish' version '0.35.0' // publish to Maven Central
7+
id 'com.github.ben-manes.versions' version '0.53.0' // check for out-of-date dependencies (run 'dependencyUpdates' manually)
8+
id 'com.github.spotbugs' version '6.4.8' // spotbugs code analysis
9+
id 'org.sonarqube' version '7.2.2.6593' // sonarQube analysis
1010
}
1111

1212
group = 'com.imsweb'
@@ -20,21 +20,19 @@ repositories {
2020
}
2121

2222
dependencies {
23-
api 'com.imsweb:staging-client-java:11.5.1'
24-
api 'org.apache.groovy:groovy:4.0.27'
23+
api 'com.imsweb:staging-client-java:11.8.1'
24+
api 'org.apache.groovy:groovy:4.0.29'
2525
api 'com.thoughtworks.xstream:xstream:1.4.21'
2626

27-
implementation 'commons-codec:commons-codec:1.19.0'
28-
implementation 'org.apache.commons:commons-lang3:3.19.0'
27+
implementation 'commons-codec:commons-codec:1.20.0'
28+
implementation 'org.apache.commons:commons-lang3:3.20.0'
2929

3030
testImplementation 'junit:junit:4.13.2'
31-
testImplementation 'commons-io:commons-io:2.20.0'
32-
testImplementation 'com.imsweb:layout:6.4'
33-
testImplementation 'com.imsweb:staging-client-java-cs:11.5.1'
34-
testImplementation 'com.imsweb:staging-client-java-eod-public:11.5.1'
35-
testImplementation 'com.imsweb:staging-client-java-tnm:11.5.1'
36-
testImplementation('com.imsweb:validation-edits-seer:025-08') { exclude module: 'validation' }
37-
testImplementation('com.imsweb:validation-edits-naaccr-translated:022-01') { exclude module: 'validation' }
31+
testImplementation 'commons-io:commons-io:2.21.0'
32+
testImplementation 'com.imsweb:layout:7.0'
33+
testImplementation 'org.apache.logging.log4j:log4j-slf4j2-impl:2.25.3'
34+
testImplementation('com.imsweb:validation-edits-seer:025-10') { exclude module: 'validation' }
35+
testImplementation('com.imsweb:validation-edits-naaccr-translated:023-01') { exclude module: 'validation' }
3836
}
3937

4038
java {
@@ -151,6 +149,6 @@ mavenPublishing {
151149

152150
// Gradle wrapper, this allows to build the project without having to install Gradle!
153151
wrapper {
154-
gradleVersion = '8.14'
152+
gradleVersion = '9.2.1'
155153
distributionType = Wrapper.DistributionType.ALL
156154
}

gradle/wrapper/gradle-wrapper.jar

59 Bytes
Binary file not shown.

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-all.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-all.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

gradlew

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gradlew.bat

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main/java/com/imsweb/validation/ValidationContextFunctions.java

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import java.time.LocalDate;
88
import java.util.ArrayList;
99
import java.util.Arrays;
10+
import java.util.Calendar;
11+
import java.util.GregorianCalendar;
1012
import java.util.HashSet;
1113
import java.util.List;
1214
import java.util.Map;
@@ -533,5 +535,57 @@ public long getNumRegexCacheHit() {
533535
public long getNumRegexCacheMiss() {
534536
return _numRegexCacheMiss == null ? 0L : _numRegexCacheMiss.get();
535537
}
538+
539+
/**
540+
* Returns the difference in days between the two day/month/year. Returns -1 if it cannot be calculated.
541+
* <p/>
542+
* Created on Dec 27, 2007 by depryf
543+
* @param day1 first day
544+
* @param month1 first month
545+
* @param year1 first year
546+
* @param day2 second day
547+
* @param month2 second month
548+
* @param year2 second year
549+
* @return difference in days between the two dates
550+
*/
551+
@SuppressWarnings("MagicConstant")
552+
@ContextFunctionDocAnnotation(paramName1 = "day1", param1 = "day of first date", paramName2 = "month1", param2 = "month of first date", paramName3 = "year1", param3 = "year of first date",
553+
paramName4 = "day2", param4 = "day of second date", paramName5 = "month2", param5 = "month of second day", paramName6 = "year2", param6 = "year of second date",
554+
desc = "Returns the difference in days between the first provided day/month/year and the second provided day/month/year, returns -1 if that cannot be determined.",
555+
example = "def days = differenceInDays(day1, month1, year1, day2, month2, year2)")
556+
public int differenceInDays(Object day1, Object month1, Object year1, Object day2, Object month2, Object year2) {
557+
558+
Integer y1 = asInt(year1);
559+
if (y1 != null)
560+
y1 = y1 == 9999 ? null : y1;
561+
Integer m1 = asInt(month1);
562+
if (m1 != null)
563+
m1 = m1 == 99 ? null : m1;
564+
Integer d1 = asInt(day1);
565+
if (d1 != null)
566+
d1 = d1 == 99 ? null : d1;
567+
Integer y2 = asInt(year2);
568+
if (y2 != null)
569+
y2 = y2 == 9999 ? null : y2;
570+
Integer m2 = asInt(month2);
571+
if (m2 != null)
572+
m2 = m2 == 99 ? null : m2;
573+
Integer d2 = asInt(day2);
574+
if (d2 != null)
575+
d2 = d2 == 99 ? null : d2;
576+
577+
if (y1 == null || m1 == null || y2 == null || m2 == null)
578+
return -1;
579+
580+
Calendar cal1 = new GregorianCalendar(y1, m1 - 1, d1 == null ? 1 : d1);
581+
Calendar cal2 = new GregorianCalendar(y2, m2 - 1, d2 == null ? 1 : d2);
582+
583+
// fix possible daylight saving time problem
584+
long fromL = cal1.getTimeInMillis() + cal1.getTimeZone().getOffset(cal1.getTimeInMillis());
585+
long toL = cal2.getTimeInMillis() + cal2.getTimeZone().getOffset(cal2.getTimeInMillis());
586+
long difference = toL - fromL;
587+
588+
return (int)(difference / (1000 * 60 * 60 * 24));
589+
}
536590
}
537591

src/main/java/com/imsweb/validation/functions/MetafileContextFunctions.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,6 @@ public class MetafileContextFunctions extends StagingContextFunctions {
113113
* relied on the CS DLL, but not on any TNM or EOD DLL.
114114
* <br/><br/>
115115
* You may provide null for the CS staging object, but any CS-related context methods won't work correctly.
116-
* <br/><br/>
117-
* Here is an example of how to create the required CS staging object:
118-
* <code>
119-
* Staging csStaging = Staging.getInstance(CsDataProvider.getInstance(CsDataProvider.CsVersion.v020550));
120-
* </code>
121-
* You will also need to add a dependency to the CS algorithm in your project, see https://github.com/imsweb/staging-algorithm-cs
122116
*/
123117
public MetafileContextFunctions(Staging csStaging) {
124118
super(csStaging, null, null);

src/test/java/com/imsweb/validation/TestingUtils.java

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import org.apache.commons.io.IOUtils;
1818
import org.junit.Assert;
1919

20+
import com.imsweb.staging.Staging;
2021
import com.imsweb.validation.entities.EditableValidator;
2122
import com.imsweb.validation.entities.RuleFailure;
2223
import com.imsweb.validation.entities.Validator;
@@ -25,6 +26,10 @@ public final class TestingUtils {
2526

2627
public static File TMP_DIR = new File(getWorkingDirectory() + "/build/test-tmp");
2728

29+
private static Staging _CS_STAGING;
30+
private static Staging _TNM_STAGING;
31+
private static Staging _EOD_STAGING;
32+
2833
public static void init() {
2934

3035
if (!TMP_DIR.exists() && !TMP_DIR.mkdirs())
@@ -39,6 +44,34 @@ public static void init() {
3944
options.enableEngineStats();
4045
ValidationEngine.getInstance().initialize(options);
4146
}
47+
48+
if (_CS_STAGING == null)
49+
_CS_STAGING = loadStagingInstance("cs-02.05.50.zip");
50+
if (_TNM_STAGING == null)
51+
_TNM_STAGING = loadStagingInstance("tnm-2.0.zip");
52+
if (_EOD_STAGING == null)
53+
_EOD_STAGING = loadStagingInstance("eod_public-3.3.zip");
54+
}
55+
56+
private static Staging loadStagingInstance(String data) {
57+
try (InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("staging/" + data)) {
58+
return Staging.getInstance(is);
59+
}
60+
catch (IOException e) {
61+
throw new IllegalStateException("Unable to initialize staging from " + data, e);
62+
}
63+
}
64+
65+
public static Staging getCsStaging() {
66+
return _CS_STAGING;
67+
}
68+
69+
public static Staging getTnmStaging() {
70+
return _TNM_STAGING;
71+
}
72+
73+
public static Staging getEodStaging() {
74+
return _EOD_STAGING;
4275
}
4376

4477
public static String getWorkingDirectory() {
@@ -98,7 +131,7 @@ public static void assertEditFailure(Collection<RuleFailure> results, String...
98131
StringBuilder buf = new StringBuilder();
99132
for (RuleFailure rf : results)
100133
buf.append(" ").append(rf.getRule().getId()).append(": ").append(rf.getMessage()).append("\n");
101-
if (buf.length() == 0)
134+
if (buf.isEmpty())
102135
buf.append("none");
103136
Assert.fail("\nWas expecting a failure for '" + ruleId + "' but didn't get it; failures:\n" + buf);
104137
}
@@ -127,7 +160,7 @@ public static void assertNoEditFailure(Collection<RuleFailure> results, String..
127160
else
128161
buf.append(" ").append(rf.getRule().getId()).append(": ").append(rf.getMessage()).append("\n");
129162
}
130-
if (buf.length() == 0)
163+
if (buf.isEmpty())
131164
buf.append("none");
132165
Assert.fail("\nWas expecting no failure for '" + ruleId + "' but got it; failures:\n" + buf);
133166
}

src/test/java/com/imsweb/validation/ValidationContextFunctionsTest.java

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
public class ValidationContextFunctionsTest {
2020

21-
private ValidationContextFunctions _functions = new ValidationContextFunctions();
21+
private final ValidationContextFunctions _functions = new ValidationContextFunctions();
2222

2323
@Before
2424
public void setUp() {
@@ -327,4 +327,32 @@ public void testMatches() {
327327
_functions.disableRegexCaching();
328328
}
329329
}
330+
331+
@Test
332+
public void testDifferenceInDays() {
333+
Assert.assertEquals(-1, _functions.differenceInDays(1, 1, null, 1, 1, 2000));
334+
Assert.assertEquals(-1, _functions.differenceInDays(1, null, 2000, 1, 1, 2000));
335+
Assert.assertEquals(-1, _functions.differenceInDays(1, 1, 2000, 1, 1, null));
336+
Assert.assertEquals(-1, _functions.differenceInDays(1, 1, 2000, 1, null, 2000));
337+
Assert.assertEquals(-1, _functions.differenceInDays(1, 1, 2000, 1, 1, 9999));
338+
Assert.assertEquals(-1, _functions.differenceInDays(1, 1, 2000, 1, 99, 2000));
339+
Assert.assertEquals(-1, _functions.differenceInDays(1, 1, "A", 1, 1, 2000));
340+
Assert.assertEquals(-1, _functions.differenceInDays(1, "A", 2000, 1, 1, 2000));
341+
Assert.assertEquals(-1, _functions.differenceInDays(1, 1, 2000, 1, 1, "A"));
342+
Assert.assertEquals(-1, _functions.differenceInDays(1, 1, 2000, 1, "A", 2000));
343+
344+
Assert.assertEquals(0, _functions.differenceInDays(1, 1, 2000, 1, 1, 2000));
345+
Assert.assertEquals(0, _functions.differenceInDays(null, 1, 2000, null, 1, 2000));
346+
Assert.assertEquals(1, _functions.differenceInDays("A", 1, 2000, 2, 1, 2000));
347+
Assert.assertEquals(31, _functions.differenceInDays(1, 1, 2000, 1, 2, 2000));
348+
Assert.assertEquals(366, _functions.differenceInDays(1, 1, 2000, 1, 1, 2001));
349+
Assert.assertEquals(2, _functions.differenceInDays(31, 12, 2000, 2, 1, 2001));
350+
Assert.assertEquals(87, _functions.differenceInDays(null, 1, 2000, 88, 1, 2000));
351+
Assert.assertEquals(0, _functions.differenceInDays(99, 1, 2000, 1, 1, 2000));
352+
353+
Assert.assertEquals(-1, _functions.differenceInDays(2, 1, 2000, 1, 1, 2000));
354+
Assert.assertEquals(-31, _functions.differenceInDays(1, 2, 2000, 1, 1, 2000));
355+
Assert.assertEquals(-366, _functions.differenceInDays(1, 1, 2001, 1, 1, 2000));
356+
357+
}
330358
}

0 commit comments

Comments
 (0)