Skip to content

Commit

Permalink
Merge pull request #148 from dhis2/DHIS2-15891-legacy
Browse files Browse the repository at this point in the history
fix: Use correct value type for dates [DHIS2-15891]
  • Loading branch information
enricocolasante authored Dec 31, 2024
2 parents ad638af + 1f413fa commit 101982a
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 45 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>org.hisp.dhis.rules</groupId>
<artifactId>rule-engine</artifactId>
<version>2.1.8.2-SNAPSHOT</version>
<version>2.1.8.3-SNAPSHOT</version>
<packaging>jar</packaging>
<name>rule-engine</name>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ private Map<String, RuleVariableValue> buildEnvironmentVariables()
String currentDate = dateFormat.format( new Date() );

valueMap.put( RuleEngineUtils.ENV_VAR_CURRENT_DATE,
create( currentDate, RuleValueType.TEXT, Arrays.asList( currentDate ), currentDate ) );
create( currentDate, RuleValueType.DATE, Arrays.asList( currentDate ), currentDate ) );

if ( triggerEnvironment != null )
{
Expand All @@ -307,11 +307,11 @@ private Map<String, RuleVariableValue> buildEnvironmentVariables()

String enrollmentDate = dateFormat.format( ruleEnrollment.enrollmentDate() );
valueMap.put( RuleEngineUtils.ENV_VAR_ENROLLMENT_DATE, create( enrollmentDate,
RuleValueType.TEXT, Arrays.asList( enrollmentDate ), currentDate ) );
RuleValueType.DATE, Arrays.asList( enrollmentDate ), currentDate ) );

String incidentDate = dateFormat.format( ruleEnrollment.incidentDate() );
valueMap.put( RuleEngineUtils.ENV_VAR_INCIDENT_DATE, create( incidentDate,
RuleValueType.TEXT, Arrays.asList( incidentDate ), currentDate ) );
RuleValueType.DATE, Arrays.asList( incidentDate ), currentDate ) );

String status = ruleEnrollment.status().toString();
valueMap.put( RuleEngineUtils.ENV_VAR_ENROLLMENT_STATUS, create( status,
Expand All @@ -330,18 +330,18 @@ private Map<String, RuleVariableValue> buildEnvironmentVariables()
if ( ruleEvent != null )
{
String eventDate = dateFormat.format( ruleEvent.eventDate() );
valueMap.put( RuleEngineUtils.ENV_VAR_EVENT_DATE, create( eventDate, RuleValueType.TEXT,
valueMap.put( RuleEngineUtils.ENV_VAR_EVENT_DATE, create( eventDate, RuleValueType.DATE,
Arrays.asList( eventDate ), currentDate ) );

if ( ruleEvent.dueDate() != null ) {
String dueDate = dateFormat.format(ruleEvent.dueDate());
valueMap.put(RuleEngineUtils.ENV_VAR_DUE_DATE, create(dueDate, RuleValueType.TEXT,
valueMap.put(RuleEngineUtils.ENV_VAR_DUE_DATE, create(dueDate, RuleValueType.DATE,
Arrays.asList(dueDate), currentDate));
}
if ( ruleEvent.completedDate() != null )
{
String completedDate = dateFormat.format( ruleEvent.completedDate() );
valueMap.put( RuleEngineUtils.ENV_VAR_COMPLETED_DATE, create( completedDate, RuleValueType.TEXT,
valueMap.put( RuleEngineUtils.ENV_VAR_COMPLETED_DATE, create( completedDate, RuleValueType.DATE,
Arrays.asList( completedDate ), currentDate ) );
}

Expand Down
Loading

0 comments on commit 101982a

Please sign in to comment.