use of org.hisp.dhis.dxf2.events.trackedentity.store.query.EventQuery.COLUMNS.UID in project dhis2-core by dhis2.
the class SmsGatewayController method getGatewayConfiguration.
@PreAuthorize("hasRole('ALL') or hasRole('F_MOBILE_SENDSMS')")
@GetMapping(value = "/{uid}", produces = APPLICATION_JSON_VALUE)
public void getGatewayConfiguration(@PathVariable String uid, HttpServletResponse response) throws WebMessageException, IOException {
SmsGatewayConfig gateway = gatewayAdminService.getByUid(uid);
if (gateway == null) {
throw new WebMessageException(notFound("No gateway found"));
}
generateOutput(response, gateway);
}
use of org.hisp.dhis.dxf2.events.trackedentity.store.query.EventQuery.COLUMNS.UID in project dhis2-core by dhis2.
the class ProgramStageInstanceSupplierTest method verifySupplier.
@Test
void verifySupplier() throws SQLException {
// mock resultset data
when(mockResultSet.getLong("programstageinstanceid")).thenReturn(100L);
when(mockResultSet.getString("uid")).thenReturn("abcded");
when(mockResultSet.getString("status")).thenReturn("ACTIVE");
when(mockResultSet.getBoolean("deleted")).thenReturn(false);
// create event to import
Event event = new Event();
event.setUid(CodeGenerator.generateUid());
event.setEnrollment("abcded");
// mock resultset extraction
mockResultSetExtractor(mockResultSet);
Map<String, ProgramStageInstance> map = subject.get(ImportOptions.getDefaultImportOptions(), Collections.singletonList(event));
ProgramStageInstance programStageInstance = map.get("abcded");
assertThat(programStageInstance, is(notNullValue()));
assertThat(programStageInstance.getId(), is(100L));
assertThat(programStageInstance.getUid(), is("abcded"));
assertThat(programStageInstance.getStatus(), is(EventStatus.ACTIVE));
assertThat(programStageInstance.isDeleted(), is(false));
}
use of org.hisp.dhis.dxf2.events.trackedentity.store.query.EventQuery.COLUMNS.UID in project dhis2-core by dhis2.
the class ProgramSupplierTest method verifySupplier.
@ParameterizedTest
@MethodSource("data")
public void verifySupplier(String idScheme) throws SQLException {
when(mockResultSet.next()).thenReturn(true).thenReturn(true).thenReturn(false);
when(mockResultSet.getLong("id")).thenReturn(100L);
when(mockResultSet.getString("uid")).thenReturn("abcded");
when(mockResultSet.getString("code")).thenReturn("ALFA");
when(mockResultSet.getString("name")).thenReturn("My Program");
when(mockResultSet.getString("type")).thenReturn(ProgramType.WITHOUT_REGISTRATION.getValue());
when(mockResultSet.getString("program_sharing")).thenReturn(generateSharing(null, "rw------", false));
when(mockResultSet.getInt("opendaysaftercoenddate")).thenReturn(42);
when(mockResultSet.getLong("catcombo_id")).thenReturn(200L);
when(mockResultSet.getString("catcombo_uid")).thenReturn("389dh83");
when(mockResultSet.getString("catcombo_code")).thenReturn("BETA");
when(mockResultSet.getString("catcombo_name")).thenReturn("My CatCombo");
when(mockResultSet.getLong("ps_id")).thenReturn(5L, 6L);
when(mockResultSet.getString("ps_uid")).thenReturn("abcd5", "abcd6");
when(mockResultSet.getString("ps_code")).thenReturn("cod5", "cod6");
when(mockResultSet.getString("ps_name")).thenReturn("name5", "name6");
when(mockResultSet.getInt("sort_order")).thenReturn(1, 2);
when(mockResultSet.getString("ps_sharing")).thenReturn(generateSharing(null, "rw------", false));
when(mockResultSet.getString("ps_feature_type")).thenReturn(null, "POINT");
when(mockResultSet.getBoolean("ps_repeatable")).thenReturn(true, false);
when(mockResultSet.getString("validationstrategy")).thenReturn("ON_COMPLETE");
when(mockResultSet.getObject("uid")).thenReturn("abcded");
when(mockResultSet.getObject("id")).thenReturn(100L);
when(mockResultSet.getObject("name")).thenReturn("My Program");
when(mockResultSet.getObject("code")).thenReturn("ALFA");
// mock resultset extraction
mockResultSetExtractorWithoutParameters(mockResultSet);
ImportOptions importOptions = ImportOptions.getDefaultImportOptions();
importOptions.getIdSchemes().setProgramIdScheme(idScheme);
final Map<String, Program> map = subject.get(importOptions, null);
Program program = map.get(getIdByScheme(idScheme));
assertThat(program, is(notNullValue()));
assertThat(program.getProgramStages(), hasSize(2));
assertThat(program.getId(), is(100L));
assertThat(program.getCode(), is("ALFA"));
assertThat(program.getName(), is("My Program"));
assertThat(program.getProgramType(), is(ProgramType.WITHOUT_REGISTRATION));
assertThat(program.getSharing().getPublicAccess(), is("rw------"));
assertThat(program.getOpenDaysAfterCoEndDate(), is(42));
assertThat(program.getCategoryCombo(), is(notNullValue()));
assertThat(program.getCategoryCombo().getId(), is(200L));
assertThat(program.getCategoryCombo().getUid(), is("389dh83"));
assertThat(program.getCategoryCombo().getName(), is("My CatCombo"));
assertThat(program.getCategoryCombo().getCode(), is("BETA"));
// TODO assert more data
}
use of org.hisp.dhis.dxf2.events.trackedentity.store.query.EventQuery.COLUMNS.UID in project dhis2-core by dhis2.
the class DataValueSetServiceTest method testImportDataValuesXmlDryRun.
@Test
void testImportDataValuesXmlDryRun() throws Exception {
in = new ClassPathResource("datavalueset/dataValueSetB.xml").getInputStream();
ImportOptions importOptions = new ImportOptions().setDryRun(true).setIdScheme("UID").setDataElementIdScheme("UID").setOrgUnitIdScheme("UID");
ImportSummary summary = dataValueSetService.importDataValueSetXml(in, importOptions);
assertEquals(ImportStatus.SUCCESS, summary.getStatus());
assertHasNoConflicts(summary);
Collection<DataValue> dataValues = mockDataValueBatchHandler.getInserts();
assertNotNull(dataValues);
assertEquals(0, dataValues.size());
}
use of org.hisp.dhis.dxf2.events.trackedentity.store.query.EventQuery.COLUMNS.UID in project dhis2-core by dhis2.
the class TrackerEventsExportController method getEvent.
@GetMapping("/{uid}")
public org.hisp.dhis.tracker.domain.Event getEvent(@PathVariable("uid") String uid, @RequestParam Map<String, String> parameters, HttpServletRequest request) throws Exception {
Event event = eventService.getEvent(programStageInstanceService.getProgramStageInstance(uid));
if (event == null) {
throw new WebMessageException(notFound("Event not found for ID " + uid));
}
event.setHref(getUri(uid, request));
return EVENTS_MAPPER.from(event);
}
Aggregations