Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.88 KB | None | 0 0
  1. public Obs getObs  (Obs obs,String view){
  2.     File file = getComplexDataFile(obs);
  3.     log.debug("value complex: " + obs.getValueComplex());
  4.     log.debug("file path: " + file.getAbsolutePath());
  5.     ComplexData complexData = null;
  6.     // to handle problem with downloading/saving files with blank spaces or commas in their names
  7.     // also need to remove the "file" text appended to the end of the file name
  8.     String[] names = obs.getValueComplex().split("\\|");
  9.     String originalFilename = names[0];
  10.     if ("download".equals(view)) {
  11.         originalFilename = originalFilename.replaceAll(",", "").replaceAll(" ", "").replaceAll("file$", "");
  12.     }
  13.    
  14.     try {
  15.         complexData = new ComplexData(originalFilename, OpenmrsUtil.getFileAsString(file).toCharArray());
  16.     }
  17.     catch (IOException e) {
  18.         log.error("Trying to read file: " + file.getAbsolutePath(), e);
  19.     }
  20.    
  21.     obs.setComplexData(complexData);
  22.    
  23.     return obs;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement