use of org.hisp.dhis.common.DimensionalItemObject in project dhis2-core by dhis2.
the class EnrollmentAnalyticsManagerTest method verifyGetColumnOfTypeCoordinateAndWithProgramStagesAndParamsWithReferenceTypeValue.
@Test
void verifyGetColumnOfTypeCoordinateAndWithProgramStagesAndParamsWithReferenceTypeValue() {
// Given
DimensionalItemObject dio = new BaseDimensionalItemObject(dataElementA.getUid());
QueryItem item = new QueryItem(dio);
item.setValueType(ValueType.COORDINATE);
item.setProgramStage(programStageWithRepeatableParams);
item.setProgram(programB);
RepeatableStageParams repeatableStageParams = new RepeatableStageParams();
repeatableStageParams.setStartIndex(0);
repeatableStageParams.setCount(100);
repeatableStageParams.setStartDate(DateUtils.parseDate("2022-01-01"));
repeatableStageParams.setEndDate(DateUtils.parseDate("2022-01-31"));
item.setRepeatableStageParams(repeatableStageParams);
// When
String columnSql = subject.getColumn(item);
// Then
assertThat(columnSql, is("(select json_agg(t1) from (select \"" + dataElementA.getUid() + "\", incidentdate, duedate, executiondate from analytics_event_" + programB.getUid() + " where analytics_event_" + programB.getUid() + ".pi = ax.pi and \"" + dataElementA.getUid() + "\" is not null and ps = '" + programStageWithRepeatableParams.getUid() + "' and executiondate >= '2022-01-01' and executiondate <= '2022-01-31' order by executiondate desc LIMIT 100 ) as t1)"));
}
use of org.hisp.dhis.common.DimensionalItemObject in project dhis2-core by dhis2.
the class EnrollmentAnalyticsManagerTest method verifyGetCoordinateColumnWithNoProgram.
@Test
void verifyGetCoordinateColumnWithNoProgram() {
// Given
DimensionalItemObject dio = new BaseDimensionalItemObject(dataElementA.getUid());
QueryItem item = new QueryItem(dio);
item.setValueType(ValueType.COORDINATE);
item.setProgramStage(programStage);
// When
String columnSql = subject.getCoordinateColumn(item);
// Then
assertThat(columnSql, is(EMPTY));
}
use of org.hisp.dhis.common.DimensionalItemObject in project dhis2-core by dhis2.
the class EventAnalyticsTest method createRequestParams.
protected EventQueryParams createRequestParams(ProgramStage withProgramStage, ValueType withQueryItemValueType) {
EventQueryParams.Builder params = new EventQueryParams.Builder(_createRequestParams());
DimensionalItemObject dio = new BaseDimensionalItemObject(dataElementA.getUid());
params.withProgram(programA);
if (withProgramStage != null) {
params.withProgramStage(programStage);
}
if (withQueryItemValueType != null) {
QueryItem queryItem = new QueryItem(dio);
if (withProgramStage != null) {
queryItem.setProgramStage(programStage);
}
queryItem.setProgram(programA);
queryItem.setValueType(withQueryItemValueType);
params.addItem(queryItem);
}
return params.build();
}
use of org.hisp.dhis.common.DimensionalItemObject in project dhis2-core by dhis2.
the class EventDataQueryServiceTest method testSetItemsForDimensionFilters.
@Test
void testSetItemsForDimensionFilters() {
TrackedEntityAttribute tea = new TrackedEntityAttribute();
tea.setAutoFields();
TrackedEntityAttributeDimension tead = new TrackedEntityAttributeDimension(tea, null, "EQ:2");
EventChart eventChart = new EventChart();
eventChart.setAutoFields();
eventChart.getColumnDimensions().add(tea.getUid());
eventChart.getAttributeDimensions().add(tead);
Grid grid = new ListGrid();
grid.addHeader(new GridHeader(tea.getUid(), tea.getName()));
grid.addRow().addValue("1");
grid.addRow().addValue("2");
grid.addRow().addValue("3");
grid.addRow().addValue(null);
eventChart.populateAnalyticalProperties();
DimensionalObject dim = eventChart.getColumns().get(0);
DimensionalObjectUtils.setDimensionItemsForFilters(dim, grid, true);
assertNotNull(dim);
assertEquals(DimensionType.PROGRAM_ATTRIBUTE, dim.getDimensionType());
assertEquals(AnalyticsType.EVENT, dim.getAnalyticsType());
assertEquals(tead.getFilter(), dim.getFilter());
List<DimensionalItemObject> items = dim.getItems();
assertEquals(4, items.size());
assertNotNull(items.get(0).getUid());
assertNotNull(items.get(0).getName());
assertNotNull(items.get(0).getCode());
assertNotNull(items.get(0).getShortName());
}
use of org.hisp.dhis.common.DimensionalItemObject in project dhis2-core by dhis2.
the class QueryPlannerTest method testGetDataPeriodAggregationPeriodMap.
@Test
void testGetDataPeriodAggregationPeriodMap() {
DataQueryParams params = DataQueryParams.newBuilder().withDataElements(getList(deA, deB, deC, deD)).withOrganisationUnits(getList(ouA, ouB, ouC, ouD, ouE)).withPeriods(getList(createPeriod("2000Q1"), createPeriod("2000Q2"), createPeriod("2000Q3"), createPeriod("2000Q4"), createPeriod("2001Q1"), createPeriod("2001Q2"))).withPeriodType(QuarterlyPeriodType.NAME).withDataPeriodType(new YearlyPeriodType()).build();
ListMap<DimensionalItemObject, DimensionalItemObject> map = params.getDataPeriodAggregationPeriodMap();
assertEquals(2, map.size());
assertTrue(map.containsKey(createPeriod("2000")));
assertTrue(map.containsKey(createPeriod("2001")));
assertEquals(4, map.get(createPeriod("2000")).size());
assertEquals(2, map.get(createPeriod("2001")).size());
assertTrue(map.get(createPeriod("2000")).contains(createPeriod("2000Q1")));
assertTrue(map.get(createPeriod("2000")).contains(createPeriod("2000Q2")));
assertTrue(map.get(createPeriod("2000")).contains(createPeriod("2000Q3")));
assertTrue(map.get(createPeriod("2000")).contains(createPeriod("2000Q4")));
assertTrue(map.get(createPeriod("2001")).contains(createPeriod("2001Q1")));
assertTrue(map.get(createPeriod("2001")).contains(createPeriod("2001Q2")));
}
Aggregations