Skip to content

Commit

Permalink
#183 updated the region district filter in android
Browse files Browse the repository at this point in the history
  • Loading branch information
Anthony4m committed Jan 9, 2025
1 parent ebe33d9 commit d990198
Showing 1 changed file with 32 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;

import de.symeda.sormas.api.ebs.EbsTriagingDecision;
import de.symeda.sormas.api.ebs.SignalCategory;
Expand All @@ -18,12 +19,14 @@
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.region.Community;
import de.symeda.sormas.app.backend.region.District;
import de.symeda.sormas.app.backend.region.Region;
import de.symeda.sormas.app.backend.user.User;

public class EbsDao extends AbstractAdoDao<Ebs> {
public EbsDao(Dao<Ebs, Long> innerDao) {
Expand Down Expand Up @@ -118,15 +121,37 @@ else if (criteria.getSignalOutcome() == SignalOutcome.NON_EVENT){
triagingLongQueryBuilder.where().between(Triaging.DATE_OF_DECISION,DateHelper.getStartOfDay(criteria.getTriageDate()),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 (currentUser.getCommunity() != null) {
// locationLongQueryBuilder.where().eq(Location.COMMUNITY + "_id", currentUser.getCommunity().getId());
// }
// if (currentUser.getRegion() != null) {
// locationLongQueryBuilder.where().eq(Location.REGION + "_id", currentUser.getRegion().getId());
// queryBuilder.leftJoin(locationLongQueryBuilder);
// }
// if (criteria.getRegion() != null) {
// if (Objects.equals(currentUser.getRegion().getId(), criteria.getRegion().getId())) {
// System.out.println("User Region: " + currentUser.getRegion().getId());
// }
// }
if (criteria.getDistrict() != null) {
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

0 comments on commit d990198

Please sign in to comment.