Skip to content

Commit

Permalink
#12550 - Refactorings and changes
Browse files Browse the repository at this point in the history
- Only regions, districts and communities can be made default
- Add parent validation to make sure that e.g. a district from another region than the default region can be set as default
- Add column to grids
  • Loading branch information
MateStrysewske committed Oct 17, 2023
1 parent 36e131b commit 2178769
Show file tree
Hide file tree
Showing 98 changed files with 593 additions and 516 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ public interface Validations {
String contactFollowUpUntilDateSoftValidation = "contactFollowUpUntilDateSoftValidation";
String contactWithoutInfrastructureData = "contactWithoutInfrastructureData";
String defaultInfrastructureAlreadyExisting = "defaultInfrastructureAlreadyExisting";
String defaultInfrastructureInvalidParentDistrict = "defaultInfrastructureInvalidParentDistrict";
String defaultInfrastructureInvalidParentRegion = "defaultInfrastructureInvalidParentRegion";
String duplicateEpidNumber = "duplicateEpidNumber";
String duplicateExternalToken = "duplicateExternalToken";
String emptyOverwrittenFollowUpUntilDate = "emptyOverwrittenFollowUpUntilDate";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@

public abstract class InfrastructureDto extends EntityDto {

public static final String DEFAULT_INFRASTRUCTURE = "defaultInfrastructure";

private boolean centrallyManaged;
private boolean archived;
private boolean defaultInfrastructure;

protected InfrastructureDto() {
}
Expand All @@ -36,11 +33,4 @@ public void setArchived(boolean archived) {
this.archived = archived;
}

public boolean isDefaultInfrastructure() {
return defaultInfrastructure;
}

public void setDefaultInfrastructure(boolean defaultInfrastructure) {
this.defaultInfrastructure = defaultInfrastructure;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* SORMAS® - Surveillance Outbreak Response Management & Analysis System
* Copyright © 2016-2023 Helmholtz-Zentrum für Infektionsforschung GmbH (HZI)
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package de.symeda.sormas.api.infrastructure;

import java.util.Date;

public abstract class InfrastructureDtoWithDefault extends InfrastructureDto {

public static final String DEFAULT_INFRASTRUCTURE = "defaultInfrastructure";

private boolean defaultInfrastructure;

protected InfrastructureDtoWithDefault() {
super();
}

protected InfrastructureDtoWithDefault(Date creationDate, Date changeDate, String uuid, boolean archived) {
super(creationDate, changeDate, uuid, archived);
}

public boolean isDefaultInfrastructure() {
return defaultInfrastructure;
}

public void setDefaultInfrastructure(boolean defaultInfrastructure) {
this.defaultInfrastructure = defaultInfrastructure;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@

import de.symeda.sormas.api.MappingException;
import de.symeda.sormas.api.i18n.Validations;
import de.symeda.sormas.api.infrastructure.InfrastructureDto;
import de.symeda.sormas.api.infrastructure.InfrastructureDtoWithDefault;
import de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto;
import de.symeda.sormas.api.infrastructure.region.RegionReferenceDto;
import de.symeda.sormas.api.utils.DataHelper;
import de.symeda.sormas.api.utils.FeatureIndependent;
import de.symeda.sormas.api.utils.FieldConstraints;

@FeatureIndependent
public class CommunityDto extends InfrastructureDto {
public class CommunityDto extends InfrastructureDtoWithDefault {

private static final long serialVersionUID = -8833267932522978860L;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@
import com.fasterxml.jackson.annotation.JsonIgnore;

import de.symeda.sormas.api.i18n.Validations;
import de.symeda.sormas.api.infrastructure.InfrastructureDto;
import de.symeda.sormas.api.infrastructure.InfrastructureDtoWithDefault;
import de.symeda.sormas.api.infrastructure.region.RegionReferenceDto;
import de.symeda.sormas.api.utils.DataHelper;
import de.symeda.sormas.api.utils.FeatureIndependent;
import de.symeda.sormas.api.utils.FieldConstraints;

@FeatureIndependent
public class DistrictDto extends InfrastructureDto {
public class DistrictDto extends InfrastructureDtoWithDefault {

private static final long serialVersionUID = 8990957700033431836L;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,15 @@ public class DistrictIndexDto extends EntityDto {
public static final String GROWTH_RATE = "growthRate";
public static final String REGION = "region";
public static final String EXTERNAL_ID = "externalID";
public static final String DEFAULT_INFRASTRUCTURE = "defaultInfrastructure";

private String name;
private String epidCode;
private Integer population;
private Float growthRate;
private RegionReferenceDto region;
private String externalID;
private boolean defaultInfrastructure;

public DistrictIndexDto() {
super();
Expand Down Expand Up @@ -106,6 +108,14 @@ public void setExternalID(String externalID) {
this.externalID = externalID;
}

public boolean isDefaultInfrastructure() {
return defaultInfrastructure;
}

public void setDefaultInfrastructure(boolean defaultInfrastructure) {
this.defaultInfrastructure = defaultInfrastructure;
}

public DistrictReferenceDto toReference() {
return new DistrictReferenceDto(getUuid(), name, externalID);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import de.symeda.sormas.api.feature.FeatureType;
import de.symeda.sormas.api.i18n.I18nProperties;
import de.symeda.sormas.api.i18n.Validations;
import de.symeda.sormas.api.infrastructure.InfrastructureDto;
import de.symeda.sormas.api.infrastructure.InfrastructureDtoWithDefault;
import de.symeda.sormas.api.infrastructure.area.AreaReferenceDto;
import de.symeda.sormas.api.infrastructure.country.CountryReferenceDto;
import de.symeda.sormas.api.utils.DataHelper;
Expand All @@ -32,7 +32,7 @@
import de.symeda.sormas.api.utils.FieldConstraints;

@FeatureIndependent
public class RegionDto extends InfrastructureDto {
public class RegionDto extends InfrastructureDtoWithDefault {

private static final long serialVersionUID = -1610675328037466348L;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public class RegionIndexDto extends EntityDto {
public static final String EXTERNAL_ID = "externalID";
public static final String AREA = "area";
public static final String COUNTRY = "country";
public static final String DEFAULT_INFRASTRUCTURE = "defaultInfrastructure";

private String name;
private String epidCode;
Expand All @@ -44,6 +45,7 @@ public class RegionIndexDto extends EntityDto {
private String externalID;
private AreaReferenceDto area;
private CountryReferenceDto country;
private boolean defaultInfrastructure;

public String getName() {
return name;
Expand Down Expand Up @@ -101,6 +103,14 @@ public void setCountry(CountryReferenceDto country) {
this.country = country;
}

public boolean isDefaultInfrastructure() {
return defaultInfrastructure;
}

public void setDefaultInfrastructure(boolean defaultInfrastructure) {
this.defaultInfrastructure = defaultInfrastructure;
}

public RegionReferenceDto toReference() {
return new RegionReferenceDto(getUuid(), name, externalID);
}
Expand Down
4 changes: 3 additions & 1 deletion sormas-api/src/main/resources/validations.properties
Original file line number Diff line number Diff line change
Expand Up @@ -279,4 +279,6 @@ environmentWaterFieldsSetWithNotWaterMedia = The following fields can be set onl
gpsCoordinatesRequired = GPS coordinates are required
latitudeBetween = Latitude must be between -90 and 90
longitudeBetween = Longitude must be between -180 and 180
defaultInfrastructureAlreadyExisting = There already is another default %s in the database. Only one default %s is allowed.
defaultInfrastructureAlreadyExisting = There already is another default %s in the database. Only one default %s is allowed.
defaultInfrastructureInvalidParentRegion = This district is in a different region than the default region, or there is no default region.
defaultInfrastructureInvalidParentDistrict = This community is in a different district than the default district, or there is no default district.
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@
import static de.symeda.sormas.api.utils.FieldConstraints.CHARACTER_LIMIT_BIG;
import static de.symeda.sormas.api.utils.FieldConstraints.CHARACTER_LIMIT_DEFAULT;

import com.j256.ormlite.field.DataType;
import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable;

import org.apache.commons.lang3.StringUtils;

import java.util.Date;

import javax.persistence.Column;
Expand All @@ -32,6 +26,12 @@
import javax.persistence.Enumerated;
import javax.persistence.Transient;

import org.apache.commons.lang3.StringUtils;

import com.j256.ormlite.field.DataType;
import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable;

import de.symeda.sormas.api.Disease;
import de.symeda.sormas.api.caze.CaseClassification;
import de.symeda.sormas.api.caze.CaseIdentificationSource;
Expand Down Expand Up @@ -64,8 +64,8 @@
import de.symeda.sormas.app.backend.epidata.EpiData;
import de.symeda.sormas.app.backend.facility.Facility;
import de.symeda.sormas.app.backend.hospitalization.Hospitalization;
import de.symeda.sormas.app.backend.infrastructure.PointOfEntry;
import de.symeda.sormas.app.backend.person.Person;
import de.symeda.sormas.app.backend.pointofentry.PointOfEntry;
import de.symeda.sormas.app.backend.region.Community;
import de.symeda.sormas.app.backend.region.District;
import de.symeda.sormas.app.backend.region.Region;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@
import de.symeda.sormas.app.backend.facility.FacilityDtoHelper;
import de.symeda.sormas.app.backend.hospitalization.Hospitalization;
import de.symeda.sormas.app.backend.hospitalization.HospitalizationDtoHelper;
import de.symeda.sormas.app.backend.infrastructure.PointOfEntry;
import de.symeda.sormas.app.backend.infrastructure.PointOfEntryDtoHelper;
import de.symeda.sormas.app.backend.person.Person;
import de.symeda.sormas.app.backend.person.PersonDependentDtoHelper;
import de.symeda.sormas.app.backend.person.PersonDtoHelper;
import de.symeda.sormas.app.backend.pointofentry.PointOfEntry;
import de.symeda.sormas.app.backend.pointofentry.PointOfEntryDtoHelper;
import de.symeda.sormas.app.backend.region.Community;
import de.symeda.sormas.app.backend.region.CommunityDtoHelper;
import de.symeda.sormas.app.backend.region.District;
Expand Down Expand Up @@ -80,7 +80,7 @@ protected Class<CaseDataDto> getDtoClass() {
}

@Override
protected Call<List<CaseDataDto>> pullAllSince(long since, Integer size, String lastSynchronizedUuid) throws NoConnectionException {
protected Call<List<CaseDataDto>> pullAllSince(long since, Integer size, String lastSynchronizedUuid) throws NoConnectionException {
return RetroProvider.getCaseFacade().pullAllSince(since, size, lastSynchronizedUuid);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import de.symeda.sormas.app.backend.environment.Environment;
import de.symeda.sormas.app.backend.environment.environmentsample.EnvironmentSample;
import de.symeda.sormas.app.backend.feature.FeatureConfiguration;
import de.symeda.sormas.app.backend.infrastructure.InfrastructureAdo;
import de.symeda.sormas.app.component.dialog.SynchronizationDialog;
import de.symeda.sormas.app.util.MetaProperty;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,6 @@
import de.symeda.sormas.app.backend.hospitalization.PreviousHospitalizationDao;
import de.symeda.sormas.app.backend.immunization.Immunization;
import de.symeda.sormas.app.backend.immunization.ImmunizationDao;
import de.symeda.sormas.app.backend.infrastructure.PointOfEntry;
import de.symeda.sormas.app.backend.infrastructure.PointOfEntryDao;
import de.symeda.sormas.app.backend.lbds.LbdsSync;
import de.symeda.sormas.app.backend.lbds.LbdsSyncDao;
import de.symeda.sormas.app.backend.location.Location;
Expand All @@ -127,6 +125,8 @@
import de.symeda.sormas.app.backend.person.PersonContactDetail;
import de.symeda.sormas.app.backend.person.PersonContactDetailDao;
import de.symeda.sormas.app.backend.person.PersonDao;
import de.symeda.sormas.app.backend.pointofentry.PointOfEntry;
import de.symeda.sormas.app.backend.pointofentry.PointOfEntryDao;
import de.symeda.sormas.app.backend.region.Area;
import de.symeda.sormas.app.backend.region.AreaDao;
import de.symeda.sormas.app.backend.region.Community;
Expand Down Expand Up @@ -3139,15 +3139,9 @@ public void onUpgrade(SQLiteDatabase db, ConnectionSource connectionSource, int

case 353:
currentVersion = 353;
getDao(Continent.class).executeRaw("ALTER TABLE continent ADD COLUMN defaultInfrastructure boolean default false;");
getDao(Subcontinent.class).executeRaw("ALTER TABLE subcontinent ADD COLUMN defaultInfrastructure boolean default false;");
getDao(Country.class).executeRaw("ALTER TABLE country ADD COLUMN defaultInfrastructure boolean default false;");
getDao(Area.class).executeRaw("ALTER TABLE area ADD COLUMN defaultInfrastructure boolean default false;");
getDao(Region.class).executeRaw("ALTER TABLE region ADD COLUMN defaultInfrastructure boolean default false;");
getDao(District.class).executeRaw("ALTER TABLE district ADD COLUMN defaultInfrastructure boolean default false;");
getDao(Community.class).executeRaw("ALTER TABLE community ADD COLUMN defaultInfrastructure boolean default false;");
getDao(PointOfEntry.class).executeRaw("ALTER TABLE pointOfEntry ADD COLUMN defaultInfrastructure boolean default false;");
getDao(Facility.class).executeRaw("ALTER TABLE facility ADD COLUMN defaultInfrastructure boolean default false;");

// ATTENTION: break should only be done after last version
break;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,20 @@
import static de.symeda.sormas.api.utils.FieldConstraints.CHARACTER_LIMIT_BIG;
import static de.symeda.sormas.api.utils.FieldConstraints.CHARACTER_LIMIT_DEFAULT;

import androidx.databinding.Bindable;

import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;

import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable;

import androidx.databinding.Bindable;

import de.symeda.sormas.api.infrastructure.area.AreaType;
import de.symeda.sormas.api.infrastructure.facility.FacilityHelper;
import de.symeda.sormas.api.infrastructure.facility.FacilityType;
import de.symeda.sormas.app.backend.common.InfrastructureAdo;
import de.symeda.sormas.app.backend.infrastructure.InfrastructureAdo;
import de.symeda.sormas.app.backend.region.Community;
import de.symeda.sormas.app.backend.region.District;
import de.symeda.sormas.app.backend.region.Region;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
import de.symeda.sormas.api.infrastructure.facility.FacilityDto;
import de.symeda.sormas.api.infrastructure.facility.FacilityType;
import de.symeda.sormas.app.backend.common.AbstractDomainObject;
import de.symeda.sormas.app.backend.common.AbstractInfrastructureAdoDao;
import de.symeda.sormas.app.backend.common.InfrastructureAdo;
import de.symeda.sormas.app.backend.infrastructure.AbstractInfrastructureAdoDao;
import de.symeda.sormas.app.backend.infrastructure.InfrastructureAdo;
import de.symeda.sormas.app.backend.region.Community;
import de.symeda.sormas.app.backend.region.District;
import de.symeda.sormas.app.backend.region.Region;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ public void fillInnerFromDto(Facility target, FacilityDto source) {
target.setPublicOwnership(source.isPublicOwnership());
target.setType(source.getType());
target.setArchived(source.isArchived());
target.setDefaultInfrastructure(source.isDefaultInfrastructure());
}

@Override
Expand Down
Loading

0 comments on commit 2178769

Please sign in to comment.