Downloads Documentation Community Contribute Demo






Show Sidebar
Login | Register
Show
Ignore:
Timestamp:
05/11/08 23:52:52 (7 months ago)
Author:
bmckown
Message:

complex_obs branch: Changed to mapping the ComplexObsHandlers instead of using ConceptComplexHandler class.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • openmrs/branches/complex_obs/src/api/org/openmrs/obs/handler/ImageHandler.java

    r4129 r4166  
    5858        public Obs saveObs(Obs obs) { 
    5959                BufferedImage img = (BufferedImage) obs.getComplexData() 
    60                                                        .getBinaryObject(); 
     60                                                       .getData(); 
    6161                String title = obs.getComplexData().getTitle(); 
    6262                SimpleDateFormat longfmt = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ"); 
     
    6767                File outputfile = null; 
    6868 
     69                // Write the image to the file system. 
    6970                try { 
    7071                        if (null == title) { 
     
    7475                        } 
    7576                        if (outputfile.exists()) { 
    76                                 //String filename = outputfile.getName() + now; 
    7777                                File altfile = new File(outputfile.getAbsolutePath() + now); 
    7878                                ImageIO.write(img, "jpg", altfile); 
     
    8484                        log.error("Trying to write complex obs to the file system. ", ioe); 
    8585                } 
    86                 obs.setValueComplex(outputfile.getAbsolutePath()); 
     86                 
     87                // Set the Title and URI for the valueComplex 
     88                obs.setValueComplex("JPG Image |" + outputfile.getAbsolutePath()); 
    8789 
    8890                // TODO: Will the ComplexData instance remain in memory or be gc'd? 
     
    101103                } 
    102104 
    103                 ComplexData complexData = new ComplexData(); 
    104                 complexData.setBinaryObject(img); 
    105                 complexData.setTitle(file.getName()); 
     105                ComplexData complexData = new ComplexData(file.getName(), img); 
    106106                 
    107107                obs.setComplexData(complexData); 
     
    109109                return obs; 
    110110        } 
     111         
     112        public Obs purgeObs(Obs obs) { 
     113                return obs; 
     114        } 
    111115 
    112116}