Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Rename executionDate to occurredDate in service layer [TECH-1615] #15557

Merged
merged 4 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/Event.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public class Event extends SoftDeletableObject {

private Date dueDate;

private Date executionDate;
private Date occurredDate;

@AuditAttribute private OrganisationUnit organisationUnit;

Expand Down Expand Up @@ -226,12 +226,12 @@ public void setDueDate(Date dueDate) {

@JsonProperty("eventDate")
@JacksonXmlProperty(localName = "eventDate", namespace = DxfNamespaces.DXF_2_0)
public Date getExecutionDate() {
return executionDate;
public Date getOccurredDate() {
return occurredDate;
}

public void setExecutionDate(Date executionDate) {
this.executionDate = executionDate;
public void setOccurredDate(Date occurredDate) {
this.occurredDate = occurredDate;
}

@JsonProperty
Expand Down Expand Up @@ -362,7 +362,7 @@ public void setAssignedUser(User assignedUser) {
public boolean isCreatableInSearchScope() {
return this.getStatus() == EventStatus.SCHEDULE
&& this.getEventDataValues().isEmpty()
&& this.getExecutionDate() == null;
&& this.getOccurredDate() == null;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
public class EventVisitDateComparator implements Comparator<Event> {
@Override
public int compare(Event event1, Event event2) {
Date d1 = (event1.getExecutionDate() != null) ? event1.getExecutionDate() : event1.getDueDate();
Date d2 = (event2.getExecutionDate() != null) ? event2.getExecutionDate() : event2.getDueDate();
Date d1 = (event1.getOccurredDate() != null) ? event1.getOccurredDate() : event1.getDueDate();
Date d2 = (event2.getOccurredDate() != null) ? event2.getOccurredDate() : event2.getDueDate();
if (d1.before(d2)) {
return -1;
} else if (d1.after(d2)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ public class ProgramStageNotificationMessageRenderer
event -> event.getOrganisationUnit().getCode())
.put(ProgramStageTemplateVariable.DUE_DATE, event -> formatDate(event.getDueDate()))
.put(
ProgramStageTemplateVariable.EVENT_DATE,
event -> formatDate(event.getExecutionDate()))
ProgramStageTemplateVariable.EVENT_DATE, event -> formatDate(event.getOccurredDate()))
.put(
ProgramStageTemplateVariable.DAYS_SINCE_DUE_DATE,
event -> daysSince(event.getDueDate()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ public void cancelEnrollmentStatus(Enrollment enrollment) {
// ---------------------------------------------------------------------

for (Event event : enrollment.getEvents()) {
if (event.getExecutionDate() == null) {
if (event.getOccurredDate() == null) {
// -------------------------------------------------------------
// Set status as skipped for overdue events, or delete
// -------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public Event createEvent(
if (programStage.getOpenAfterEnrollment()
|| enrollment.getProgram().isWithoutRegistration()
|| programStage.getPeriodType() != null) {
event.setExecutionDate(dueDate);
event.setOccurredDate(dueDate);
event.setStatus(EventStatus.ACTIVE);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ public List<Event> getWithScheduledNotifications(
+ "inner join ev.programStage as ps "
+ "where :notificationTemplate in elements(ps.notificationTemplates) "
+ "and ev.dueDate is not null "
+ "and ev.executionDate is null "
+ "and ev.occurredDate is null "
+ "and ev.status != :skippedEventStatus "
+ "and cast(:targetDate as date) = ev.dueDate "
+ "and ev.deleted is false";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ protected void register(
event.setOrganisationUnit(ous.iterator().next());
event.setProgramStage(smsCommand.getProgramStage());
event.setEnrollment(enrollment);
event.setExecutionDate(sms.getSentDate());
event.setOccurredDate(sms.getSentDate());
event.setDueDate(sms.getSentDate());
event.setAttributeOptionCombo(dataElementCategoryService.getDefaultCategoryOptionCombo());
event.setCompletedBy("DHIS 2");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ protected List<Object> saveNewEvent(
event.setOrganisationUnit(orgUnit);
event.setProgramStage(programStage);
event.setEnrollment(enrollment);
event.setExecutionDate(eventDate);
event.setOccurredDate(eventDate);
event.setDueDate(dueDate);
event.setAttributeOptionCombo(aoc);
event.setStoredBy(user.getUsername());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@

<property name="dueDate" column="duedate" />

<property name="executionDate" column="executiondate" type="timestamp" index="programstageinstance_executiondate" />
<property name="occurredDate" column="executiondate" type="timestamp" index="programstageinstance_executiondate" />

<many-to-one name="organisationUnit" class="org.hisp.dhis.organisationunit.OrganisationUnit" column="organisationunitid"
foreign-key="fk_programstageinstance_organisationunitid" index="programstageinstance_organisationunitid" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public void initTest() {
event.setProgramStage(programStageA);
event.setOrganisationUnit(organisationUnitA);
enrollment.setEnrollmentDate(new Date());
event.setExecutionDate(new Date());
event.setOccurredDate(new Date());
event.setDueDate(new Date());
event.setEnrollment(enrollment);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ public org.hisp.dhis.dxf2.deprecated.tracker.event.Event getEvent(
event.setEnrollmentStatus(
EnrollmentStatus.fromProgramStatus(programStageInstance.getEnrollment().getStatus()));
event.setStatus(programStageInstance.getStatus());
event.setEventDate(DateUtils.getIso8601NoTz(programStageInstance.getExecutionDate()));
event.setEventDate(DateUtils.getIso8601NoTz(programStageInstance.getOccurredDate()));
event.setDueDate(DateUtils.getIso8601NoTz(programStageInstance.getDueDate()));
event.setStoredBy(programStageInstance.getStoredBy());
event.setCompletedBy(programStageInstance.getCompletedBy());
Expand Down Expand Up @@ -826,7 +826,7 @@ public void updateEventForEventDate(org.hisp.dhis.dxf2.deprecated.tracker.event.
}

programStageInstance.setOrganisationUnit(organisationUnit);
programStageInstance.setExecutionDate(executionDate);
programStageInstance.setOccurredDate(executionDate);
eventService.updateEvent(programStageInstance);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@

import static java.util.stream.Collectors.toList;
import static org.apache.commons.collections4.CollectionUtils.isNotEmpty;
import static org.hisp.dhis.common.OrganisationUnitSelectionMode.ACCESSIBLE;
import static org.hisp.dhis.common.OrganisationUnitSelectionMode.CAPTURE;
import static org.hisp.dhis.common.OrganisationUnitSelectionMode.CHILDREN;
import static org.hisp.dhis.common.OrganisationUnitSelectionMode.DESCENDANTS;
import static org.hisp.dhis.common.OrganisationUnitSelectionMode.SELECTED;
import static org.hisp.dhis.common.ValueType.NUMERIC_TYPES;
import static org.hisp.dhis.dxf2.deprecated.tracker.event.AbstractEventService.STATIC_EVENT_COLUMNS;
import static org.hisp.dhis.dxf2.deprecated.tracker.event.EventSearchParams.EVENT_ATTRIBUTE_OPTION_COMBO_ID;
Expand Down Expand Up @@ -1947,7 +1942,7 @@ private void bindEventParamsForInsert(PreparedStatement ps, Event event)
ps.setLong(1, event.getEnrollment().getId());
ps.setLong(2, event.getProgramStage().getId());
ps.setTimestamp(3, JdbcEventSupport.toTimestamp(event.getDueDate()));
ps.setTimestamp(4, JdbcEventSupport.toTimestamp(event.getExecutionDate()));
ps.setTimestamp(4, JdbcEventSupport.toTimestamp(event.getOccurredDate()));
ps.setLong(5, event.getOrganisationUnit().getId());
ps.setString(6, event.getStatus().toString());
ps.setTimestamp(7, JdbcEventSupport.toTimestamp(event.getCompletedDate()));
Expand Down Expand Up @@ -1982,7 +1977,7 @@ private MapSqlParameterSource getSqlParametersForUpdate(org.hisp.dhis.program.Ev
JdbcEventSupport.toTimestamp(event.getDueDate()))
.addValue(
EventQuery.COLUMNS.EXECUTION_DATE.getColumnName(),
JdbcEventSupport.toTimestamp(event.getExecutionDate()))
JdbcEventSupport.toTimestamp(event.getOccurredDate()))
.addValue("organisationunitid", event.getOrganisationUnit().getId())
.addValue(EventQuery.COLUMNS.STATUS.getColumnName(), event.getStatus().toString())
.addValue(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public Map<String, Event> get(
psi.setProgramStage(getProgramStage(importOptions, rs.getLong("programstageid")));
psi.setOrganisationUnit(getOu(rs));
psi.setDueDate(rs.getTimestamp("duedate"));
psi.setExecutionDate(rs.getTimestamp("executiondate"));
psi.setOccurredDate(rs.getTimestamp("executiondate"));
psi.setCompletedDate(rs.getTimestamp("completeddate"));
psi.setAttributeOptionCombo(getCatOptionCombo(rs));
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ private Optional<OrganisationUnit> getOrganisationUnit(
private void setExecutionDate(
org.hisp.dhis.dxf2.deprecated.tracker.event.Event event, Event psi) {
if (event.getEventDate() != null) {
psi.setExecutionDate(parseDate(event.getEventDate()));
psi.setOccurredDate(parseDate(event.getEventDate()));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void process(

if (programStageInstance != null) {
if (event.getEventDate() != null) {
programStageInstance.setExecutionDate(parseDate(event.getEventDate()));
programStageInstance.setOccurredDate(parseDate(event.getEventDate()));
}

if (categoryOptionCombo != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,11 @@ private ImportSummary checkEventOrPsiExpirationDate(
if (programStageInstance != null) {
Date today = new Date();

if (programStageInstance.getExecutionDate() == null) {
if (programStageInstance.getOccurredDate() == null) {
return error("Event needs to have event date", event.getEvent());
}

Period period = periodType.createPeriod(programStageInstance.getExecutionDate());
Period period = periodType.createPeriod(programStageInstance.getOccurredDate());
if (!Period.isDateInTimeFrame(
null, addDays(period.getEndDate(), program.getExpiryDays()), today)) {
return error(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ void failWhenProgramStageInstanceHasExecutionDateBeforeAllowedProgramExpiryDaysB
Map<String, Event> psiMap = new HashMap<>();
Event psi = new Event();
// month length + 5
psi.setExecutionDate(getTodayMinusDays(35));
psi.setOccurredDate(getTodayMinusDays(35));
// days
psi.setUid(event.getUid());
psiMap.put(event.getUid(), psi);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ public RuleEvent toMappedRuleEvent(Event eventToEvaluate) {
eventToEvaluate.getUid(),
eventToEvaluate.getProgramStage().getUid(),
RuleEvent.Status.valueOf(eventToEvaluate.getStatus().toString()),
ObjectUtils.defaultIfNull(eventToEvaluate.getExecutionDate(), eventToEvaluate.getDueDate()),
ObjectUtils.defaultIfNull(eventToEvaluate.getOccurredDate(), eventToEvaluate.getDueDate()),
eventToEvaluate.getDueDate(),
orgUnit,
orgUnitCode,
Expand All @@ -449,7 +449,7 @@ public RuleEvent toMappedRuleEvent(Event eventToEvaluate) {
dv ->
RuleDataValue.create(
ObjectUtils.defaultIfNull(
eventToEvaluate.getExecutionDate(), eventToEvaluate.getDueDate()),
eventToEvaluate.getOccurredDate(), eventToEvaluate.getDueDate()),
eventToEvaluate.getProgramStage().getUid(),
dv.getDataElement(),
dv.getValue()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -475,13 +475,13 @@ private void setUpProgramRules() {
eventA.setOrganisationUnit(organisationUnit);
eventA.setAutoFields();
eventA.setDueDate(new Date());
eventA.setExecutionDate(new Date());
eventA.setOccurredDate(new Date());
eventA.setEventDataValues(Sets.newHashSet(eventDataValueA));

eventB.setOrganisationUnit(organisationUnit);
eventB.setAutoFields();
eventB.setDueDate(new Date());
eventB.setExecutionDate(new Date());
eventB.setOccurredDate(new Date());
eventB.setEventDataValues(Sets.newHashSet(eventDataValueB));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public Event getEvent(@Nonnull Event event, EventParams eventParams) throws Forb
result.setUid(event.getUid());

result.setStatus(event.getStatus());
result.setExecutionDate(event.getExecutionDate());
result.setOccurredDate(event.getOccurredDate());
result.setDueDate(event.getDueDate());
result.setStoredBy(event.getStoredBy());
result.setCompletedBy(event.getCompletedBy());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ public class EventOperationParams {

private String trackedEntityUid;

private Date startDate;
private Date occurredAfter;

private Date endDate;
private Date occurredBefore;

private EventStatus eventStatus;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ public EventQueryParams map(EventOperationParams operationParams)
.setAssignedUserQueryParam(
new AssignedUserQueryParam(
operationParams.getAssignedUserMode(), user, operationParams.getAssignedUsers()))
.setStartDate(operationParams.getStartDate())
.setEndDate(operationParams.getEndDate())
.setOccurredStartDate(operationParams.getOccurredAfter())
.setOccurredEndDate(operationParams.getOccurredBefore())
.setScheduleAtStartDate(operationParams.getScheduledAfter())
.setScheduleAtEndDate(operationParams.getScheduledBefore())
.setUpdatedAtStartDate(operationParams.getUpdatedAfter())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ class EventQueryParams {

private TrackedEntity trackedEntity;

private Date startDate;
private Date occurredStartDate;

private Date endDate;
private Date occurredEndDate;

private EventStatus eventStatus;

Expand Down Expand Up @@ -267,21 +267,21 @@ public EventQueryParams setTrackedEntity(TrackedEntity trackedEntity) {
return this;
}

public Date getStartDate() {
return startDate;
public Date getOccurredStartDate() {
return occurredStartDate;
}

public EventQueryParams setStartDate(Date startDate) {
this.startDate = startDate;
public EventQueryParams setOccurredStartDate(Date occurredStartDate) {
this.occurredStartDate = occurredStartDate;
return this;
}

public Date getEndDate() {
return endDate;
public Date getOccurredEndDate() {
return occurredEndDate;
}

public EventQueryParams setEndDate(Date endDate) {
this.endDate = endDate;
public EventQueryParams setOccurredEndDate(Date occurredEndDate) {
this.occurredEndDate = occurredEndDate;
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ class JdbcEventStore implements EventStore {
entry("enrollment.enrollmentDate", COLUMN_ENROLLMENT_DATE),
entry("organisationUnit.uid", COLUMN_ORG_UNIT_UID),
entry("enrollment.trackedEntity.uid", COLUMN_TRACKEDENTITY_UID),
entry("executionDate", COLUMN_EVENT_EXECUTION_DATE),
entry("occurredDate", COLUMN_EVENT_EXECUTION_DATE),
entry("enrollment.followUp", COLUMN_ENROLLMENT_FOLLOWUP),
entry("status", COLUMN_EVENT_STATUS),
entry("dueDate", COLUMN_EVENT_DUE_DATE),
Expand Down Expand Up @@ -325,7 +325,7 @@ private List<Event> fetchEvents(EventQueryParams queryParams, PageParams pagePar

event.setStoredBy(resultSet.getString(COLUMN_EVENT_STORED_BY));
event.setDueDate(resultSet.getTimestamp(COLUMN_EVENT_DUE_DATE));
event.setExecutionDate(resultSet.getTimestamp(COLUMN_EVENT_EXECUTION_DATE));
event.setOccurredDate(resultSet.getTimestamp(COLUMN_EVENT_EXECUTION_DATE));
event.setCreated(resultSet.getTimestamp(COLUMN_EVENT_CREATED));
event.setCreatedByUserInfo(
EventUtils.jsonToUserInfo(
Expand Down Expand Up @@ -977,8 +977,8 @@ private StringBuilder getFromWhereClause(
fromBuilder.append(hlp.whereAnd()).append(orgUnitSql);
}

if (params.getStartDate() != null) {
mapSqlParameterSource.addValue("startDate", params.getStartDate(), Types.DATE);
if (params.getOccurredStartDate() != null) {
mapSqlParameterSource.addValue("startDate", params.getOccurredStartDate(), Types.DATE);

fromBuilder
.append(hlp.whereAnd())
Expand All @@ -989,8 +989,9 @@ private StringBuilder getFromWhereClause(
.append(" )) ");
}

if (params.getEndDate() != null) {
mapSqlParameterSource.addValue("endDate", addDays(params.getEndDate(), 1), Types.DATE);
if (params.getOccurredEndDate() != null) {
mapSqlParameterSource.addValue(
"endDate", addDays(params.getOccurredEndDate(), 1), Types.DATE);

fromBuilder
.append(hlp.whereAnd())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ private Event getEvent(ResultSet rs) throws SQLException {
event.setId(rs.getLong(EventQuery.getColumnName(COLUMNS.ID)));

event.setStatus(EventStatus.valueOf(rs.getString(EventQuery.getColumnName(COLUMNS.STATUS))));
event.setExecutionDate(rs.getTimestamp(EventQuery.getColumnName(COLUMNS.EXECUTION_DATE)));
event.setOccurredDate(rs.getTimestamp(EventQuery.getColumnName(COLUMNS.EXECUTION_DATE)));
event.setDueDate(rs.getTimestamp(EventQuery.getColumnName(COLUMNS.DUE_DATE)));
event.setStoredBy(rs.getString(EventQuery.getColumnName(COLUMNS.STOREDBY)));
event.setCompletedBy(rs.getString(EventQuery.getColumnName(COLUMNS.COMPLETEDBY)));
Expand Down
Loading
Loading