Downloads Documentation Community Contribute Demo






Show Sidebar
Login | Register
Show
Ignore:
Timestamp:
05/12/08 12:34:55 (7 months ago)
Author:
dkayiwa
Message:

xforms module: upgrading to use 1.2.04 version of the openmrs api

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • openmrs-modules/xforms/trunk/src/org/openmrs/module/xforms/ProcessXformsQueueTask.java

    r3226 r4171  
    44import org.apache.commons.logging.LogFactory; 
    55import org.openmrs.api.APIException; 
    6 import org.openmrs.api.AdministrationService; 
    76import org.openmrs.api.context.Context; 
    8 import org.openmrs.api.context.ContextAuthenticationException; 
    9 import org.openmrs.module.xforms.bluetooth.XformsBluetoothTask; 
    10 import org.openmrs.scheduler.TaskConfig; 
    11 import org.openmrs.scheduler.Schedulable; 
    12  
     7import org.openmrs.scheduler.tasks.AbstractTask; 
    138 
    149/** 
     
    1813 * @version 1.0 
    1914 */ 
    20 public class ProcessXformsQueueTask implements Schedulable
     15public class ProcessXformsQueueTask extends AbstractTask
    2116 
    22 //      Logger 
     17       // Logger 
    2318        private static Log log = LogFactory.getLog(ProcessXformsQueueTask.class); 
    2419 
    25         // Task configuration  
    26         private TaskConfig taskConfig; 
    27          
    28         //Instance of xforms processor. 
     20        // Instance of xforms processor. 
    2921        private XformsQueueProcessor processor = null; 
    30          
     22 
    3123        /** 
    3224         * Default Constructor (Uses SchedulerConstants.username and 
     
    4032 
    4133        /** 
    42          * Process the next xform in the queue and then remove the xform 
    43          * from the queue. 
     34         * Process the next xform in the queue and then remove the xform from the 
     35         * queue. 
    4436         */ 
    45         public void run() { 
     37        public void execute() { 
    4638                Context.openSession(); 
    4739                log.debug("Running xforms queue task... "); 
     
    4941                        if (Context.isAuthenticated() == false) 
    5042                                authenticate(); 
    51                          
    5243                        processor.processXformsQueue(); 
    53                          
    5444                } catch (APIException e) { 
    5545                        log.error("Error running xforms queue task", e); 
     
    5949                } 
    6050        } 
    61          
     51 
    6252        /** 
    6353         * Clean up any resources here 
    64          * 
     54         *  
    6555         */ 
    6656        public void shutdown() { 
    67                  
    68         } 
    69          
    70         /** 
    71          * Initialize task. 
    72          *  
    73          * @param config 
    74          */ 
    75         public void initialize(TaskConfig config) {  
    76                 this.taskConfig = config; 
    77         } 
    78          
    79         private void authenticate() { 
    80                 try { 
    81                         AdministrationService adminService = Context.getAdministrationService(); 
    82                         Context.authenticate(adminService.getGlobalProperty("scheduler.username"), 
    83                                 adminService.getGlobalProperty("scheduler.password")); 
    84                          
    85                 } catch (ContextAuthenticationException e) { 
    86                         log.error("Error authenticating user", e); 
    87                 } 
     57                processor = null; 
     58                super.shutdown(); 
     59                log.debug("Shutting down ProcessXformsQueue task ..."); 
    8860        } 
    8961}