- Timestamp:
- 05/11/08 23:52:52 (7 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
openmrs/branches/complex_obs/src/api/org/openmrs/obs/handler/ImageHandler.java
r4129 r4166 58 58 public Obs saveObs(Obs obs) { 59 59 BufferedImage img = (BufferedImage) obs.getComplexData() 60 .get BinaryObject();60 .getData(); 61 61 String title = obs.getComplexData().getTitle(); 62 62 SimpleDateFormat longfmt = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ"); … … 67 67 File outputfile = null; 68 68 69 // Write the image to the file system. 69 70 try { 70 71 if (null == title) { … … 74 75 } 75 76 if (outputfile.exists()) { 76 //String filename = outputfile.getName() + now;77 77 File altfile = new File(outputfile.getAbsolutePath() + now); 78 78 ImageIO.write(img, "jpg", altfile); … … 84 84 log.error("Trying to write complex obs to the file system. ", ioe); 85 85 } 86 obs.setValueComplex(outputfile.getAbsolutePath()); 86 87 // Set the Title and URI for the valueComplex 88 obs.setValueComplex("JPG Image |" + outputfile.getAbsolutePath()); 87 89 88 90 // TODO: Will the ComplexData instance remain in memory or be gc'd? … … 101 103 } 102 104 103 ComplexData complexData = new ComplexData(); 104 complexData.setBinaryObject(img); 105 complexData.setTitle(file.getName()); 105 ComplexData complexData = new ComplexData(file.getName(), img); 106 106 107 107 obs.setComplexData(complexData); … … 109 109 return obs; 110 110 } 111 112 public Obs purgeObs(Obs obs) { 113 return obs; 114 } 111 115 112 116 }