use of org.hisp.dhis.reporttable.ReportTable in project dhis2-core by dhis2.
the class DimensionServiceTest method testMergeAnalyticalObject.
@Test
public void testMergeAnalyticalObject() {
ReportTable reportTable = new ReportTable();
reportTable.getColumns().add(new BaseDimensionalObject(DimensionalObject.DATA_X_DIM_ID, DimensionType.DATA_X, Lists.newArrayList(deA, deB)));
reportTable.getRows().add(new BaseDimensionalObject(DimensionalObject.ORGUNIT_DIM_ID, DimensionType.ORGANISATION_UNIT, Lists.newArrayList(ouA, ouB, ouC, ouD, ouE)));
reportTable.getFilters().add(new BaseDimensionalObject(DimensionalObject.PERIOD_DIM_ID, DimensionType.PERIOD, Lists.newArrayList(peA, peB)));
dimensionService.mergeAnalyticalObject(reportTable);
assertEquals(2, reportTable.getDataDimensionItems().size());
assertEquals(2, reportTable.getPeriods().size());
assertEquals(5, reportTable.getOrganisationUnits().size());
}
use of org.hisp.dhis.reporttable.ReportTable in project dhis2-core by dhis2.
the class InterpretationController method writeReportTableInterpretation.
// -------------------------------------------------------------------------
// Intepretation create
// -------------------------------------------------------------------------
@RequestMapping(value = "/reportTable/{uid}", method = RequestMethod.POST, consumes = { "text/html", "text/plain" })
public void writeReportTableInterpretation(@PathVariable("uid") String reportTableUid, @RequestParam(value = "pe", required = false) String isoPeriod, @RequestParam(value = "ou", required = false) String orgUnitUid, @RequestBody String text, HttpServletResponse response, HttpServletRequest request) throws WebMessageException {
ReportTable reportTable = idObjectManager.get(ReportTable.class, reportTableUid);
if (reportTable == null) {
throw new WebMessageException(WebMessageUtils.conflict("Report table does not exist or is not accessible: " + reportTableUid));
}
Period period = PeriodType.getPeriodFromIsoString(isoPeriod);
OrganisationUnit orgUnit = getUserOrganisationUnit(orgUnitUid, reportTable, currentUserService.getCurrentUser());
createIntepretation(new Interpretation(reportTable, period, orgUnit, text), request, response);
}
use of org.hisp.dhis.reporttable.ReportTable in project dhis2-core by dhis2.
the class GetReportParamsAction method execute.
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@Override
public String execute() {
User user = currentUserService.getCurrentUser();
selectionTreeManager.setSelectedOrganisationUnit(user.getOrganisationUnit());
if (uid != null) {
ReportTable reportTable = reportTableService.getReportTable(uid, ReportTableService.MODE_REPORT_TABLE);
if (reportTable != null) {
reportParams = reportTable.getReportParams();
if (reportParams.isParamReportingMonth() && reportTable.getRelatives() != null) {
CalendarPeriodType periodType = (CalendarPeriodType) reportTable.getRelatives().getPeriodType();
periods = periodType.generateLast5Years(new Date());
Collections.reverse(periods);
FilterUtils.filter(periods, new PastAndCurrentPeriodFilter());
for (Period period : periods) {
period.setName(format.formatPeriod(period));
}
}
}
}
return SUCCESS;
}
use of org.hisp.dhis.reporttable.ReportTable in project dhis2-core by dhis2.
the class DefaultReportTableService method getReportTableGridByUser.
@Override
public Grid getReportTableGridByUser(String uid, Date reportingPeriod, String organisationUnitUid, User user) {
I18nFormat format = i18nManager.getI18nFormat();
ReportTable reportTable = getReportTable(uid);
OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit(organisationUnitUid);
List<OrganisationUnit> atLevels = new ArrayList<>();
List<OrganisationUnit> inGroups = new ArrayList<>();
if (reportTable.hasOrganisationUnitLevels()) {
atLevels.addAll(organisationUnitService.getOrganisationUnitsAtLevels(reportTable.getOrganisationUnitLevels(), reportTable.getOrganisationUnits()));
}
if (reportTable.hasItemOrganisationUnitGroups()) {
inGroups.addAll(organisationUnitService.getOrganisationUnits(reportTable.getItemOrganisationUnitGroups(), reportTable.getOrganisationUnits()));
}
reportTable.init(user, reportingPeriod, organisationUnit, atLevels, inGroups, format);
Map<String, Object> valueMap = analyticsService.getAggregatedDataValueMapping(reportTable);
Grid reportTableGrid = reportTable.getGrid(new ListGrid(), valueMap, DisplayProperty.SHORTNAME, true);
reportTable.clearTransientState();
return reportTableGrid;
}
use of org.hisp.dhis.reporttable.ReportTable in project dhis2-core by dhis2.
the class GetReportParamsAction method execute.
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@Override
public String execute() {
if (mode == null || uid == null) {
return SUCCESS;
}
RelativePeriods relatives = null;
if (MODE_REPORT_TABLE.equals(mode)) {
ReportTable reportTable = reportTableService.getReportTable(uid);
if (reportTable != null) {
reportParams = reportTable.getReportParams();
relatives = reportTable.getRelatives();
}
} else if (MODE_REPORT.equals(mode)) {
Report report = reportService.getReport(uid);
if (report != null && report.isTypeReportTable()) {
reportParams = report.getReportTable().getReportParams();
relatives = report.getReportTable().getRelatives();
} else if (report != null && (report.isTypeJdbc() || report.isTypeHtml())) {
reportParams = report.getReportParams();
relatives = report.getRelatives();
}
if (type == null && report != null) {
// Set type based on report
type = report.getType();
}
}
if (reportParams != null && reportParams.isParamReportingMonth() && relatives != null) {
CalendarPeriodType periodType = (CalendarPeriodType) relatives.getPeriodType();
List<Period> periods = periodType.generateLast5Years(new Date());
Collections.reverse(periods);
FilterUtils.filter(periods, new PastAndCurrentPeriodFilter());
Calendar calendar = PeriodType.getCalendar();
for (Period period_ : periods) {
BaseIdentifiableObject period = new BaseIdentifiableObject();
if (calendar.isIso8601()) {
period.setUid(period_.getIsoDate());
period.setDisplayName(format.formatPeriod(period_));
} else {
DateTimeUnit dateTimeUnit = calendar.fromIso(period_.getStartDate());
period.setUid(period_.getPeriodType().getIsoDate(dateTimeUnit));
period.setDisplayName(format.formatPeriod(period_));
}
this.periods.add(period);
}
}
return SUCCESS;
}
Aggregations