use of org.hisp.dhis.antlr.ParserExceptionWithoutContext 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.antlr.ParserExceptionWithoutContext in project dhis2-core by dhis2.
the class ProgramItemStageElement method getSql.
@Override
public Object getSql(ExprContext ctx, CommonExpressionVisitor visitor) {
assumeStageElementSyntax(ctx);
String programStageId = ctx.uid0.getText();
String dataElementId = ctx.uid1.getText();
ProgramExpressionParams params = visitor.getProgParams();
int stageOffset = visitor.getState().getStageOffset();
String column;
if (isNonDefaultStageOffset(stageOffset)) {
if (isRepeatableStage(visitor.getProgramStageService(), programStageId)) {
column = visitor.getStatementBuilder().getProgramIndicatorEventColumnSql(programStageId, Integer.valueOf(stageOffset).toString(), SqlUtils.quote(dataElementId), params.getReportingStartDate(), params.getReportingEndDate(), params.getProgramIndicator());
} else {
throw new ParserException(getErrorMessage(programStageId));
}
} else {
column = visitor.getStatementBuilder().getProgramIndicatorDataValueSelectSql(programStageId, dataElementId, params.getReportingStartDate(), params.getReportingEndDate(), params.getProgramIndicator());
}
if (visitor.getState().isReplaceNulls()) {
DataElement dataElement = visitor.getIdObjectManager().get(DataElement.class, dataElementId);
if (dataElement == null) {
throw new ParserExceptionWithoutContext("Data element " + dataElementId + " not found during SQL generation.");
}
column = replaceNullSqlValues(column, dataElement.getValueType());
}
return column;
}
use of org.hisp.dhis.antlr.ParserExceptionWithoutContext in project dhis2-core by dhis2.
the class ItemOrgUnitGroupCount method getDescription.
@Override
public Object getDescription(ExprContext ctx, CommonExpressionVisitor visitor) {
OrganisationUnitGroup orgUnitGroup = visitor.getIdObjectManager().get(OrganisationUnitGroup.class, ctx.uid0.getText());
if (orgUnitGroup == null) {
throw new ParserExceptionWithoutContext("No organization unit group defined for " + ctx.uid0.getText());
}
visitor.getItemDescriptions().put(ctx.getText(), orgUnitGroup.getDisplayName());
return DOUBLE_VALUE_IF_NULL;
}
use of org.hisp.dhis.antlr.ParserExceptionWithoutContext in project dhis2-core by dhis2.
the class FunctionOrgUnitGroup method getDescription.
@Override
public Object getDescription(ExpressionParser.ExprContext ctx, CommonExpressionVisitor visitor) {
for (TerminalNode uid : ctx.UID()) {
OrganisationUnitGroup orgUnitGroup = visitor.getIdObjectManager().get(OrganisationUnitGroup.class, uid.getText());
if (orgUnitGroup == null) {
throw new ParserExceptionWithoutContext("No organization unit group defined for " + uid.getText());
}
visitor.getItemDescriptions().put(uid.getText(), orgUnitGroup.getDisplayName());
}
return false;
}
use of org.hisp.dhis.antlr.ParserExceptionWithoutContext in project dhis2-core by dhis2.
the class D2RelationshipCount method getDescription.
@Override
public Object getDescription(ExprContext ctx, CommonExpressionVisitor visitor) {
if (ctx.QUOTED_UID() != null) {
String relationshipId = trimQuotes(ctx.QUOTED_UID().getText());
RelationshipType relationshipType = visitor.getIdObjectManager().get(RelationshipType.class, relationshipId);
if (relationshipType == null) {
throw new ParserExceptionWithoutContext("Relationship type " + relationshipId + " not found");
}
visitor.getItemDescriptions().put(ctx.QUOTED_UID().getText(), relationshipType.getDisplayName());
}
return DEFAULT_DOUBLE_VALUE;
}
Aggregations