Search in sources :

Example 6 with DataEntryForm

use of org.hisp.dhis.dataentryform.DataEntryForm in project dhis2-core by dhis2.

the class ValidateDataEntryFormAction method execute.

// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@Override
public String execute() throws Exception {
    name = name.trim();
    DataEntryForm match = dataEntryFormService.getDataEntryFormByName(name);
    if (match != null && (dataEntryFormId == null || match.getId() != dataEntryFormId)) {
        message = i18n.getString("duplicate_names");
        return ERROR;
    }
    message = i18n.getString("everything_is_ok");
    return SUCCESS;
}
Also used : DataEntryForm(org.hisp.dhis.dataentryform.DataEntryForm)

Example 7 with DataEntryForm

use of org.hisp.dhis.dataentryform.DataEntryForm 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 8 with DataEntryForm

use of org.hisp.dhis.dataentryform.DataEntryForm 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 9 with DataEntryForm

use of org.hisp.dhis.dataentryform.DataEntryForm 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 10 with DataEntryForm

use of org.hisp.dhis.dataentryform.DataEntryForm 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

DataEntryForm (org.hisp.dhis.dataentryform.DataEntryForm)15 Program (org.hisp.dhis.program.Program)4 DhisSpringTest (org.hisp.dhis.DhisSpringTest)3 DataElement (org.hisp.dhis.dataelement.DataElement)3 DataSet (org.hisp.dhis.dataset.DataSet)3 Test (org.junit.Test)3 HashSet (java.util.HashSet)2 DataElementCategoryOptionCombo (org.hisp.dhis.dataelement.DataElementCategoryOptionCombo)2 WebMessageException (org.hisp.dhis.dxf2.webmessage.WebMessageException)2 ProgramStage (org.hisp.dhis.program.ProgramStage)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)2 Action (com.opensymphony.xwork2.Action)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1