Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BAH-4106 | Fix. Create beans for scheduler task classes to initialize context properly #83

Merged
merged 2 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
}
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;
}
}
Loading