Search in sources :

Example 1 with ParserExceptionWithoutContext

use of org.hisp.dhis.antlr.ParserExceptionWithoutContext in project dhis2-core by dhis2.

the class DimensionalItem method getDescription.

@Override
public final Object getDescription(ExprContext ctx, CommonExpressionVisitor visitor) {
    DimensionalItemId itemId = getDimensionalItemId(ctx, visitor);
    DimensionalItemObject item = visitor.getDimensionService().getDataDimensionalItemObject(itemId);
    if (item == null) {
        throw new ParserExceptionWithoutContext("Can't find " + itemId.getDimensionItemType().name() + " for '" + itemId + "'");
    }
    visitor.getItemDescriptions().put(ctx.getText(), item.getDisplayName());
    return ValidationUtils.getNullReplacementValue(getItemValueType(item));
}
Also used : ParserExceptionWithoutContext(org.hisp.dhis.antlr.ParserExceptionWithoutContext) DimensionalItemId(org.hisp.dhis.common.DimensionalItemId) DimensionalItemObject(org.hisp.dhis.common.DimensionalItemObject) ValueTypedDimensionalItemObject(org.hisp.dhis.common.ValueTypedDimensionalItemObject)

Example 2 with ParserExceptionWithoutContext

use of org.hisp.dhis.antlr.ParserExceptionWithoutContext in project dhis2-core by dhis2.

the class FunctionOrgUnitAncestor method getDescription.

@Override
public Object getDescription(ExpressionParser.ExprContext ctx, CommonExpressionVisitor visitor) {
    for (TerminalNode uid : ctx.UID()) {
        OrganisationUnit orgUnit = visitor.getIdObjectManager().get(OrganisationUnit.class, uid.getText());
        if (orgUnit == null) {
            throw new ParserExceptionWithoutContext("No organization unit defined for " + uid.getText());
        }
        visitor.getItemDescriptions().put(uid.getText(), orgUnit.getDisplayName());
    }
    return false;
}
Also used : ParserExceptionWithoutContext(org.hisp.dhis.antlr.ParserExceptionWithoutContext) OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) TerminalNode(org.antlr.v4.runtime.tree.TerminalNode)

Example 3 with ParserExceptionWithoutContext

use of org.hisp.dhis.antlr.ParserExceptionWithoutContext in project dhis2-core by dhis2.

the class ProgramItemPsEventdate method getDescription.

@Override
public Object getDescription(ExprContext ctx, CommonExpressionVisitor visitor) {
    String programStageUid = ctx.uid0.getText();
    ProgramStage programStage = visitor.getProgramStageService().getProgramStage(programStageUid);
    if (programStage == null) {
        throw new ParserExceptionWithoutContext("Program stage " + ctx.uid0.getText() + " not found");
    }
    visitor.getItemDescriptions().put(programStageUid, programStage.getDisplayName());
    return DEFAULT_DATE_VALUE;
}
Also used : ParserExceptionWithoutContext(org.hisp.dhis.antlr.ParserExceptionWithoutContext) ProgramStage(org.hisp.dhis.program.ProgramStage)

Example 4 with ParserExceptionWithoutContext

use of org.hisp.dhis.antlr.ParserExceptionWithoutContext in project dhis2-core by dhis2.

the class ProgramItemAttribute method getDescription.

@Override
public Object getDescription(ExprContext ctx, CommonExpressionVisitor visitor) {
    String attributeId = getProgramAttributeId(ctx);
    TrackedEntityAttribute attribute = visitor.getIdObjectManager().get(TrackedEntityAttribute.class, attributeId);
    if (attribute == null) {
        throw new ParserExceptionWithoutContext("Tracked entity attribute " + attributeId + " not found.");
    }
    visitor.getItemDescriptions().put(ctx.getText(), attribute.getDisplayName());
    return ValidationUtils.getNullReplacementValue(attribute.getValueType());
}
Also used : ParserExceptionWithoutContext(org.hisp.dhis.antlr.ParserExceptionWithoutContext) TrackedEntityAttribute(org.hisp.dhis.trackedentity.TrackedEntityAttribute)

Example 5 with ParserExceptionWithoutContext

use of org.hisp.dhis.antlr.ParserExceptionWithoutContext in project dhis2-core by dhis2.

the class ProgramItemAttribute method getSql.

@Override
public Object getSql(ExprContext ctx, CommonExpressionVisitor visitor) {
    String attributeId = getProgramAttributeId(ctx);
    String column = visitor.getStatementBuilder().columnQuote(attributeId);
    if (visitor.getState().isReplaceNulls()) {
        TrackedEntityAttribute attribute = visitor.getIdObjectManager().get(TrackedEntityAttribute.class, attributeId);
        if (attribute == null) {
            throw new ParserExceptionWithoutContext("Tracked entity attribute " + attributeId + " not found during SQL generation.");
        }
        column = replaceNullSqlValues(column, attribute.getValueType());
    }
    return column;
}
Also used : ParserExceptionWithoutContext(org.hisp.dhis.antlr.ParserExceptionWithoutContext) TrackedEntityAttribute(org.hisp.dhis.trackedentity.TrackedEntityAttribute)

Aggregations

ParserExceptionWithoutContext (org.hisp.dhis.antlr.ParserExceptionWithoutContext)12 TerminalNode (org.antlr.v4.runtime.tree.TerminalNode)2 ParserException (org.hisp.dhis.antlr.ParserException)2 DataElement (org.hisp.dhis.dataelement.DataElement)2 OrganisationUnitGroup (org.hisp.dhis.organisationunit.OrganisationUnitGroup)2 ProgramStage (org.hisp.dhis.program.ProgramStage)2 TrackedEntityAttribute (org.hisp.dhis.trackedentity.TrackedEntityAttribute)2 Date (java.util.Date)1 DimensionalItemId (org.hisp.dhis.common.DimensionalItemId)1 DimensionalItemObject (org.hisp.dhis.common.DimensionalItemObject)1 ValueTypedDimensionalItemObject (org.hisp.dhis.common.ValueTypedDimensionalItemObject)1 Constant (org.hisp.dhis.constant.Constant)1 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)1 ProgramExpressionParams (org.hisp.dhis.parser.expression.ProgramExpressionParams)1 ProgramStageService (org.hisp.dhis.program.ProgramStageService)1 RelationshipType (org.hisp.dhis.relationship.RelationshipType)1 DateUtils.parseDate (org.hisp.dhis.util.DateUtils.parseDate)1