Downloads Documentation Community Contribute Demo






Show Sidebar
Login | Register

Changeset 4142

Show
Ignore:
Timestamp:
05/08/08 16:37:10 (8 months ago)
Author:
catullus
Message:

child-vct-report: updated to work with new scheduler.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • openmrs-modules/ChildVCTReportModule/.classpath

    r4035 r4142  
    66        <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> 
    77        <classpathentry kind="lib" path="metadata"/> 
    8          
    9         <!-- Uncomment this line to be able to recognize omods placed in here for junit testing --> 
    10         <!-- <classpathentry kind="lib" path="dist"/> --> 
    11          
    128        <classpathentry kind="lib" path="lib-common/junit-3.8.1.jar"/> 
    13         <classpathentry kind="lib" path="lib-common/openmrs-api-1.2.0.3409.jar"/> 
    14         <classpathentry kind="lib" path="lib-common/web-openmrs-api-1.2.0.3530.jar"/> 
    159        <classpathentry kind="lib" path="lib-common/commons-logging-1.0.4.jar"/> 
    1610        <classpathentry kind="lib" path="lib-common/spring-2.0.jar"/> 
    1711        <classpathentry kind="lib" path="lib-common/servlet-api.jar"/> 
    1812        <classpathentry kind="lib" path="lib-common/hibernate3.jar"/> 
    19          
     13        <classpathentry kind="lib" path="lib-common/openmrs-api-1.2.04.4131.jar" sourcepath="/openmrs-sync/src"/> 
     14        <classpathentry kind="lib" path="lib-common/web-openmrs-api-1.2.04.4131.jar"/> 
    2015        <classpathentry kind="output" path="build"/> 
    2116</classpath> 
  • openmrs-modules/ChildVCTReportModule/dist

    • Property svn:ignore set to
      childvctreportmodule-1.0.omod
      childvctreportmodule-1.1.omod
  • openmrs-modules/ChildVCTReportModule/metadata/config.xml

    r4050 r4142  
    77        <id>childvctreportmodule</id> 
    88        <name>Child VCT Report Module</name> 
    9         <version>1.0</version> 
     9        <version>1.1</version> 
    1010        <package>org.openmrs.module.@MODULE_ID@</package> 
    1111        <author>Chase Yarbrough</author> 
     
    1919        <!-- /Child VCT Report Module Properties --> 
    2020         
    21         <require_version>1.2.0.3872</require_version> 
     21        <require_version>1.2.04.4132</require_version> 
    2222         
    2323        <!-- Extensions --> 
     
    4545        <globalProperty> 
    4646                <property>@MODULE_ID@.weeklySummary.emailTo</property> 
    47                 <defaultValue></defaultValue> 
     47                <defaultValue>vergil@gmail.com</defaultValue> 
    4848                <description> 
    4949                        The weekly summary is emailed to this address. 
  • openmrs-modules/ChildVCTReportModule/src/org/openmrs/module/childvctreportmodule/ChildVCTReport.java

    r4050 r4142  
    3939         * @throws IOException 
    4040         */ 
    41         public void generateCSV(ServletOutputStream out) throws IOException{ 
    42                 generateTitleRow(out); 
     41        public String generateCSV() throws IOException{ 
     42                String titleRow = generateTitleRow(); 
     43                String otherRows = ""; 
    4344                for(ChildVCTReportItem reportItem : itemList) 
    44                         generateDataRow(reportItem, out); 
     45                        otherRows+=generateDataRow(reportItem) + "\r\n"; 
     46                return titleRow + "\r\n" + otherRows; 
    4547         } 
    4648         
    47         private void generateDataRow(ChildVCTReportItem reportItem, ServletOutputStream out) throws IOException{ 
     49        private String generateDataRow(ChildVCTReportItem reportItem) throws IOException{ 
    4850                String dataRow = ""; 
    4951                for(String column : reportItem.getReportColumns()) 
    5052                        dataRow+=column + ","; 
    51                 out.println(dataRow)
     53                return dataRow
    5254        } 
    5355 
    54         private void generateTitleRow(ServletOutputStream out) throws IOException { 
     56        private String generateTitleRow() throws IOException { 
    5557                String headerRow = ""; 
    5658                for(String columnName : ChildVCTReportItem.REPORT_COLUMNS_NAMES) 
    5759                        headerRow+=columnName + ","; 
    58                 out.println(headerRow)
     60                return headerRow
    5961        } 
    6062 
     
    8284                return itemList.isEmpty(); 
    8385        } 
     86 
     87        public int length() { 
     88                return itemList.size(); 
     89        } 
    8490         
    8591        private ArrayList<ChildVCTReportItem> itemList; 
     92 
    8693         
    8794} 
  • openmrs-modules/ChildVCTReportModule/src/org/openmrs/module/childvctreportmodule/ChildVCTReportModuleActivator.java

    r4035 r4142  
    2626        private Log log = LogFactory.getLog(this.getClass()); 
    2727 
     28         
    2829        /** 
    2930         * @see org.openmrs.module.Activator#startup() 
     
    3132        public void startup() { 
    3233                log.info("Starting Basic Module"); 
     34                 
    3335        } 
    3436         
  • openmrs-modules/ChildVCTReportModule/web/module/childvctreportmoduleSettingsForm.jsp

    r4050 r4142  
    55<h2>Automatic Weekly Report Settings</h2> 
    66<br/> 
    7 <openmrs:portlet url="globalProperties" parameters="title=${title}|propertyPrefix=childvctreportmodule.|excludePrefix=formimportexport.started|hidePrefix=true"/> 
     7<openmrs:portlet url="globalProperties" parameters="title=${title}|propertyPrefix=mail.|hidePrefix=false"/> 
     8<openmrs:portlet url="globalProperties" parameters="title=${title}|propertyPrefix=childvctreportmodule.|excludePrefix=childvctreportmodule.started|hidePrefix=false"/> 
    89 
     10<form method="post"> 
     11        Select day and time for weekly email: <br> 
     12        <select name="day"> 
     13                <option value="Sunday">Sunday</option> 
     14                <option value="Monday">Monday</option> 
     15                <option value="Tuesday">Tuesday</option> 
     16                <option value="Wednesday">Wednesday</option> 
     17                <option value="Thursday">Thursday</option> 
     18                <option value="Friday">Friday</option> 
     19                <option value="Saturday">Saturday</option> 
     20        </select> 
     21        <select name="time"> 
     22                <option value="0">12:00am</option> 
     23                <option value="1">1:00am</option> 
     24                <option value="2">2:00am</option> 
     25                <option value="3">3:00am</option> 
     26                <option value="4">4:00am</option> 
     27                <option value="5">5:00am</option> 
     28                <option value="6">6:00am</option> 
     29                <option value="7">7:00am</option> 
     30                <option value="8">8:00am</option> 
     31                <option value="9">9:00am</option> 
     32                <option value="10">10:00am</option> 
     33                <option value="11">11:00am</option> 
     34                <option value="12">12:00pm</option> 
     35                <option value="13">1:00pm</option> 
     36                <option value="14">2:00pm</option> 
     37                <option value="15">3:00pm</option> 
     38                <option value="16">4:00pm</option> 
     39                <option value="17">5:00pm</option> 
     40                <option value="18">6:00pm</option> 
     41                <option value="19">7:00pm</option> 
     42                <option value="20">8:00pm</option> 
     43                <option value="21">9:00pm</option> 
     44                <option value="22">10:00pm</option> 
     45                <option value="23">11:00pm</option> 
     46        </select> 
     47        <input type="submit" value="submit"> 
     48</form> 
    949<%@ include file="/WEB-INF/template/footer.jsp"%> 
  • openmrs-modules/ChildVCTReportModule/web/src/org/openmrs/module/childvctreportmodule/web/controller/ChildVCTReportModuleFormController.java

    r4050 r4142  
    7575                ServletOutputStream out = response.getOutputStream(); 
    7676                 
    77                 report.generateCSV(out); 
     77                out.print(report.generateCSV()); 
    7878                 
    7979        return new ModelAndView(new RedirectView(getSuccessView())); 
  • openmrs-modules/ChildVCTReportModule/web/src/org/openmrs/module/childvctreportmodule/web/controller/ChildVCTReportModuleManualFormController.java

    r4050 r4142  
    6464                        response.setHeader("Content-Disposition", "attachment; filename=" + filename); 
    6565                        ServletOutputStream out = response.getOutputStream(); 
    66                         report.generateCSV(out); 
     66                        String reportAsString = report.generateCSV(); 
     67                        out.print(reportAsString); 
    6768                } 
    6869                 
  • openmrs-modules/ChildVCTReportModule/web/src/org/openmrs/module/childvctreportmodule/web/controller/ChildVCTReportModuleSettingsFormController.java

    r4050 r4142  
    88import java.util.Map; 
    99 
    10 import javax.servlet.ServletOutputStream; 
    1110import javax.servlet.http.HttpServletRequest; 
    1211import javax.servlet.http.HttpServletResponse; 
     
    1413import org.openmrs.Patient; 
    1514import org.openmrs.api.context.Context; 
    16 import org.openmrs.module.childvctreportmodule.ChildVCTReport; 
    17 import org.openmrs.module.childvctreportmodule.ChildVCTReportModuleService; 
     15import org.openmrs.module.childvctreportmodule.ChildVCTReportConstants; 
     16import org.openmrs.scheduler.SchedulerException; 
     17import org.openmrs.scheduler.TaskDefinition; 
    1818import org.springframework.validation.BindException; 
    1919import org.springframework.validation.Errors; 
     
    4343        @Override 
    4444        protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object object, BindException exceptions) throws Exception { 
    45                 response.getOutputStream().println("success"); 
     45                String day = request.getParameter("day"); 
     46                String time = request.getParameter("time"); 
     47                 
     48                SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy.MM.dd.H"); 
     49                 
     50                Date date = dateFormat.parse("2008.04.20." + time); 
     51                 
     52                if(day.equals("Sunday")) 
     53                        date = dateFormat.parse("2008.04.20." + time); 
     54                else if(day.equals("Monday")) 
     55                        date = dateFormat.parse("2008.04.21." + time); 
     56                else if(day.equals("Tuesday")) 
     57                        date = dateFormat.parse("2008.04.22." + time); 
     58                else if(day.equals("Wednesday")) 
     59                        date = dateFormat.parse("2008.04.23." + time); 
     60                else if(day.equals("Thursday")) 
     61                        date = dateFormat.parse("2008.04.24." + time); 
     62                else if(day.equals("Friday")) 
     63                        date = dateFormat.parse("2008.04.25." + time); 
     64                else if(day.equals("Saturday")) 
     65                        date = dateFormat.parse("2008.04.26." + time); 
     66                 
     67                Collection<TaskDefinition> tasks = Context.getSchedulerService().getRegisteredTasks(); 
     68                for(TaskDefinition task : tasks){ 
     69                        if(task.getTaskClass().equals(ChildVCTReportConstants.SCHEDULABLE_CLASS_NAME)) 
     70                                Context.getSchedulerService().deleteTask(task.getId()); 
     71                } 
     72                 
     73                TaskDefinition reportEmailTaskConfig = new TaskDefinition(); 
     74                 
     75                reportEmailTaskConfig.setName("Child VCT weekly Email report"); 
     76                reportEmailTaskConfig.setDescription("Sends a weekly email with the Child VCT Report."); 
     77                reportEmailTaskConfig.setRepeatInterval(ChildVCTReportConstants.REPEAT_INTERVAL_SECONDS); 
     78                reportEmailTaskConfig.setStartTime(date); 
     79                reportEmailTaskConfig.setTaskClass(ChildVCTReportConstants.SCHEDULABLE_CLASS_NAME); 
     80                reportEmailTaskConfig.setStarted(true); 
     81                reportEmailTaskConfig.setStartOnStartup(true); 
     82                 
     83                Context.getSchedulerService().saveTask(reportEmailTaskConfig); 
     84                try { 
     85                        Context.getSchedulerService().scheduleTask(reportEmailTaskConfig); 
     86                } catch (SchedulerException e) { 
     87                        e.printStackTrace(); 
     88                } 
    4689        return new ModelAndView(new RedirectView(getSuccessView())); 
    4790    }