use of org.hisp.dhis.dataset.DataSet in project dhis2-core by dhis2.
the class UndoCompleteAction method execute.
@Override
public String execute() throws Exception {
OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit(organisationUnitId);
Period period = periodService.getPeriod(isoPeriod);
DataSet dataSet = dataSetService.getDataSet(dataSetId);
//TODO
DataElementCategoryOptionCombo optionCombo = categoryService.getDefaultDataElementCategoryOptionCombo();
CompleteDataSetRegistration registration = registrationService.getCompleteDataSetRegistration(dataSet, period, organisationUnit, optionCombo);
if (registration != null) {
registrationService.deleteCompleteDataSetRegistration(registration);
}
return SUCCESS;
}
use of org.hisp.dhis.dataset.DataSet in project dhis2-core by dhis2.
the class DataSetReportController method getDataSetReport.
@RequestMapping(method = RequestMethod.GET)
public void getDataSetReport(HttpServletResponse response, @RequestParam String ds, @RequestParam String pe, @RequestParam String ou, @RequestParam(required = false) Set<String> dimension, @RequestParam(required = false) boolean selectedUnitOnly, @RequestParam(required = false) String type) throws Exception {
OrganisationUnit selectedOrgunit = idObjectManager.get(OrganisationUnit.class, ou);
DataSet selectedDataSet = dataSetService.getDataSet(ds);
Period selectedPeriod = PeriodType.getPeriodFromIsoString(pe);
if (selectedOrgunit == null) {
throw new WebMessageException(WebMessageUtils.conflict("Illegal organisation unit identifier: " + ou));
}
if (selectedDataSet == null) {
throw new WebMessageException(WebMessageUtils.conflict("Illegal data set identifier: " + ds));
}
if (selectedPeriod == null) {
throw new WebMessageException(WebMessageUtils.conflict("Illegal period identifier: " + pe));
}
selectedPeriod = periodService.reloadPeriod(selectedPeriod);
String customDataEntryFormCode = null;
List<Grid> grids = new ArrayList<>();
FormType formType = selectedDataSet.getFormType();
// ---------------------------------------------------------------------
// Configure response
// ---------------------------------------------------------------------
contextUtils.configureResponse(response, ContextUtils.CONTENT_TYPE_HTML, CacheStrategy.RESPECT_SYSTEM_SETTING);
if (formType.isCustom()) {
if (type != null) {
grids = dataSetReportService.getCustomDataSetReportAsGrid(selectedDataSet, selectedPeriod, selectedOrgunit, dimension, selectedUnitOnly, i18nManager.getI18nFormat());
} else {
customDataEntryFormCode = dataSetReportService.getCustomDataSetReport(selectedDataSet, selectedPeriod, selectedOrgunit, dimension, selectedUnitOnly, i18nManager.getI18nFormat());
}
} else if (formType.isSection()) {
grids = dataSetReportService.getSectionDataSetReport(selectedDataSet, selectedPeriod, selectedOrgunit, dimension, selectedUnitOnly, i18nManager.getI18nFormat(), i18nManager.getI18n());
} else {
grids = dataSetReportService.getDefaultDataSetReport(selectedDataSet, selectedPeriod, selectedOrgunit, dimension, selectedUnitOnly, i18nManager.getI18nFormat(), i18nManager.getI18n());
}
// ---------------------------------------------------------------------
// Write response
// ---------------------------------------------------------------------
Writer output = response.getWriter();
if (formType.isCustom() && type == null) {
IOUtils.write(customDataEntryFormCode, output);
} else {
for (Grid grid : grids) {
GridUtils.toHtmlCss(grid, output);
}
}
}
use of org.hisp.dhis.dataset.DataSet in project dhis2-core by dhis2.
the class DataApprovalController method getDataApprovalList.
private List<DataApproval> getDataApprovalList(Approvals approvals) throws WebMessageException {
List<DataSet> dataSets = objectManager.getByUid(DataSet.class, approvals.getDs());
List<Period> periods = PeriodType.getPeriodsFromIsoStrings(approvals.getPe());
periods = periodService.reloadPeriods(periods);
User user = currentUserService.getCurrentUser();
DataElementCategoryOptionCombo defaultOptionCombo = categoryService.getDefaultDataElementCategoryOptionCombo();
Date date = new Date();
// Avoid duplicates when different data sets have the same work flow
Set<DataApproval> set = new HashSet<>();
for (DataSet dataSet : dataSets) {
if (dataSet.getWorkflow() == null) {
throw new WebMessageException(WebMessageUtils.conflict("DataSet has no approval workflow: " + dataSet.getName()));
}
Set<DataElementCategoryOptionCombo> dataSetOptionCombos = dataSet.getCategoryCombo() != null ? dataSet.getCategoryCombo().getOptionCombos() : null;
for (Approval approval : approvals.getApprovals()) {
OrganisationUnit unit = organisationUnitService.getOrganisationUnit(approval.getOu());
DataElementCategoryOptionCombo optionCombo = categoryService.getDataElementCategoryOptionCombo(approval.getAoc());
optionCombo = ObjectUtils.firstNonNull(optionCombo, defaultOptionCombo);
for (Period period : periods) {
if (dataSetOptionCombos != null && dataSetOptionCombos.contains(optionCombo)) {
DataApproval dataApproval = new DataApproval(null, dataSet.getWorkflow(), period, unit, optionCombo, false, date, user);
set.add(dataApproval);
}
}
}
}
return new ArrayList<>(set);
}
use of org.hisp.dhis.dataset.DataSet in project dhis2-core by dhis2.
the class DataSetController method getVersion.
@RequestMapping(value = "/{uid}/version", method = RequestMethod.GET)
public void getVersion(@PathVariable("uid") String uid, @RequestParam Map<String, String> parameters, HttpServletResponse response) throws Exception {
DataSet dataSet = manager.get(DataSet.class, uid);
if (dataSet == null) {
throw new WebMessageException(WebMessageUtils.conflict("Data set does not exist: " + uid));
}
Map<String, Integer> versionMap = new HashMap<>();
versionMap.put("version", dataSet.getVersion());
renderService.toJson(response.getOutputStream(), versionMap);
}
use of org.hisp.dhis.dataset.DataSet in project dhis2-core by dhis2.
the class DataApprovalController method removeApproval.
// -------------------------------------------------------------------------
// Delete
// -------------------------------------------------------------------------
@PreAuthorize("hasRole('ALL') or hasRole('F_APPROVE_DATA') or hasRole('F_APPROVE_DATA_LOWER_LEVELS')")
@RequestMapping(value = APPROVALS_PATH, method = RequestMethod.DELETE)
@ResponseStatus(HttpStatus.NO_CONTENT)
public void removeApproval(@RequestParam Set<String> ds, @RequestParam String pe, @RequestParam String ou, HttpServletResponse response) throws WebMessageException {
Set<DataSet> dataSets = parseDataSetsWithWorkflow(ds);
if (dataSets.size() != ds.size()) {
throw new WebMessageException(WebMessageUtils.conflict("Illegal data set identifier in this list: " + ds));
}
Period period = getAndValidatePeriod(pe);
OrganisationUnit organisationUnit = getAndValidateOrgUnit(ou);
DataApprovalLevel dataApprovalLevel = getAndValidateApprovalLevel(organisationUnit);
User user = currentUserService.getCurrentUser();
List<DataApproval> dataApprovalList = newArrayList();
for (DataSet dataSet : dataSets) {
dataApprovalList.addAll(getApprovalsAsList(dataApprovalLevel, dataSet.getWorkflow(), period, organisationUnit, false, new Date(), user));
}
dataApprovalService.unapproveData(dataApprovalList);
}
Aggregations