use of org.hisp.dhis.program.ProgramStage in project dhis2-core by dhis2.
the class LabelMapperTest method testGetHeaderNameFor_NAME_EVENT_DATE.
@Test
void testGetHeaderNameFor_NAME_EVENT_DATE() {
// Given
final ProgramStage aMockedProgramStageWithLabels = mockProgramStageWithLabels();
// When
final String actualName = LabelMapper.getEventDateLabel(aMockedProgramStageWithLabels, EVENT_DATE);
// Then
assertThat(actualName, is(aMockedProgramStageWithLabels.getExecutionDateLabel()));
}
use of org.hisp.dhis.program.ProgramStage in project dhis2-core by dhis2.
the class LabelMapperTest method mockProgramStageWithoutLabels.
private ProgramStage mockProgramStageWithoutLabels() {
final ProgramStage programStage = new ProgramStage();
final Program program = new Program();
programStage.setProgram(program);
return programStage;
}
use of org.hisp.dhis.program.ProgramStage in project dhis2-core by dhis2.
the class LabelMapperTest method testGetHeaderNameWhenProgramStageIsNull.
@Test
void testGetHeaderNameWhenProgramStageIsNull() {
// Given
final ProgramStage nullProgramStage = null;
// When
final String actualName = LabelMapper.getIncidentDateLabel(nullProgramStage, INCIDENT_DATE);
// Then
assertThat(actualName, is(INCIDENT_DATE));
}
use of org.hisp.dhis.program.ProgramStage in project dhis2-core by dhis2.
the class LabelMapperTest method mockProgramStageWithLabels.
private ProgramStage mockProgramStageWithLabels() {
final ProgramStage programStage = new ProgramStage();
programStage.setExecutionDateLabel("execution date label");
final Program program = new Program();
program.setEnrollmentDateLabel("enrollment date label");
program.setIncidentDateLabel("incident date label");
programStage.setProgram(program);
return programStage;
}
use of org.hisp.dhis.program.ProgramStage in project dhis2-core by dhis2.
the class ProgramItemStageElement method getDescription.
@Override
public Object getDescription(ExprContext ctx, CommonExpressionVisitor visitor) {
assumeStageElementSyntax(ctx);
String programStageId = ctx.uid0.getText();
String dataElementId = ctx.uid1.getText();
ProgramStageService stageService = visitor.getProgramStageService();
ProgramStage programStage = stageService.getProgramStage(programStageId);
DataElement dataElement = visitor.getIdObjectManager().get(DataElement.class, dataElementId);
if (programStage == null) {
throw new ParserExceptionWithoutContext("Program stage " + programStageId + " not found");
}
if (dataElement == null) {
throw new ParserExceptionWithoutContext("Data element " + dataElementId + " not found");
}
if (isNonDefaultStageOffset(visitor.getState().getStageOffset()) && !isRepeatableStage(stageService, programStageId)) {
throw new ParserException(getErrorMessage(programStageId));
}
String description = programStage.getDisplayName() + ProgramIndicator.SEPARATOR_ID + dataElement.getDisplayName();
visitor.getItemDescriptions().put(ctx.getText(), description);
return ValidationUtils.getNullReplacementValue(dataElement.getValueType());
}
Aggregations