use of org.hisp.dhis.dataelement.DataElementCategoryOptionCombo in project dhis2-core by dhis2.
the class DataApprovalController method getApprovalPermissions.
// -------------------------------------------------------------------------
// Get
// -------------------------------------------------------------------------
@RequestMapping(value = APPROVALS_PATH, method = RequestMethod.GET, produces = ContextUtils.CONTENT_TYPE_JSON)
public void getApprovalPermissions(@RequestParam(required = false) String ds, @RequestParam(required = false) String wf, @RequestParam String pe, @RequestParam String ou, HttpServletResponse response) throws IOException, WebMessageException {
DataApprovalWorkflow workflow = getAndValidateWorkflow(ds, wf);
Period period = getAndValidatePeriod(pe);
OrganisationUnit organisationUnit = getAndValidateOrgUnit(ou);
DataElementCategoryOptionCombo optionCombo = categoryService.getDefaultDataElementCategoryOptionCombo();
DataApprovalStatus status = dataApprovalService.getDataApprovalStatusAndPermissions(workflow, period, organisationUnit, optionCombo);
DataApprovalPermissions permissions = status.getPermissions();
permissions.setState(status.getState().toString());
response.setContentType(MediaType.APPLICATION_JSON_VALUE);
renderService.toJson(response.getOutputStream(), status.getPermissions());
}
use of org.hisp.dhis.dataelement.DataElementCategoryOptionCombo in project dhis2-core by dhis2.
the class DataApprovalController method getApprovalsAsList.
private List<DataApproval> getApprovalsAsList(DataApprovalLevel dataApprovalLevel, DataApprovalWorkflow workflow, Period period, OrganisationUnit organisationUnit, boolean accepted, Date created, User creator) {
List<DataApproval> approvals = new ArrayList<>();
DataElementCategoryOptionCombo combo = categoryService.getDefaultDataElementCategoryOptionCombo();
period = periodService.reloadPeriod(period);
approvals.add(new DataApproval(dataApprovalLevel, workflow, period, organisationUnit, combo, accepted, created, creator));
return approvals;
}
use of org.hisp.dhis.dataelement.DataElementCategoryOptionCombo in project dhis2-core by dhis2.
the class CompleteDataSetRegistrationController method saveCompleteDataSetRegistration.
@ApiVersion({ DhisApiVersion.V23, DhisApiVersion.V24, DhisApiVersion.V25 })
@RequestMapping(method = RequestMethod.POST, consumes = "application/json", value = MULTIPLE_SAVE_RESOURCE_PATH)
@ResponseStatus(HttpStatus.NO_CONTENT)
public void saveCompleteDataSetRegistration(@RequestBody CompleteDataSetRegistrationRequests completeDataSetRegistrationRequests, HttpServletResponse response) throws WebMessageException {
List<CompleteDataSetRegistration> registrations = new ArrayList<>();
for (CompleteDataSetRegistrationRequest completeDataSetRegistrationRequest : completeDataSetRegistrationRequests) {
String ds = completeDataSetRegistrationRequest.getDs();
DataSet dataSet = dataSetService.getDataSet(ds);
if (dataSet == null) {
throw new WebMessageException(WebMessageUtils.conflict("Illegal data set identifier: " + ds));
}
String pe = completeDataSetRegistrationRequest.getPe();
Period period = PeriodType.getPeriodFromIsoString(pe);
if (period == null) {
throw new WebMessageException(WebMessageUtils.conflict("Illegal period identifier: " + pe));
}
String ou = completeDataSetRegistrationRequest.getOu();
OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit(ou);
if (organisationUnit == null) {
throw new WebMessageException(WebMessageUtils.conflict("Illegal organisation unit identifier: " + ou));
}
String cc = completeDataSetRegistrationRequest.getCc();
String cp = completeDataSetRegistrationRequest.getCp();
DataElementCategoryOptionCombo attributeOptionCombo = inputUtils.getAttributeOptionCombo(cc, cp, false);
if (attributeOptionCombo == null) {
return;
}
// ---------------------------------------------------------------------
// Check locked status
// ---------------------------------------------------------------------
boolean multiOu = completeDataSetRegistrationRequest.isMultiOu();
if (dataSetService.isLocked(dataSet, period, organisationUnit, attributeOptionCombo, null, multiOu)) {
throw new WebMessageException(WebMessageUtils.conflict("Data set is locked: " + ds));
}
// ---------------------------------------------------------------------
// Register as completed data set
// ---------------------------------------------------------------------
String sb = completeDataSetRegistrationRequest.getSb();
String storedBy = (sb == null) ? currentUserService.getCurrentUsername() : sb;
Date cd = completeDataSetRegistrationRequest.getCd();
Date completionDate = (cd == null) ? new Date() : cd;
Set<OrganisationUnit> orgUnits = new HashSet<>();
orgUnits.add(organisationUnit);
if (multiOu) {
orgUnits.addAll(organisationUnit.getChildren());
}
addRegistrationsForOrgUnits(registrations, orgUnits, dataSet, period, attributeOptionCombo, storedBy, completionDate);
}
registrationService.saveCompleteDataSetRegistrations(registrations, true);
}
use of org.hisp.dhis.dataelement.DataElementCategoryOptionCombo in project dhis2-core by dhis2.
the class RunValidationAction method execute.
// -------------------------------------------------------------------------
// Execute
// -------------------------------------------------------------------------
@Override
public String execute() {
organisationUnit = organisationUnitService.getOrganisationUnit(organisationUnitId);
List<OrganisationUnit> organisationUnits = organisationUnitService.getOrganisationUnitWithChildren(organisationUnit.getId());
ValidationRuleGroup group = validationRuleGroupId == -1 ? null : validationRuleService.getValidationRuleGroup(validationRuleGroupId);
DataElementCategoryOptionCombo attributeOptionCombo = attributeOptionComboId == null || attributeOptionComboId == -1 ? null : dataElementCategoryService.getDataElementCategoryOptionCombo(attributeOptionComboId);
log.info("Validating data for " + (group == null ? "all rules" : "group: " + group.getName()));
validationResults = new ArrayList<>(validationService.startInteractiveValidationAnalysis(format.parseDate(startDate), format.parseDate(endDate), organisationUnits, attributeOptionCombo, group, sendNotifications, format));
maxExceeded = validationResults.size() > ValidationService.MAX_INTERACTIVE_ALERTS;
Collections.sort(validationResults, new ValidationResultComparator());
SessionUtils.setSessionVar(KEY_VALIDATIONRESULT, validationResults);
computeShowAttributeCombos();
log.info("Validation done");
return SUCCESS;
}
Aggregations