Search in sources :

Example 21 with Program

use of org.hisp.dhis.program.Program in project dhis2-core by dhis2.

the class DefineProgramAssociationsAction method execute.

// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@Override
public String execute() throws Exception {
    Program program = programService.getProgram(id);
    Collection<OrganisationUnit> units = selectionTreeManager.getReloadedSelectedOrganisationUnits();
    programService.mergeWithCurrentUserOrganisationUnits(program, units);
    return SUCCESS;
}
Also used : OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) Program(org.hisp.dhis.program.Program)

Example 22 with Program

use of org.hisp.dhis.program.Program in project dhis2-core by dhis2.

the class RemoveDataEntryFormAction method execute.

// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@Override
public String execute() throws Exception {
    DataEntryForm dataEntryForm = dataEntryFormService.getDataEntryForm(id);
    Program program = programStageService.getProgramStage(programStageId).getProgram();
    programId = program.getId();
    Set<ProgramStage> programStages = program.getProgramStages();
    for (ProgramStage programStage : programStages) {
        DataEntryForm programEntryForm = programStage.getDataEntryForm();
        if (programEntryForm != null && programEntryForm.equals(dataEntryForm)) {
            programStage.setDataEntryForm(null);
            programStageService.updateProgramStage(programStage);
        }
    }
    program.increaseVersion();
    dataEntryFormService.deleteDataEntryForm(dataEntryForm);
    return SUCCESS;
}
Also used : Program(org.hisp.dhis.program.Program) DataEntryForm(org.hisp.dhis.dataentryform.DataEntryForm) ProgramStage(org.hisp.dhis.program.ProgramStage)

Example 23 with Program

use of org.hisp.dhis.program.Program in project dhis2-core by dhis2.

the class RemoveProgramEntryFormAction method execute.

// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@Override
public String execute() throws Exception {
    Program program = programService.getProgram(programId);
    program.setDataEntryForm(null);
    programService.updateProgram(program);
    DataEntryForm dataEntryForm = program.getDataEntryForm();
    dataEntryFormService.deleteDataEntryForm(dataEntryForm);
    return SUCCESS;
}
Also used : Program(org.hisp.dhis.program.Program) DataEntryForm(org.hisp.dhis.dataentryform.DataEntryForm)

Example 24 with Program

use of org.hisp.dhis.program.Program in project dhis2-core by dhis2.

the class SaveDataEntryFormAction method execute.

// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@Override
public String execute() throws Exception {
    ProgramStage programStage = programStageService.getProgramStage(programStageId);
    Program program = programStage.getProgram();
    programId = program.getId();
    DataEntryForm dataEntryForm = null;
    if (dataEntryFormId == null) {
        dataEntryForm = programStage.getDataEntryForm();
    } else {
        dataEntryForm = dataEntryFormService.getDataEntryForm(dataEntryFormId);
    }
    if (dataEntryForm == null || !dataEntryForm.getHtmlCode().equals(designTextarea)) {
        program.increaseVersion();
    }
    designTextarea = dataEntryFormService.prepareDataEntryFormForSave(designTextarea);
    if (dataEntryForm == null) {
        program.increaseVersion();
        dataEntryForm = new DataEntryForm(StringUtils.trimToNull(name), designTextarea);
        dataEntryFormService.addDataEntryForm(dataEntryForm);
    } else {
        dataEntryForm.setName(StringUtils.trimToNull(name));
        dataEntryForm.setHtmlCode(designTextarea);
        dataEntryFormService.updateDataEntryForm(dataEntryForm);
    }
    programStage.setDataEntryForm(dataEntryForm);
    programStageService.updateProgramStage(programStage);
    return SUCCESS;
}
Also used : Program(org.hisp.dhis.program.Program) DataEntryForm(org.hisp.dhis.dataentryform.DataEntryForm) ProgramStage(org.hisp.dhis.program.ProgramStage)

Example 25 with Program

use of org.hisp.dhis.program.Program in project dhis2-core by dhis2.

the class SaveProgramEntryFormAction method execute.

// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@Override
public String execute() throws Exception {
    name = StringUtils.trimToNull(name);
    designTextarea = StringUtils.trimToNull(designTextarea);
    Program program = programService.getProgram(programId);
    DataEntryForm dataEntryForm = program.getDataEntryForm();
    if (dataEntryForm == null) {
        dataEntryForm = new DataEntryForm(name, designTextarea);
        program.setDataEntryForm(dataEntryForm);
        programService.updateProgram(program);
    } else {
        dataEntryForm.setName(name);
        dataEntryForm.setHtmlCode(designTextarea);
        dataEntryFormService.updateDataEntryForm(dataEntryForm);
    }
    Integer dataEntryFormId = dataEntryFormService.getDataEntryFormByName(name).getId();
    message = dataEntryFormId + "";
    return SUCCESS;
}
Also used : Program(org.hisp.dhis.program.Program) DataEntryForm(org.hisp.dhis.dataentryform.DataEntryForm)

Aggregations

Program (org.hisp.dhis.program.Program)344 Test (org.junit.jupiter.api.Test)160 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)123 ProgramStage (org.hisp.dhis.program.ProgramStage)109 ProgramInstance (org.hisp.dhis.program.ProgramInstance)79 TrackedEntityInstance (org.hisp.dhis.trackedentity.TrackedEntityInstance)68 Date (java.util.Date)47 Collectors (java.util.stream.Collectors)44 User (org.hisp.dhis.user.User)44 CategoryOptionCombo (org.hisp.dhis.category.CategoryOptionCombo)42 TrackedEntityType (org.hisp.dhis.trackedentity.TrackedEntityType)42 BeforeEach (org.junit.jupiter.api.BeforeEach)42 TrackedEntityAttribute (org.hisp.dhis.trackedentity.TrackedEntityAttribute)41 ValidationErrorReporter (org.hisp.dhis.tracker.report.ValidationErrorReporter)41 DhisConvenienceTest (org.hisp.dhis.DhisConvenienceTest)40 DhisConvenienceTest.createProgram (org.hisp.dhis.DhisConvenienceTest.createProgram)39 CategoryCombo (org.hisp.dhis.category.CategoryCombo)39 DataElement (org.hisp.dhis.dataelement.DataElement)39 Event (org.hisp.dhis.tracker.domain.Event)38 Enrollment (org.hisp.dhis.tracker.domain.Enrollment)37