use of org.hisp.dhis.dataapproval.DataApprovalWorkflow in project dhis2-core by dhis2.
the class DataApprovalController method acceptApproval.
// -------------------------------------------------------------------------
// Post, acceptance
// -------------------------------------------------------------------------
@PreAuthorize("hasRole('ALL') or hasRole('F_ACCEPT_DATA_LOWER_LEVELS')")
@RequestMapping(value = ACCEPTANCES_PATH, method = RequestMethod.POST)
@ResponseStatus(HttpStatus.NO_CONTENT)
public void acceptApproval(@RequestParam(required = false) String ds, @RequestParam(required = false) String wf, @RequestParam String pe, @RequestParam String ou, HttpServletResponse response) throws WebMessageException {
DataApprovalWorkflow workflow = getAndValidateWorkflow(ds, wf);
Period period = getAndValidatePeriod(pe);
OrganisationUnit organisationUnit = getAndValidateOrgUnit(ou);
DataApprovalLevel dataApprovalLevel = getAndValidateApprovalLevel(organisationUnit);
User user = currentUserService.getCurrentUser();
List<DataApproval> dataApprovalList = getApprovalsAsList(dataApprovalLevel, workflow, period, organisationUnit, false, new Date(), user);
dataApprovalService.acceptData(dataApprovalList);
}
use of org.hisp.dhis.dataapproval.DataApprovalWorkflow in project dhis2-core by dhis2.
the class DataApprovalController method unacceptApproval.
@PreAuthorize("hasRole('ALL') or hasRole('F_ACCEPT_DATA_LOWER_LEVELS')")
@RequestMapping(value = ACCEPTANCES_PATH, method = RequestMethod.DELETE)
@ResponseStatus(HttpStatus.NO_CONTENT)
public void unacceptApproval(@RequestParam(required = false) String ds, @RequestParam(required = false) String wf, @RequestParam String pe, @RequestParam String ou, HttpServletResponse response) throws WebMessageException {
DataApprovalWorkflow workflow = getAndValidateWorkflow(ds, wf);
Period period = getAndValidatePeriod(pe);
OrganisationUnit organisationUnit = getAndValidateOrgUnit(ou);
DataApprovalLevel dataApprovalLevel = getAndValidateApprovalLevel(organisationUnit);
User user = currentUserService.getCurrentUser();
List<DataApproval> dataApprovalList = getApprovalsAsList(dataApprovalLevel, workflow, period, organisationUnit, false, new Date(), user);
dataApprovalService.unacceptData(dataApprovalList);
}
use of org.hisp.dhis.dataapproval.DataApprovalWorkflow in project dhis2-core by dhis2.
the class DataApprovalWorkflowObjectBundleHook method preCreate.
@Override
public <T extends IdentifiableObject> void preCreate(T object, ObjectBundle bundle) {
if (!DataApprovalWorkflow.class.isInstance(object))
return;
DataApprovalWorkflow dataApprovalWorkflow = (DataApprovalWorkflow) object;
if (dataApprovalWorkflow.getPeriodType() != null) {
PeriodType periodType = bundle.getPreheat().getPeriodTypeMap().get(dataApprovalWorkflow.getPeriodType().getName());
dataApprovalWorkflow.setPeriodType(periodType);
}
}
use of org.hisp.dhis.dataapproval.DataApprovalWorkflow in project dhis2-core by dhis2.
the class DataOrgUnitMergeHandlerTest method setUpTest.
@Override
public void setUpTest() {
cocA = categoryService.getDefaultCategoryOptionCombo();
deA = createDataElement('A');
deB = createDataElement('B');
idObjectManager.save(deA);
idObjectManager.save(deB);
PeriodType monthly = periodService.getPeriodTypeByClass(MonthlyPeriodType.class);
peA = monthly.createPeriod("202101");
peB = monthly.createPeriod("202102");
periodService.addPeriod(peA);
periodService.addPeriod(peB);
ouA = createOrganisationUnit('A');
ouB = createOrganisationUnit('B');
ouC = createOrganisationUnit('C');
idObjectManager.save(ouA);
idObjectManager.save(ouB);
idObjectManager.save(ouC);
usA = createUser('A');
userService.addUser(usA);
dlA = new DataApprovalLevel("DataApprovalLevelA", 1);
idObjectManager.save(dlA);
dwA = new DataApprovalWorkflow("DataApprovalWorkflowA", monthly, Sets.newHashSet(dlA));
idObjectManager.save(dwA);
}
use of org.hisp.dhis.dataapproval.DataApprovalWorkflow in project dhis2-core by dhis2.
the class DataSetServiceTest method approveData.
private void approveData(DataSet dataSet, Period period, OrganisationUnit unit) {
DataApprovalLevel level = new DataApprovalLevel("Level A", unit.getLevel(), null);
levelService.addDataApprovalLevel(level);
DataApprovalWorkflow workflow = new DataApprovalWorkflow("Workflow A", period.getPeriodType(), newHashSet(level));
dataApprovalService.addWorkflow(workflow);
dataSet.assignWorkflow(workflow);
dataSet.addOrganisationUnit(unit);
dataSetService.updateDataSet(dataSet);
User user = mockCurrentUserService.getCurrentUser();
DataApproval approval = new DataApproval(level, workflow, period, unit, attributeOptionCombo, false, new Date(), user);
approvalService.approveData(newArrayList(approval));
}
Aggregations