Skip to content

Commit

Permalink
fix: Missing support for headers + NPE/clean-up [DHIS2-16065] (#15865)
Browse files Browse the repository at this point in the history
* fix: Missing sup. for headers + NPE/clean-up [DHIS2-16065]

* fix: Dependency issue + unit tests [DHIS2-16065]

* fix: Columns and headers names [DHIS2-16065]

* fix: Missing Javadoc [DHIS2-16065]

* test: Fix typos [DHIS2-16065]

* fix: Code formatting [DHIS2-16065]

* test: Fix e2e header [DHIS2-16065]

* fix: Code formatting [DHIS2-16065]
  • Loading branch information
maikelarabori authored Dec 11, 2023
1 parent df7e1f5 commit 1390944
Show file tree
Hide file tree
Showing 21 changed files with 389 additions and 323 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ public static List<Period> getPeriodTypePeriods(

/**
* Returns the ISO period name for the given {@link ResultSet} row. Requires that a column <code>
* pe_start_date</code> of type date and a column <code>pt_name</code> are present.
* startDate</code> of type date and a column <code>periodType</code> are present.
*
* @param calendar the {@link Calendar}.
* @param rs the {@link ResultSet}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,35 +36,6 @@
* @author Markus Bekken
*/
public interface EnrollmentAnalyticsService {
String ITEM_TEI = "tei";

String ITEM_PI = "pi";

String ITEM_ENROLLMENT_DATE = "enrollmentdate";

String ITEM_INCIDENT_DATE = "incidentdate";

String ITEM_STORED_BY = "storedby";

String ITEM_CREATED_BY_DISPLAY_NAME = "createdbydisplayname";

String ITEM_LAST_UPDATED_BY_DISPLAY_NAME = "lastupdatedbydisplayname";

String ITEM_LAST_UPDATED = "lastupdated";

String ITEM_GEOMETRY = "geometry";

String ITEM_LONGITUDE = "longitude";

String ITEM_LATITUDE = "latitude";

String ITEM_ORG_UNIT_NAME = "ouname";

String ITEM_ORG_UNIT_NAME_HIERARCHY = "ounamehierarchy";

String ITEM_ORG_UNIT_CODE = "oucode";

String ITEM_PROGRAM_STATUS = "programstatus";

/**
* Returns a list of enrollments matching the given query.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,53 +40,6 @@
* @author Lars Helge Overland
*/
public interface EventAnalyticsService {
String ITEM_EVENT = "psi";

String ITEM_TRACKED_ENTITY_INSTANCE = "tei";

String ITEM_PROGRAM_INSTANCE = "pi";

String ITEM_PROGRAM_STAGE = "ps";

String ITEM_EVENT_DATE = "eventdate";

String ITEM_STORED_BY = "storedby";

String ITEM_CREATED_BY_DISPLAY_NAME = "createdbydisplayname";

String ITEM_LAST_UPDATED_BY_DISPLAY_NAME = "lastupdatedbydisplayname";

String ITEM_LAST_UPDATED = "lastupdated";

String ITEM_SCHEDULED_DATE = "scheduleddate";

String ITEM_ENROLLMENT_DATE = "enrollmentdate";

String ITEM_INCIDENT_DATE = "incidentdate";

String ITEM_GEOMETRY = "geometry";

String ITEM_LONGITUDE = "longitude";

String ITEM_LATITUDE = "latitude";

String ITEM_ORG_UNIT_NAME = "ouname";

String ITEM_ORG_UNIT_NAME_HIERARCHY = "ounamehierarchy";

String ITEM_ORG_UNIT_CODE = "oucode";

String ITEM_COUNT = "count";

String ITEM_CENTER = "center";

String ITEM_EXTENT = "extent";

String ITEM_POINTS = "points";

String ITEM_PROGRAM_STATUS = "programstatus";

String ITEM_EVENT_STATUS = "eventstatus";

/**
* Generates aggregated event data for the given query.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,21 @@
import static com.google.common.base.Preconditions.checkNotNull;
import static org.hisp.dhis.analytics.DataQueryParams.VALUE_HEADER_NAME;
import static org.hisp.dhis.analytics.DataQueryParams.VALUE_ID;
import static org.hisp.dhis.analytics.common.ColumnHeader.CREATED_BY_DISPLAY_NAME;
import static org.hisp.dhis.analytics.common.ColumnHeader.ENROLLMENT;
import static org.hisp.dhis.analytics.common.ColumnHeader.ENROLLMENT_DATE;
import static org.hisp.dhis.analytics.common.ColumnHeader.GEOMETRY;
import static org.hisp.dhis.analytics.common.ColumnHeader.INCIDENT_DATE;
import static org.hisp.dhis.analytics.common.ColumnHeader.LAST_UPDATED;
import static org.hisp.dhis.analytics.common.ColumnHeader.LAST_UPDATED_BY_DISPLAY_NAME;
import static org.hisp.dhis.analytics.common.ColumnHeader.LATITUDE;
import static org.hisp.dhis.analytics.common.ColumnHeader.LONGITUDE;
import static org.hisp.dhis.analytics.common.ColumnHeader.ORG_UNIT_CODE;
import static org.hisp.dhis.analytics.common.ColumnHeader.ORG_UNIT_NAME;
import static org.hisp.dhis.analytics.common.ColumnHeader.ORG_UNIT_NAME_HIERARCHY;
import static org.hisp.dhis.analytics.common.ColumnHeader.PROGRAM_STATUS;
import static org.hisp.dhis.analytics.common.ColumnHeader.STORED_BY;
import static org.hisp.dhis.analytics.common.ColumnHeader.TEI;
import static org.hisp.dhis.common.ValueType.DATE;
import static org.hisp.dhis.common.ValueType.NUMBER;
import static org.hisp.dhis.common.ValueType.TEXT;
Expand Down Expand Up @@ -59,35 +74,6 @@
@Service("org.hisp.dhis.analytics.event.EnrollmentAnalyticsService")
public class DefaultEnrollmentAnalyticsService extends AbstractAnalyticsService
implements EnrollmentAnalyticsService {
private static final String NAME_TEI = "Tracked entity instance";

private static final String NAME_PI = "Enrollment";

private static final String NAME_GEOMETRY = "Geometry";

private static final String NAME_ENROLLMENT_DATE = "Enrollment date";

private static final String NAME_INCIDENT_DATE = "Incident date";

private static final String NAME_STORED_BY = "Stored by";

private static final String NAME_CREATED_BY_DISPLAY_NAME = "Created by";

private static final String NAME_LAST_UPDATED_BY_DISPLAY_NAME = "Last updated by";

private static final String NAME_LAST_UPDATED = "Last updated on";

private static final String NAME_LONGITUDE = "Longitude";

private static final String NAME_LATITUDE = "Latitude";

private static final String NAME_ORG_UNIT_NAME = "Organisation unit name";

private static final String NAME_ORG_UNIT_NAME_HIERARCHY = "Organisation unit name hierarchy";

private static final String NAME_ORG_UNIT_CODE = "Organisation unit code";

private static final String NAME_PROGRAM_STATUS = "Program status";

private final EnrollmentAnalyticsManager enrollmentAnalyticsManager;

Expand Down Expand Up @@ -127,43 +113,55 @@ protected Grid createGridWithHeaders(EventQueryParams params) {
}

return new ListGrid()
.addHeader(new GridHeader(ITEM_PI, NAME_PI, TEXT, false, true))
.addHeader(new GridHeader(ITEM_TEI, NAME_TEI, TEXT, false, true))
.addHeader(new GridHeader(ENROLLMENT.getItem(), ENROLLMENT.getName(), TEXT, false, true))
.addHeader(new GridHeader(TEI.getItem(), TEI.getName(), TEXT, false, true))
.addHeader(
new GridHeader(
ITEM_ENROLLMENT_DATE,
LabelMapper.getEnrollmentDateLabel(params.getProgram(), NAME_ENROLLMENT_DATE),
ENROLLMENT_DATE.getItem(),
LabelMapper.getEnrollmentDateLabel(params.getProgram(), ENROLLMENT_DATE.getName()),
DATE,
false,
true))
.addHeader(
new GridHeader(
ITEM_INCIDENT_DATE,
LabelMapper.getIncidentDateLabel(params.getProgram(), NAME_INCIDENT_DATE),
INCIDENT_DATE.getItem(),
LabelMapper.getIncidentDateLabel(params.getProgram(), INCIDENT_DATE.getName()),
DATE,
false,
true))
.addHeader(new GridHeader(ITEM_STORED_BY, NAME_STORED_BY, TEXT, false, true))
.addHeader(new GridHeader(STORED_BY.getItem(), STORED_BY.getName(), TEXT, false, true))
.addHeader(
new GridHeader(
ITEM_CREATED_BY_DISPLAY_NAME, NAME_CREATED_BY_DISPLAY_NAME, TEXT, false, true))
CREATED_BY_DISPLAY_NAME.getItem(),
CREATED_BY_DISPLAY_NAME.getName(),
TEXT,
false,
true))
.addHeader(
new GridHeader(
ITEM_LAST_UPDATED_BY_DISPLAY_NAME,
NAME_LAST_UPDATED_BY_DISPLAY_NAME,
LAST_UPDATED_BY_DISPLAY_NAME.getItem(),
LAST_UPDATED_BY_DISPLAY_NAME.getName(),
TEXT,
false,
true))
.addHeader(new GridHeader(ITEM_LAST_UPDATED, NAME_LAST_UPDATED, DATE, false, true))
.addHeader(new GridHeader(ITEM_GEOMETRY, NAME_GEOMETRY, TEXT, false, true))
.addHeader(new GridHeader(ITEM_LONGITUDE, NAME_LONGITUDE, NUMBER, false, true))
.addHeader(new GridHeader(ITEM_LATITUDE, NAME_LATITUDE, NUMBER, false, true))
.addHeader(new GridHeader(ITEM_ORG_UNIT_NAME, NAME_ORG_UNIT_NAME, TEXT, false, true))
.addHeader(
new GridHeader(LAST_UPDATED.getItem(), LAST_UPDATED.getName(), DATE, false, true))
.addHeader(new GridHeader(GEOMETRY.getItem(), GEOMETRY.getName(), TEXT, false, true))
.addHeader(new GridHeader(LONGITUDE.getItem(), LONGITUDE.getName(), NUMBER, false, true))
.addHeader(new GridHeader(LATITUDE.getItem(), LATITUDE.getName(), NUMBER, false, true))
.addHeader(
new GridHeader(ORG_UNIT_NAME.getItem(), ORG_UNIT_NAME.getName(), TEXT, false, true))
.addHeader(
new GridHeader(
ITEM_ORG_UNIT_NAME_HIERARCHY, NAME_ORG_UNIT_NAME_HIERARCHY, TEXT, false, true))
.addHeader(new GridHeader(ITEM_ORG_UNIT_CODE, NAME_ORG_UNIT_CODE, TEXT, false, true))
.addHeader(new GridHeader(ITEM_PROGRAM_STATUS, NAME_PROGRAM_STATUS, TEXT, false, true));
ORG_UNIT_NAME_HIERARCHY.getItem(),
ORG_UNIT_NAME_HIERARCHY.getName(),
TEXT,
false,
true))
.addHeader(
new GridHeader(ORG_UNIT_CODE.getItem(), ORG_UNIT_CODE.getName(), TEXT, false, true))
.addHeader(
new GridHeader(PROGRAM_STATUS.getItem(), PROGRAM_STATUS.getName(), TEXT, false, true));
}

@Override
Expand Down
Loading

0 comments on commit 1390944

Please sign in to comment.