-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BAH-4106 | Fix. Create beans for scheduler task classes to initialize…
… context properly (#83) * BAH-4106 | Fix. Create beans for scheduler task classes to initialize context properly * BAH-4106 | Refactor. Use Context class to get bean of IPDEventManager
- Loading branch information
Showing
2 changed files
with
6 additions
and
21 deletions.
There are no files selected for viewing
14 changes: 3 additions & 11 deletions
14
api/src/main/java/org/openmrs/module/ipd/api/scheduler/tasks/RollOverNonMedicationTasks.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,22 @@ | ||
package org.openmrs.module.ipd.api.scheduler.tasks; | ||
|
||
import org.openmrs.api.context.Context; | ||
import org.openmrs.module.ipd.api.events.IPDEventManager; | ||
import org.openmrs.module.ipd.api.events.model.IPDEvent; | ||
import org.openmrs.module.ipd.api.events.model.IPDEventType; | ||
import org.openmrs.scheduler.tasks.AbstractTask; | ||
import org.springframework.context.ApplicationContext; | ||
import org.springframework.context.ApplicationContextAware; | ||
import org.springframework.stereotype.Component; | ||
|
||
|
||
public class RollOverNonMedicationTasks extends AbstractTask implements ApplicationContextAware { | ||
|
||
private static ApplicationContext context; | ||
public class RollOverNonMedicationTasks extends AbstractTask { | ||
|
||
@Override | ||
public void execute() { | ||
IPDEventManager eventManager = context.getBean(IPDEventManager.class); | ||
IPDEventManager eventManager = Context.getRegisteredComponents(IPDEventManager.class).get(0); | ||
IPDEventType eventType = eventManager.getEventTypeForEncounter(String.valueOf(IPDEventType.ROLLOVER_TASK)); | ||
if (eventType != null) { | ||
IPDEvent ipdEvent = new IPDEvent(null, null, eventType); | ||
eventManager.processEvent(ipdEvent); | ||
} | ||
} | ||
|
||
@Override | ||
public void setApplicationContext(ApplicationContext applicationContext) { | ||
this.context = applicationContext; | ||
} | ||
} |
13 changes: 3 additions & 10 deletions
13
api/src/main/java/org/openmrs/module/ipd/api/scheduler/tasks/ShiftStartTasks.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,22 @@ | ||
package org.openmrs.module.ipd.api.scheduler.tasks; | ||
|
||
import org.openmrs.api.context.Context; | ||
import org.openmrs.module.ipd.api.events.IPDEventManager; | ||
import org.openmrs.module.ipd.api.events.model.IPDEvent; | ||
import org.openmrs.module.ipd.api.events.model.IPDEventType; | ||
import org.openmrs.scheduler.tasks.AbstractTask; | ||
import org.springframework.context.ApplicationContext; | ||
import org.springframework.context.ApplicationContextAware; | ||
import org.springframework.stereotype.Component; | ||
|
||
|
||
public class ShiftStartTasks extends AbstractTask implements ApplicationContextAware { | ||
public class ShiftStartTasks extends AbstractTask { | ||
|
||
private static ApplicationContext context; | ||
@Override | ||
public void execute() { | ||
IPDEventManager eventManager = context.getBean(IPDEventManager.class); | ||
IPDEventManager eventManager = Context.getRegisteredComponents(IPDEventManager.class).get(0); | ||
IPDEventType eventType = eventManager.getEventTypeForEncounter(String.valueOf(IPDEventType.SHIFT_START_TASK)); | ||
if (eventType != null) { | ||
IPDEvent ipdEvent = new IPDEvent(null, null, eventType); | ||
eventManager.processEvent(ipdEvent); | ||
} | ||
} | ||
|
||
@Override | ||
public void setApplicationContext(ApplicationContext applicationContext) { | ||
this.context = applicationContext; | ||
} | ||
} |