diff --git a/sormas-api/src/main/java/de/symeda/sormas/api/i18n/Validations.java b/sormas-api/src/main/java/de/symeda/sormas/api/i18n/Validations.java index 1fa5552fcc5..d900548a1f2 100644 --- a/sormas-api/src/main/java/de/symeda/sormas/api/i18n/Validations.java +++ b/sormas-api/src/main/java/de/symeda/sormas/api/i18n/Validations.java @@ -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"; diff --git a/sormas-api/src/main/java/de/symeda/sormas/api/infrastructure/InfrastructureDto.java b/sormas-api/src/main/java/de/symeda/sormas/api/infrastructure/InfrastructureDto.java index d9a141ea535..32a390c7d44 100644 --- a/sormas-api/src/main/java/de/symeda/sormas/api/infrastructure/InfrastructureDto.java +++ b/sormas-api/src/main/java/de/symeda/sormas/api/infrastructure/InfrastructureDto.java @@ -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() { } @@ -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; - } } diff --git a/sormas-api/src/main/java/de/symeda/sormas/api/infrastructure/InfrastructureDtoWithDefault.java b/sormas-api/src/main/java/de/symeda/sormas/api/infrastructure/InfrastructureDtoWithDefault.java new file mode 100644 index 00000000000..62de224f452 --- /dev/null +++ b/sormas-api/src/main/java/de/symeda/sormas/api/infrastructure/InfrastructureDtoWithDefault.java @@ -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 . + */ + +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; + } + +} diff --git a/sormas-api/src/main/java/de/symeda/sormas/api/infrastructure/community/CommunityDto.java b/sormas-api/src/main/java/de/symeda/sormas/api/infrastructure/community/CommunityDto.java index 9f56921b60a..d0d09cb3808 100644 --- a/sormas-api/src/main/java/de/symeda/sormas/api/infrastructure/community/CommunityDto.java +++ b/sormas-api/src/main/java/de/symeda/sormas/api/infrastructure/community/CommunityDto.java @@ -22,7 +22,7 @@ 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; @@ -30,7 +30,7 @@ import de.symeda.sormas.api.utils.FieldConstraints; @FeatureIndependent -public class CommunityDto extends InfrastructureDto { +public class CommunityDto extends InfrastructureDtoWithDefault { private static final long serialVersionUID = -8833267932522978860L; diff --git a/sormas-api/src/main/java/de/symeda/sormas/api/infrastructure/district/DistrictDto.java b/sormas-api/src/main/java/de/symeda/sormas/api/infrastructure/district/DistrictDto.java index 58475644628..2eaf4de4da3 100644 --- a/sormas-api/src/main/java/de/symeda/sormas/api/infrastructure/district/DistrictDto.java +++ b/sormas-api/src/main/java/de/symeda/sormas/api/infrastructure/district/DistrictDto.java @@ -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; diff --git a/sormas-api/src/main/java/de/symeda/sormas/api/infrastructure/district/DistrictIndexDto.java b/sormas-api/src/main/java/de/symeda/sormas/api/infrastructure/district/DistrictIndexDto.java index 0f96f5e4125..8e5f42e8b06 100644 --- a/sormas-api/src/main/java/de/symeda/sormas/api/infrastructure/district/DistrictIndexDto.java +++ b/sormas-api/src/main/java/de/symeda/sormas/api/infrastructure/district/DistrictIndexDto.java @@ -36,6 +36,7 @@ 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; @@ -43,6 +44,7 @@ public class DistrictIndexDto extends EntityDto { private Float growthRate; private RegionReferenceDto region; private String externalID; + private boolean defaultInfrastructure; public DistrictIndexDto() { super(); @@ -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); } diff --git a/sormas-api/src/main/java/de/symeda/sormas/api/infrastructure/region/RegionDto.java b/sormas-api/src/main/java/de/symeda/sormas/api/infrastructure/region/RegionDto.java index 8e11e0c06bc..c497ab01903 100644 --- a/sormas-api/src/main/java/de/symeda/sormas/api/infrastructure/region/RegionDto.java +++ b/sormas-api/src/main/java/de/symeda/sormas/api/infrastructure/region/RegionDto.java @@ -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; @@ -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; diff --git a/sormas-api/src/main/java/de/symeda/sormas/api/infrastructure/region/RegionIndexDto.java b/sormas-api/src/main/java/de/symeda/sormas/api/infrastructure/region/RegionIndexDto.java index a4686223a5d..aeab786a747 100644 --- a/sormas-api/src/main/java/de/symeda/sormas/api/infrastructure/region/RegionIndexDto.java +++ b/sormas-api/src/main/java/de/symeda/sormas/api/infrastructure/region/RegionIndexDto.java @@ -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; @@ -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; @@ -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); } diff --git a/sormas-api/src/main/resources/validations.properties b/sormas-api/src/main/resources/validations.properties index c35a70943a0..20740b1f32d 100644 --- a/sormas-api/src/main/resources/validations.properties +++ b/sormas-api/src/main/resources/validations.properties @@ -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. \ No newline at end of file +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. \ No newline at end of file diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/caze/Case.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/caze/Case.java index a21bdd75078..6f44008fcfe 100644 --- a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/caze/Case.java +++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/caze/Case.java @@ -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; @@ -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; @@ -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; diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/caze/CaseDtoHelper.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/caze/CaseDtoHelper.java index beb9cf1d5dc..1fa528dc03c 100644 --- a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/caze/CaseDtoHelper.java +++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/caze/CaseDtoHelper.java @@ -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; @@ -80,7 +80,7 @@ protected Class getDtoClass() { } @Override - protected Call> pullAllSince(long since, Integer size, String lastSynchronizedUuid) throws NoConnectionException { + protected Call> pullAllSince(long since, Integer size, String lastSynchronizedUuid) throws NoConnectionException { return RetroProvider.getCaseFacade().pullAllSince(since, size, lastSynchronizedUuid); } diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/common/AbstractAdoDao.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/common/AbstractAdoDao.java index 314c5277fbe..5b118f510b0 100644 --- a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/common/AbstractAdoDao.java +++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/common/AbstractAdoDao.java @@ -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; diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/common/DatabaseHelper.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/common/DatabaseHelper.java index 7a5ca51edd9..9feef31bfd6 100644 --- a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/common/DatabaseHelper.java +++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/common/DatabaseHelper.java @@ -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; @@ -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; @@ -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; diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/common/InfrastructureAdo.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/common/InfrastructureAdo.java deleted file mode 100644 index 5668aed584a..00000000000 --- a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/common/InfrastructureAdo.java +++ /dev/null @@ -1,32 +0,0 @@ -package de.symeda.sormas.app.backend.common; - -import javax.persistence.MappedSuperclass; - -import com.j256.ormlite.field.DatabaseField; - -@MappedSuperclass -public class InfrastructureAdo extends AbstractDomainObject { - - public static final String ARCHIVED = "archived"; - - @DatabaseField - private boolean archived = false; - @DatabaseField - private boolean defaultInfrastructure = false; - - public boolean isArchived() { - return archived; - } - - public void setArchived(boolean archived) { - this.archived = archived; - } - - public boolean isDefaultInfrastructure() { - return defaultInfrastructure; - } - - public void setDefaultInfrastructure(boolean defaultInfrastructure) { - this.defaultInfrastructure = defaultInfrastructure; - } -} diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/facility/Facility.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/facility/Facility.java index bbc003671cb..8ab05df0d92 100644 --- a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/facility/Facility.java +++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/facility/Facility.java @@ -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; diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/facility/FacilityDao.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/facility/FacilityDao.java index 5e2279bbb23..38739bc384c 100644 --- a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/facility/FacilityDao.java +++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/facility/FacilityDao.java @@ -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; diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/facility/FacilityDtoHelper.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/facility/FacilityDtoHelper.java index 02ad13f2af8..a2ec1751cec 100644 --- a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/facility/FacilityDtoHelper.java +++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/facility/FacilityDtoHelper.java @@ -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 diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/common/AbstractInfrastructureAdoDao.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/infrastructure/AbstractInfrastructureAdoDao.java similarity index 69% rename from sormas-app/app/src/main/java/de/symeda/sormas/app/backend/common/AbstractInfrastructureAdoDao.java rename to sormas-app/app/src/main/java/de/symeda/sormas/app/backend/infrastructure/AbstractInfrastructureAdoDao.java index f6cbe24a3dc..3234b7f0554 100644 --- a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/common/AbstractInfrastructureAdoDao.java +++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/infrastructure/AbstractInfrastructureAdoDao.java @@ -1,13 +1,31 @@ -package de.symeda.sormas.app.backend.common; +/* + * 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 . + */ -import android.util.Log; +package de.symeda.sormas.app.backend.infrastructure; + +import java.sql.SQLException; +import java.util.List; import com.j256.ormlite.dao.Dao; import com.j256.ormlite.stmt.QueryBuilder; import com.j256.ormlite.stmt.Where; -import java.sql.SQLException; -import java.util.List; +import android.util.Log; + +import de.symeda.sormas.app.backend.common.AbstractAdoDao; +import de.symeda.sormas.app.backend.common.AbstractDomainObject; public abstract class AbstractInfrastructureAdoDao extends AbstractAdoDao { diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/infrastructure/InfrastructureAdo.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/infrastructure/InfrastructureAdo.java new file mode 100644 index 00000000000..d0dd142d82c --- /dev/null +++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/infrastructure/InfrastructureAdo.java @@ -0,0 +1,40 @@ +/* + * 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 . + */ + +package de.symeda.sormas.app.backend.infrastructure; + +import javax.persistence.MappedSuperclass; + +import com.j256.ormlite.field.DatabaseField; + +import de.symeda.sormas.app.backend.common.AbstractDomainObject; + +@MappedSuperclass +public class InfrastructureAdo extends AbstractDomainObject { + + public static final String ARCHIVED = "archived"; + + @DatabaseField + private boolean archived = false; + + public boolean isArchived() { + return archived; + } + + public void setArchived(boolean archived) { + this.archived = archived; + } + +} diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/infrastructure/InfrastructureAdoWithDefault.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/infrastructure/InfrastructureAdoWithDefault.java new file mode 100644 index 00000000000..40bdfef58bb --- /dev/null +++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/infrastructure/InfrastructureAdoWithDefault.java @@ -0,0 +1,33 @@ +/* + * 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 . + */ + +package de.symeda.sormas.app.backend.infrastructure; + +import com.j256.ormlite.field.DatabaseField; + +public abstract class InfrastructureAdoWithDefault extends InfrastructureAdo { + + @DatabaseField + private boolean defaultInfrastructure = false; + + public boolean isDefaultInfrastructure() { + return defaultInfrastructure; + } + + public void setDefaultInfrastructure(boolean defaultInfrastructure) { + this.defaultInfrastructure = defaultInfrastructure; + } + +} diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/infrastructure/InfrastructureHelper.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/infrastructure/InfrastructureHelper.java index 2af8abdcc36..7dde78d9752 100644 --- a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/infrastructure/InfrastructureHelper.java +++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/infrastructure/InfrastructureHelper.java @@ -13,6 +13,7 @@ import de.symeda.sormas.app.backend.disease.DiseaseConfigurationDtoHelper; import de.symeda.sormas.app.backend.facility.FacilityDtoHelper; import de.symeda.sormas.app.backend.feature.FeatureConfigurationDtoHelper; +import de.symeda.sormas.app.backend.pointofentry.PointOfEntryDtoHelper; import de.symeda.sormas.app.backend.region.AreaDtoHelper; import de.symeda.sormas.app.backend.region.CommunityDtoHelper; import de.symeda.sormas.app.backend.region.ContinentDtoHelper; diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/infrastructure/PointOfEntry.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/pointofentry/PointOfEntry.java similarity index 94% rename from sormas-app/app/src/main/java/de/symeda/sormas/app/backend/infrastructure/PointOfEntry.java rename to sormas-app/app/src/main/java/de/symeda/sormas/app/backend/pointofentry/PointOfEntry.java index 5124588f94b..92425e21529 100644 --- a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/infrastructure/PointOfEntry.java +++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/pointofentry/PointOfEntry.java @@ -1,6 +1,6 @@ /* * SORMAS® - Surveillance Outbreak Response Management & Analysis System - * Copyright © 2016-2018 Helmholtz-Zentrum für Infektionsforschung GmbH (HZI) + * 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 @@ -13,19 +13,19 @@ * along with this program. If not, see . */ -package de.symeda.sormas.app.backend.infrastructure; - -import com.j256.ormlite.field.DatabaseField; -import com.j256.ormlite.table.DatabaseTable; +package de.symeda.sormas.app.backend.pointofentry; 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 de.symeda.sormas.api.infrastructure.InfrastructureHelper; import de.symeda.sormas.api.infrastructure.pointofentry.PointOfEntryType; -import de.symeda.sormas.app.backend.common.InfrastructureAdo; +import de.symeda.sormas.app.backend.infrastructure.InfrastructureAdo; import de.symeda.sormas.app.backend.region.District; import de.symeda.sormas.app.backend.region.Region; diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/infrastructure/PointOfEntryDao.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/pointofentry/PointOfEntryDao.java similarity index 92% rename from sormas-app/app/src/main/java/de/symeda/sormas/app/backend/infrastructure/PointOfEntryDao.java rename to sormas-app/app/src/main/java/de/symeda/sormas/app/backend/pointofentry/PointOfEntryDao.java index f97b657a439..da0360c8325 100644 --- a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/infrastructure/PointOfEntryDao.java +++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/pointofentry/PointOfEntryDao.java @@ -1,6 +1,6 @@ /* * SORMAS® - Surveillance Outbreak Response Management & Analysis System - * Copyright © 2016-2018 Helmholtz-Zentrum für Infektionsforschung GmbH (HZI) + * 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 @@ -13,7 +13,7 @@ * along with this program. If not, see . */ -package de.symeda.sormas.app.backend.infrastructure; +package de.symeda.sormas.app.backend.pointofentry; import java.sql.SQLException; import java.util.List; @@ -26,9 +26,9 @@ import de.symeda.sormas.api.infrastructure.pointofentry.PointOfEntryDto; 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.config.ConfigProvider; +import de.symeda.sormas.app.backend.infrastructure.AbstractInfrastructureAdoDao; +import de.symeda.sormas.app.backend.infrastructure.InfrastructureAdo; import de.symeda.sormas.app.backend.region.District; public class PointOfEntryDao extends AbstractInfrastructureAdoDao { diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/infrastructure/PointOfEntryDtoHelper.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/pointofentry/PointOfEntryDtoHelper.java similarity index 95% rename from sormas-app/app/src/main/java/de/symeda/sormas/app/backend/infrastructure/PointOfEntryDtoHelper.java rename to sormas-app/app/src/main/java/de/symeda/sormas/app/backend/pointofentry/PointOfEntryDtoHelper.java index a8d4a66c8d3..f8ace260f56 100644 --- a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/infrastructure/PointOfEntryDtoHelper.java +++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/pointofentry/PointOfEntryDtoHelper.java @@ -13,7 +13,7 @@ * along with this program. If not, see . */ -package de.symeda.sormas.app.backend.infrastructure; +package de.symeda.sormas.app.backend.pointofentry; import java.util.List; @@ -65,7 +65,6 @@ public void fillInnerFromDto(PointOfEntry target, PointOfEntryDto source) { target.setLongitude(source.getLongitude()); target.setActive(source.isActive()); target.setArchived(source.isArchived()); - target.setDefaultInfrastructure(source.isDefaultInfrastructure()); target.setRegion(DatabaseHelper.getRegionDao().getByReferenceDto(source.getRegion())); target.setDistrict(DatabaseHelper.getDistrictDao().getByReferenceDto(source.getDistrict())); @@ -79,7 +78,6 @@ public void fillInnerFromAdo(PointOfEntryDto target, PointOfEntry source) { target.setLongitude(source.getLongitude()); target.setActive(source.isActive()); target.setArchived(source.isArchived()); - target.setDefaultInfrastructure(source.isDefaultInfrastructure()); if (source.getRegion() != null) { Region region = DatabaseHelper.getRegionDao().queryForId(source.getRegion().getId()); diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/region/Area.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/region/Area.java index c7ac8c6ec2e..381fd6e3df5 100644 --- a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/region/Area.java +++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/region/Area.java @@ -1,68 +1,65 @@ /* * SORMAS® - Surveillance Outbreak Response Management & Analysis System * Copyright © 2016-2020 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 + * 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 . + * along with this program. If not, see . */ package de.symeda.sormas.app.backend.region; -import com.j256.ormlite.table.DatabaseTable; - import javax.persistence.Column; import javax.persistence.Entity; -import de.symeda.sormas.app.backend.common.InfrastructureAdo; +import com.j256.ormlite.table.DatabaseTable; + +import de.symeda.sormas.app.backend.infrastructure.InfrastructureAdo; @Entity(name = Area.TABLE_NAME) @DatabaseTable(tableName = Area.TABLE_NAME) public class Area extends InfrastructureAdo { - public static final String TABLE_NAME = "area"; - public static final String I18N_PREFIX = "Area"; + public static final String TABLE_NAME = "area"; + public static final String I18N_PREFIX = "Area"; - public static final String NAME = "name"; - public static final String EXTERNAL_ID = "externalId"; + public static final String NAME = "name"; + public static final String EXTERNAL_ID = "externalId"; - @Column - private String name; - @Column - private String externalId; + @Column + private String name; + @Column + private String externalId; - public String getName() { - return name; - } + public String getName() { + return name; + } - public void setName(String name) { - this.name = name; - } + public void setName(String name) { + this.name = name; + } - public String getExternalId() { - return externalId; - } + public String getExternalId() { + return externalId; + } - public void setExternalId(String externalId) { - this.externalId = externalId; - } + public void setExternalId(String externalId) { + this.externalId = externalId; + } - @Override - public String buildCaption() { - return getName(); - } + @Override + public String buildCaption() { + return getName(); + } - @Override - public String getI18nPrefix() { - return I18N_PREFIX; - } + @Override + public String getI18nPrefix() { + return I18N_PREFIX; + } } diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/region/AreaDao.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/region/AreaDao.java index 519a12b2032..3922978915a 100644 --- a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/region/AreaDao.java +++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/region/AreaDao.java @@ -1,39 +1,37 @@ /* * SORMAS® - Surveillance Outbreak Response Management & Analysis System * Copyright © 2016-2020 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 + * 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 . + * along with this program. If not, see . */ package de.symeda.sormas.app.backend.region; import com.j256.ormlite.dao.Dao; -import de.symeda.sormas.app.backend.common.AbstractInfrastructureAdoDao; +import de.symeda.sormas.app.backend.infrastructure.AbstractInfrastructureAdoDao; public class AreaDao extends AbstractInfrastructureAdoDao { - public AreaDao(Dao innerDao) { - super(innerDao); - } - @Override - protected Class getAdoClass() { - return Area.class; - } + public AreaDao(Dao innerDao) { + super(innerDao); + } - @Override - public String getTableName() { - return Area.TABLE_NAME; - } + @Override + protected Class getAdoClass() { + return Area.class; + } + + @Override + public String getTableName() { + return Area.TABLE_NAME; + } } diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/region/AreaDtoHelper.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/region/AreaDtoHelper.java index 603ed6f52ce..ee6b082c6a3 100644 --- a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/region/AreaDtoHelper.java +++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/region/AreaDtoHelper.java @@ -56,7 +56,6 @@ protected void fillInnerFromDto(Area area, AreaDto dto) { area.setName(dto.getName()); area.setExternalId(dto.getExternalId()); area.setArchived(dto.isArchived()); - area.setDefaultInfrastructure(dto.isDefaultInfrastructure()); } @Override diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/region/Community.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/region/Community.java index 78e382a1505..37f3ca4c441 100644 --- a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/region/Community.java +++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/region/Community.java @@ -15,20 +15,20 @@ package de.symeda.sormas.app.backend.region; -import com.j256.ormlite.field.DatabaseField; -import com.j256.ormlite.table.DatabaseTable; - import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; -import de.symeda.sormas.app.backend.common.InfrastructureAdo; +import com.j256.ormlite.field.DatabaseField; +import com.j256.ormlite.table.DatabaseTable; + +import de.symeda.sormas.app.backend.infrastructure.InfrastructureAdoWithDefault; @Entity(name = Community.TABLE_NAME) @DatabaseTable(tableName = Community.TABLE_NAME) -public class Community extends InfrastructureAdo { +public class Community extends InfrastructureAdoWithDefault { private static final long serialVersionUID = 1971053920357795693L; diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/region/CommunityDao.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/region/CommunityDao.java index d4ebc45fc71..a20617ef9aa 100644 --- a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/region/CommunityDao.java +++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/region/CommunityDao.java @@ -20,8 +20,8 @@ import com.j256.ormlite.dao.Dao; -import de.symeda.sormas.app.backend.common.AbstractInfrastructureAdoDao; import de.symeda.sormas.app.backend.common.DaoException; +import de.symeda.sormas.app.backend.infrastructure.AbstractInfrastructureAdoDao; public class CommunityDao extends AbstractInfrastructureAdoDao { diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/region/Continent.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/region/Continent.java index 2fc9b8db782..27bb1ede14a 100644 --- a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/region/Continent.java +++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/region/Continent.java @@ -1,58 +1,55 @@ /* * SORMAS® - Surveillance Outbreak Response Management & Analysis System * Copyright © 2016-2020 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 + * 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 . + * along with this program. If not, see . */ package de.symeda.sormas.app.backend.region; -import com.j256.ormlite.table.DatabaseTable; - import javax.persistence.Column; import javax.persistence.Entity; -import de.symeda.sormas.app.backend.common.InfrastructureAdo; +import com.j256.ormlite.table.DatabaseTable; + +import de.symeda.sormas.app.backend.infrastructure.InfrastructureAdo; @Entity(name = Continent.TABLE_NAME) @DatabaseTable(tableName = Continent.TABLE_NAME) public class Continent extends InfrastructureAdo { - public static final String TABLE_NAME = "continent"; - public static final String I18N_PREFIX = "Continent"; + public static final String TABLE_NAME = "continent"; + public static final String I18N_PREFIX = "Continent"; - public static final String DEFAULT_NAME = "defaultName"; + public static final String DEFAULT_NAME = "defaultName"; - @Column(columnDefinition = "text") - private String defaultName; + @Column(columnDefinition = "text") + private String defaultName; - public String getDefaultName() { - return defaultName; - } + public String getDefaultName() { + return defaultName; + } - public void setDefaultName(String defaultName) { - this.defaultName = defaultName; - } + public void setDefaultName(String defaultName) { + this.defaultName = defaultName; + } - @Override - public String buildCaption() { - return getDefaultName(); - } + @Override + public String buildCaption() { + return getDefaultName(); + } - @Override - public String getI18nPrefix() { - return I18N_PREFIX; - } + @Override + public String getI18nPrefix() { + return I18N_PREFIX; + } } diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/region/ContinentDao.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/region/ContinentDao.java index 60d7b106f3d..8fc3875a471 100644 --- a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/region/ContinentDao.java +++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/region/ContinentDao.java @@ -1,40 +1,37 @@ /* * SORMAS® - Surveillance Outbreak Response Management & Analysis System * Copyright © 2016-2020 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 + * 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 . + * along with this program. If not, see . */ package de.symeda.sormas.app.backend.region; import com.j256.ormlite.dao.Dao; -import de.symeda.sormas.app.backend.common.AbstractInfrastructureAdoDao; +import de.symeda.sormas.app.backend.infrastructure.AbstractInfrastructureAdoDao; public class ContinentDao extends AbstractInfrastructureAdoDao { - public ContinentDao(Dao innerDao) { - super(innerDao); - } + public ContinentDao(Dao innerDao) { + super(innerDao); + } - @Override - protected Class getAdoClass() { - return Continent.class; - } + @Override + protected Class getAdoClass() { + return Continent.class; + } - @Override - public String getTableName() { - return Continent.TABLE_NAME; - } + @Override + public String getTableName() { + return Continent.TABLE_NAME; + } } diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/region/ContinentDtoHelper.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/region/ContinentDtoHelper.java index 3ac6d0df2a8..1db1477729d 100644 --- a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/region/ContinentDtoHelper.java +++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/region/ContinentDtoHelper.java @@ -56,7 +56,6 @@ protected Call> pushAll(List continentDtos) thr protected void fillInnerFromDto(Continent continent, ContinentDto dto) { continent.setDefaultName(dto.getDefaultName()); continent.setArchived(dto.isArchived()); - continent.setDefaultInfrastructure(dto.isDefaultInfrastructure()); } @Override diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/region/Country.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/region/Country.java index 4ef7615dce2..fec84e024bb 100644 --- a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/region/Country.java +++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/region/Country.java @@ -1,15 +1,15 @@ package de.symeda.sormas.app.backend.region; -import com.j256.ormlite.field.DatabaseField; -import com.j256.ormlite.table.DatabaseTable; - import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; -import de.symeda.sormas.app.backend.common.InfrastructureAdo; +import com.j256.ormlite.field.DatabaseField; +import com.j256.ormlite.table.DatabaseTable; + +import de.symeda.sormas.app.backend.infrastructure.InfrastructureAdo; @Entity(name = Country.TABLE_NAME) @DatabaseTable(tableName = Country.TABLE_NAME) diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/region/CountryDao.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/region/CountryDao.java index 8c2cd62d9f6..81570dce253 100644 --- a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/region/CountryDao.java +++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/region/CountryDao.java @@ -1,17 +1,17 @@ package de.symeda.sormas.app.backend.region; -import android.util.Log; +import java.sql.SQLException; +import java.util.List; import com.j256.ormlite.dao.Dao; import com.j256.ormlite.stmt.QueryBuilder; import com.j256.ormlite.stmt.Where; -import java.sql.SQLException; -import java.util.List; +import android.util.Log; 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; public class CountryDao extends AbstractInfrastructureAdoDao { @@ -39,9 +39,9 @@ public List queryActiveBySubcontinent(Subcontinent subcontinent) { QueryBuilder builder = queryBuilder(); Where where = builder.where(); where.and( - where.eq(AbstractDomainObject.SNAPSHOT, false), - where.eq(InfrastructureAdo.ARCHIVED, false), - where.eq(Country.SUBCONTINENT + "_id", subcontinent)); + where.eq(AbstractDomainObject.SNAPSHOT, false), + where.eq(InfrastructureAdo.ARCHIVED, false), + where.eq(Country.SUBCONTINENT + "_id", subcontinent)); return builder.orderBy(Country.NAME, true).query(); } catch (SQLException | IllegalArgumentException e) { diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/region/CountryDtoHelper.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/region/CountryDtoHelper.java index 056d69f16c6..1c9d4791af6 100644 --- a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/region/CountryDtoHelper.java +++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/region/CountryDtoHelper.java @@ -43,7 +43,6 @@ protected void fillInnerFromDto(Country ado, CountryDto dto) { ado.setName(dto.getDefaultName()); ado.setIsoCode(dto.getIsoCode()); ado.setArchived(dto.isArchived()); - ado.setDefaultInfrastructure(dto.isDefaultInfrastructure()); ado.setSubcontinent(DatabaseHelper.getSubcontinentDao().getByReferenceDto(dto.getSubcontinent())); } diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/region/District.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/region/District.java index 3589ded8708..238e076ec32 100644 --- a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/region/District.java +++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/region/District.java @@ -15,20 +15,20 @@ package de.symeda.sormas.app.backend.region; -import com.j256.ormlite.field.DatabaseField; -import com.j256.ormlite.table.DatabaseTable; - import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; -import de.symeda.sormas.app.backend.common.InfrastructureAdo; +import com.j256.ormlite.field.DatabaseField; +import com.j256.ormlite.table.DatabaseTable; + +import de.symeda.sormas.app.backend.infrastructure.InfrastructureAdoWithDefault; @Entity(name = District.TABLE_NAME) @DatabaseTable(tableName = District.TABLE_NAME) -public class District extends InfrastructureAdo { +public class District extends InfrastructureAdoWithDefault { private static final long serialVersionUID = -6057113756091470463L; diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/region/DistrictDao.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/region/DistrictDao.java index e9766cb8f8e..9643a33ca33 100644 --- a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/region/DistrictDao.java +++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/region/DistrictDao.java @@ -20,8 +20,8 @@ import com.j256.ormlite.dao.Dao; -import de.symeda.sormas.app.backend.common.AbstractInfrastructureAdoDao; import de.symeda.sormas.app.backend.common.DaoException; +import de.symeda.sormas.app.backend.infrastructure.AbstractInfrastructureAdoDao; public class DistrictDao extends AbstractInfrastructureAdoDao { diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/region/Region.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/region/Region.java index 14116fc1c76..89b16a0a008 100644 --- a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/region/Region.java +++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/region/Region.java @@ -15,17 +15,17 @@ package de.symeda.sormas.app.backend.region; -import com.j256.ormlite.field.DatabaseField; -import com.j256.ormlite.table.DatabaseTable; - import javax.persistence.Column; import javax.persistence.Entity; -import de.symeda.sormas.app.backend.common.InfrastructureAdo; +import com.j256.ormlite.field.DatabaseField; +import com.j256.ormlite.table.DatabaseTable; + +import de.symeda.sormas.app.backend.infrastructure.InfrastructureAdoWithDefault; @Entity(name = Region.TABLE_NAME) @DatabaseTable(tableName = Region.TABLE_NAME) -public class Region extends InfrastructureAdo { +public class Region extends InfrastructureAdoWithDefault { private static final long serialVersionUID = -2958216667876104358L; diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/region/RegionDao.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/region/RegionDao.java index 87a598a9469..82dd1217094 100644 --- a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/region/RegionDao.java +++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/region/RegionDao.java @@ -15,20 +15,20 @@ package de.symeda.sormas.app.backend.region; -import android.util.Log; +import java.sql.SQLException; +import java.util.List; import com.j256.ormlite.dao.Dao; import com.j256.ormlite.stmt.QueryBuilder; import com.j256.ormlite.stmt.Where; -import java.sql.SQLException; -import java.util.List; +import android.util.Log; import de.symeda.sormas.app.backend.common.AbstractDomainObject; -import de.symeda.sormas.app.backend.common.AbstractInfrastructureAdoDao; import de.symeda.sormas.app.backend.common.DatabaseHelper; -import de.symeda.sormas.app.backend.common.InfrastructureAdo; import de.symeda.sormas.app.backend.config.ConfigProvider; +import de.symeda.sormas.app.backend.infrastructure.AbstractInfrastructureAdoDao; +import de.symeda.sormas.app.backend.infrastructure.InfrastructureAdo; public class RegionDao extends AbstractInfrastructureAdoDao { diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/region/Subcontinent.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/region/Subcontinent.java index 990dd0c4ab6..836f737b799 100644 --- a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/region/Subcontinent.java +++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/region/Subcontinent.java @@ -15,16 +15,16 @@ package de.symeda.sormas.app.backend.region; -import com.j256.ormlite.field.DatabaseField; -import com.j256.ormlite.table.DatabaseTable; - import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; -import de.symeda.sormas.app.backend.common.InfrastructureAdo; +import com.j256.ormlite.field.DatabaseField; +import com.j256.ormlite.table.DatabaseTable; + +import de.symeda.sormas.app.backend.infrastructure.InfrastructureAdo; @Entity(name = Subcontinent.TABLE_NAME) @DatabaseTable(tableName = Subcontinent.TABLE_NAME) diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/region/SubcontinentDao.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/region/SubcontinentDao.java index 210b987c847..787a0d49fee 100644 --- a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/region/SubcontinentDao.java +++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/region/SubcontinentDao.java @@ -15,18 +15,18 @@ package de.symeda.sormas.app.backend.region; -import android.util.Log; +import java.sql.SQLException; +import java.util.List; import com.j256.ormlite.dao.Dao; import com.j256.ormlite.stmt.QueryBuilder; import com.j256.ormlite.stmt.Where; -import java.sql.SQLException; -import java.util.List; +import android.util.Log; 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; public class SubcontinentDao extends AbstractInfrastructureAdoDao { @@ -49,9 +49,9 @@ public List queryActiveByContinent(Continent continent) { QueryBuilder builder = queryBuilder(); Where where = builder.where(); where.and( - where.eq(AbstractDomainObject.SNAPSHOT, false), - where.eq(InfrastructureAdo.ARCHIVED, false), - where.eq(Subcontinent.CONTINENT + "_id", continent)); + where.eq(AbstractDomainObject.SNAPSHOT, false), + where.eq(InfrastructureAdo.ARCHIVED, false), + where.eq(Subcontinent.CONTINENT + "_id", continent)); return builder.orderBy(Subcontinent.DEFAULT_NAME, true).query(); } catch (SQLException | IllegalArgumentException e) { diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/region/SubcontinentDtoHelper.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/region/SubcontinentDtoHelper.java index bd2106afe30..cbec98ba29b 100644 --- a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/region/SubcontinentDtoHelper.java +++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/region/SubcontinentDtoHelper.java @@ -57,7 +57,6 @@ protected Call> pushAll(List subcontinentDto protected void fillInnerFromDto(Subcontinent subcontinent, SubcontinentDto dto) { subcontinent.setDefaultName(dto.getDefaultName()); subcontinent.setArchived(dto.isArchived()); - subcontinent.setDefaultInfrastructure(dto.isDefaultInfrastructure()); subcontinent.setContinent(DatabaseHelper.getContinentDao().queryUuid(dto.getContinent().getUuid())); } diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/report/AggregateReport.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/report/AggregateReport.java index 992fbc17b97..eb0dac90a7b 100644 --- a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/report/AggregateReport.java +++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/report/AggregateReport.java @@ -1,17 +1,17 @@ package de.symeda.sormas.app.backend.report; -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 de.symeda.sormas.api.Disease; import de.symeda.sormas.app.backend.common.AbstractDomainObject; import de.symeda.sormas.app.backend.facility.Facility; -import de.symeda.sormas.app.backend.infrastructure.PointOfEntry; +import de.symeda.sormas.app.backend.pointofentry.PointOfEntry; import de.symeda.sormas.app.backend.region.District; import de.symeda.sormas.app.backend.region.Region; import de.symeda.sormas.app.backend.user.User; diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/report/AggregateReportDao.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/report/AggregateReportDao.java index 638f70c7ea2..46c449b85a8 100644 --- a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/report/AggregateReportDao.java +++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/report/AggregateReportDao.java @@ -17,10 +17,10 @@ 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.common.InfrastructureAdo; import de.symeda.sormas.app.backend.config.ConfigProvider; import de.symeda.sormas.app.backend.facility.Facility; -import de.symeda.sormas.app.backend.infrastructure.PointOfEntry; +import de.symeda.sormas.app.backend.infrastructure.InfrastructureAdo; +import de.symeda.sormas.app.backend.pointofentry.PointOfEntry; import de.symeda.sormas.app.backend.region.District; import de.symeda.sormas.app.backend.user.User; diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/report/AggregateReportDtoHelper.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/report/AggregateReportDtoHelper.java index 4a76d3b636b..ed9d00ac051 100644 --- a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/report/AggregateReportDtoHelper.java +++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/report/AggregateReportDtoHelper.java @@ -8,8 +8,8 @@ import de.symeda.sormas.app.backend.common.DatabaseHelper; import de.symeda.sormas.app.backend.facility.Facility; import de.symeda.sormas.app.backend.facility.FacilityDtoHelper; -import de.symeda.sormas.app.backend.infrastructure.PointOfEntry; -import de.symeda.sormas.app.backend.infrastructure.PointOfEntryDtoHelper; +import de.symeda.sormas.app.backend.pointofentry.PointOfEntry; +import de.symeda.sormas.app.backend.pointofentry.PointOfEntryDtoHelper; import de.symeda.sormas.app.backend.region.District; import de.symeda.sormas.app.backend.region.DistrictDtoHelper; import de.symeda.sormas.app.backend.region.Region; @@ -33,7 +33,7 @@ protected Class getDtoClass() { } @Override - protected Call> pullAllSince(long since, Integer size, String lastSynchronizedUuid) throws NoConnectionException { + protected Call> pullAllSince(long since, Integer size, String lastSynchronizedUuid) throws NoConnectionException { return RetroProvider.getAggregateReportFacade().pullAllSince(since); } @@ -109,8 +109,8 @@ public void fillInnerFromAdo(AggregateReportDto target, AggregateReport source) target.setAgeGroup(source.getAgeGroup()); } - @Override - protected long getApproximateJsonSizeInBytes() { - return AggregateReportDto.APPROXIMATE_JSON_SIZE_IN_BYTES; - } + @Override + protected long getApproximateJsonSizeInBytes() { + return AggregateReportDto.APPROXIMATE_JSON_SIZE_IN_BYTES; + } } diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/user/User.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/user/User.java index 7f0624b5a65..eee3830021b 100644 --- a/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/user/User.java +++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/backend/user/User.java @@ -15,9 +15,6 @@ package de.symeda.sormas.app.backend.user; -import com.j256.ormlite.field.DatabaseField; -import com.j256.ormlite.table.DatabaseTable; - import java.util.Arrays; import java.util.Set; @@ -26,13 +23,16 @@ import javax.persistence.EnumType; import javax.persistence.Enumerated; +import com.j256.ormlite.field.DatabaseField; +import com.j256.ormlite.table.DatabaseTable; + import de.symeda.sormas.api.Disease; import de.symeda.sormas.api.Language; import de.symeda.sormas.api.user.JurisdictionLevel; import de.symeda.sormas.app.backend.common.AbstractDomainObject; import de.symeda.sormas.app.backend.facility.Facility; -import de.symeda.sormas.app.backend.infrastructure.PointOfEntry; import de.symeda.sormas.app.backend.location.Location; +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; diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/component/controls/InfrastructureSpinnerField.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/component/controls/InfrastructureSpinnerField.java index 46aade2f4f8..fe6d9b15223 100644 --- a/sormas-app/app/src/main/java/de/symeda/sormas/app/component/controls/InfrastructureSpinnerField.java +++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/component/controls/InfrastructureSpinnerField.java @@ -8,36 +8,37 @@ import de.symeda.sormas.api.i18n.I18nProperties; import de.symeda.sormas.api.i18n.Strings; -import de.symeda.sormas.app.backend.common.InfrastructureAdo; +import de.symeda.sormas.app.backend.infrastructure.InfrastructureAdo; import de.symeda.sormas.app.component.Item; public class InfrastructureSpinnerField extends ControlSpinnerField { - public InfrastructureSpinnerField(Context context) { - super(context); - } - public InfrastructureSpinnerField(Context context, AttributeSet attrs) { - super(context, attrs); - } + public InfrastructureSpinnerField(Context context) { + super(context); + } - public InfrastructureSpinnerField(Context context, AttributeSet attrs, int defStyle) { - super(context, attrs, defStyle); - } + public InfrastructureSpinnerField(Context context, AttributeSet attrs) { + super(context, attrs); + } - @Override + public InfrastructureSpinnerField(Context context, AttributeSet attrs, int defStyle) { + super(context, attrs, defStyle); + } + + @Override public void setSpinnerData(List items, Object selectedValue) { - List processedItems = null; - if(items != null){ - processedItems = new ArrayList<>(items.size()); - for (Item i : items) { - if (i.getValue() != null && ((InfrastructureAdo) i.getValue()).isArchived()) { - processedItems.add(new Item(i.getKey() + " (" + I18nProperties.getString(Strings.inactive) + ")", i.getValue())); - } else { - processedItems.add(i); - } - } - } - - super.setSpinnerData(processedItems, selectedValue); - } + List processedItems = null; + if (items != null) { + processedItems = new ArrayList<>(items.size()); + for (Item i : items) { + if (i.getValue() != null && ((InfrastructureAdo) i.getValue()).isArchived()) { + processedItems.add(new Item(i.getKey() + " (" + I18nProperties.getString(Strings.inactive) + ")", i.getValue())); + } else { + processedItems.add(i); + } + } + } + + super.setSpinnerData(processedItems, selectedValue); + } } diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/report/aggregate/AggregateReportsFragment.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/report/aggregate/AggregateReportsFragment.java index b9a1fcdc65d..eba69b54aa7 100644 --- a/sormas-app/app/src/main/java/de/symeda/sormas/app/report/aggregate/AggregateReportsFragment.java +++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/report/aggregate/AggregateReportsFragment.java @@ -32,10 +32,10 @@ import de.symeda.sormas.app.R; import de.symeda.sormas.app.backend.common.DaoException; import de.symeda.sormas.app.backend.common.DatabaseHelper; -import de.symeda.sormas.app.backend.common.InfrastructureAdo; import de.symeda.sormas.app.backend.config.ConfigProvider; import de.symeda.sormas.app.backend.facility.Facility; -import de.symeda.sormas.app.backend.infrastructure.PointOfEntry; +import de.symeda.sormas.app.backend.infrastructure.InfrastructureAdo; +import de.symeda.sormas.app.backend.pointofentry.PointOfEntry; import de.symeda.sormas.app.backend.region.District; import de.symeda.sormas.app.backend.report.AggregateReport; import de.symeda.sormas.app.backend.user.User; diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/rest/SynchronizeDataAsync.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/rest/SynchronizeDataAsync.java index 2f25de40c0d..557853980f8 100644 --- a/sormas-app/app/src/main/java/de/symeda/sormas/app/rest/SynchronizeDataAsync.java +++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/rest/SynchronizeDataAsync.java @@ -87,9 +87,9 @@ import de.symeda.sormas.app.backend.immunization.Immunization; import de.symeda.sormas.app.backend.immunization.ImmunizationDtoHelper; import de.symeda.sormas.app.backend.infrastructure.InfrastructureHelper; -import de.symeda.sormas.app.backend.infrastructure.PointOfEntryDtoHelper; import de.symeda.sormas.app.backend.outbreak.OutbreakDtoHelper; import de.symeda.sormas.app.backend.person.PersonDtoHelper; +import de.symeda.sormas.app.backend.pointofentry.PointOfEntryDtoHelper; import de.symeda.sormas.app.backend.region.AreaDtoHelper; import de.symeda.sormas.app.backend.region.CommunityDtoHelper; import de.symeda.sormas.app.backend.region.ContinentDtoHelper; diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/util/InfrastructureDaoHelper.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/util/InfrastructureDaoHelper.java index 0e142a67f40..2e8be4c14b3 100644 --- a/sormas-app/app/src/main/java/de/symeda/sormas/app/util/InfrastructureDaoHelper.java +++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/util/InfrastructureDaoHelper.java @@ -34,7 +34,7 @@ import de.symeda.sormas.api.infrastructure.pointofentry.PointOfEntryDto; import de.symeda.sormas.app.backend.common.DatabaseHelper; import de.symeda.sormas.app.backend.facility.Facility; -import de.symeda.sormas.app.backend.infrastructure.PointOfEntry; +import de.symeda.sormas.app.backend.pointofentry.PointOfEntry; import de.symeda.sormas.app.backend.region.Area; import de.symeda.sormas.app.backend.region.Community; import de.symeda.sormas.app.backend.region.Continent; diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/util/InfrastructureFieldsDependencyHandler.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/util/InfrastructureFieldsDependencyHandler.java index df8c8f82390..5160ccef790 100644 --- a/sormas-app/app/src/main/java/de/symeda/sormas/app/util/InfrastructureFieldsDependencyHandler.java +++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/util/InfrastructureFieldsDependencyHandler.java @@ -38,7 +38,7 @@ import de.symeda.sormas.app.backend.common.DatabaseHelper; import de.symeda.sormas.app.backend.config.ConfigProvider; import de.symeda.sormas.app.backend.facility.Facility; -import de.symeda.sormas.app.backend.infrastructure.PointOfEntry; +import de.symeda.sormas.app.backend.pointofentry.PointOfEntry; import de.symeda.sormas.app.backend.region.Community; import de.symeda.sormas.app.backend.region.Continent; import de.symeda.sormas.app.backend.region.Country; diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/util/TextViewBindingAdapters.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/util/TextViewBindingAdapters.java index d22ed5d331e..f40de190efc 100644 --- a/sormas-app/app/src/main/java/de/symeda/sormas/app/util/TextViewBindingAdapters.java +++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/util/TextViewBindingAdapters.java @@ -62,9 +62,9 @@ import de.symeda.sormas.app.backend.environment.Environment; import de.symeda.sormas.app.backend.event.Event; import de.symeda.sormas.app.backend.facility.Facility; -import de.symeda.sormas.app.backend.infrastructure.PointOfEntry; import de.symeda.sormas.app.backend.location.Location; import de.symeda.sormas.app.backend.person.Person; +import de.symeda.sormas.app.backend.pointofentry.PointOfEntry; import de.symeda.sormas.app.backend.sample.PathogenTest; import de.symeda.sormas.app.backend.sample.Sample; import de.symeda.sormas.app.backend.task.Task; diff --git a/sormas-app/app/src/main/res/layout/fragment_case_edit_port_health_info_layout.xml b/sormas-app/app/src/main/res/layout/fragment_case_edit_port_health_info_layout.xml index 41343552717..26c896596ba 100644 --- a/sormas-app/app/src/main/res/layout/fragment_case_edit_port_health_info_layout.xml +++ b/sormas-app/app/src/main/res/layout/fragment_case_edit_port_health_info_layout.xml @@ -29,7 +29,7 @@ - + diff --git a/sormas-app/app/src/main/res/layout/fragment_case_read_port_health_info_layout.xml b/sormas-app/app/src/main/res/layout/fragment_case_read_port_health_info_layout.xml index 7fcd23fb25f..1e81b845491 100644 --- a/sormas-app/app/src/main/res/layout/fragment_case_read_port_health_info_layout.xml +++ b/sormas-app/app/src/main/res/layout/fragment_case_read_port_health_info_layout.xml @@ -29,7 +29,7 @@ - + diff --git a/sormas-backend/src/main/java/de/symeda/sormas/backend/common/AbstractInfrastructureAdoService.java b/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/AbstractInfrastructureAdoService.java similarity index 80% rename from sormas-backend/src/main/java/de/symeda/sormas/backend/common/AbstractInfrastructureAdoService.java rename to sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/AbstractInfrastructureAdoService.java index 507e56865ec..c34c3979330 100644 --- a/sormas-backend/src/main/java/de/symeda/sormas/backend/common/AbstractInfrastructureAdoService.java +++ b/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/AbstractInfrastructureAdoService.java @@ -1,4 +1,19 @@ -package de.symeda.sormas.backend.common; +/* + * 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 . + */ + +package de.symeda.sormas.backend.infrastructure; import java.util.ArrayList; import java.util.Collection; @@ -12,6 +27,9 @@ import de.symeda.sormas.api.EntityRelevanceStatus; import de.symeda.sormas.api.utils.criteria.BaseCriteria; +import de.symeda.sormas.backend.common.AbstractDomainObject; +import de.symeda.sormas.backend.common.AdoServiceWithUserFilterAndJurisdiction; +import de.symeda.sormas.backend.common.CriteriaBuilderHelper; import de.symeda.sormas.backend.util.QueryHelper; public abstract class AbstractInfrastructureAdoService @@ -115,7 +133,7 @@ public ADO getDefaultInfrastructure() { CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery cq = cb.createQuery(getElementClass()); Root from = cq.from(getElementClass()); - cq.where(cb.and(createBasicFilter(cb, from), cb.isTrue(from.get(InfrastructureAdo.DEFAULT_INFRASTRUCTURE)))); + cq.where(cb.and(createBasicFilter(cb, from), cb.isTrue(from.get(InfrastructureAdoWithDefault.DEFAULT_INFRASTRUCTURE)))); List result = em.createQuery(cq).getResultList(); return result.size() > 0 ? result.get(0) : null; diff --git a/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/AbstractInfrastructureFacadeEjb.java b/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/AbstractInfrastructureFacadeEjb.java index 7539936ff16..f7a2273864f 100644 --- a/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/AbstractInfrastructureFacadeEjb.java +++ b/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/AbstractInfrastructureFacadeEjb.java @@ -23,6 +23,7 @@ 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.InfrastructureFacade; import de.symeda.sormas.api.user.UserRight; import de.symeda.sormas.api.utils.AccessDeniedException; @@ -31,9 +32,8 @@ import de.symeda.sormas.api.utils.criteria.BaseCriteria; import de.symeda.sormas.backend.common.AbstractBaseEjb; import de.symeda.sormas.backend.common.AbstractDomainObject; -import de.symeda.sormas.backend.common.AbstractInfrastructureAdoService; -import de.symeda.sormas.backend.common.InfrastructureAdo; import de.symeda.sormas.backend.feature.FeatureConfigurationFacadeEjb; +import de.symeda.sormas.backend.infrastructure.district.District; import de.symeda.sormas.backend.user.User; import de.symeda.sormas.backend.util.Pseudonymizer; import de.symeda.sormas.backend.util.RightsAllowed; @@ -136,7 +136,7 @@ protected DTO doSave(DTO dtoToSave, boolean allowMerge, boolean includeArchived, ADO existingEntity = service.getByUuid(dtoToSave.getUuid()); - if (dtoToSave.isDefaultInfrastructure()) { + if (dtoToSave instanceof InfrastructureDtoWithDefault && ((InfrastructureDtoWithDefault) dtoToSave).isDefaultInfrastructure()) { ADO defaultInfrastructure = getDefaultInfrastructure(); if (defaultInfrastructure != null) { if (!dtoToSave.getUuid().equals(defaultInfrastructure.getUuid())) { @@ -146,11 +146,18 @@ protected DTO doSave(DTO dtoToSave, boolean allowMerge, boolean includeArchived, I18nProperties.getCaption(adoClass.getSimpleName()), I18nProperties.getCaption(adoClass.getSimpleName()))); } - } else { + } else if (checkDefaultEligible(dtoToSave)) { // Default infrastructure set for the first time, needs to be re-queried defaultInfrastructureCache.setQueried(false); + } else { + throw new ValidationRuntimeException( + I18nProperties.getValidationError( + adoClass == District.class + ? Validations.defaultInfrastructureInvalidParentRegion + : Validations.defaultInfrastructureInvalidParentDistrict)); } - } else if (existingEntity != null && existingEntity.isDefaultInfrastructure()) { + } else if (existingEntity instanceof InfrastructureAdoWithDefault + && ((InfrastructureAdoWithDefault) existingEntity).isDefaultInfrastructure()) { // Default infrastructure removed if (defaultInfrastructureCache != null) { defaultInfrastructureCache.setDefaultInfrastructure(null); @@ -341,13 +348,21 @@ protected void restorePseudonymizedDto(DTO dto, DTO existingDto, ADO entity, Pse protected void applyToDtoInheritance(DTO dto, ADO entity) { dto.setArchived(entity.isArchived()); dto.setCentrallyManaged(entity.isCentrallyManaged()); - dto.setDefaultInfrastructure(entity.isDefaultInfrastructure()); + if (dto instanceof InfrastructureDtoWithDefault) { + ((InfrastructureDtoWithDefault) dto).setDefaultInfrastructure(((InfrastructureAdoWithDefault) entity).isDefaultInfrastructure()); + } } protected void applyFillOrBuildEntityInheritance(ADO entity, DTO dto) { entity.setArchived(dto.isArchived()); entity.setCentrallyManaged(dto.isCentrallyManaged()); - entity.setDefaultInfrastructure(dto.isDefaultInfrastructure()); + if (entity instanceof InfrastructureAdoWithDefault) { + ((InfrastructureAdoWithDefault) entity).setDefaultInfrastructure(((InfrastructureDtoWithDefault) dto).isDefaultInfrastructure()); + } + } + + protected boolean checkDefaultEligible(DTO dto) { + return true; } protected ADO getDefaultInfrastructure() { diff --git a/sormas-backend/src/main/java/de/symeda/sormas/backend/common/InfrastructureAdo.java b/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/InfrastructureAdo.java similarity index 56% rename from sormas-backend/src/main/java/de/symeda/sormas/backend/common/InfrastructureAdo.java rename to sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/InfrastructureAdo.java index 41f66546b1c..1cb972479e5 100644 --- a/sormas-backend/src/main/java/de/symeda/sormas/backend/common/InfrastructureAdo.java +++ b/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/InfrastructureAdo.java @@ -1,8 +1,25 @@ -package de.symeda.sormas.backend.common; +/* + * 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 . + */ + +package de.symeda.sormas.backend.infrastructure; import javax.persistence.Column; import javax.persistence.MappedSuperclass; +import de.symeda.sormas.backend.common.AbstractDomainObject; + /** * An extension of the {@link AbstractDomainObject} that defines infrastructure data (e.g. regions, districts). * Infrastructure data should not be deleted from the system, but can be archived. Archived infrastructure data @@ -16,11 +33,9 @@ public abstract class InfrastructureAdo extends AbstractDomainObject { // todo this should be included, however, we face problems as externalID used used sometimes in the code. See #6549. //public static final String EXTERNAL_ID = "externalId"; public static final String ARCHIVED = "archived"; - public static final String DEFAULT_INFRASTRUCTURE = "defaultInfrastructure"; private boolean centrallyManaged; private boolean archived; - private boolean defaultInfrastructure; @Column(name = "centrally_managed") public boolean isCentrallyManaged() { @@ -40,12 +55,4 @@ public void setArchived(boolean archived) { this.archived = archived; } - @Column - public boolean isDefaultInfrastructure() { - return defaultInfrastructure; - } - - public void setDefaultInfrastructure(boolean defaultInfrastructure) { - this.defaultInfrastructure = defaultInfrastructure; - } } diff --git a/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/InfrastructureAdoWithDefault.java b/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/InfrastructureAdoWithDefault.java new file mode 100644 index 00000000000..1d220312391 --- /dev/null +++ b/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/InfrastructureAdoWithDefault.java @@ -0,0 +1,39 @@ +/* + * 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 . + */ + +package de.symeda.sormas.backend.infrastructure; + +import javax.persistence.Column; +import javax.persistence.MappedSuperclass; + +@MappedSuperclass +public abstract class InfrastructureAdoWithDefault extends InfrastructureAdo { + + private static final long serialVersionUID = -3652788824027864843L; + + public static final String DEFAULT_INFRASTRUCTURE = "defaultInfrastructure"; + + private boolean defaultInfrastructure; + + @Column + public boolean isDefaultInfrastructure() { + return defaultInfrastructure; + } + + public void setDefaultInfrastructure(boolean defaultInfrastructure) { + this.defaultInfrastructure = defaultInfrastructure; + } + +} diff --git a/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/area/Area.java b/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/area/Area.java index 4e1a98ffebf..0d38effe6dc 100644 --- a/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/area/Area.java +++ b/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/area/Area.java @@ -9,7 +9,7 @@ import org.hibernate.annotations.Cache; import org.hibernate.annotations.CacheConcurrencyStrategy; -import de.symeda.sormas.backend.common.InfrastructureAdo; +import de.symeda.sormas.backend.infrastructure.InfrastructureAdo; @Entity(name = "areas") @Cacheable diff --git a/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/area/AreaService.java b/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/area/AreaService.java index 5c1f7a4d9b2..5e9c9b5155e 100644 --- a/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/area/AreaService.java +++ b/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/area/AreaService.java @@ -15,8 +15,8 @@ import de.symeda.sormas.api.EntityRelevanceStatus; import de.symeda.sormas.api.infrastructure.area.AreaCriteria; import de.symeda.sormas.api.utils.DataHelper; -import de.symeda.sormas.backend.common.AbstractInfrastructureAdoService; import de.symeda.sormas.backend.common.CriteriaBuilderHelper; +import de.symeda.sormas.backend.infrastructure.AbstractInfrastructureAdoService; import de.symeda.sormas.backend.infrastructure.region.Region; @Stateless diff --git a/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/community/Community.java b/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/community/Community.java index 50ce563352e..763d6053f95 100644 --- a/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/community/Community.java +++ b/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/community/Community.java @@ -30,13 +30,13 @@ import org.hibernate.annotations.Cache; import org.hibernate.annotations.CacheConcurrencyStrategy; -import de.symeda.sormas.backend.common.InfrastructureAdo; +import de.symeda.sormas.backend.infrastructure.InfrastructureAdoWithDefault; import de.symeda.sormas.backend.infrastructure.district.District; @Entity @Cacheable @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) -public class Community extends InfrastructureAdo { +public class Community extends InfrastructureAdoWithDefault { private static final long serialVersionUID = 1971053920357795693L; diff --git a/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/community/CommunityFacadeEjb.java b/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/community/CommunityFacadeEjb.java index fe0b2628f20..e2d0a54e26d 100644 --- a/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/community/CommunityFacadeEjb.java +++ b/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/community/CommunityFacadeEjb.java @@ -38,6 +38,7 @@ import de.symeda.sormas.backend.feature.FeatureConfigurationFacadeEjb.FeatureConfigurationFacadeEjbLocal; import de.symeda.sormas.backend.infrastructure.AbstractInfrastructureFacadeEjb; import de.symeda.sormas.backend.infrastructure.district.DistrictFacadeEjb; +import de.symeda.sormas.backend.infrastructure.district.DistrictFacadeEjb.DistrictFacadeEjbLocal; import de.symeda.sormas.backend.infrastructure.district.DistrictService; import de.symeda.sormas.backend.infrastructure.facility.Facility; import de.symeda.sormas.backend.infrastructure.region.RegionFacadeEjb; @@ -50,6 +51,8 @@ public class CommunityFacadeEjb extends AbstractInfrastructureFacadeEjb implements CommunityFacade { + @EJB + private DistrictFacadeEjbLocal districtFacade; @EJB private DistrictService districtService; @@ -177,6 +180,11 @@ protected Community fillOrBuildEntity(@NotNull CommunityDto source, Community ta return target; } + @Override + protected boolean checkDefaultEligible(CommunityDto dto) { + return dto.getDistrict().equals(districtFacade.getDefaultInfrastructureReference()); + } + @LocalBean @Stateless public static class CommunityFacadeEjbLocal extends CommunityFacadeEjb { diff --git a/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/community/CommunityService.java b/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/community/CommunityService.java index 8b3d1c452bd..c50b87a8876 100644 --- a/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/community/CommunityService.java +++ b/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/community/CommunityService.java @@ -49,9 +49,9 @@ import de.symeda.sormas.api.utils.DataHelper; import de.symeda.sormas.api.utils.SortProperty; import de.symeda.sormas.backend.common.AbstractDomainObject; -import de.symeda.sormas.backend.common.AbstractInfrastructureAdoService; import de.symeda.sormas.backend.common.CriteriaBuilderHelper; -import de.symeda.sormas.backend.common.InfrastructureAdo; +import de.symeda.sormas.backend.infrastructure.AbstractInfrastructureAdoService; +import de.symeda.sormas.backend.infrastructure.InfrastructureAdo; import de.symeda.sormas.backend.infrastructure.country.Country; import de.symeda.sormas.backend.infrastructure.country.CountryFacadeEjb.CountryFacadeEjbLocal; import de.symeda.sormas.backend.infrastructure.district.District; @@ -239,9 +239,9 @@ public boolean hasArchivedParentInfrastructure(Collection communityUuids Join regionJoin = districtJoin.join(District.REGION); cq.where( - cb.and( - cb.or(cb.isTrue(districtJoin.get(InfrastructureAdo.ARCHIVED)), cb.isTrue(regionJoin.get(InfrastructureAdo.ARCHIVED))), - root.get(AbstractDomainObject.UUID).in(communityUuids))); + cb.and( + cb.or(cb.isTrue(districtJoin.get(InfrastructureAdo.ARCHIVED)), cb.isTrue(regionJoin.get(InfrastructureAdo.ARCHIVED))), + root.get(AbstractDomainObject.UUID).in(communityUuids))); cq.select(root.get(AbstractDomainObject.ID)); diff --git a/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/continent/Continent.java b/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/continent/Continent.java index 1112dbeee2d..f8c3fe2c911 100644 --- a/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/continent/Continent.java +++ b/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/continent/Continent.java @@ -12,7 +12,7 @@ import org.hibernate.annotations.CacheConcurrencyStrategy; import de.symeda.sormas.api.infrastructure.continent.ContinentReferenceDto; -import de.symeda.sormas.backend.common.InfrastructureAdo; +import de.symeda.sormas.backend.infrastructure.InfrastructureAdo; import de.symeda.sormas.backend.infrastructure.subcontinent.Subcontinent; @Entity diff --git a/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/continent/ContinentService.java b/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/continent/ContinentService.java index 30e60b4b633..f0c8c0cecfd 100644 --- a/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/continent/ContinentService.java +++ b/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/continent/ContinentService.java @@ -12,8 +12,8 @@ import javax.persistence.criteria.Root; import de.symeda.sormas.api.infrastructure.continent.ContinentCriteria; -import de.symeda.sormas.backend.common.AbstractInfrastructureAdoService; import de.symeda.sormas.backend.common.CriteriaBuilderHelper; +import de.symeda.sormas.backend.infrastructure.AbstractInfrastructureAdoService; @Stateless @LocalBean diff --git a/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/country/Country.java b/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/country/Country.java index 7e4427504fb..84539fb3547 100644 --- a/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/country/Country.java +++ b/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/country/Country.java @@ -9,7 +9,7 @@ import org.hibernate.annotations.Cache; import org.hibernate.annotations.CacheConcurrencyStrategy; -import de.symeda.sormas.backend.common.InfrastructureAdo; +import de.symeda.sormas.backend.infrastructure.InfrastructureAdo; import de.symeda.sormas.backend.infrastructure.subcontinent.Subcontinent; @Entity diff --git a/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/country/CountryFacadeEjb.java b/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/country/CountryFacadeEjb.java index fb0ee21a219..3975d12d455 100644 --- a/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/country/CountryFacadeEjb.java +++ b/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/country/CountryFacadeEjb.java @@ -56,9 +56,9 @@ import de.symeda.sormas.api.utils.SortProperty; import de.symeda.sormas.backend.common.AbstractDomainObject; import de.symeda.sormas.backend.common.ConfigFacadeEjb; -import de.symeda.sormas.backend.common.InfrastructureAdo; import de.symeda.sormas.backend.feature.FeatureConfigurationFacadeEjb.FeatureConfigurationFacadeEjbLocal; import de.symeda.sormas.backend.infrastructure.AbstractInfrastructureFacadeEjb; +import de.symeda.sormas.backend.infrastructure.InfrastructureAdo; import de.symeda.sormas.backend.infrastructure.continent.Continent; import de.symeda.sormas.backend.infrastructure.continent.ContinentService; import de.symeda.sormas.backend.infrastructure.subcontinent.Subcontinent; diff --git a/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/country/CountryService.java b/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/country/CountryService.java index 92bf95cc7ca..59a055d6ea9 100644 --- a/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/country/CountryService.java +++ b/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/country/CountryService.java @@ -16,8 +16,8 @@ import de.symeda.sormas.api.EntityRelevanceStatus; import de.symeda.sormas.api.infrastructure.country.CountryCriteria; import de.symeda.sormas.api.utils.DataHelper; -import de.symeda.sormas.backend.common.AbstractInfrastructureAdoService; import de.symeda.sormas.backend.common.CriteriaBuilderHelper; +import de.symeda.sormas.backend.infrastructure.AbstractInfrastructureAdoService; import de.symeda.sormas.backend.infrastructure.subcontinent.Subcontinent; @Stateless diff --git a/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/district/District.java b/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/district/District.java index 094a19092c3..e193a21873b 100644 --- a/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/district/District.java +++ b/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/district/District.java @@ -34,15 +34,15 @@ import org.hibernate.annotations.Cache; import org.hibernate.annotations.CacheConcurrencyStrategy; -import de.symeda.sormas.backend.common.InfrastructureAdo; import de.symeda.sormas.backend.feature.FeatureConfiguration; +import de.symeda.sormas.backend.infrastructure.InfrastructureAdoWithDefault; import de.symeda.sormas.backend.infrastructure.community.Community; import de.symeda.sormas.backend.infrastructure.region.Region; @Entity @Cacheable @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) -public class District extends InfrastructureAdo { +public class District extends InfrastructureAdoWithDefault { private static final long serialVersionUID = -6057113756091470463L; diff --git a/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/district/DistrictFacadeEjb.java b/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/district/DistrictFacadeEjb.java index 515b12630de..90f164986fe 100644 --- a/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/district/DistrictFacadeEjb.java +++ b/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/district/DistrictFacadeEjb.java @@ -51,9 +51,9 @@ import de.symeda.sormas.api.user.UserRight; import de.symeda.sormas.api.utils.SortProperty; import de.symeda.sormas.backend.common.AbstractDomainObject; -import de.symeda.sormas.backend.common.InfrastructureAdo; import de.symeda.sormas.backend.feature.FeatureConfigurationFacadeEjb.FeatureConfigurationFacadeEjbLocal; import de.symeda.sormas.backend.infrastructure.AbstractInfrastructureFacadeEjb; +import de.symeda.sormas.backend.infrastructure.InfrastructureAdo; import de.symeda.sormas.backend.infrastructure.PopulationDataFacadeEjb.PopulationDataFacadeEjbLocal; import de.symeda.sormas.backend.infrastructure.area.Area; import de.symeda.sormas.backend.infrastructure.area.AreaService; @@ -62,6 +62,7 @@ import de.symeda.sormas.backend.infrastructure.pointofentry.PointOfEntry; import de.symeda.sormas.backend.infrastructure.region.Region; import de.symeda.sormas.backend.infrastructure.region.RegionFacadeEjb; +import de.symeda.sormas.backend.infrastructure.region.RegionFacadeEjb.RegionFacadeEjbLocal; import de.symeda.sormas.backend.infrastructure.region.RegionService; import de.symeda.sormas.backend.util.DtoHelper; import de.symeda.sormas.backend.util.QueryHelper; @@ -76,6 +77,8 @@ public class DistrictFacadeEjb @EJB private AreaService areaService; @EJB + private RegionFacadeEjbLocal regionFacade; + @EJB private RegionService regionService; @EJB private PopulationDataFacadeEjbLocal populationDataFacade; @@ -309,6 +312,7 @@ public DistrictIndexDto toIndexDto(District entity) { dto.setPopulation(populationDataFacade.getDistrictPopulation(dto.getUuid())); dto.setRegion(RegionFacadeEjb.toReferenceDto(entity.getRegion())); dto.setExternalID(entity.getExternalID()); + dto.setDefaultInfrastructure(entity.isDefaultInfrastructure()); return dto; } @@ -336,7 +340,11 @@ public String getFullEpidCodeForDistrict(String districtUuid) { return (district.getRegion().getEpidCode() != null ? district.getRegion().getEpidCode() : "") + "-" + (district.getEpidCode() != null ? district.getEpidCode() : ""); + } + @Override + protected boolean checkDefaultEligible(DistrictDto dto) { + return dto.getRegion().equals(regionFacade.getDefaultInfrastructureReference()); } @LocalBean diff --git a/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/district/DistrictService.java b/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/district/DistrictService.java index 66ebfe473f0..d6a150cc1ad 100644 --- a/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/district/DistrictService.java +++ b/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/district/DistrictService.java @@ -34,8 +34,8 @@ import de.symeda.sormas.api.infrastructure.country.CountryReferenceDto; import de.symeda.sormas.api.infrastructure.district.DistrictCriteria; import de.symeda.sormas.api.utils.DataHelper; -import de.symeda.sormas.backend.common.AbstractInfrastructureAdoService; import de.symeda.sormas.backend.common.CriteriaBuilderHelper; +import de.symeda.sormas.backend.infrastructure.AbstractInfrastructureAdoService; import de.symeda.sormas.backend.infrastructure.area.Area; import de.symeda.sormas.backend.infrastructure.country.Country; import de.symeda.sormas.backend.infrastructure.country.CountryFacadeEjb.CountryFacadeEjbLocal; diff --git a/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/facility/Facility.java b/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/facility/Facility.java index f3b80a8cce2..b7ef0f1af4a 100644 --- a/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/facility/Facility.java +++ b/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/facility/Facility.java @@ -33,7 +33,7 @@ import de.symeda.sormas.api.infrastructure.area.AreaType; import de.symeda.sormas.api.infrastructure.facility.FacilityType; -import de.symeda.sormas.backend.common.InfrastructureAdo; +import de.symeda.sormas.backend.infrastructure.InfrastructureAdo; import de.symeda.sormas.backend.infrastructure.community.Community; import de.symeda.sormas.backend.infrastructure.district.District; import de.symeda.sormas.backend.infrastructure.region.Region; diff --git a/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/facility/FacilityService.java b/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/facility/FacilityService.java index 648655f878f..84d73896177 100644 --- a/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/facility/FacilityService.java +++ b/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/facility/FacilityService.java @@ -40,8 +40,8 @@ import de.symeda.sormas.api.infrastructure.facility.FacilityDto; import de.symeda.sormas.api.infrastructure.facility.FacilityType; import de.symeda.sormas.api.utils.DataHelper; -import de.symeda.sormas.backend.common.AbstractInfrastructureAdoService; import de.symeda.sormas.backend.common.CriteriaBuilderHelper; +import de.symeda.sormas.backend.infrastructure.AbstractInfrastructureAdoService; import de.symeda.sormas.backend.infrastructure.community.Community; import de.symeda.sormas.backend.infrastructure.country.Country; import de.symeda.sormas.backend.infrastructure.country.CountryFacadeEjb.CountryFacadeEjbLocal; diff --git a/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/pointofentry/PointOfEntry.java b/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/pointofentry/PointOfEntry.java index d624e6e7423..28c0da432eb 100644 --- a/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/pointofentry/PointOfEntry.java +++ b/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/pointofentry/PointOfEntry.java @@ -14,7 +14,7 @@ import org.hibernate.annotations.CacheConcurrencyStrategy; import de.symeda.sormas.api.infrastructure.pointofentry.PointOfEntryType; -import de.symeda.sormas.backend.common.InfrastructureAdo; +import de.symeda.sormas.backend.infrastructure.InfrastructureAdo; import de.symeda.sormas.backend.infrastructure.district.District; import de.symeda.sormas.backend.infrastructure.region.Region; diff --git a/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/pointofentry/PointOfEntryService.java b/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/pointofentry/PointOfEntryService.java index 7f15c5c5e09..09e3fbc93b2 100644 --- a/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/pointofentry/PointOfEntryService.java +++ b/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/pointofentry/PointOfEntryService.java @@ -22,8 +22,8 @@ import de.symeda.sormas.api.utils.DataHelper; import de.symeda.sormas.backend.caze.Case; import de.symeda.sormas.backend.caze.CaseJoins; -import de.symeda.sormas.backend.common.AbstractInfrastructureAdoService; import de.symeda.sormas.backend.common.CriteriaBuilderHelper; +import de.symeda.sormas.backend.infrastructure.AbstractInfrastructureAdoService; import de.symeda.sormas.backend.infrastructure.country.Country; import de.symeda.sormas.backend.infrastructure.country.CountryFacadeEjb.CountryFacadeEjbLocal; import de.symeda.sormas.backend.infrastructure.district.District; diff --git a/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/region/Region.java b/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/region/Region.java index 85aff7a78ad..d3fc81e755b 100644 --- a/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/region/Region.java +++ b/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/region/Region.java @@ -32,7 +32,7 @@ import org.hibernate.annotations.Cache; import org.hibernate.annotations.CacheConcurrencyStrategy; -import de.symeda.sormas.backend.common.InfrastructureAdo; +import de.symeda.sormas.backend.infrastructure.InfrastructureAdoWithDefault; import de.symeda.sormas.backend.infrastructure.area.Area; import de.symeda.sormas.backend.infrastructure.country.Country; import de.symeda.sormas.backend.infrastructure.district.District; @@ -40,7 +40,7 @@ @Entity @Cacheable @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) -public class Region extends InfrastructureAdo { +public class Region extends InfrastructureAdoWithDefault { private static final long serialVersionUID = -2958216667876104358L; diff --git a/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/region/RegionFacadeEjb.java b/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/region/RegionFacadeEjb.java index acb0329a46b..5968dca7b2e 100644 --- a/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/region/RegionFacadeEjb.java +++ b/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/region/RegionFacadeEjb.java @@ -257,6 +257,7 @@ public RegionIndexDto toIndexDto(Region entity) { dto.setExternalID(entity.getExternalID()); dto.setArea(AreaFacadeEjb.toReferenceDto(entity.getArea())); dto.setCountry(CountryFacadeEjb.toReferenceDto(entity.getCountry())); + dto.setDefaultInfrastructure(entity.isDefaultInfrastructure()); return dto; } diff --git a/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/region/RegionService.java b/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/region/RegionService.java index 4c428409f53..7505bad24fd 100644 --- a/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/region/RegionService.java +++ b/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/region/RegionService.java @@ -34,8 +34,8 @@ import de.symeda.sormas.api.infrastructure.country.CountryReferenceDto; import de.symeda.sormas.api.infrastructure.region.RegionCriteria; import de.symeda.sormas.api.utils.DataHelper; -import de.symeda.sormas.backend.common.AbstractInfrastructureAdoService; import de.symeda.sormas.backend.common.CriteriaBuilderHelper; +import de.symeda.sormas.backend.infrastructure.AbstractInfrastructureAdoService; import de.symeda.sormas.backend.infrastructure.country.Country; import de.symeda.sormas.backend.infrastructure.country.CountryFacadeEjb.CountryFacadeEjbLocal; diff --git a/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/subcontinent/Subcontinent.java b/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/subcontinent/Subcontinent.java index 71ec75b8830..61697ca87c7 100644 --- a/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/subcontinent/Subcontinent.java +++ b/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/subcontinent/Subcontinent.java @@ -14,7 +14,7 @@ import org.hibernate.annotations.Cache; import org.hibernate.annotations.CacheConcurrencyStrategy; -import de.symeda.sormas.backend.common.InfrastructureAdo; +import de.symeda.sormas.backend.infrastructure.InfrastructureAdo; import de.symeda.sormas.backend.infrastructure.continent.Continent; import de.symeda.sormas.backend.infrastructure.country.Country; diff --git a/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/subcontinent/SubcontinentFacadeEjb.java b/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/subcontinent/SubcontinentFacadeEjb.java index 3b87556df95..e128b5cd07e 100644 --- a/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/subcontinent/SubcontinentFacadeEjb.java +++ b/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/subcontinent/SubcontinentFacadeEjb.java @@ -51,9 +51,9 @@ import de.symeda.sormas.api.user.UserRight; import de.symeda.sormas.api.utils.SortProperty; import de.symeda.sormas.backend.common.AbstractDomainObject; -import de.symeda.sormas.backend.common.InfrastructureAdo; import de.symeda.sormas.backend.feature.FeatureConfigurationFacadeEjb.FeatureConfigurationFacadeEjbLocal; import de.symeda.sormas.backend.infrastructure.AbstractInfrastructureFacadeEjb; +import de.symeda.sormas.backend.infrastructure.InfrastructureAdo; import de.symeda.sormas.backend.infrastructure.continent.Continent; import de.symeda.sormas.backend.infrastructure.continent.ContinentFacadeEjb; import de.symeda.sormas.backend.infrastructure.continent.ContinentService; diff --git a/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/subcontinent/SubcontinentService.java b/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/subcontinent/SubcontinentService.java index 7761f8949ba..603d7c7b24b 100644 --- a/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/subcontinent/SubcontinentService.java +++ b/sormas-backend/src/main/java/de/symeda/sormas/backend/infrastructure/subcontinent/SubcontinentService.java @@ -13,8 +13,8 @@ import javax.persistence.criteria.Root; import de.symeda.sormas.api.infrastructure.subcontinent.SubcontinentCriteria; -import de.symeda.sormas.backend.common.AbstractInfrastructureAdoService; import de.symeda.sormas.backend.common.CriteriaBuilderHelper; +import de.symeda.sormas.backend.infrastructure.AbstractInfrastructureAdoService; import de.symeda.sormas.backend.infrastructure.continent.Continent; @Stateless diff --git a/sormas-backend/src/main/java/de/symeda/sormas/backend/user/UserService.java b/sormas-backend/src/main/java/de/symeda/sormas/backend/user/UserService.java index 2b11f36b0be..43380c13282 100644 --- a/sormas-backend/src/main/java/de/symeda/sormas/backend/user/UserService.java +++ b/sormas-backend/src/main/java/de/symeda/sormas/backend/user/UserService.java @@ -60,8 +60,8 @@ import de.symeda.sormas.backend.common.AbstractDomainObject; import de.symeda.sormas.backend.common.AdoServiceWithUserFilterAndJurisdiction; import de.symeda.sormas.backend.common.CriteriaBuilderHelper; -import de.symeda.sormas.backend.common.InfrastructureAdo; import de.symeda.sormas.backend.event.Event; +import de.symeda.sormas.backend.infrastructure.InfrastructureAdo; import de.symeda.sormas.backend.infrastructure.community.Community; import de.symeda.sormas.backend.infrastructure.community.CommunityService; import de.symeda.sormas.backend.infrastructure.district.District; diff --git a/sormas-backend/src/main/java/de/symeda/sormas/backend/util/JurisdictionHelper.java b/sormas-backend/src/main/java/de/symeda/sormas/backend/util/JurisdictionHelper.java index 5dd374de36d..1d5e2e535b6 100644 --- a/sormas-backend/src/main/java/de/symeda/sormas/backend/util/JurisdictionHelper.java +++ b/sormas-backend/src/main/java/de/symeda/sormas/backend/util/JurisdictionHelper.java @@ -23,8 +23,8 @@ import de.symeda.sormas.api.user.JurisdictionLevel; import de.symeda.sormas.backend.caze.Case; -import de.symeda.sormas.backend.common.InfrastructureAdo; import de.symeda.sormas.backend.contact.Contact; +import de.symeda.sormas.backend.infrastructure.InfrastructureAdo; import de.symeda.sormas.backend.infrastructure.community.Community; import de.symeda.sormas.backend.infrastructure.district.District; import de.symeda.sormas.backend.infrastructure.facility.Facility; diff --git a/sormas-backend/src/main/resources/sql/sormas_schema.sql b/sormas-backend/src/main/resources/sql/sormas_schema.sql index f291a6e77a7..bb251521b9f 100644 --- a/sormas-backend/src/main/resources/sql/sormas_schema.sql +++ b/sormas-backend/src/main/resources/sql/sormas_schema.sql @@ -12724,25 +12724,12 @@ ALTER TABLE pathogentest_history ALTER sample_id drop not null; INSERT INTO schema_version (version_number, comment) VALUES (527, 'Add pathogen tests to environment samples #12467'); -- 2023-10-05 Add defaultInfrastructure field to infrastructure entities #12550 -ALTER TABLE continent ADD COLUMN defaultinfrastructure boolean default false; -ALTER TABLE subcontinent ADD COLUMN defaultinfrastructure boolean default false; -ALTER TABLE country ADD COLUMN defaultinfrastructure boolean default false; -ALTER TABLE areas ADD COLUMN defaultinfrastructure boolean default false; ALTER TABLE region ADD COLUMN defaultinfrastructure boolean default false; ALTER TABLE district ADD COLUMN defaultinfrastructure boolean default false; ALTER TABLE community ADD COLUMN defaultinfrastructure boolean default false; -ALTER TABLE pointofentry ADD COLUMN defaultinfrastructure boolean default false; -ALTER TABLE facility ADD COLUMN defaultinfrastructure boolean default false; - -ALTER TABLE continent_history ADD COLUMN defaultinfrastructure boolean; -ALTER TABLE subcontinent_history ADD COLUMN defaultinfrastructure boolean; -ALTER TABLE country_history ADD COLUMN defaultinfrastructure boolean; -ALTER TABLE areas_history ADD COLUMN defaultinfrastructure boolean; ALTER TABLE region_history ADD COLUMN defaultinfrastructure boolean; ALTER TABLE district_history ADD COLUMN defaultinfrastructure boolean; ALTER TABLE community_history ADD COLUMN defaultinfrastructure boolean; -ALTER TABLE pointofentry_history ADD COLUMN defaultinfrastructure boolean; -ALTER TABLE facility_history ADD COLUMN defaultinfrastructure boolean; INSERT INTO schema_version (version_number, comment) VALUES (528, 'Add defaultInfrastructure field to infrastructure entities #12550'); diff --git a/sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/infrastructure/AreaEditForm.java b/sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/infrastructure/AreaEditForm.java index 8db36836326..b4cd60a400c 100644 --- a/sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/infrastructure/AreaEditForm.java +++ b/sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/infrastructure/AreaEditForm.java @@ -2,21 +2,15 @@ import static de.symeda.sormas.ui.utils.LayoutUtil.fluidRowLocs; -import com.vaadin.v7.ui.CheckBox; import com.vaadin.v7.ui.TextField; -import de.symeda.sormas.api.FacadeProvider; -import de.symeda.sormas.api.feature.FeatureType; -import de.symeda.sormas.api.feature.FeatureTypeProperty; -import de.symeda.sormas.api.infrastructure.InfrastructureDto; import de.symeda.sormas.api.infrastructure.area.AreaDto; import de.symeda.sormas.ui.utils.AbstractEditForm; @SuppressWarnings("serial") public class AreaEditForm extends AbstractEditForm { - private static final String HTML_LAYOUT = - fluidRowLocs(AreaDto.NAME, AreaDto.EXTERNAL_ID) + fluidRowLocs(InfrastructureDto.DEFAULT_INFRASTRUCTURE); + private static final String HTML_LAYOUT = fluidRowLocs(AreaDto.NAME, AreaDto.EXTERNAL_ID); public AreaEditForm(boolean create) { super(AreaDto.class, AreaDto.I18N_PREFIX); @@ -32,12 +26,6 @@ public AreaEditForm(boolean create) { protected void addFields() { addField(AreaDto.NAME, TextField.class); addField(AreaDto.EXTERNAL_ID, TextField.class); - - if (FacadeProvider.getFeatureConfigurationFacade() - .isPropertyValueTrue(FeatureType.CASE_SURVEILANCE, FeatureTypeProperty.HIDE_JURISDICTION_FIELDS)) { - addField(InfrastructureDto.DEFAULT_INFRASTRUCTURE, CheckBox.class); - } - setRequired(true, AreaDto.NAME); } diff --git a/sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/infrastructure/CommunitiesGrid.java b/sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/infrastructure/CommunitiesGrid.java index 9fb6c1a4e90..556473e8637 100644 --- a/sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/infrastructure/CommunitiesGrid.java +++ b/sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/infrastructure/CommunitiesGrid.java @@ -14,8 +14,13 @@ */ package de.symeda.sormas.ui.configuration.infrastructure; +import java.util.Optional; + +import org.apache.commons.lang3.ArrayUtils; + import de.symeda.sormas.api.FacadeProvider; import de.symeda.sormas.api.feature.FeatureType; +import de.symeda.sormas.api.feature.FeatureTypeProperty; import de.symeda.sormas.api.i18n.I18nProperties; import de.symeda.sormas.api.infrastructure.community.CommunityCriteria; import de.symeda.sormas.api.infrastructure.community.CommunityDto; @@ -23,6 +28,7 @@ import de.symeda.sormas.ui.ControllerProvider; import de.symeda.sormas.ui.UserProvider; import de.symeda.sormas.ui.ViewModelProviders; +import de.symeda.sormas.ui.utils.BooleanRenderer; import de.symeda.sormas.ui.utils.FilteredGrid; import de.symeda.sormas.ui.utils.ViewConfiguration; @@ -46,13 +52,25 @@ public CommunitiesGrid(CommunityCriteria criteria) { setCriteria(criteria); } - setColumns(CommunityDto.NAME, CommunityDto.REGION, CommunityDto.DISTRICT, CommunityDto.EXTERNAL_ID); + String[] columns = new String[] { + CommunityDto.NAME, + CommunityDto.REGION, + CommunityDto.DISTRICT, + CommunityDto.EXTERNAL_ID }; + if (FacadeProvider.getFeatureConfigurationFacade() + .isPropertyValueTrue(FeatureType.CASE_SURVEILANCE, FeatureTypeProperty.HIDE_JURISDICTION_FIELDS)) { + columns = ArrayUtils.add(columns, CommunityDto.DEFAULT_INFRASTRUCTURE); + } + setColumns(columns); if (FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.EDIT_INFRASTRUCTURE_DATA) && UserProvider.getCurrent().hasUserRight(UserRight.INFRASTRUCTURE_EDIT)) { addEditColumn(e -> ControllerProvider.getInfrastructureController().editCommunity(e.getUuid())); } + Optional.ofNullable(((Column) getColumn(CommunityDto.DEFAULT_INFRASTRUCTURE))) + .ifPresent(c -> c.setRenderer(new BooleanRenderer())); + for (Column column : getColumns()) { column.setCaption(I18nProperties.getPrefixCaption(CommunityDto.I18N_PREFIX, column.getId(), column.getCaption())); } diff --git a/sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/infrastructure/CommunityEditForm.java b/sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/infrastructure/CommunityEditForm.java index 3def93c63f9..3fe257eaec5 100644 --- a/sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/infrastructure/CommunityEditForm.java +++ b/sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/infrastructure/CommunityEditForm.java @@ -27,7 +27,7 @@ import de.symeda.sormas.api.FacadeProvider; import de.symeda.sormas.api.feature.FeatureType; import de.symeda.sormas.api.feature.FeatureTypeProperty; -import de.symeda.sormas.api.infrastructure.InfrastructureDto; +import de.symeda.sormas.api.infrastructure.InfrastructureDtoWithDefault; import de.symeda.sormas.api.infrastructure.community.CommunityDto; import de.symeda.sormas.api.infrastructure.district.DistrictDto; import de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto; @@ -43,7 +43,7 @@ public class CommunityEditForm extends AbstractEditForm { private static final String HTML_LAYOUT = loc(CommunityDto.NAME) + fluidRowLocs(CommunityDto.REGION, CommunityDto.DISTRICT) + fluidRowLocs(RegionDto.EXTERNAL_ID) - + fluidRowLocs(InfrastructureDto.DEFAULT_INFRASTRUCTURE); + + fluidRowLocs(InfrastructureDtoWithDefault.DEFAULT_INFRASTRUCTURE); private boolean create; @@ -70,7 +70,7 @@ protected void addFields() { if (FacadeProvider.getFeatureConfigurationFacade() .isPropertyValueTrue(FeatureType.CASE_SURVEILANCE, FeatureTypeProperty.HIDE_JURISDICTION_FIELDS)) { - addField(InfrastructureDto.DEFAULT_INFRASTRUCTURE, CheckBox.class); + addField(InfrastructureDtoWithDefault.DEFAULT_INFRASTRUCTURE, CheckBox.class); } setRequired(true, CommunityDto.NAME, CommunityDto.REGION, CommunityDto.DISTRICT); diff --git a/sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/infrastructure/ContinentEditForm.java b/sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/infrastructure/ContinentEditForm.java index 5314c30de4c..1fc673649cd 100644 --- a/sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/infrastructure/ContinentEditForm.java +++ b/sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/infrastructure/ContinentEditForm.java @@ -2,13 +2,9 @@ import static de.symeda.sormas.ui.utils.LayoutUtil.fluidRowLocs; -import com.vaadin.v7.ui.CheckBox; import com.vaadin.v7.ui.TextField; import de.symeda.sormas.api.FacadeProvider; -import de.symeda.sormas.api.feature.FeatureType; -import de.symeda.sormas.api.feature.FeatureTypeProperty; -import de.symeda.sormas.api.infrastructure.InfrastructureDto; import de.symeda.sormas.api.infrastructure.continent.ContinentDto; import de.symeda.sormas.api.utils.fieldaccess.UiFieldAccessCheckers; import de.symeda.sormas.api.utils.fieldvisibility.FieldVisibilityCheckers; @@ -18,8 +14,7 @@ public class ContinentEditForm extends AbstractEditForm { //@formatter:off private static final String HTML_LAYOUT = - fluidRowLocs(ContinentDto.EXTERNAL_ID, ContinentDto.DEFAULT_NAME) + - fluidRowLocs(InfrastructureDto.DEFAULT_INFRASTRUCTURE); + fluidRowLocs(ContinentDto.EXTERNAL_ID, ContinentDto.DEFAULT_NAME); //@formatter:on private final Boolean create; @@ -52,11 +47,6 @@ protected void addFields() { addField(ContinentDto.DEFAULT_NAME, TextField.class); addField(ContinentDto.EXTERNAL_ID, TextField.class); - if (FacadeProvider.getFeatureConfigurationFacade() - .isPropertyValueTrue(FeatureType.CASE_SURVEILANCE, FeatureTypeProperty.HIDE_JURISDICTION_FIELDS)) { - addField(InfrastructureDto.DEFAULT_INFRASTRUCTURE, CheckBox.class); - } - initializeVisibilitiesAndAllowedVisibilities(); setRequired(true, ContinentDto.DEFAULT_NAME); diff --git a/sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/infrastructure/ContinentsGrid.java b/sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/infrastructure/ContinentsGrid.java index a0e68f7c327..291d6bfcfe0 100644 --- a/sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/infrastructure/ContinentsGrid.java +++ b/sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/infrastructure/ContinentsGrid.java @@ -15,13 +15,6 @@ package de.symeda.sormas.ui.configuration.infrastructure; -import java.util.List; -import java.util.function.Predicate; -import java.util.stream.Stream; - -import org.apache.commons.lang3.StringUtils; - -import de.symeda.sormas.api.EntityRelevanceStatus; import de.symeda.sormas.api.FacadeProvider; import de.symeda.sormas.api.feature.FeatureType; import de.symeda.sormas.api.i18n.I18nProperties; @@ -36,9 +29,8 @@ public class ContinentsGrid extends FilteredGrid { - List allContinents; - public ContinentsGrid(ContinentCriteria criteria) { + super(ContinentIndexDto.class); setSizeFull(); @@ -84,34 +76,4 @@ public void setEagerDataProvider() { setEagerDataProvider(FacadeProvider.getContinentFacade()::getIndexList); } - private Stream createFilteredStream() { - - // get all filter properties - String nameLike = getCriteria().getNameLike() != null ? getCriteria().getNameLike().toLowerCase() : null; - EntityRelevanceStatus relevanceStatus = getCriteria().getRelevanceStatus(); - - Predicate filters = x -> true; // "empty" basefilter - - // name filter - if (!StringUtils.isEmpty(nameLike)) { - filters = filters.and( - continent -> (continent.getDefaultName().toLowerCase().contains(nameLike) - || continent.getDisplayName().toLowerCase().contains(nameLike))); - } - // relevancestatus filter (active/archived/all) - if (relevanceStatus != null) { - switch (relevanceStatus) { - case ACTIVE: - filters = filters.and(continent -> (!continent.isArchived())); - break; - case ARCHIVED: - filters = filters.and(continent -> (continent.isArchived())); - break; - } - } - - // apply filters - return allContinents.stream().filter(filters); - - } } diff --git a/sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/infrastructure/CountryEditForm.java b/sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/infrastructure/CountryEditForm.java index 9a0e9886acf..428ec4056bc 100644 --- a/sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/infrastructure/CountryEditForm.java +++ b/sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/infrastructure/CountryEditForm.java @@ -2,14 +2,10 @@ import static de.symeda.sormas.ui.utils.LayoutUtil.fluidRowLocs; -import com.vaadin.v7.ui.CheckBox; import com.vaadin.v7.ui.ComboBox; import com.vaadin.v7.ui.TextField; import de.symeda.sormas.api.FacadeProvider; -import de.symeda.sormas.api.feature.FeatureType; -import de.symeda.sormas.api.feature.FeatureTypeProperty; -import de.symeda.sormas.api.infrastructure.InfrastructureDto; import de.symeda.sormas.api.infrastructure.country.CountryDto; import de.symeda.sormas.api.utils.fieldaccess.UiFieldAccessCheckers; import de.symeda.sormas.api.utils.fieldvisibility.FieldVisibilityCheckers; @@ -22,8 +18,7 @@ public class CountryEditForm extends AbstractEditForm { //@formatter:off private static final String HTML_LAYOUT = fluidRowLocs(CountryDto.ISO_CODE, CountryDto.DEFAULT_NAME) + - fluidRowLocs(CountryDto.EXTERNAL_ID, CountryDto.UNO_CODE, CountryDto.SUBCONTINENT) + - fluidRowLocs(InfrastructureDto.DEFAULT_INFRASTRUCTURE); + fluidRowLocs(CountryDto.EXTERNAL_ID, CountryDto.UNO_CODE, CountryDto.SUBCONTINENT); //@formatter:on private final Boolean create; @@ -59,11 +54,6 @@ protected void addFields() { addField(CountryDto.UNO_CODE, TextField.class).setMaxLength(3); ComboBox subcontinent = addInfrastructureField(CountryDto.SUBCONTINENT); - if (FacadeProvider.getFeatureConfigurationFacade() - .isPropertyValueTrue(FeatureType.CASE_SURVEILANCE, FeatureTypeProperty.HIDE_JURISDICTION_FIELDS)) { - addField(InfrastructureDto.DEFAULT_INFRASTRUCTURE, CheckBox.class); - } - subcontinent.addItems(FacadeProvider.getSubcontinentFacade().getAllActiveAsReference()); initializeVisibilitiesAndAllowedVisibilities(); diff --git a/sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/infrastructure/DistrictEditForm.java b/sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/infrastructure/DistrictEditForm.java index a6251114d73..c08f03bef7d 100644 --- a/sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/infrastructure/DistrictEditForm.java +++ b/sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/infrastructure/DistrictEditForm.java @@ -26,7 +26,7 @@ import de.symeda.sormas.api.FacadeProvider; import de.symeda.sormas.api.feature.FeatureType; import de.symeda.sormas.api.feature.FeatureTypeProperty; -import de.symeda.sormas.api.infrastructure.InfrastructureDto; +import de.symeda.sormas.api.infrastructure.InfrastructureDtoWithDefault; import de.symeda.sormas.api.infrastructure.district.DistrictDto; import de.symeda.sormas.api.infrastructure.region.RegionDto; import de.symeda.sormas.ui.utils.AbstractEditForm; @@ -38,7 +38,7 @@ public class DistrictEditForm extends AbstractEditForm { private static final String HTML_LAYOUT = fluidRowLocs(DistrictDto.NAME, DistrictDto.EPID_CODE) + fluidRowLocs(DistrictDto.REGION) + fluidRowLocs(RegionDto.EXTERNAL_ID) - + fluidRowLocs(InfrastructureDto.DEFAULT_INFRASTRUCTURE); // ,DistrictDto.GROWTH_RATE); + + fluidRowLocs(InfrastructureDtoWithDefault.DEFAULT_INFRASTRUCTURE); // ,DistrictDto.GROWTH_RATE); private final boolean create; @@ -65,7 +65,7 @@ protected void addFields() { if (FacadeProvider.getFeatureConfigurationFacade() .isPropertyValueTrue(FeatureType.CASE_SURVEILANCE, FeatureTypeProperty.HIDE_JURISDICTION_FIELDS)) { - addField(InfrastructureDto.DEFAULT_INFRASTRUCTURE, CheckBox.class); + addField(InfrastructureDtoWithDefault.DEFAULT_INFRASTRUCTURE, CheckBox.class); } // TextField growthRate = addField(DistrictDto.GROWTH_RATE, TextField.class); diff --git a/sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/infrastructure/DistrictsGrid.java b/sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/infrastructure/DistrictsGrid.java index 8cba5a703fe..2e76f694170 100644 --- a/sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/infrastructure/DistrictsGrid.java +++ b/sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/infrastructure/DistrictsGrid.java @@ -14,8 +14,13 @@ */ package de.symeda.sormas.ui.configuration.infrastructure; +import java.util.Optional; + +import org.apache.commons.lang3.ArrayUtils; + import de.symeda.sormas.api.FacadeProvider; import de.symeda.sormas.api.feature.FeatureType; +import de.symeda.sormas.api.feature.FeatureTypeProperty; import de.symeda.sormas.api.i18n.I18nProperties; import de.symeda.sormas.api.infrastructure.district.DistrictCriteria; import de.symeda.sormas.api.infrastructure.district.DistrictIndexDto; @@ -23,6 +28,7 @@ import de.symeda.sormas.ui.ControllerProvider; import de.symeda.sormas.ui.UserProvider; import de.symeda.sormas.ui.ViewModelProviders; +import de.symeda.sormas.ui.utils.BooleanRenderer; import de.symeda.sormas.ui.utils.FilteredGrid; import de.symeda.sormas.ui.utils.ViewConfiguration; @@ -46,13 +52,18 @@ public DistrictsGrid(DistrictCriteria criteria) { setCriteria(criteria); } - setColumns( + String[] columns = new String[] { DistrictIndexDto.NAME, DistrictIndexDto.REGION, DistrictIndexDto.EPID_CODE, DistrictIndexDto.EXTERNAL_ID, DistrictIndexDto.POPULATION, - DistrictIndexDto.GROWTH_RATE); + DistrictIndexDto.GROWTH_RATE }; + if (FacadeProvider.getFeatureConfigurationFacade() + .isPropertyValueTrue(FeatureType.CASE_SURVEILANCE, FeatureTypeProperty.HIDE_JURISDICTION_FIELDS)) { + columns = ArrayUtils.add(columns, DistrictIndexDto.DEFAULT_INFRASTRUCTURE); + } + setColumns(columns); getColumn(DistrictIndexDto.POPULATION).setSortable(false); @@ -61,6 +72,9 @@ public DistrictsGrid(DistrictCriteria criteria) { addEditColumn(e -> ControllerProvider.getInfrastructureController().editDistrict(e.getUuid())); } + Optional.ofNullable(((Column) getColumn(DistrictIndexDto.DEFAULT_INFRASTRUCTURE))) + .ifPresent(c -> c.setRenderer(new BooleanRenderer())); + for (Column column : getColumns()) { column.setCaption(I18nProperties.getPrefixCaption(DistrictIndexDto.I18N_PREFIX, column.getId(), column.getCaption())); } diff --git a/sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/infrastructure/FacilityEditForm.java b/sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/infrastructure/FacilityEditForm.java index a7577956d2b..e711d5e6bdf 100644 --- a/sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/infrastructure/FacilityEditForm.java +++ b/sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/infrastructure/FacilityEditForm.java @@ -21,17 +21,13 @@ import com.vaadin.v7.data.util.converter.Converter; import com.vaadin.v7.data.validator.EmailValidator; -import com.vaadin.v7.ui.CheckBox; import com.vaadin.v7.ui.ComboBox; import com.vaadin.v7.ui.TextField; import de.symeda.sormas.api.FacadeProvider; -import de.symeda.sormas.api.feature.FeatureType; -import de.symeda.sormas.api.feature.FeatureTypeProperty; import de.symeda.sormas.api.i18n.Captions; 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.community.CommunityReferenceDto; import de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto; import de.symeda.sormas.api.infrastructure.facility.FacilityDto; @@ -62,8 +58,7 @@ public class FacilityEditForm extends AbstractEditForm { + fluidRowLocs(FacilityDto.CONTACT_PERSON_FIRST_NAME, FacilityDto.CONTACT_PERSON_LAST_NAME) + fluidRowLocs(FacilityDto.CONTACT_PERSON_PHONE, FacilityDto.CONTACT_PERSON_EMAIL) + fluidRowLocs(FacilityDto.LATITUDE, FacilityDto.LONGITUDE) - + fluidRowLocs(RegionDto.EXTERNAL_ID) - + fluidRowLocs(InfrastructureDto.DEFAULT_INFRASTRUCTURE); + + fluidRowLocs(RegionDto.EXTERNAL_ID); private boolean create; private ComboBox typeGroup; @@ -118,11 +113,6 @@ protected void addFields() { longitude.setConversionError(I18nProperties.getValidationError(Validations.onlyGeoCoordinatesAllowed, longitude.getCaption())); addField(RegionDto.EXTERNAL_ID, TextField.class); - if (FacadeProvider.getFeatureConfigurationFacade() - .isPropertyValueTrue(FeatureType.CASE_SURVEILANCE, FeatureTypeProperty.HIDE_JURISDICTION_FIELDS)) { - addField(InfrastructureDto.DEFAULT_INFRASTRUCTURE, CheckBox.class); - } - setRequired(true, FacilityDto.NAME, TYPE_GROUP_LOC, FacilityDto.TYPE, FacilityDto.REGION, FacilityDto.DISTRICT); typeGroup.addValueChangeListener(e -> FieldHelper.updateEnumData(type, FacilityType.getTypes((FacilityTypeGroup) typeGroup.getValue()))); diff --git a/sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/infrastructure/PointOfEntryForm.java b/sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/infrastructure/PointOfEntryForm.java index 79386ffd5c5..7149c8b7567 100644 --- a/sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/infrastructure/PointOfEntryForm.java +++ b/sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/infrastructure/PointOfEntryForm.java @@ -7,11 +7,8 @@ import com.vaadin.v7.ui.TextField; import de.symeda.sormas.api.FacadeProvider; -import de.symeda.sormas.api.feature.FeatureType; -import de.symeda.sormas.api.feature.FeatureTypeProperty; 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.pointofentry.PointOfEntryDto; import de.symeda.sormas.api.infrastructure.region.RegionDto; import de.symeda.sormas.api.infrastructure.region.RegionReferenceDto; @@ -28,8 +25,7 @@ public class PointOfEntryForm extends AbstractEditForm { + fluidRowLocs(PointOfEntryDto.REGION, PointOfEntryDto.DISTRICT) + fluidRowLocs(PointOfEntryDto.LATITUDE, PointOfEntryDto.LONGITUDE) + fluidRowLocs(RegionDto.EXTERNAL_ID) - + fluidRowLocs(PointOfEntryDto.ACTIVE) - + fluidRowLocs(InfrastructureDto.DEFAULT_INFRASTRUCTURE); + + fluidRowLocs(PointOfEntryDto.ACTIVE); private boolean create; @@ -58,11 +54,6 @@ protected void addFields() { ComboBox cbDistrict = addInfrastructureField(PointOfEntryDto.DISTRICT); addField(RegionDto.EXTERNAL_ID, TextField.class); - if (FacadeProvider.getFeatureConfigurationFacade() - .isPropertyValueTrue(FeatureType.CASE_SURVEILANCE, FeatureTypeProperty.HIDE_JURISDICTION_FIELDS)) { - addField(InfrastructureDto.DEFAULT_INFRASTRUCTURE, CheckBox.class); - } - tfLatitude.setConverter(new StringToAngularLocationConverter()); tfLatitude.setConversionError(I18nProperties.getValidationError(Validations.onlyGeoCoordinatesAllowed, tfLatitude.getCaption())); tfLongitude.setConverter(new StringToAngularLocationConverter()); diff --git a/sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/infrastructure/RegionEditForm.java b/sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/infrastructure/RegionEditForm.java index 25f6f650326..ab78ec0248f 100644 --- a/sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/infrastructure/RegionEditForm.java +++ b/sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/infrastructure/RegionEditForm.java @@ -30,7 +30,7 @@ import de.symeda.sormas.api.FacadeProvider; import de.symeda.sormas.api.feature.FeatureType; import de.symeda.sormas.api.feature.FeatureTypeProperty; -import de.symeda.sormas.api.infrastructure.InfrastructureDto; +import de.symeda.sormas.api.infrastructure.InfrastructureDtoWithDefault; import de.symeda.sormas.api.infrastructure.region.RegionDto; import de.symeda.sormas.api.utils.fieldaccess.UiFieldAccessCheckers; import de.symeda.sormas.api.utils.fieldvisibility.FieldVisibilityCheckers; @@ -47,7 +47,7 @@ public class RegionEditForm extends AbstractEditForm { fluidRowLocs(RegionDto.COUNTRY) + fluidRowLocs(RegionDto.AREA) + fluidRowLocs(RegionDto.EXTERNAL_ID) + - fluidRowLocs(InfrastructureDto.DEFAULT_INFRASTRUCTURE); + fluidRowLocs(InfrastructureDtoWithDefault.DEFAULT_INFRASTRUCTURE); //+ fluidRowLocs(RegionDto.GROWTH_RATE); //@formatter:on @@ -86,7 +86,7 @@ protected void addFields() { if (FacadeProvider.getFeatureConfigurationFacade() .isPropertyValueTrue(FeatureType.CASE_SURVEILANCE, FeatureTypeProperty.HIDE_JURISDICTION_FIELDS)) { - addField(InfrastructureDto.DEFAULT_INFRASTRUCTURE, CheckBox.class); + addField(InfrastructureDtoWithDefault.DEFAULT_INFRASTRUCTURE, CheckBox.class); } // TextField growthRate = addField(RegionDto.GROWTH_RATE, TextField.class); diff --git a/sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/infrastructure/RegionsGrid.java b/sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/infrastructure/RegionsGrid.java index 98ff84e3112..a2149b0d02e 100644 --- a/sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/infrastructure/RegionsGrid.java +++ b/sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/infrastructure/RegionsGrid.java @@ -14,10 +14,13 @@ */ package de.symeda.sormas.ui.configuration.infrastructure; +import java.util.Optional; + import org.apache.commons.lang3.ArrayUtils; import de.symeda.sormas.api.FacadeProvider; import de.symeda.sormas.api.feature.FeatureType; +import de.symeda.sormas.api.feature.FeatureTypeProperty; import de.symeda.sormas.api.i18n.I18nProperties; import de.symeda.sormas.api.infrastructure.region.RegionCriteria; import de.symeda.sormas.api.infrastructure.region.RegionIndexDto; @@ -25,6 +28,7 @@ import de.symeda.sormas.ui.ControllerProvider; import de.symeda.sormas.ui.UserProvider; import de.symeda.sormas.ui.ViewModelProviders; +import de.symeda.sormas.ui.utils.BooleanRenderer; import de.symeda.sormas.ui.utils.FilteredGrid; import de.symeda.sormas.ui.utils.ViewConfiguration; @@ -60,6 +64,10 @@ public RegionsGrid(RegionCriteria criteria) { RegionIndexDto.EXTERNAL_ID, RegionIndexDto.POPULATION, RegionIndexDto.GROWTH_RATE); + if (FacadeProvider.getFeatureConfigurationFacade() + .isPropertyValueTrue(FeatureType.CASE_SURVEILANCE, FeatureTypeProperty.HIDE_JURISDICTION_FIELDS)) { + columns = ArrayUtils.add(columns, RegionIndexDto.DEFAULT_INFRASTRUCTURE); + } setColumns(columns); getColumn(RegionIndexDto.POPULATION).setSortable(false); @@ -73,6 +81,9 @@ public RegionsGrid(RegionCriteria criteria) { addEditColumn(e -> ControllerProvider.getInfrastructureController().editRegion(e.getUuid())); } + Optional.ofNullable(((Column) getColumn(RegionIndexDto.DEFAULT_INFRASTRUCTURE))) + .ifPresent(c -> c.setRenderer(new BooleanRenderer())); + for (Column column : getColumns()) { column.setCaption(I18nProperties.getPrefixCaption(RegionIndexDto.I18N_PREFIX, column.getId(), column.getCaption())); } diff --git a/sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/infrastructure/SubcontinentEditForm.java b/sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/infrastructure/SubcontinentEditForm.java index f74f3908982..7a8a262d0ad 100644 --- a/sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/infrastructure/SubcontinentEditForm.java +++ b/sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/infrastructure/SubcontinentEditForm.java @@ -2,14 +2,10 @@ import static de.symeda.sormas.ui.utils.LayoutUtil.fluidRowLocs; -import com.vaadin.v7.ui.CheckBox; import com.vaadin.v7.ui.ComboBox; import com.vaadin.v7.ui.TextField; import de.symeda.sormas.api.FacadeProvider; -import de.symeda.sormas.api.feature.FeatureType; -import de.symeda.sormas.api.feature.FeatureTypeProperty; -import de.symeda.sormas.api.infrastructure.InfrastructureDto; import de.symeda.sormas.api.infrastructure.subcontinent.SubcontinentDto; import de.symeda.sormas.api.utils.fieldaccess.UiFieldAccessCheckers; import de.symeda.sormas.api.utils.fieldvisibility.FieldVisibilityCheckers; @@ -20,8 +16,7 @@ public class SubcontinentEditForm extends AbstractEditForm { //@formatter:off private static final String HTML_LAYOUT = fluidRowLocs(SubcontinentDto.EXTERNAL_ID, SubcontinentDto.DEFAULT_NAME) + - fluidRowLocs(SubcontinentDto.CONTINENT) + - fluidRowLocs(InfrastructureDto.DEFAULT_INFRASTRUCTURE); + fluidRowLocs(SubcontinentDto.CONTINENT); //@formatter:on private final Boolean create; @@ -55,11 +50,6 @@ protected void addFields() { addField(SubcontinentDto.EXTERNAL_ID, TextField.class); ComboBox continent = addInfrastructureField(SubcontinentDto.CONTINENT); - if (FacadeProvider.getFeatureConfigurationFacade() - .isPropertyValueTrue(FeatureType.CASE_SURVEILANCE, FeatureTypeProperty.HIDE_JURISDICTION_FIELDS)) { - addField(InfrastructureDto.DEFAULT_INFRASTRUCTURE, CheckBox.class); - } - continent.addItems(FacadeProvider.getContinentFacade().getAllActiveAsReference()); initializeVisibilitiesAndAllowedVisibilities(); diff --git a/sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/infrastructure/SubcontinentsGrid.java b/sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/infrastructure/SubcontinentsGrid.java index 3334bad4c61..3b346fead42 100644 --- a/sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/infrastructure/SubcontinentsGrid.java +++ b/sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/infrastructure/SubcontinentsGrid.java @@ -15,13 +15,6 @@ package de.symeda.sormas.ui.configuration.infrastructure; -import java.util.List; -import java.util.function.Predicate; -import java.util.stream.Stream; - -import org.apache.commons.lang3.StringUtils; - -import de.symeda.sormas.api.EntityRelevanceStatus; import de.symeda.sormas.api.FacadeProvider; import de.symeda.sormas.api.feature.FeatureType; import de.symeda.sormas.api.i18n.I18nProperties; @@ -36,9 +29,8 @@ public class SubcontinentsGrid extends FilteredGrid { - private List allSubcontinents; - public SubcontinentsGrid(SubcontinentCriteria criteria) { + super(SubcontinentIndexDto.class); setSizeFull(); @@ -88,40 +80,4 @@ public void setEagerDataProvider() { setEagerDataProvider(FacadeProvider.getSubcontinentFacade()::getIndexList); } - private Stream createFilteredStream() { - - // get all filter properties - String nameLike = getCriteria().getNameLike() != null ? getCriteria().getNameLike().toLowerCase() : null; - String continentUuid = getCriteria().getContinent() != null ? getCriteria().getContinent().getUuid() : null; - EntityRelevanceStatus relevanceStatus = getCriteria().getRelevanceStatus(); - - Predicate filters = x -> true; // "empty" basefilter - - // name filter - if (!StringUtils.isEmpty(nameLike)) { - filters = filters.and( - subcontinent -> (subcontinent.getDefaultName().toLowerCase().contains(nameLike) - || subcontinent.getDisplayName().toLowerCase().contains(nameLike))); - } - // continent filter - if (continentUuid != null) { - filters = - filters.and(subcontinent -> (subcontinent.getContinent() != null && subcontinent.getContinent().getUuid().equals(continentUuid))); - } - // relevancestatus filter (active/archived/all) - if (relevanceStatus != null) { - switch (relevanceStatus) { - case ACTIVE: - filters = filters.and(subcontinent -> (!subcontinent.isArchived())); - break; - case ARCHIVED: - filters = filters.and(subcontinent -> (subcontinent.isArchived())); - break; - } - } - - // apply filters - return allSubcontinents.stream().filter(filters); - - } }