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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations