diff --git a/sormas-api/pom.xml b/sormas-api/pom.xml index 56a9fb17b0d..77026267f1c 100644 --- a/sormas-api/pom.xml +++ b/sormas-api/pom.xml @@ -2,7 +2,7 @@ de.symeda.sormas sormas-base - 1.72.0 + 1.72.1 ../sormas-base 4.0.0 diff --git a/sormas-api/src/main/java/de/symeda/sormas/api/utils/InfoProvider.java b/sormas-api/src/main/java/de/symeda/sormas/api/utils/InfoProvider.java index 8d637fba57f..174b0eee7f6 100644 --- a/sormas-api/src/main/java/de/symeda/sormas/api/utils/InfoProvider.java +++ b/sormas-api/src/main/java/de/symeda/sormas/api/utils/InfoProvider.java @@ -34,7 +34,7 @@ public class InfoProvider { InfoProvider() { try (InputStream fis = InfoProvider.class.getResourceAsStream("/git.properties")) { - // in case you run test from the IDE and this errors, please run `mvn verify -DskipTests` from sormas-base first + // in case you run test from the IDE and encounter errors, please run `mvn verify -DskipTests` from sormas-base first Properties prop = new Properties(); prop.load(fis); this.version = prop.getProperty("git.build.version"); diff --git a/sormas-app/pom.xml b/sormas-app/pom.xml index 30434fd3402..40486815eee 100644 --- a/sormas-app/pom.xml +++ b/sormas-app/pom.xml @@ -3,7 +3,7 @@ sormas-base de.symeda.sormas - 1.72.0 + 1.72.1 ../sormas-base 4.0.0 diff --git a/sormas-backend/pom.xml b/sormas-backend/pom.xml index a6907a200cd..f829301e5c9 100644 --- a/sormas-backend/pom.xml +++ b/sormas-backend/pom.xml @@ -3,7 +3,7 @@ sormas-base de.symeda.sormas - 1.72.0 + 1.72.1 ../sormas-base 4.0.0 diff --git a/sormas-backend/src/main/java/de/symeda/sormas/backend/event/EventService.java b/sormas-backend/src/main/java/de/symeda/sormas/backend/event/EventService.java index 1db3176e7df..035b56d22ae 100644 --- a/sormas-backend/src/main/java/de/symeda/sormas/backend/event/EventService.java +++ b/sormas-backend/src/main/java/de/symeda/sormas/backend/event/EventService.java @@ -800,7 +800,7 @@ public Predicate createActiveEventsFilter(CriteriaBuilder cb, Path root) * Creates a default filter that should be used as the basis of queries that do not use {@link EventCriteria}. * This essentially removes {@link DeletableAdo#isDeleted()} events from the queries. */ - public Predicate createDefaultFilter(CriteriaBuilder cb, Root root) { + public Predicate createDefaultFilter(CriteriaBuilder cb, From root) { return cb.isFalse(root.get(Event.DELETED)); } diff --git a/sormas-backend/src/main/java/de/symeda/sormas/backend/immunization/ImmunizationService.java b/sormas-backend/src/main/java/de/symeda/sormas/backend/immunization/ImmunizationService.java index 980bf9117e9..c58d1f8a17e 100644 --- a/sormas-backend/src/main/java/de/symeda/sormas/backend/immunization/ImmunizationService.java +++ b/sormas-backend/src/main/java/de/symeda/sormas/backend/immunization/ImmunizationService.java @@ -100,6 +100,15 @@ public void deletePermanent(Immunization immunization) { } }); + /* + immunization will try to delete in cascade also the linked case . This will throw an error because the case is + related to a task. In order to delete the immunization and not the case we have to unlink the case from immunization + */ + if(immunization.getRelatedCase() != null) { + immunization.setRelatedCase(null); + ensurePersisted(immunization); + } + super.deletePermanent(immunization); } diff --git a/sormas-backend/src/main/java/de/symeda/sormas/backend/systemevent/SystemEventFacadeEjb.java b/sormas-backend/src/main/java/de/symeda/sormas/backend/systemevent/SystemEventFacadeEjb.java index ba039346970..a45297a6d95 100644 --- a/sormas-backend/src/main/java/de/symeda/sormas/backend/systemevent/SystemEventFacadeEjb.java +++ b/sormas-backend/src/main/java/de/symeda/sormas/backend/systemevent/SystemEventFacadeEjb.java @@ -1,3 +1,18 @@ +/* + * SORMAS® - Surveillance Outbreak Response Management & Analysis System + * Copyright © 2016-2022 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.systemevent; import java.sql.Timestamp; @@ -48,39 +63,41 @@ public boolean existsStartedEvent(SystemEventType type) { /** * * @param type + * the type of the SystemEvent to be fetched * @return the latest SystemEvent of the specified type with SystemEventStatus == SUCCESS. */ @Override public SystemEventDto getLatestSuccessByType(SystemEventType type) { + CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery cq = cb.createQuery(SystemEvent.class); Root systemEventRoot = cq.from(SystemEvent.class); - cq.where(cb.equal(systemEventRoot.get(SystemEvent.STATUS), SystemEventStatus.SUCCESS)); + cq.where(cb.equal(systemEventRoot.get(SystemEvent.STATUS), SystemEventStatus.SUCCESS), cb.equal(systemEventRoot.get(SystemEvent.TYPE), type)); cq.orderBy(cb.desc(systemEventRoot.get(SystemEvent.START_DATE))); return QueryHelper.getFirstResult(em, cq, this::toDto); } - @Override @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) public void saveSystemEvent(@Valid SystemEventDto dto) { - SystemEvent systemEvent = systemEventService.getByUuid(dto.getUuid()); + SystemEvent systemEvent = systemEventService.getByUuid(dto.getUuid()); systemEvent = fromDto(dto, systemEvent, true); systemEventService.ensurePersisted(systemEvent); - } @Override public void reportSuccess(SystemEventDto systemEvent, String message, Date end) { + systemEvent.setAdditionalInfo(message); reportSuccess(systemEvent, end); } @Override public void reportSuccess(SystemEventDto systemEvent, Date end) { + systemEvent.setStatus(SystemEventStatus.SUCCESS); systemEvent.setEndDate(end); systemEvent.setChangeDate(new Date()); @@ -89,6 +106,7 @@ public void reportSuccess(SystemEventDto systemEvent, Date end) { @Override public void reportError(SystemEventDto systemEvent, String errorMessage, Date end) { + systemEvent.setStatus(SystemEventStatus.ERROR); systemEvent.setAdditionalInfo(errorMessage); systemEvent.setEndDate(end); @@ -98,6 +116,7 @@ public void reportError(SystemEventDto systemEvent, String errorMessage, Date en @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) public void markPreviouslyStartedAsUnclear(SystemEventType type) { + CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaUpdate cu = cb.createCriteriaUpdate(SystemEvent.class); Root root = cu.from(SystemEvent.class); @@ -117,7 +136,6 @@ public SystemEvent fromDto(@NotNull SystemEventDto source, SystemEvent target, b target.setAdditionalInfo(source.getAdditionalInfo()); return target; - } public SystemEventDto toDto(SystemEvent source) { diff --git a/sormas-backend/src/main/java/de/symeda/sormas/backend/task/TaskService.java b/sormas-backend/src/main/java/de/symeda/sormas/backend/task/TaskService.java index 8eea506e927..cf980dc414e 100644 --- a/sormas-backend/src/main/java/de/symeda/sormas/backend/task/TaskService.java +++ b/sormas-backend/src/main/java/de/symeda/sormas/backend/task/TaskService.java @@ -52,7 +52,6 @@ import de.symeda.sormas.backend.caze.Case; import de.symeda.sormas.backend.caze.CaseQueryContext; import de.symeda.sormas.backend.caze.CaseService; -import de.symeda.sormas.backend.common.AbstractDomainObject; import de.symeda.sormas.backend.common.AdoServiceWithUserFilter; import de.symeda.sormas.backend.common.CriteriaBuilderHelper; import de.symeda.sormas.backend.common.TaskCreationException; @@ -156,46 +155,54 @@ public Predicate createUserFilter(TaskQueryContext taskQueryContext) { CriteriaBuilder cb = taskQueryContext.getCriteriaBuilder(); From taskPath = taskQueryContext.getRoot(); - Predicate assigneeFilter = createAssigneeFilter(cb, taskQueryContext.getJoins().getAssignee()); + TaskJoins joins = taskQueryContext.getJoins(); + Predicate assigneeFilter = createAssigneeFilter(cb, joins.getAssignee()); Predicate contactRightsPredicate = this.createContactFilter( cb, taskQueryContext.getRoot(), - (taskQueryContext.getJoins()).getAssignee(), - (taskQueryContext.getJoins()).getTaskObservers(), + joins.getAssignee(), + joins.getTaskObservers(), currentUser); if (contactRightsPredicate != null) { assigneeFilter = cb.and(assigneeFilter, contactRightsPredicate); } + Predicate relatedEntityNotDeletedFilter = cb.or( + cb.equal(taskPath.get(Task.TASK_CONTEXT), TaskContext.GENERAL), + caseService.createDefaultFilter(cb, joins.getCaze()), + contactService.createDefaultFilter(cb, joins.getContact()), + eventService.createDefaultFilter(cb, joins.getEvent()), + travelEntryService.createDefaultFilter(cb, joins.getTravelEntry())); + final JurisdictionLevel jurisdictionLevel = currentUser.getJurisdictionLevel(); if ((jurisdictionLevel == JurisdictionLevel.NATION && !UserRole.isPortHealthUser(currentUser.getUserRoles())) || currentUser.hasUserRole(UserRole.REST_USER)) { - return assigneeFilter; + return cb.and(assigneeFilter, relatedEntityNotDeletedFilter); } Predicate filter = cb.equal(taskPath.get(Task.CREATOR_USER), currentUser); filter = cb.or(filter, cb.equal(taskPath.get(Task.ASSIGNEE_USER), currentUser)); - Predicate caseFilter = caseService.createUserFilter(new CaseQueryContext(cb, cq, taskQueryContext.getJoins().getCaseJoins())); + Predicate caseFilter = caseService.createUserFilter(new CaseQueryContext(cb, cq, joins.getCaseJoins())); if (caseFilter != null) { filter = cb.or(filter, caseFilter); } - Predicate contactFilter = contactService.createUserFilter(new ContactQueryContext(cb, cq, taskQueryContext.getJoins().getContactJoins())); + Predicate contactFilter = contactService.createUserFilter(new ContactQueryContext(cb, cq, joins.getContactJoins())); if (contactFilter != null) { filter = cb.or(filter, contactFilter); } - Predicate eventFilter = eventService.createUserFilter(new EventQueryContext(cb, cq, taskQueryContext.getJoins().getEventJoins())); + Predicate eventFilter = eventService.createUserFilter(new EventQueryContext(cb, cq, joins.getEventJoins())); if (eventFilter != null) { filter = cb.or(filter, eventFilter); } Predicate travelEntryFilter = - travelEntryService.createUserFilter(new TravelEntryQueryContext(cb, cq, taskQueryContext.getJoins().getTravelEntryJoins())); + travelEntryService.createUserFilter(new TravelEntryQueryContext(cb, cq, joins.getTravelEntryJoins())); if (travelEntryFilter != null) { filter = cb.or(filter, travelEntryFilter); } - return CriteriaBuilderHelper.and(cb, filter, assigneeFilter); + return CriteriaBuilderHelper.and(cb, filter, relatedEntityNotDeletedFilter, assigneeFilter); } public Predicate createAssigneeFilter(CriteriaBuilder cb, Join assigneeUserJoin) { diff --git a/sormas-backend/src/test/java/de/symeda/sormas/backend/systemevent/SystemEventFacadeEjbTest.java b/sormas-backend/src/test/java/de/symeda/sormas/backend/systemevent/SystemEventFacadeEjbTest.java index 02c97fddea0..f54f7c44348 100644 --- a/sormas-backend/src/test/java/de/symeda/sormas/backend/systemevent/SystemEventFacadeEjbTest.java +++ b/sormas-backend/src/test/java/de/symeda/sormas/backend/systemevent/SystemEventFacadeEjbTest.java @@ -30,15 +30,20 @@ public void testGetLatestSuccessByType() { Date earliestDate = new Date(100000L); Date intermediateDate = new Date(200000L); Date latestDate = new Date(300000L); + Date centralSyncDate = new Date(400000L); SystemEventDto earlierSuccess = creator.createSystemEvent(SystemEventType.FETCH_LAB_MESSAGES, earliestDate, SystemEventStatus.SUCCESS); SystemEventDto latestSuccess = creator.createSystemEvent(SystemEventType.FETCH_LAB_MESSAGES, intermediateDate, SystemEventStatus.SUCCESS); SystemEventDto error = creator.createSystemEvent(SystemEventType.FETCH_LAB_MESSAGES, latestDate, SystemEventStatus.ERROR); + SystemEventDto centralSync = creator.createSystemEvent(SystemEventType.CENTRAL_SYNC_INFRA, centralSyncDate, SystemEventStatus.SUCCESS); getSystemEventFacade().saveSystemEvent(earlierSuccess); getSystemEventFacade().saveSystemEvent(latestSuccess); getSystemEventFacade().saveSystemEvent(error); + getSystemEventFacade().saveSystemEvent(centralSync); + assertEquals(latestSuccess, getSystemEventFacade().getLatestSuccessByType(SystemEventType.FETCH_LAB_MESSAGES)); + assertEquals(centralSync, getSystemEventFacade().getLatestSuccessByType(SystemEventType.CENTRAL_SYNC_INFRA)); } @Test diff --git a/sormas-backend/src/test/java/de/symeda/sormas/backend/task/TaskFacadeEjbTest.java b/sormas-backend/src/test/java/de/symeda/sormas/backend/task/TaskFacadeEjbTest.java index 503f7864801..3db2976b9a5 100644 --- a/sormas-backend/src/test/java/de/symeda/sormas/backend/task/TaskFacadeEjbTest.java +++ b/sormas-backend/src/test/java/de/symeda/sormas/backend/task/TaskFacadeEjbTest.java @@ -31,13 +31,14 @@ import java.util.Calendar; import java.util.Collections; import java.util.Date; -import java.util.HashSet; import java.util.List; import java.util.Map; -import java.util.Set; import java.util.stream.Collectors; -import de.symeda.sormas.api.user.UserReferenceDto; +import de.symeda.sormas.api.EntityRelevanceStatus; +import de.symeda.sormas.api.common.DeletionDetails; +import de.symeda.sormas.api.task.TaskCriteria; +import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.junit.MockitoJUnitRunner; @@ -68,6 +69,37 @@ @RunWith(MockitoJUnitRunner.class) public class TaskFacadeEjbTest extends AbstractBeanTest { + @Test + public void testTaskDirectoryForDeletedLinkedCase() { + RDCF rdcf = creator.createRDCF("Region", "District", "Community", "Facility"); + UserDto user = creator + .createUser(rdcf.region.getUuid(), rdcf.district.getUuid(), rdcf.facility.getUuid(), "Surv", "Sup", UserRole.SURVEILLANCE_SUPERVISOR); + PersonDto cazePerson = creator.createPerson("Case", "Person"); + CaseDataDto caze = creator.createCase( + user.toReference(), + cazePerson.toReference(), + Disease.EVD, + CaseClassification.PROBABLE, + InvestigationStatus.PENDING, + new Date(), + rdcf); + + TaskDto task = creator.createTask( + TaskContext.CASE, + TaskType.OTHER, + TaskStatus.PENDING, + caze.toReference(), + null, + null, + DateHelper.addDays(new Date(), 1), + user.toReference()); + + getCaseFacade().delete(caze.getUuid(), new DeletionDetails()); + + List tasks = getTaskFacade().getIndexList(new TaskCriteria().relevanceStatus(EntityRelevanceStatus.ALL), 0, 100, null); + Assert.assertEquals(0, tasks.size()); + } + @Test public void testSampleDeletion() { diff --git a/sormas-base/dependencies/serverlibs.pom b/sormas-base/dependencies/serverlibs.pom index cac6a456cbb..882f5f41a38 100644 --- a/sormas-base/dependencies/serverlibs.pom +++ b/sormas-base/dependencies/serverlibs.pom @@ -8,7 +8,7 @@ sormas-base de.symeda.sormas - 1.72.0 + 1.72.1 ../ diff --git a/sormas-base/pom.xml b/sormas-base/pom.xml index af8a8d540a3..d4762cf5204 100644 --- a/sormas-base/pom.xml +++ b/sormas-base/pom.xml @@ -5,7 +5,7 @@ de.symeda.sormas sormas-base pom - 1.72.0 + 1.72.1 1.8 @@ -912,7 +912,7 @@ com.google.oauth-client google-oauth-client - 1.33.1 + 1.33.3 com.google.http-client diff --git a/sormas-cargoserver/pom.xml b/sormas-cargoserver/pom.xml index 43f13c85b11..c70f4c59df2 100644 --- a/sormas-cargoserver/pom.xml +++ b/sormas-cargoserver/pom.xml @@ -3,7 +3,7 @@ de.symeda.sormas sormas-base - 1.72.0 + 1.72.1 ../sormas-base diff --git a/sormas-ear/pom.xml b/sormas-ear/pom.xml index 4ff46f60039..83d277a6f52 100644 --- a/sormas-ear/pom.xml +++ b/sormas-ear/pom.xml @@ -3,7 +3,7 @@ de.symeda.sormas sormas-base - 1.72.0 + 1.72.1 ../sormas-base diff --git a/sormas-keycloak-service-provider/pom.xml b/sormas-keycloak-service-provider/pom.xml index 6beeeeecffc..a8452a73d14 100644 --- a/sormas-keycloak-service-provider/pom.xml +++ b/sormas-keycloak-service-provider/pom.xml @@ -3,7 +3,7 @@ sormas-base de.symeda.sormas - 1.72.0 + 1.72.1 ../sormas-base 4.0.0 diff --git a/sormas-rest/pom.xml b/sormas-rest/pom.xml index 453abe1cf20..5ac07d6dd75 100644 --- a/sormas-rest/pom.xml +++ b/sormas-rest/pom.xml @@ -3,7 +3,7 @@ de.symeda.sormas sormas-base - 1.72.0 + 1.72.1 ../sormas-base diff --git a/sormas-ui/pom.xml b/sormas-ui/pom.xml index e4ea6f5a97b..ccd6e6e0e5a 100644 --- a/sormas-ui/pom.xml +++ b/sormas-ui/pom.xml @@ -3,7 +3,7 @@ sormas-base de.symeda.sormas - 1.72.0 + 1.72.1 ../sormas-base 4.0.0 diff --git a/sormas-ui/src/main/java/de/symeda/sormas/ui/person/PersonEditForm.java b/sormas-ui/src/main/java/de/symeda/sormas/ui/person/PersonEditForm.java index cf88faee431..fdc49972465 100644 --- a/sormas-ui/src/main/java/de/symeda/sormas/ui/person/PersonEditForm.java +++ b/sormas-ui/src/main/java/de/symeda/sormas/ui/person/PersonEditForm.java @@ -587,9 +587,6 @@ private void addListenersToInfrastructureFields( facilityField.addValueChangeListener(e -> { updateFacilityDetailsVisibility(detailsField, (FacilityReferenceDto) e.getProperty().getValue()); - if (facilityField.equals(cbPlaceOfBirthFacility)) { - this.getValue().setPlaceOfBirthFacilityType((FacilityType) typeField.getValue()); - } }); // Set initial visibility updateFacilityDetailsVisibility(detailsField, (FacilityReferenceDto) facilityField.getValue()); diff --git a/sormas-widgetset/pom.xml b/sormas-widgetset/pom.xml index 9d17f20acc0..c4a9fe6d700 100644 --- a/sormas-widgetset/pom.xml +++ b/sormas-widgetset/pom.xml @@ -3,7 +3,7 @@ sormas-base de.symeda.sormas - 1.72.0 + 1.72.1 ../sormas-base 4.0.0