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)))));
}
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);
}
}
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()));
}
}
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());
}
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());
}
Aggregations