Search in sources :

Example 1 with DataApprovalWorkflow

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);
}
Also used : OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) DataApprovalLevel(org.hisp.dhis.dataapproval.DataApprovalLevel) DataApproval(org.hisp.dhis.dataapproval.DataApproval) User(org.hisp.dhis.user.User) Period(org.hisp.dhis.period.Period) DataApprovalWorkflow(org.hisp.dhis.dataapproval.DataApprovalWorkflow) Date(java.util.Date) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with DataApprovalWorkflow

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);
}
Also used : OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) DataApprovalLevel(org.hisp.dhis.dataapproval.DataApprovalLevel) DataApproval(org.hisp.dhis.dataapproval.DataApproval) User(org.hisp.dhis.user.User) Period(org.hisp.dhis.period.Period) DataApprovalWorkflow(org.hisp.dhis.dataapproval.DataApprovalWorkflow) Date(java.util.Date) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with DataApprovalWorkflow

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);
    }
}
Also used : PeriodType(org.hisp.dhis.period.PeriodType) DataApprovalWorkflow(org.hisp.dhis.dataapproval.DataApprovalWorkflow)

Example 4 with DataApprovalWorkflow

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);
}
Also used : MonthlyPeriodType(org.hisp.dhis.period.MonthlyPeriodType) PeriodType(org.hisp.dhis.period.PeriodType) DataApprovalLevel(org.hisp.dhis.dataapproval.DataApprovalLevel) DataApprovalWorkflow(org.hisp.dhis.dataapproval.DataApprovalWorkflow)

Example 5 with DataApprovalWorkflow

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));
}
Also used : DataApprovalLevel(org.hisp.dhis.dataapproval.DataApprovalLevel) DataApproval(org.hisp.dhis.dataapproval.DataApproval) User(org.hisp.dhis.user.User) DataApprovalWorkflow(org.hisp.dhis.dataapproval.DataApprovalWorkflow) Date(java.util.Date)

Aggregations

DataApprovalWorkflow (org.hisp.dhis.dataapproval.DataApprovalWorkflow)32 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)20 Period (org.hisp.dhis.period.Period)19 DataApprovalLevel (org.hisp.dhis.dataapproval.DataApprovalLevel)18 DataApproval (org.hisp.dhis.dataapproval.DataApproval)16 User (org.hisp.dhis.user.User)15 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)13 Date (java.util.Date)11 ArrayList (java.util.ArrayList)10 CategoryOptionCombo (org.hisp.dhis.category.CategoryOptionCombo)10 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)10 DataSet (org.hisp.dhis.dataset.DataSet)9 DataApprovalStatus (org.hisp.dhis.dataapproval.DataApprovalStatus)8 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)8 Map (java.util.Map)6 Set (java.util.Set)5 CategoryCombo (org.hisp.dhis.category.CategoryCombo)5 Test (org.junit.jupiter.api.Test)5 Collection (java.util.Collection)4 List (java.util.List)4