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

FLAG-81: fixed the exception in evaluate all flags #95

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
Expand Up @@ -673,8 +673,7 @@ public Future<?> evaluateAllFlags() {
if (executor == null) {
executor = Executors.newSingleThreadExecutor();
}
dao.deleteAllPatientFlags();
return executor.submit(PatientFlagTask.evaluateAllFlags());
return executor.submit(new PatientFlagTask());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,10 +318,4 @@ public interface FlagDAO {
*/
void deletePatientFlagsForFlag(Flag flag) throws DAOException;

/**
* Delete all patient flags.
*
* @throws DAOException the dao exception
*/
void deleteAllPatientFlags() throws DAOException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -458,20 +458,4 @@ public List<PatientFlag> getPatientFlags(Patient patient) throws DAOException {
return criteria.list();
}


/**
* Delete all patient flags.
*
* @throws DAOException the dao exception
*/
@Override
public void deleteAllPatientFlags() throws DAOException {
Criteria criteria = sessionFactory.getCurrentSession().createCriteria(PatientFlag.class);
List<PatientFlag> flags = criteria.list();

flags.forEach(patientFlag -> {
sessionFactory.getCurrentSession().delete(patientFlag);
});
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ else if (flag != null) {
evaluateAllFlags();
}
}
public static Runnable evaluateAllFlags() {
return Daemon.runInDaemonThread(new AllFlagsEvaluator(), daemonToken);

public void evaluateAllFlags() {
Daemon.runInDaemonThread(new AllFlagsEvaluator(), daemonToken);
}

public static void setDaemonToken(DaemonToken token) {
Expand All @@ -75,12 +75,8 @@ public void generatePatientFlags(Flag flag) {
}

private static void generatePatientFlags(Flag flag, FlagService service) {

service.deletePatientFlagsForFlag(flag);
generatePatientFlagsForFlagAndPatient(flag,service);
}

private static void generatePatientFlagsForFlagAndPatient(Flag flag, FlagService service){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do these methods get merged?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I created generatePatientFalgsForFalgAndPatient(..) method in this PR and this used to generate patient flags without deleting the existing patient flag. With the new changes we can use generatePatientFlags(Flag flag) method.

if (!flag.getEnabled() || flag.getRetired()) {
return;
}
Expand Down Expand Up @@ -138,7 +134,6 @@ private static class AllFlagsEvaluator implements Runnable {
@Override
public void run() {
FlagService flagService = Context.getService(FlagService.class);

flagService.getAllFlags().forEach(flag -> Daemon.runInNewDaemonThread(new PatientFlagGenerator(flag)));
}
}
Expand All @@ -150,10 +145,10 @@ private static class PatientFlagGenerator implements Runnable {
this.flag = flag;
}

@Override
public void run() {
FlagService service = Context.getService(FlagService.class);
generatePatientFlagsForFlagAndPatient(flag, service);
}
}
@Override
public void run() {
FlagService service = Context.getService(FlagService.class);
generatePatientFlags(flag, service);
}
}
}