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/ComplexData.java

    r4129 r4166  
    1919/** 
    2020 * ComplexObs is a transient Object that extends Obs but is not itself persisted 
    21  * in the database. It has a binaryObject and a title. 
     21 * in the database. It has a data Object and a title. 
    2222 *  
    2323 */ 
     
    2626        public static final long serialVersionUID = 345734100L; 
    2727 
    28         private Object binaryObject
     28        private Object data
    2929        private String title; 
    3030 
    31         public ComplexData() { 
    32  
    33         } 
    34  
    35         public ComplexData(String title, Object binaryObject) { 
     31        /** 
     32         * Default constructor requires title and data. 
     33         *  
     34         * @param title Name or brief description of ComplexData. 
     35         * @param data The complex data for an Obs 
     36         */ 
     37        public ComplexData(String title, Object data) { 
    3638                setTitle(title); 
    37                 setBinaryObject(binaryObject); 
     39                setData(data); 
    3840        } 
    3941 
    4042        /** 
    41          * Static convenience method to get the ComplexObsHandler associated with a 
    42          * complex Obs. Returns the ComplexObsHandler. Returns null if the 
    43          * Obs.isComplexObs() is false or there is an error instantiating the 
    44          * handler class.  
     43         * Set the data Object. 
    4544         *  
    46          * TODO: Should ComplexObsHandler be an abstract class and 
    47          * put this method there instead? 
    48          *  
    49          * @param obs A complex Obs. 
    50          * @return ComplexObsHandler for the complex Obs. or null on error. 
     45         * @param data 
    5146         */ 
    52         public static ComplexObsHandler getHandler(Obs obs) { 
    53                 if (!obs.getConcept().isComplex()) { 
    54                         return null; 
    55                 } 
    56                 String className = ((ConceptComplex) obs.getConcept()).getHandler() 
    57                                                                       .getHandlerClass(); 
    58                 ComplexObsHandler handler = null; 
    59                 try { 
    60                         Class handlerClass = Class.forName(className); 
    61                         handler = (ComplexObsHandler) handlerClass.newInstance(); 
    62                 } catch (ClassNotFoundException cnfe) { 
    63                         return null; 
    64                 } catch (InstantiationException ie) { 
    65                         return null; 
    66                 } catch (IllegalAccessException iae) { 
    67                         return null; 
    68                 } 
    69                 return handler; 
     47        public void setData(Object data) { 
     48                this.data = data; 
    7049        } 
    7150 
    72         public void setBinaryObject(Object binaryObject) { 
    73                 this.binaryObject = binaryObject; 
     51        /** 
     52         * Get the data Object 
     53         *  
     54         * @return 
     55         */ 
     56        public Object getData() { 
     57                return this.data; 
    7458        } 
    7559 
    76         public Object getBinaryObject() { 
    77                 return this.binaryObject; 
    78         } 
    79  
     60        /** 
     61         * Set the title for this ComplexData 
     62         *  
     63         * @param title 
     64         */ 
    8065        public void setTitle(String title) { 
    8166                this.title = title; 
    8267        } 
    8368 
     69        /** 
     70         * Get the title for this ComplexData 
     71         *  
     72         * @return 
     73         */ 
    8474        public String getTitle() { 
    8575                return this.title;