File tree Expand file tree Collapse file tree 4 files changed +155
-73
lines changed
java/org/openmrs/module/ugandaemrreports Expand file tree Collapse file tree 4 files changed +155
-73
lines changed Original file line number Diff line number Diff line change 2828 * This class contains the logic that is run every time this module is either started or stopped.
2929 */
3030public class UgandaEMRReportsActivator extends BaseModuleActivator {
31-
31+
3232 protected Log log = LogFactory .getLog (getClass ());
3333
3434 File folder = FileUtils .toFile (UgandaEMRReportsActivator .class .getClassLoader ().getResource ("report_designs" ));
@@ -39,14 +39,19 @@ public List<Initializer> getInitializers() {
3939 return l ;
4040 }
4141
42- @ Override
43- public void started () {
44- log .info ("UgandaEMR Reports module started - initializing..." );
45- Context .getService (FlattenDatabaseService .class ).setupEtl ();
46- for (Initializer initializer : getInitializers ()) {
47- initializer .started ();
48- }
49- }
42+ @ Override
43+ public void started () {
44+ log .info ("UgandaEMR Reports module started - initializing..." );
45+
46+ try {
47+ Context .getService (FlattenDatabaseService .class ).setupEtl ();
48+ for (Initializer initializer : getInitializers ()) {
49+ initializer .started ();
50+ }
51+ } catch (Exception e ) {
52+ log .error ("Error starting UgandaEMR Reports module" , e );
53+ }
54+ }
5055
5156 @ Override
5257 public void stopped () {
Original file line number Diff line number Diff line change 1+ package org .openmrs .module .ugandaemrreports .tasks ;
2+
3+ import org .apache .commons .logging .Log ;
4+ import org .apache .commons .logging .LogFactory ;
5+ import org .openmrs .api .context .Context ;
6+ import org .openmrs .module .mambacore .api .FlattenDatabaseService ;
7+ import org .openmrs .module .ugandaemrreports .activator .AppConfigInitializer ;
8+ import org .openmrs .module .ugandaemrreports .activator .Initializer ;
9+ import org .openmrs .module .ugandaemrreports .activator .ReportInitializer ;
10+ import org .openmrs .scheduler .tasks .AbstractTask ;
11+
12+ import java .util .ArrayList ;
13+ import java .util .List ;
14+
15+ public class InitaliseUgandaEMRReportsTask extends AbstractTask {
16+ Log log = LogFactory .getLog (InitaliseUgandaEMRReportsTask .class );
17+
18+ @ Override
19+ public void execute () {
20+
21+ log .info ("UgandaEMR Reports module started - initializing..." );
22+
23+ try {
24+ Context .getService (FlattenDatabaseService .class ).setupEtl ();
25+ for (Initializer initializer : getInitializers ()) {
26+ initializer .started ();
27+ }
28+ } catch (Exception e ) {
29+ log .error ("Error starting UgandaEMR Reports module" , e );
30+ }
31+
32+ }
33+
34+ public List <Initializer > getInitializers () {
35+ List <Initializer > l = new ArrayList <Initializer >();
36+ l .add (new AppConfigInitializer ());
37+ l .add (new ReportInitializer ());
38+ return l ;
39+ }
40+ }
Original file line number Diff line number Diff line change 177177 </insert >
178178 </changeSet >
179179
180+ <changeSet id =" ugandaemreports-2025-11-14" author =" slubwama" >
181+ <preConditions onFail =" MARK_RAN" >
182+ <sqlCheck expectedResult =" 0" >
183+ SELECT COUNT(*) FROM scheduler_task_config
184+ WHERE schedulable_class = 'org.openmrs.module.ugandaemrreports.tasks.InitaliseUgandaEMRReportsTask'
185+ </sqlCheck >
186+ </preConditions >
187+ <comment >Adding the InitaliseUgandaEMRReportsTask</comment >
188+ <insert tableName =" scheduler_task_config" >
189+ <column name =" name" value =" Initalise UgandaEMR Reports" />
190+ <column name =" description" value =" Initalises UgandaEMR Reports" />
191+ <column name =" schedulable_class" value =" org.openmrs.module.ugandaemrreports.tasks.InitaliseUgandaEMRReportsTask" />
192+ <column name =" start_time_pattern" value =" MM/dd/yyyy HH:mm:ss" />
193+ <column name =" start_time" valueDate =" 2023-01-15T19:44:15" />
194+ <column name =" repeat_interval" value =" 86400" />
195+ <column name =" date_created" valueDate =" CURRENT_TIMESTAMP" />
196+ <column name =" created_by" value =" 1" />
197+ <column name =" start_on_startup" value =" 1" />
198+ <column name =" started" value =" 1" />
199+ <column name =" uuid" value =" 816f3510-c12f-11f0-935f-b42cbf3ceef6" />
200+ </insert >
201+ </changeSet >
202+
180203</databaseChangeLog >
You can’t perform that action at this time.
0 commit comments