Search in sources :

Example 6 with ParserException

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

the class DefaultProgramIndicatorService method getAnyValueExistsClauseAnalyticsSql.

@Override
@Transactional(readOnly = true)
public String getAnyValueExistsClauseAnalyticsSql(String expression, AnalyticsType analyticsType) {
    if (expression == null) {
        return null;
    }
    try {
        Set<String> uids = getDataElementAndAttributeIdentifiers(expression, analyticsType);
        if (uids.isEmpty()) {
            return null;
        }
        String sql = StringUtils.EMPTY;
        for (String uid : uids) {
            sql += statementBuilder.columnQuote(uid) + " is not null or ";
        }
        return TextUtils.removeLastOr(sql).trim();
    } catch (ParserException e) {
        return null;
    }
}
Also used : ParserException(org.hisp.dhis.antlr.ParserException) AntlrParserUtils.castString(org.hisp.dhis.antlr.AntlrParserUtils.castString) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

ParserException (org.hisp.dhis.antlr.ParserException)6 ParserExceptionWithoutContext (org.hisp.dhis.antlr.ParserExceptionWithoutContext)2 DataElement (org.hisp.dhis.dataelement.DataElement)2 DataIntegrityIssue (org.hisp.dhis.dataintegrity.DataIntegrityDetails.DataIntegrityIssue)2 ProgramIndicator (org.hisp.dhis.program.ProgramIndicator)2 Test (org.junit.jupiter.api.Test)2 HashMap (java.util.HashMap)1 AntlrParserUtils.castString (org.hisp.dhis.antlr.AntlrParserUtils.castString)1 BaseIdentifiableObject (org.hisp.dhis.common.BaseIdentifiableObject)1 DimensionalItemId (org.hisp.dhis.common.DimensionalItemId)1 DimensionalItemObject (org.hisp.dhis.common.DimensionalItemObject)1 IdentifiableObject (org.hisp.dhis.common.IdentifiableObject)1 ProgramExpressionParams (org.hisp.dhis.parser.expression.ProgramExpressionParams)1 ProgramStage (org.hisp.dhis.program.ProgramStage)1 ProgramStageService (org.hisp.dhis.program.ProgramStageService)1 Transactional (org.springframework.transaction.annotation.Transactional)1