use of org.hisp.dhis.dataelement.DataElementCategoryOptionCombo in project dhis2-core by dhis2.
the class EventController method getEventsGrid.
// -------------------------------------------------------------------------
// READ
// -------------------------------------------------------------------------
@RequestMapping(value = "/query", method = RequestMethod.GET, produces = { ContextUtils.CONTENT_TYPE_JSON, ContextUtils.CONTENT_TYPE_JAVASCRIPT })
@PreAuthorize("hasRole('ALL') or hasRole('F_TRACKED_ENTITY_DATAVALUE_ADD') or hasRole('F_TRACKED_ENTITY_DATAVALUE_READ')")
@ResponseBody
public Grid getEventsGrid(@RequestParam(required = false) String program, @RequestParam(required = false) String programStage, @RequestParam(required = false) ProgramStatus programStatus, @RequestParam(required = false) Boolean followUp, @RequestParam(required = false) String trackedEntityInstance, @RequestParam(required = false) String orgUnit, @RequestParam(required = false) OrganisationUnitSelectionMode ouMode, @RequestParam(required = false) Date startDate, @RequestParam(required = false) Date endDate, @RequestParam(required = false) Date dueDateStart, @RequestParam(required = false) Date dueDateEnd, @RequestParam(required = false) Date lastUpdated, @RequestParam(required = false) Date lastUpdatedStartDate, @RequestParam(required = false) Date lastUpdatedEndDate, @RequestParam(required = false) EventStatus status, @RequestParam(required = false) String attributeCc, @RequestParam(required = false) String attributeCos, @RequestParam(required = false) boolean skipMeta, @RequestParam(required = false) Integer page, @RequestParam(required = false) Integer pageSize, @RequestParam(required = false) boolean totalPages, @RequestParam(required = false) boolean skipPaging, @RequestParam(required = false) String order, @RequestParam(required = false) String attachment, @RequestParam(required = false, defaultValue = "false") boolean includeDeleted, @RequestParam(required = false) String event, @RequestParam(required = false) Set<String> filter, @RequestParam(required = false) Set<String> dataElement, @RequestParam Map<String, String> parameters, IdSchemes idSchemes, Model model, HttpServletResponse response, HttpServletRequest request) throws WebMessageException {
List<String> fields = Lists.newArrayList(contextService.getParameterValues("fields"));
if (fields.isEmpty()) {
fields.addAll(Preset.ALL.getFields());
}
boolean allowNoAttrOptionCombo = trackedEntityInstance != null && entityInstanceService.getTrackedEntityInstance(trackedEntityInstance) != null;
DataElementCategoryOptionCombo attributeOptionCombo = inputUtils.getAttributeOptionCombo(attributeCc, attributeCos, allowNoAttrOptionCombo);
if (attributeOptionCombo == null && !allowNoAttrOptionCombo) {
throw new WebMessageException(WebMessageUtils.conflict("Illegal attribute option combo identifier: " + attributeCc + " " + attributeCos));
}
Set<String> eventIds = TextUtils.splitToArray(event, TextUtils.SEMICOLON);
lastUpdatedStartDate = lastUpdatedStartDate != null ? lastUpdatedStartDate : lastUpdated;
EventSearchParams params = eventService.getFromUrl(program, programStage, programStatus, followUp, orgUnit, ouMode, trackedEntityInstance, startDate, endDate, dueDateStart, dueDateEnd, lastUpdatedStartDate, lastUpdatedEndDate, status, attributeOptionCombo, idSchemes, page, pageSize, totalPages, skipPaging, null, getGridOrderParams(order), false, eventIds, filter, dataElement, includeDeleted);
contextUtils.configureResponse(response, ContextUtils.CONTENT_TYPE_JSON, CacheStrategy.NO_CACHE);
return eventService.getEventsGrid(params);
}
use of org.hisp.dhis.dataelement.DataElementCategoryOptionCombo in project dhis2-core by dhis2.
the class EventController method getEventRows.
@RequestMapping(value = "/eventRows", method = RequestMethod.GET)
@PreAuthorize("hasRole('ALL') or hasRole('F_TRACKED_ENTITY_DATAVALUE_ADD') or hasRole('F_TRACKED_ENTITY_DATAVALUE_READ')")
@ResponseBody
public EventRows getEventRows(@RequestParam(required = false) String program, @RequestParam(required = false) String orgUnit, @RequestParam(required = false) OrganisationUnitSelectionMode ouMode, @RequestParam(required = false) ProgramStatus programStatus, @RequestParam(required = false) EventStatus eventStatus, @RequestParam(required = false) Date startDate, @RequestParam(required = false) Date endDate, @RequestParam(required = false) String attributeCc, @RequestParam(required = false) String attributeCos, @RequestParam(required = false) boolean totalPages, @RequestParam(required = false) boolean skipPaging, @RequestParam(required = false) String order, @RequestParam(required = false, defaultValue = "false") boolean includeDeleted, @RequestParam Map<String, String> parameters, Model model) throws WebMessageException {
DataElementCategoryOptionCombo attributeOptionCombo = inputUtils.getAttributeOptionCombo(attributeCc, attributeCos, true);
EventSearchParams params = eventService.getFromUrl(program, null, programStatus, null, orgUnit, ouMode, null, startDate, endDate, null, null, null, null, eventStatus, attributeOptionCombo, null, null, null, totalPages, skipPaging, getOrderParams(order), null, true, null, null, null, includeDeleted);
return eventRowService.getEventRows(params);
}
use of org.hisp.dhis.dataelement.DataElementCategoryOptionCombo in project dhis2-core by dhis2.
the class EventController method getEvents.
@RequestMapping(value = "", method = RequestMethod.GET)
@PreAuthorize("hasRole('ALL') or hasRole('F_TRACKED_ENTITY_DATAVALUE_ADD') or hasRole('F_TRACKED_ENTITY_DATAVALUE_READ')")
@ResponseBody
public RootNode getEvents(@RequestParam(required = false) String program, @RequestParam(required = false) String programStage, @RequestParam(required = false) ProgramStatus programStatus, @RequestParam(required = false) Boolean followUp, @RequestParam(required = false) String trackedEntityInstance, @RequestParam(required = false) String orgUnit, @RequestParam(required = false) OrganisationUnitSelectionMode ouMode, @RequestParam(required = false) Date startDate, @RequestParam(required = false) Date endDate, @RequestParam(required = false) Date dueDateStart, @RequestParam(required = false) Date dueDateEnd, @RequestParam(required = false) Date lastUpdated, @RequestParam(required = false) Date lastUpdatedStartDate, @RequestParam(required = false) Date lastUpdatedEndDate, @RequestParam(required = false) EventStatus status, @RequestParam(required = false) String attributeCc, @RequestParam(required = false) String attributeCos, @RequestParam(required = false) boolean skipMeta, @RequestParam(required = false) Integer page, @RequestParam(required = false) Integer pageSize, @RequestParam(required = false) boolean totalPages, @RequestParam(required = false) boolean skipPaging, @RequestParam(required = false) String order, @RequestParam(required = false) String attachment, @RequestParam(required = false, defaultValue = "false") boolean includeDeleted, @RequestParam(required = false) String event, @RequestParam Map<String, String> parameters, IdSchemes idSchemes, Model model, HttpServletResponse response, HttpServletRequest request) throws WebMessageException {
WebOptions options = new WebOptions(parameters);
List<String> fields = Lists.newArrayList(contextService.getParameterValues("fields"));
if (fields.isEmpty()) {
fields.addAll(Preset.ALL.getFields());
}
boolean allowNoAttrOptionCombo = trackedEntityInstance != null && entityInstanceService.getTrackedEntityInstance(trackedEntityInstance) != null;
DataElementCategoryOptionCombo attributeOptionCombo = inputUtils.getAttributeOptionCombo(attributeCc, attributeCos, allowNoAttrOptionCombo);
if (attributeOptionCombo == null && !allowNoAttrOptionCombo) {
throw new WebMessageException(WebMessageUtils.conflict("Illegal attribute option combo identifier: " + attributeCc + " " + attributeCos));
}
Set<String> eventIds = TextUtils.splitToArray(event, TextUtils.SEMICOLON);
lastUpdatedStartDate = lastUpdatedStartDate != null ? lastUpdatedStartDate : lastUpdated;
EventSearchParams params = eventService.getFromUrl(program, programStage, programStatus, followUp, orgUnit, ouMode, trackedEntityInstance, startDate, endDate, dueDateStart, dueDateEnd, lastUpdatedStartDate, lastUpdatedEndDate, status, attributeOptionCombo, idSchemes, page, pageSize, totalPages, skipPaging, getOrderParams(order), null, false, eventIds, null, null, includeDeleted);
Events events = eventService.getEvents(params);
if (hasHref(fields)) {
events.getEvents().forEach(e -> e.setHref(ContextUtils.getRootPath(request) + RESOURCE_PATH + "/" + e.getEvent()));
}
if (!skipMeta && params.getProgram() != null) {
events.setMetaData(getMetaData(params.getProgram()));
}
model.addAttribute("model", events);
model.addAttribute("viewClass", options.getViewClass("detailed"));
RootNode rootNode = NodeUtils.createMetadata();
if (events.getPager() != null) {
rootNode.addChild(NodeUtils.createPager(events.getPager()));
}
if (!StringUtils.isEmpty(attachment)) {
response.addHeader(ContextUtils.HEADER_CONTENT_DISPOSITION, "attachment; filename=" + attachment);
response.addHeader(ContextUtils.HEADER_CONTENT_TRANSFER_ENCODING, "binary");
}
rootNode.addChild(fieldFilterService.filter(Event.class, events.getEvents(), fields));
return rootNode;
}
use of org.hisp.dhis.dataelement.DataElementCategoryOptionCombo in project dhis2-core by dhis2.
the class GenerateDataSetReportAction method execute.
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@Override
public String execute() throws Exception {
// ---------------------------------------------------------------------
// Configure response
// ---------------------------------------------------------------------
HttpServletResponse response = ServletActionContext.getResponse();
contextUtils.configureResponse(response, ContextUtils.CONTENT_TYPE_HTML, CacheStrategy.RESPECT_SYSTEM_SETTING, null, false);
// ---------------------------------------------------------------------
// Assemble report
// ---------------------------------------------------------------------
selectedDataSet = dataSetService.getDataSetNoAcl(ds);
if (pe != null) {
selectedPeriod = PeriodType.getPeriodFromIsoString(pe);
selectedPeriod = periodService.reloadPeriod(selectedPeriod);
}
selectedOrgunit = organisationUnitService.getOrganisationUnit(ou);
FormType formType = selectedDataSet.getFormType();
DataElementCategoryOptionCombo attributeOptionCombo = categoryService.getDefaultDataElementCategoryOptionCombo();
registration = registrationService.getCompleteDataSetRegistration(selectedDataSet, selectedPeriod, selectedOrgunit, attributeOptionCombo);
if (formType.isCustom()) {
if (type != null) {
grids = dataSetReportService.getCustomDataSetReportAsGrid(selectedDataSet, selectedPeriod, selectedOrgunit, dimension, selectedUnitOnly, format);
} else {
customDataEntryFormCode = dataSetReportService.getCustomDataSetReport(selectedDataSet, selectedPeriod, selectedOrgunit, dimension, selectedUnitOnly, format);
}
} else if (formType.isSection()) {
grids = dataSetReportService.getSectionDataSetReport(selectedDataSet, selectedPeriod, selectedOrgunit, dimension, selectedUnitOnly, format, i18n);
} else {
grids = dataSetReportService.getDefaultDataSetReport(selectedDataSet, selectedPeriod, selectedOrgunit, dimension, selectedUnitOnly, format, i18n);
}
return type != null ? type : formType.toString();
}
use of org.hisp.dhis.dataelement.DataElementCategoryOptionCombo in project dhis2-core by dhis2.
the class DefaultDataApprovalAuditService method retainFromDimensionConstraints.
// -------------------------------------------------------------------------
// Supportive methods
// -------------------------------------------------------------------------
/**
* Retain the DataApprovalAudits that the user can read
* despite any dimension constraints that the user my have.
*
* @param audits the list of audit records.
*/
private void retainFromDimensionConstraints(List<DataApprovalAudit> audits) {
User user = currentUserService.getCurrentUser();
Set<CategoryOptionGroupSet> cogDimensionConstraints = user.getUserCredentials().getCogsDimensionConstraints();
Set<DataElementCategory> catDimensionConstraints = user.getUserCredentials().getCatDimensionConstraints();
if (currentUserService.currentUserIsSuper() || (CollectionUtils.isEmpty(cogDimensionConstraints) && CollectionUtils.isEmpty(catDimensionConstraints))) {
return;
}
// Local cached results
Map<DataElementCategoryOptionCombo, Boolean> readableOptionCombos = new HashMap<>();
for (Iterator<DataApprovalAudit> i = audits.iterator(); i.hasNext(); ) {
DataElementCategoryOptionCombo optionCombo = i.next().getAttributeOptionCombo();
Boolean canRead = readableOptionCombos.get(optionCombo);
if (canRead == null) {
canRead = canReadOptionCombo(user, optionCombo, cogDimensionConstraints, catDimensionConstraints);
readableOptionCombos.put(optionCombo, canRead);
}
if (!canRead) {
i.remove();
}
}
}
Aggregations