Skip to content

Commit

Permalink
[GITFLOW]merging 'hotfix-1.72.1' into 'master'
Browse files Browse the repository at this point in the history
  • Loading branch information
MateStrysewske committed May 24, 2022
2 parents 1715a54 + a4fcff2 commit cd89f01
Show file tree
Hide file tree
Showing 19 changed files with 103 additions and 35 deletions.
2 changes: 1 addition & 1 deletion sormas-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<parent>
<groupId>de.symeda.sormas</groupId>
<artifactId>sormas-base</artifactId>
<version>1.72.0</version>
<version>1.72.1</version>
<relativePath>../sormas-base</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion sormas-app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>sormas-base</artifactId>
<groupId>de.symeda.sormas</groupId>
<version>1.72.0</version>
<version>1.72.1</version>
<relativePath>../sormas-base</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion sormas-backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>sormas-base</artifactId>
<groupId>de.symeda.sormas</groupId>
<version>1.72.0</version>
<version>1.72.1</version>
<relativePath>../sormas-base</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,7 @@ public Predicate createActiveEventsFilter(CriteriaBuilder cb, Path<Event> 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<Event> root) {
public Predicate createDefaultFilter(CriteriaBuilder cb, From<?, Event> root) {
return cb.isFalse(root.get(Event.DELETED));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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 <https://www.gnu.org/licenses/>.
*/

package de.symeda.sormas.backend.systemevent;

import java.sql.Timestamp;
Expand Down Expand Up @@ -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<SystemEvent> cq = cb.createQuery(SystemEvent.class);
Root<SystemEvent> 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());
Expand All @@ -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);
Expand All @@ -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<SystemEvent> cu = cb.createCriteriaUpdate(SystemEvent.class);
Root<SystemEvent> root = cu.from(SystemEvent.class);
Expand All @@ -117,7 +136,6 @@ public SystemEvent fromDto(@NotNull SystemEventDto source, SystemEvent target, b
target.setAdditionalInfo(source.getAdditionalInfo());

return target;

}

public SystemEventDto toDto(SystemEvent source) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -156,46 +155,54 @@ public Predicate createUserFilter(TaskQueryContext taskQueryContext) {
CriteriaBuilder cb = taskQueryContext.getCriteriaBuilder();
From<?, Task> 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<?, User> assigneeUserJoin) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<TaskIndexDto> tasks = getTaskFacade().getIndexList(new TaskCriteria().relevanceStatus(EntityRelevanceStatus.ALL), 0, 100, null);
Assert.assertEquals(0, tasks.size());
}

@Test
public void testSampleDeletion() {

Expand Down
2 changes: 1 addition & 1 deletion sormas-base/dependencies/serverlibs.pom
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<parent>
<artifactId>sormas-base</artifactId>
<groupId>de.symeda.sormas</groupId>
<version>1.72.0</version>
<version>1.72.1</version>
<relativePath>../</relativePath>
</parent>

Expand Down
4 changes: 2 additions & 2 deletions sormas-base/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<groupId>de.symeda.sormas</groupId>
<artifactId>sormas-base</artifactId>
<packaging>pom</packaging>
<version>1.72.0</version>
<version>1.72.1</version>

<properties>
<maven.compiler.source>1.8</maven.compiler.source>
Expand Down Expand Up @@ -912,7 +912,7 @@
<dependency>
<groupId>com.google.oauth-client</groupId>
<artifactId>google-oauth-client</artifactId>
<version>1.33.1</version>
<version>1.33.3</version>
</dependency>
<dependency>
<groupId>com.google.http-client</groupId>
Expand Down
2 changes: 1 addition & 1 deletion sormas-cargoserver/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>de.symeda.sormas</groupId>
<artifactId>sormas-base</artifactId>
<version>1.72.0</version>
<version>1.72.1</version>
<relativePath>../sormas-base</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion sormas-ear/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>de.symeda.sormas</groupId>
<artifactId>sormas-base</artifactId>
<version>1.72.0</version>
<version>1.72.1</version>
<relativePath>../sormas-base</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion sormas-keycloak-service-provider/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>sormas-base</artifactId>
<groupId>de.symeda.sormas</groupId>
<version>1.72.0</version>
<version>1.72.1</version>
<relativePath>../sormas-base</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion sormas-rest/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>de.symeda.sormas</groupId>
<artifactId>sormas-base</artifactId>
<version>1.72.0</version>
<version>1.72.1</version>
<relativePath>../sormas-base</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion sormas-ui/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>sormas-base</artifactId>
<groupId>de.symeda.sormas</groupId>
<version>1.72.0</version>
<version>1.72.1</version>
<relativePath>../sormas-base</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
2 changes: 1 addition & 1 deletion sormas-widgetset/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>sormas-base</artifactId>
<groupId>de.symeda.sormas</groupId>
<version>1.72.0</version>
<version>1.72.1</version>
<relativePath>../sormas-base</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down

0 comments on commit cd89f01

Please sign in to comment.