Downloads Documentation Community Contribute Demo






Show Sidebar
Login | Register
Show
Ignore:
Timestamp:
05/15/08 20:28:28 (6 months ago)
Author:
bmckown
Message:

complex_obs branch: Added ComplexObsServlet. Added extra (copied) ComplexObsHandler. Changed conceptForm.jsp to reflect api changes.

Files:

Legend:

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

    r4166 r4232  
    1919import java.text.SimpleDateFormat; 
    2020import java.util.Date; 
     21import java.util.HashMap; 
     22import java.util.Map; 
    2123 
    2224import javax.imageio.ImageIO; 
     
    3739        public Log log = LogFactory.getLog(this.getClass()); 
    3840         
    39         /** 
    40          * @see org.openmrs.obs.ComplexDataHandler#getValueAsString() 
    41          */ 
    42         public String getValueAsString() { 
    43                 // TODO Auto-generated method stub 
    44                 return null; 
     41        private Map<String, ComplexObsHandler> handlers; 
     42         
     43        public ImageHandler( ) { 
     44                handlers = new HashMap<String, ComplexObsHandler>(); 
    4545        } 
    46  
     46         
    4747        /** 
    4848         * @see org.openmrs.obs.ComplexDataHandler#renderObs() 
     
    5151                // TODO Auto-generated method stub 
    5252 
     53        } 
     54         
     55        public Obs saveObs(Obs obs, String context) { 
     56                if (this.handlers.containsKey(context)) { 
     57                        return this.handlers.get(context).saveObs(obs); 
     58                } 
     59                return this.saveObs(obs); 
     60        } 
     61         
     62        public Obs getObs(Obs obs, String context) { 
     63                if (this.handlers.containsKey(context)) { 
     64                        return this.handlers.get(context).getObs(obs); 
     65                } 
     66                return this.getObs(obs); 
    5367        } 
    5468 
     
    86100                 
    87101                // Set the Title and URI for the valueComplex 
    88                 obs.setValueComplex("JPG Image |" + outputfile.getAbsolutePath()); 
     102                //obs.setValueComplex("JPG Image |" + outputfile.getAbsolutePath()); 
     103                obs.setValueComplex("JPG Image |" + outputfile.getName()); 
    89104 
    90105                // TODO: Will the ComplexData instance remain in memory or be gc'd? 
     
    110125        } 
    111126         
     127        /** 
     128         * TODO: Implement this method! 
     129         *  
     130         * @param obs 
     131         * @return 
     132         */ 
    112133        public Obs purgeObs(Obs obs) { 
    113134                return obs; 
    114135        } 
    115136 
     137        public void putHandler(String context, ComplexObsHandler handler) { 
     138                this.handlers.put(context, handler); 
     139        } 
     140         
     141        public ComplexObsHandler getHandler(String context) { 
     142                return this.handlers.get(context); 
     143        } 
     144         
     145        public void putAllHandlers(Map<String, ComplexObsHandler> handlers) { 
     146                this.handlers.putAll(handlers); 
     147        } 
     148         
     149        public Map<String, ComplexObsHandler> getAllHandlers( ) { 
     150                return this.handlers; 
     151        } 
     152         
     153        public void removeHandler(String context) { 
     154                this.handlers.remove(context); 
     155        } 
     156         
     157        public boolean containsContext(String context) { 
     158                return this.handlers.containsKey(context); 
     159        } 
     160         
     161        public boolean containsHandler(ComplexObsHandler handler) { 
     162                return this.handlers.containsKey(handler); 
     163        } 
     164         
    116165}