use of org.hisp.dhis.dxf2.events.trackedentity.store.query.EventQuery.COLUMNS.UID in project dhis2-core by dhis2.
the class UidGeneratorTest method verifyEventsGetUidAssigned.
@Test
void verifyEventsGetUidAssigned() {
final String uid = CodeGenerator.generateUid();
// Given
Event event1 = new Event();
Event event2 = new Event();
Event event3 = new Event();
Event event4 = new Event();
event4.setEvent(uid);
// When
List<Event> events = subject.assignUidToEvents(Lists.newArrayList(event1, event2, event3, event4));
// Then
assertThat(events, hasSize(4));
events.forEach(e -> assertNotNull(e.getUid()));
// make sure we got 4 distinct UIDs
assertThat(events.stream().collect(Collectors.toMap(Event::getUid, Function.identity())).keySet(), hasSize(4));
// make sure Event4 has retained the original UID
assertThat(event4.getUid(), is(uid));
assertThat(event4.getEvent(), is(uid));
}
use of org.hisp.dhis.dxf2.events.trackedentity.store.query.EventQuery.COLUMNS.UID in project dhis2-core by dhis2.
the class ProgramOrgUnitCheckTest method verifySuccessWhenProgramHasOrgUnitMatchingEventOrgUnit.
private void verifySuccessWhenProgramHasOrgUnitMatchingEventOrgUnit(String orgUnitId, IdScheme scheme) {
// assign a UID to the event's org unit
event.setOrgUnit(orgUnitId);
// Prepare data
Program program = createProgram('P');
program.setId(1);
OrganisationUnit ou = new OrganisationUnit();
ou.setId(1);
ou.setUid(orgUnitId);
when(workContext.getOrganisationUnitMap()).thenReturn(ImmutableMap.of(event.getUid(), ou));
when(workContext.getProgramWithOrgUnitsMap()).thenReturn(ImmutableMap.of(1L, ImmutableList.of(1L)));
ProgramInstance pi = new ProgramInstance();
pi.setProgram(program);
Map<String, ProgramInstance> programInstanceMap = new HashMap<>();
programInstanceMap.put(event.getUid(), pi);
when(workContext.getProgramInstanceMap()).thenReturn(programInstanceMap);
ImportOptions importOptions = ImportOptions.getDefaultImportOptions();
importOptions.setOrgUnitIdScheme(scheme.name());
when(workContext.getImportOptions()).thenReturn(importOptions);
// method under test
ImportSummary summary = rule.check(new ImmutableEvent(event), workContext);
assertNoError(summary);
}
use of org.hisp.dhis.dxf2.events.trackedentity.store.query.EventQuery.COLUMNS.UID in project dhis2-core by dhis2.
the class MapController method getMapData.
// --------------------------------------------------------------------------
// Get data
// --------------------------------------------------------------------------
@GetMapping(value = { "/{uid}/data", "/{uid}/data.png" })
public void getMapData(@PathVariable String uid, @RequestParam(value = "date", required = false) Date date, @RequestParam(value = "ou", required = false) String ou, @RequestParam(required = false) Integer width, @RequestParam(required = false) Integer height, @RequestParam(value = "attachment", required = false) boolean attachment, HttpServletResponse response) throws Exception {
Map map = mappingService.getMapNoAcl(uid);
if (map == null) {
throw new WebMessageException(notFound("Map does not exist: " + uid));
}
if (width != null && width < MAP_MIN_WIDTH) {
throw new WebMessageException(conflict("Min map width is " + MAP_MIN_WIDTH + ": " + width));
}
if (height != null && height < MAP_MIN_HEIGHT) {
throw new WebMessageException(conflict("Min map height is " + MAP_MIN_HEIGHT + ": " + height));
}
OrganisationUnit unit = ou != null ? organisationUnitService.getOrganisationUnit(ou) : null;
renderMapViewPng(map, date, unit, width, height, attachment, response);
}
use of org.hisp.dhis.dxf2.events.trackedentity.store.query.EventQuery.COLUMNS.UID in project dhis2-core by dhis2.
the class MapController method putJsonObject.
// --------------------------------------------------------------------------
// CRUD
// --------------------------------------------------------------------------
@Override
@PutMapping(value = "/{uid}", consumes = APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.NO_CONTENT)
@ResponseBody
public WebMessage putJsonObject(@PathVariable String uid, @CurrentUser User currentUser, HttpServletRequest request) throws Exception {
Map map = mappingService.getMap(uid);
if (map == null) {
return notFound("Map does not exist: " + uid);
}
MetadataImportParams params = importService.getParamsFromMap(contextService.getParameterValuesMap());
Map newMap = deserializeJsonEntity(request);
newMap.setUid(uid);
mergeService.merge(new MergeParams<>(newMap, map).setMergeMode(params.getMergeMode()).setSkipSharing(params.isSkipSharing()).setSkipTranslation(params.isSkipTranslation()));
mappingService.updateMap(map);
return null;
}
use of org.hisp.dhis.dxf2.events.trackedentity.store.query.EventQuery.COLUMNS.UID in project dhis2-core by dhis2.
the class MapViewController method getMapViewData.
// --------------------------------------------------------------------------
// Get data
// --------------------------------------------------------------------------
@GetMapping(value = { "/{uid}/data", "/{uid}/data.png" })
public void getMapViewData(@PathVariable String uid, HttpServletResponse response) throws Exception {
MapView mapView = mappingService.getMapView(uid);
if (mapView == null) {
throw new WebMessageException(notFound("Map view does not exist: " + uid));
}
renderMapViewPng(mapView, response);
}
Aggregations