use of org.hisp.dhis.common.IllegalQueryException in project dhis2-core by dhis2.
the class AnalyticsSecurityManagerTest method testDataViewMaxOrganisationUnitLevel.
@Test
void testDataViewMaxOrganisationUnitLevel() {
DataQueryParams params = DataQueryParams.newBuilder().withPeriods(Lists.newArrayList(createPeriod("201801"), createPeriod("201802"))).withOrganisationUnits(Lists.newArrayList(ouD)).build();
IllegalQueryException ex = assertThrows(IllegalQueryException.class, () -> securityManager.decideAccess(params));
assertEquals(ErrorCode.E7120, ex.getErrorCode());
}
use of org.hisp.dhis.common.IllegalQueryException in project dhis2-core by dhis2.
the class AnalyticsSecurityManagerTest method testDataViewOrganisationUnits.
@Test
void testDataViewOrganisationUnits() {
DataQueryParams params = DataQueryParams.newBuilder().withPeriods(Lists.newArrayList(createPeriod("201801"), createPeriod("201802"))).withOrganisationUnits(Lists.newArrayList(ouF)).build();
IllegalQueryException ex = assertThrows(IllegalQueryException.class, () -> securityManager.decideAccess(params));
assertEquals(ErrorCode.E7120, ex.getErrorCode());
}
use of org.hisp.dhis.common.IllegalQueryException in project dhis2-core by dhis2.
the class DefaultProgramMessageService method hasAccess.
@Override
@Transactional(readOnly = true)
public void hasAccess(ProgramMessageQueryParams params, User user) {
ProgramInstance programInstance = null;
Set<Program> programs;
if (params.hasProgramInstance()) {
programInstance = params.getProgramInstance();
}
if (params.hasProgramStageInstance()) {
programInstance = params.getProgramStageInstance().getProgramInstance();
}
if (programInstance == null) {
throw new IllegalQueryException("ProgramInstance or ProgramStageInstance has to be provided");
}
programs = new HashSet<>(programService.getUserPrograms(user));
if (user != null && !programs.contains(programInstance.getProgram())) {
throw new IllegalQueryException("User does not have access to the required program");
}
}
use of org.hisp.dhis.common.IllegalQueryException in project dhis2-core by dhis2.
the class DefaultProgramInstanceService method incompleteProgramInstanceStatus.
@Override
@Transactional
public void incompleteProgramInstanceStatus(ProgramInstance programInstance) {
Program program = programInstance.getProgram();
TrackedEntityInstance tei = programInstance.getEntityInstance();
if (getProgramInstances(tei, program, ProgramStatus.ACTIVE).size() > 0) {
log.warn("Program has another active enrollment going on. Not possible to incomplete");
throw new IllegalQueryException("Program has another active enrollment going on. Not possible to incomplete");
}
// -----------------------------------------------------------------
// Update program-instance
// -----------------------------------------------------------------
programInstance.setStatus(ProgramStatus.ACTIVE);
programInstance.setEndDate(null);
updateProgramInstance(programInstance);
}
use of org.hisp.dhis.common.IllegalQueryException in project dhis2-core by dhis2.
the class OutlierDetectionServiceValidationTest method testErrorValidation.
@Test
void testErrorValidation() {
OutlierDetectionRequest request = new OutlierDetectionRequest.Builder().withDataElements(Lists.newArrayList(deA, deB, deC)).withStartEndDate(getDate(2020, 1, 1), getDate(2020, 3, 1)).build();
IllegalQueryException ex = assertThrows(IllegalQueryException.class, () -> subject.validate(request));
assertEquals(ErrorCode.E2203, ex.getErrorCode());
}
Aggregations