Search in sources :

Example 21 with ErrorMessage

use of org.hisp.dhis.feedback.ErrorMessage in project dhis2-core by dhis2.

the class DefaultQueryItemLocator method getQueryItemFromDimension.

@Override
public QueryItem getQueryItemFromDimension(String dimension, Program program, EventOutputType type) {
    checkNotNull(program, "Program can not be null");
    LegendSet legendSet = getLegendSet(dimension);
    return getDataElement(dimension, program, legendSet, type).orElseGet(() -> getTrackedEntityAttribute(dimension, program, legendSet).orElseGet(() -> getProgramIndicator(dimension, program, legendSet).orElseThrow(() -> new IllegalQueryException(new ErrorMessage(ErrorCode.E7224, dimension)))));
}
Also used : LegendSet(org.hisp.dhis.legend.LegendSet) IllegalQueryException(org.hisp.dhis.common.IllegalQueryException) ErrorMessage(org.hisp.dhis.feedback.ErrorMessage)

Example 22 with ErrorMessage

use of org.hisp.dhis.feedback.ErrorMessage in project dhis2-core by dhis2.

the class DefaultQueryItemLocator method getRepeatableStageParams.

private static RepeatableStageParams getRepeatableStageParams(String dimension) {
    try {
        RepeatableStageParams repeatableStageParams = RepeatableStageParamsHelper.getRepeatableStageParams(dimension);
        repeatableStageParams.setDimension(dimension);
        return repeatableStageParams;
    } catch (InvalidRepeatableStageParamsException e) {
        ErrorMessage errorMessage = new ErrorMessage(dimension, ErrorCode.E1101);
        throw new IllegalQueryException(errorMessage);
    }
}
Also used : InvalidRepeatableStageParamsException(org.hisp.dhis.common.exception.InvalidRepeatableStageParamsException) RepeatableStageParams(org.hisp.dhis.common.RepeatableStageParams) IllegalQueryException(org.hisp.dhis.common.IllegalQueryException) ErrorMessage(org.hisp.dhis.feedback.ErrorMessage)

Example 23 with ErrorMessage

use of org.hisp.dhis.feedback.ErrorMessage in project dhis2-core by dhis2.

the class RelationshipTypeJoinGenerator method addRelationshipWhereClause.

private static String addRelationshipWhereClause(Long relationshipTypeId, RelationshipEntity relationshipEntity) {
    String sql = new StringSubstitutor(ImmutableMap.<String, Long>builder().put("relationshipid", relationshipTypeId).build()).replace(RELATIONSHIP_JOIN);
    sql += " AND ";
    switch(relationshipEntity) {
        case TRACKED_ENTITY_INSTANCE:
            return sql + "tei.uid = ax.tei ";
        case PROGRAM_STAGE_INSTANCE:
            return sql + "psi.uid = ax.psi ";
        case PROGRAM_INSTANCE:
            return sql + "pi.uid = ax.pi ";
        default:
            throw new IllegalQueryException(new ErrorMessage(ErrorCode.E7227, relationshipEntity.name()));
    }
}
Also used : StringSubstitutor(org.apache.commons.text.StringSubstitutor) IllegalQueryException(org.hisp.dhis.common.IllegalQueryException) ErrorMessage(org.hisp.dhis.feedback.ErrorMessage)

Example 24 with ErrorMessage

use of org.hisp.dhis.feedback.ErrorMessage in project dhis2-core by dhis2.

the class EventQueryValidatorTest method validateErrorPageSize.

@Test
void validateErrorPageSize() {
    EventQueryParams params = new EventQueryParams.Builder().withProgram(prA).withStartDate(new DateTime(2010, 6, 1, 0, 0).toDate()).withEndDate(new DateTime(2012, 3, 20, 0, 0).toDate()).withOrganisationUnits(Lists.newArrayList(ouB)).withPageSize(-1).build();
    ErrorMessage error = queryValidator.validateForErrorMessage(params);
    assertEquals(ErrorCode.E7208, error.getErrorCode());
}
Also used : EventQueryParams(org.hisp.dhis.analytics.event.EventQueryParams) ErrorMessage(org.hisp.dhis.feedback.ErrorMessage) DateTime(org.joda.time.DateTime) Test(org.junit.jupiter.api.Test) DhisSpringTest(org.hisp.dhis.DhisSpringTest)

Example 25 with ErrorMessage

use of org.hisp.dhis.feedback.ErrorMessage in project dhis2-core by dhis2.

the class EventQueryValidatorTest method validateErrorFallbackCoordinateField.

@Test
void validateErrorFallbackCoordinateField() {
    EventQueryParams params = new EventQueryParams.Builder().withProgram(prA).withStartDate(new DateTime(2010, 6, 1, 0, 0).toDate()).withEndDate(new DateTime(2012, 3, 20, 0, 0).toDate()).withOrganisationUnits(Lists.newArrayList(ouA)).withCoordinateOuFallback(true).withFallbackCoordinateField("ougeometryx").build();
    ErrorMessage error = queryValidator.validateForErrorMessage(params);
    assertEquals(ErrorCode.E7228, error.getErrorCode());
}
Also used : EventQueryParams(org.hisp.dhis.analytics.event.EventQueryParams) ErrorMessage(org.hisp.dhis.feedback.ErrorMessage) DateTime(org.joda.time.DateTime) Test(org.junit.jupiter.api.Test) DhisSpringTest(org.hisp.dhis.DhisSpringTest)

Aggregations

ErrorMessage (org.hisp.dhis.feedback.ErrorMessage)34 IllegalQueryException (org.hisp.dhis.common.IllegalQueryException)22 Test (org.junit.jupiter.api.Test)10 DhisSpringTest (org.hisp.dhis.DhisSpringTest)7 EventQueryParams (org.hisp.dhis.analytics.event.EventQueryParams)7 BaseDimensionalObject (org.hisp.dhis.common.BaseDimensionalObject)5 DateTime (org.joda.time.DateTime)5 DataQueryParams (org.hisp.dhis.analytics.DataQueryParams)4 ArrayList (java.util.ArrayList)3 ValueType.fromString (org.hisp.dhis.common.ValueType.fromString)3 DataElement (org.hisp.dhis.dataelement.DataElement)3 Date (java.util.Date)2 DimensionalItemObject (org.hisp.dhis.common.DimensionalItemObject)2 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)2 Preconditions.checkNotNull (com.google.common.base.Preconditions.checkNotNull)1 LocalDate (java.time.LocalDate)1 ZoneId (java.time.ZoneId)1 DateTimeFormatter (java.time.format.DateTimeFormatter)1 Collection (java.util.Collection)1 LinkedHashSet (java.util.LinkedHashSet)1