use of org.hisp.dhis.dxf2.webmessage.WebMessage in project dhis2-core by dhis2.
the class EventController method putJsonEventForEventDate.
@PutMapping(value = "/{uid}/eventDate", consumes = APPLICATION_JSON_VALUE)
@ResponseBody
public WebMessage putJsonEventForEventDate(HttpServletRequest request, @PathVariable("uid") String uid, ImportOptions importOptions) throws IOException {
if (!programStageInstanceService.programStageInstanceExists(uid)) {
return notFound("Event not found for ID " + uid);
}
InputStream inputStream = StreamUtils.wrapAndCheckCompressionFormat(request.getInputStream());
Event updatedEvent = renderService.fromJson(inputStream, Event.class);
updatedEvent.setEvent(uid);
eventService.updateEventForEventDate(updatedEvent);
return ok("Event updated " + uid);
}
use of org.hisp.dhis.dxf2.webmessage.WebMessage in project dhis2-core by dhis2.
the class EventController method postJsonEventForNote.
@PostMapping(value = "/{uid}/note", consumes = APPLICATION_JSON_VALUE)
@ResponseBody
public WebMessage postJsonEventForNote(@PathVariable("uid") String uid, HttpServletRequest request, ImportOptions importOptions) throws IOException {
if (!programStageInstanceService.programStageInstanceExists(uid)) {
return notFound("Event not found for ID " + uid);
}
InputStream inputStream = StreamUtils.wrapAndCheckCompressionFormat(request.getInputStream());
Event event = renderService.fromJson(inputStream, Event.class);
event.setEvent(uid);
eventService.updateEventForNote(event);
return ok("Event updated: " + uid);
}
use of org.hisp.dhis.dxf2.webmessage.WebMessage in project dhis2-core by dhis2.
the class EventController method putXmlEvent.
// -------------------------------------------------------------------------
// Update
// -------------------------------------------------------------------------
@PutMapping(value = "/{uid}", consumes = { APPLICATION_XML_VALUE, TEXT_XML_VALUE })
@ResponseBody
public WebMessage putXmlEvent(HttpServletRequest request, @PathVariable("uid") String uid, ImportOptions importOptions) throws IOException {
InputStream inputStream = StreamUtils.wrapAndCheckCompressionFormat(request.getInputStream());
Event updatedEvent = renderService.fromXml(inputStream, Event.class);
updatedEvent.setEvent(uid);
return updateEvent(updatedEvent, false, importOptions);
}
use of org.hisp.dhis.dxf2.webmessage.WebMessage in project dhis2-core by dhis2.
the class EventController method startAsyncImport.
// -------------------------------------------------------------------------
// Supportive methods
// -------------------------------------------------------------------------
/**
* Starts an asynchronous import task.
*
* @param importOptions the ImportOptions.
* @param events the events to import.
*/
private WebMessage startAsyncImport(ImportOptions importOptions, List<Event> events) {
JobConfiguration jobId = new JobConfiguration("inMemoryEventImport", EVENT_IMPORT, currentUserService.getCurrentUser().getUid(), true);
taskExecutor.executeTask(new ImportEventsTask(events, eventService, importOptions, jobId));
return jobConfigurationReport(jobId).setLocation("/system/tasks/" + EVENT_IMPORT);
}
use of org.hisp.dhis.dxf2.webmessage.WebMessage in project dhis2-core by dhis2.
the class EventController method putJsonEventSingleValue.
@PutMapping(value = "/{uid}/{dataElementUid}", consumes = APPLICATION_JSON_VALUE)
@ResponseBody
public WebMessage putJsonEventSingleValue(HttpServletRequest request, @PathVariable("uid") String uid, @PathVariable("dataElementUid") String dataElementUid) throws IOException {
DataElement dataElement = dataElementService.getDataElement(dataElementUid);
if (dataElement == null) {
return notFound("DataElement not found for ID " + dataElementUid);
}
InputStream inputStream = StreamUtils.wrapAndCheckCompressionFormat(request.getInputStream());
Event updatedEvent = renderService.fromJson(inputStream, Event.class);
updatedEvent.setEvent(uid);
return updateEvent(updatedEvent, true, null);
}
Aggregations