/** * @see org.openmrs.customdatatype.CustomDatatype#save(java.lang.Object, java.lang.String) */ @Override public String save(String typedValue, String existingValueReference) throws InvalidCustomValueException { // get existing object or create a new one ClobDatatypeStorage storage = existingValueReference != null ? Context.getDatatypeService() .getClobDatatypeStorageByUuid(existingValueReference) : new ClobDatatypeStorage(); storage.setValue(typedValue); storage = Context.getDatatypeService().saveClobDatatypeStorage(storage); return storage.getUuid(); }
@RequestMapping(method = RequestMethod.POST) @ResponseBody public String create(@RequestParam MultipartFile file, HttpServletRequest request, HttpServletResponse response) throws IOException { ClobDatatypeStorage clobData = new ClobDatatypeStorage(); String encoding = request.getHeader("Content-Encoding"); clobData.setValue(IOUtils.toString(file.getInputStream(), encoding)); clobData = datatypeService.saveClobDatatypeStorage(clobData); response.setStatus(HttpServletResponse.SC_CREATED); return clobData.getUuid(); }