Skip to content

Commit

Permalink
#917 - region is no longer required for laboratories, enabled region …
Browse files Browse the repository at this point in the history
…editing for laboratories
  • Loading branch information
MateStrysewske committed Jan 11, 2019
1 parent 3b6d277 commit deffe0a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -244,10 +244,10 @@ public List<FacilityDto> getIndexList(String userUuid, FacilityCriteria facility
public void saveFacility(FacilityDto dto) throws ValidationRuntimeException {
Facility facility = facilityService.getByUuid(dto.getUuid());

if (dto.getRegion() == null) {
throw new ValidationRuntimeException("You have to specify a valid region");
}
if (dto.getType() != FacilityType.LABORATORY) {
if (dto.getRegion() == null) {
throw new ValidationRuntimeException("You have to specify a valid region");
}
if (dto.getDistrict() == null) {
throw new ValidationRuntimeException("You have to specify a valid district");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

import de.symeda.sormas.api.facility.FacilityCriteria;
import de.symeda.sormas.api.facility.FacilityDto;
import de.symeda.sormas.api.facility.FacilityHelper;
import de.symeda.sormas.api.facility.FacilityType;
import de.symeda.sormas.api.utils.DataHelper;
import de.symeda.sormas.api.utils.DateHelper;
Expand Down Expand Up @@ -428,7 +429,11 @@ public Predicate buildCriteriaFilter(FacilityCriteria facilityCriteria, Criteria
filter = and(cb, filter, cb.equal(from.join(Facility.COMMUNITY, JoinType.LEFT).get(District.UUID), facilityCriteria.getCommunity().getUuid()));
}
if (facilityCriteria.isExcludeStaticFacilities() != null && facilityCriteria.isExcludeStaticFacilities()) {
filter = and(cb, filter, cb.isNotNull(from.get(Facility.REGION)));
Predicate excludeFilter = cb.and(
cb.notEqual(from.get(Facility.UUID), FacilityDto.OTHER_FACILITY_UUID),
cb.notEqual(from.get(Facility.UUID), FacilityDto.NONE_FACILITY_UUID),
cb.notEqual(from.get(Facility.UUID), FacilityDto.OTHER_LABORATORY_UUID));
filter = and(cb, filter, excludeFilter);
}
filter = and(cb, filter, cb.equal(from.get(Facility.TYPE), facilityCriteria.getType()));
return filter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ protected void addFields() {
longitude.setConversionError("Only geo coordinate values are allowed for " + longitude.getCaption());

name.setRequired(true);
region.setRequired(true);
if (!laboratory) {
region.setRequired(true);
district.setRequired(true);
community.setRequired(true);
}
Expand All @@ -99,7 +99,9 @@ protected void addFields() {

// TODO: Workaround until cases and other data is properly transfered when infrastructure data changes
if (!create) {
region.setEnabled(false);
if (!laboratory) {
region.setEnabled(false);
}
district.setEnabled(false);
community.setEnabled(false);
}
Expand Down

0 comments on commit deffe0a

Please sign in to comment.