Skip to content

Commit

Permalink
#183 ported jusrisdiction from 1.74 to 1.87
Browse files Browse the repository at this point in the history
  • Loading branch information
Anthony4m committed Jan 13, 2025
1 parent 1a1da40 commit 0ad95af
Show file tree
Hide file tree
Showing 5 changed files with 284 additions and 267 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;

import com.j256.ormlite.dao.Dao;
import com.j256.ormlite.stmt.QueryBuilder;
Expand All @@ -18,9 +19,11 @@
import de.symeda.sormas.app.backend.common.AbstractAdoDao;
import de.symeda.sormas.app.backend.common.AbstractDomainObject;
import de.symeda.sormas.app.backend.common.DatabaseHelper;
import de.symeda.sormas.app.backend.config.ConfigProvider;
import de.symeda.sormas.app.backend.ebs.signalVerification.SignalVerification;
import de.symeda.sormas.app.backend.ebs.triaging.Triaging;
import de.symeda.sormas.app.backend.location.Location;
import de.symeda.sormas.app.backend.user.User;

public class EbsDao extends AbstractAdoDao<Ebs> {

Expand Down Expand Up @@ -124,15 +127,24 @@ private QueryBuilder<Ebs, Long> buildQueryBuilder(EbsCriteria criteria) throws S
DateHelper.getEndOfDay(criteria.getTriageDate()));
}

if (criteria.getRegion() != null) {
locationLongQueryBuilder.where().eq(Location.REGION + "_id", criteria.getRegion().getId());
User currentUser = ConfigProvider.getUser();

if (currentUser.getRegion() != null || currentUser.getDistrict() != null) {
if (currentUser.getRegion() != null) {
locationLongQueryBuilder.where().eq(Location.REGION + "_id", currentUser.getRegion().getId());
}
if (currentUser.getDistrict() != null) {
locationLongQueryBuilder.where().eq(Location.DISTRICT + "_id", currentUser.getDistrict().getId());
}
if (currentUser.getCommunity() != null) {
locationLongQueryBuilder.where().eq(Location.COMMUNITY + "_id", currentUser.getCommunity().getId());
}
queryBuilder.leftJoin(locationLongQueryBuilder);
}
if (criteria.getDistrict() != null) {
locationLongQueryBuilder.where().eq(Location.DISTRICT + "_id", criteria.getDistrict().getId());
}
if (criteria.getCommunity() != null) {
locationLongQueryBuilder.where().eq(Location.COMMUNITY + "_id", criteria.getCommunity().getId());
if (Objects.equals(currentUser.getDistrict().getId(), criteria.getDistrict().getId())) {
System.out.println("User District: " + currentUser.getDistrict().getId() + " Criteria District: " + criteria.getDistrict().getId());
}
}
if (!whereStatements.isEmpty()) {
Where<Ebs, Long> whereStatement = where.and(whereStatements.size());
Expand Down
Loading

0 comments on commit 0ad95af

Please sign in to comment.