Skip to content

Commit

Permalink
#353 - Fixed server crashing when trying to log in as an Admin
Browse files Browse the repository at this point in the history
  • Loading branch information
MateStrysewske committed Oct 4, 2017
1 parent 40cab2f commit 8aa9319
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ public Predicate createUserFilter(CriteriaBuilder cb, CriteriaQuery cq, From<Cas
sampleCaseSubquery.select(sampleRoot.get(Sample.ASSOCIATED_CASE).get(Case.ID));
filter = cb.in(casePath.get(Case.ID)).value(sampleCaseSubquery);
break;
case ADMIN:
break;

default:
throw new IllegalArgumentException(userRole.toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,23 @@ public List<Contact> getMapContacts(Date fromDate, Date toDate, Disease disease,
if (toDate != null) {
dateFilter = cb.and(dateFilter, cb.lessThanOrEqualTo(from.get(Contact.REPORT_DATE_TIME), toDate));
}
filter = cb.and(filter, dateFilter);
if (filter != null) {
filter = cb.and(filter, dateFilter);
} else {
filter = dateFilter;
}
}
if (disease != null) {
Join<Contact, Case> contactCase = from.join(Contact.CAZE);
Predicate diseaseFilter = cb.equal(contactCase.get(Case.DISEASE), disease);
filter = cb.and(filter, diseaseFilter);
}
// Only retrieve contacts that are currently under follow-up
filter = cb.and(filter, cb.equal(from.get(Contact.FOLLOW_UP_STATUS), FollowUpStatus.FOLLOW_UP));
if (filter != null) {
filter = cb.and(filter, cb.equal(from.get(Contact.FOLLOW_UP_STATUS), FollowUpStatus.FOLLOW_UP));
} else {
filter = cb.equal(from.get(Contact.FOLLOW_UP_STATUS), FollowUpStatus.FOLLOW_UP);
}
cq.where(filter);
return em.createQuery(cq).getResultList();
}
Expand Down

0 comments on commit 8aa9319

Please sign in to comment.