use of org.hisp.dhis.program.ProgramStageService 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());
}
use of org.hisp.dhis.program.ProgramStageService in project dhis2-core by dhis2.
the class EventAnalyticsDimensionsServiceTest method setup.
@BeforeEach
void setup() {
ProgramStageService programStageService = mock(ProgramStageService.class);
CategoryService categoryService = mock(CategoryService.class);
Program program = mock(Program.class);
ProgramStage programStage = mock(ProgramStage.class);
when(programStageService.getProgramStage(any())).thenReturn(programStage);
when(programStage.getProgram()).thenReturn(program);
when(program.getDataElements()).thenReturn(allValueTypeDataElements());
when(program.getProgramIndicators()).thenReturn(Collections.emptySet());
when(program.getTrackedEntityAttributes()).thenReturn(allValueTypeTEAs());
eventAnalyticsDimensionsService = new DefaultEventAnalyticsDimensionsService(programStageService, categoryService);
}
Aggregations