1 64 65 70 package com.jcorporate.expresso.services.job; 71 72 import com.jcorporate.expresso.core.dbobj.SecuredDBObject; 73 import com.jcorporate.expresso.core.job.Job; 74 import com.jcorporate.expresso.core.misc.EventHandler; 75 import com.jcorporate.expresso.core.security.User; 76 import com.jcorporate.expresso.services.dbobj.JobQueue; 77 import com.jcorporate.expresso.services.dbobj.JobQueueParam; 78 import org.apache.log4j.Logger; 79 80 import java.util.Iterator ; 81 82 83 92 public class TestJob 93 extends Job { 94 private static Logger log = Logger.getLogger(TestJob.class); 95 96 99 public TestJob() { 100 log.debug("INSTANTIATED TEST JOB"); 101 setSchema("com.jcorporate.expresso.core.ExpressoSchema"); 102 } 103 104 107 public String getTitle() { 108 return getString("Test_Job"); 109 } 110 111 114 public void run() { 115 log.debug("RUNNING TEST JOB"); 116 super.run(); 117 118 try { 119 StringBuffer mailMsg = new StringBuffer (""); 120 JobQueue jq = getJobQueueEntry(); 121 String uid = jq.getField("ExpUid"); 122 JobQueueParam jqp = new JobQueueParam(SecuredDBObject.SYSTEM_ACCOUNT); 123 jqp.setField("JobNumber", jq.getField("JobNumber")); 124 mailMsg.append(getString("Job_Number_") + 125 jq.getField("JobNumber")); 126 mailMsg.append("\n"); 127 128 JobQueueParam oneJqp = null; 129 130 for (Iterator je = jqp.searchAndRetrieveList("ParamNumber").iterator(); 131 je.hasNext();) { 132 oneJqp = (JobQueueParam) je.next(); 133 mailMsg.append(java.util.ResourceBundle.getBundle("com/jcorporate/expresso/core/MessagesBundle_en").getString( 134 "Parameter_") + 135 oneJqp.getField("ParamCode")); 136 mailMsg.append("="); 137 mailMsg.append(oneJqp.getField("ParamValue")); 138 mailMsg.append("\n"); 139 } 140 141 142 User oneUser = new User(); 143 oneUser.setDataContext(getDataContext()); 144 oneUser.setUid(uid); 145 oneUser.retrieve(); 146 EventHandler.notify(getJobQueueEntry().getDataContext(), 147 oneUser.getUid(), 148 getString("Test_Job_Complete"), 149 mailMsg.toString()); 150 log.info(getString("Test_Job_completed_-_removing_queue_entry")); 151 finish(getString("Test_Job_Completed")); 152 } catch (Exception de) { 153 finish(getString("Test_Job_Failed"), de); 154 } 155 } 156 157 } 158 | Popular Tags |