Skip to content

Commit

Permalink
[GITFLOW]merging 'hotfix-1.70.3' into 'master'
Browse files Browse the repository at this point in the history
  • Loading branch information
MateStrysewske committed Apr 21, 2022
2 parents 8db7b70 + 37ca35b commit 60b5aba
Show file tree
Hide file tree
Showing 18 changed files with 77 additions and 31 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.70.2</version>
<version>1.70.3</version>
<relativePath>../sormas-base</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
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.70.2</version>
<version>1.70.3</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.70.2</version>
<version>1.70.3</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 @@ -1378,7 +1378,8 @@ public CaseDataDto save(@Valid @NotNull CaseDataDto dto) throws ValidationRuntim
@Override
@RolesAllowed({
UserRight._CASE_CREATE,
UserRight._CASE_EDIT })
UserRight._CASE_EDIT,
UserRight._EXTERNAL_VISITS })
public CaseDataDto save(@Valid @NotNull CaseDataDto dto, boolean systemSave) throws ValidationRuntimeException {
return save(dto, true, true, true, systemSave);
}
Expand Down Expand Up @@ -2609,6 +2610,9 @@ public CaseReferenceDto convertToReferenceDto(Case source) {
return dto;
}

@RolesAllowed({
UserRight._CASE_VIEW,
UserRight._EXTERNAL_VISITS })
public CaseDataDto toDto(Case source) {
return toCaseDto(source);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -987,11 +987,19 @@ private void deleteCaseLinks(Case caze) {
// Remove the case as the resulting case and source case from all contacts
Optional.ofNullable(caze.getContacts()).ifPresent(cl -> cl.forEach(c -> {
c.setCaze(null);

// Assign the case jurisdiction to the contact if it does not already have one
if (c.getDistrict() == null) {
c.setRegion(caze.getResponsibleRegion());
c.setDistrict(caze.getResponsibleDistrict());
c.setCommunity(caze.getResponsibleCommunity());
}

externalJournalService.handleExternalJournalPersonUpdateAsync(c.getPerson().toReference());
contactService.ensurePersisted(c);
}));

contactService.getAllByResultingCase(caze).forEach(c -> {
contactService.getAllByResultingCase(caze, true).forEach(c -> {
c.setResultingCase(null);
externalJournalService.handleExternalJournalPersonUpdateAsync(c.getPerson().toReference());
contactService.ensurePersisted(c);
Expand All @@ -1010,7 +1018,7 @@ private void deleteCaseLinks(Case caze) {
}));

// Remove the case as the resulting case of travel entries
travelEntryService.getAllByResultingCase(caze).forEach(t -> {
travelEntryService.getAllByResultingCase(caze, true).forEach(t -> {
t.setResultingCase(null);
travelEntryService.ensurePersisted(t);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1606,6 +1606,9 @@ public static ContactReferenceDto toReferenceDto(Contact source) {
return source.toReference();
}

@RolesAllowed({
UserRight._CONTACT_VIEW,
UserRight._EXTERNAL_VISITS })
public ContactDto toDto(Contact source) {
return toContactDto(source);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,12 +252,19 @@ public List<String> getAllActiveUuids(User user) {
}

public List<Contact> getAllByResultingCase(Case caze) {
return getAllByResultingCase(caze, false);
}

public List<Contact> getAllByResultingCase(Case caze, boolean includeDeleted) {

CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Contact> cq = cb.createQuery(getElementClass());
Root<Contact> from = cq.from(getElementClass());

cq.where(cb.and(createDefaultFilter(cb, from), cb.equal(from.get(Contact.RESULTING_CASE), caze)));
Predicate filter = includeDeleted ? null : createDefaultFilter(cb, from);
filter = CriteriaBuilderHelper.and(cb, filter, cb.equal(from.get(Contact.RESULTING_CASE), caze));
cq.where(filter);

cq.orderBy(cb.desc(from.get(Contact.REPORT_DATE_TIME)));

return em.createQuery(cq).getResultList();
Expand Down Expand Up @@ -993,7 +1000,7 @@ public Predicate createUserFilterWithoutCase(ContactQueryContext qc, ContactCrit
// National users can access all contacts in the system
final JurisdictionLevel jurisdictionLevel = currentUser.getJurisdictionLevel();
if ((jurisdictionLevel == JurisdictionLevel.NATION && !UserRole.isPortHealthUser(currentUser.getUserRoles()))
|| currentUser.hasUserRole(UserRole.REST_USER)) {
|| currentUser.hasUserRole(UserRole.REST_USER)) {
if (currentUser.getLimitedDisease() != null) {
return cb.equal(contactPath.get(Contact.DISEASE), currentUser.getLimitedDisease());
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;

import de.symeda.sormas.api.EditPermissionType;
import org.apache.commons.collections4.CollectionUtils;

import de.symeda.sormas.api.EditPermissionType;
import de.symeda.sormas.api.EntityRelevanceStatus;
import de.symeda.sormas.api.document.DocumentRelatedEntityType;
import de.symeda.sormas.api.task.TaskCriteria;
Expand Down Expand Up @@ -177,12 +177,19 @@ public Predicate createActiveTravelEntriesFilter(CriteriaBuilder cb, From<?, Tra
}

public List<TravelEntry> getAllByResultingCase(Case caze) {
return getAllByResultingCase(caze, false);
}

public List<TravelEntry> getAllByResultingCase(Case caze, boolean includeDeleted) {

CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<TravelEntry> cq = cb.createQuery(getElementClass());
Root<TravelEntry> from = cq.from(getElementClass());

cq.where(cb.and(createDefaultFilter(cb, from), cb.equal(from.get(TravelEntry.RESULTING_CASE), caze)));
Predicate filter = includeDeleted ? null : createDefaultFilter(cb, from);
filter = CriteriaBuilderHelper.and(cb, filter, cb.equal(from.get(TravelEntry.RESULTING_CASE), caze));
cq.where(filter);

cq.orderBy(cb.desc(from.get(TravelEntry.REPORT_DATE)));

return em.createQuery(cq).getResultList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,19 @@ public void testCasePermanentDeletion() throws IOException {
CaseDataDto duplicateCase = creator.createCase(user.toReference(), person.toReference(), rdcf);
getCaseFacade().deleteCaseAsDuplicate(duplicateCase.getUuid(), caze.getUuid());

ContactDto resultingContact = creator.createContact(user.toReference(), person.toReference(), caze);
final ContactDto resultingContact = creator.createContact(user.toReference(), person.toReference(), caze);
assertNull(resultingContact.getRegion());
ContactDto sourceContact = creator.createContact(
user.toReference(),
person.toReference(),
caze.getDisease(),
contactDto -> contactDto.setResultingCase(caze.toReference()));
ContactDto deletedSourceContact = creator.createContact(
user.toReference(),
person.toReference(),
caze.getDisease(),
contactDto -> contactDto.setResultingCase(caze.toReference()));
getContactFacade().delete(deletedSourceContact.getUuid());
EventDto event = creator.createEvent(user.toReference(), caze.getDisease());
EventParticipantDto eventParticipant = creator.createEventParticipant(
event.toReference(),
Expand All @@ -138,6 +145,10 @@ public void testCasePermanentDeletion() throws IOException {
sampleDto -> sampleDto.setAssociatedContact(resultingContact.toReference()));
TravelEntryDto travelEntry =
creator.createTravelEntry(person.toReference(), user.toReference(), rdcf, te -> te.setResultingCase(caze.toReference()));
creator.createTravelEntry(person.toReference(), user.toReference(), rdcf, te -> {
te.setResultingCase(caze.toReference());
te.setDeleted(true);
});
ImmunizationDto immunization = creator.createImmunization(
caze.getDisease(),
person.toReference(),
Expand All @@ -157,6 +168,8 @@ public void testCasePermanentDeletion() throws IOException {
getCoreEntityDeletionService().executePermanentDeletion();
loginWith(user);

ContactDto resultingContactUpdated = getContactFacade().getByUuid(resultingContact.getUuid());

assertEquals(0, getCaseService().count());
assertEquals(0, getClinicalVisitService().count());
assertEquals(0, getTreatmentService().count());
Expand All @@ -166,13 +179,16 @@ public void testCasePermanentDeletion() throws IOException {
assertNull(getSampleFacade().getSampleByUuid(multiSample.getUuid()).getAssociatedCase());
assertEquals(0, getSurveillanceReportService().count());
assertTrue(getDocumentService().getAll().get(0).isDeleted());
assertNull(getContactFacade().getByUuid(resultingContact.getUuid()).getCaze());
assertNull(resultingContactUpdated.getCaze());
assertEquals(rdcf.region, resultingContactUpdated.getRegion());
assertEquals(rdcf.district, resultingContactUpdated.getDistrict());
assertEquals(rdcf.community, resultingContactUpdated.getCommunity());
assertNull(getContactFacade().getByUuid(sourceContact.getUuid()).getResultingCase());
assertNull(getEventParticipantFacade().getByUuid(eventParticipant.getUuid()).getResultingCase());
assertNull(getTravelEntryFacade().getByUuid(travelEntry.getUuid()).getResultingCase());
assertNull(getImmunizationFacade().getByUuid(immunization.getUuid()).getRelatedCase());
}

@Test
public void testCaseVisitPermanentDeletion() {

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.70.2</version>
<version>1.70.3</version>
<relativePath>../</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion 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.70.2</version>
<version>1.70.3</version>

<properties>
<maven.compiler.source>1.8</maven.compiler.source>
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.70.2</version>
<version>1.70.3</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.70.2</version>
<version>1.70.3</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.70.2</version>
<version>1.70.3</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.70.2</version>
<version>1.70.3</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.70.2</version>
<version>1.70.3</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 @@ -29,7 +29,6 @@
import com.vaadin.ui.Label;
import com.vaadin.ui.Notification;
import com.vaadin.ui.Notification.Type;
import com.vaadin.ui.UI;
import com.vaadin.ui.themes.ValoTheme;

import de.symeda.sormas.api.FacadeProvider;
Expand Down Expand Up @@ -203,19 +202,21 @@ public CommitDiscardWrapperComponent<?> getEventGroupEditComponent(String uuid)
});
}

if (user.hasUserRight(UserRight.EVENTGROUP_DELETE) && hasRegion) {
editView.addDeleteListener(() -> {
deleteEventGroup(eventGroup);
UI.getCurrent().getNavigator().navigateTo(EventsView.VIEW_NAME);
}, I18nProperties.getString(Strings.entityEventGroup));
}
// TODO #8851: Enable temporarily removed button when EventGroup deletion works
// if (user.hasUserRight(UserRight.EVENTGROUP_DELETE) && hasRegion) {
// editView.addDeleteListener(() -> {
// deleteEventGroup(eventGroup);
// UI.getCurrent().getNavigator().navigateTo(EventsView.VIEW_NAME);
// }, I18nProperties.getString(Strings.entityEventGroup));
// }

// Initialize 'Archive' button
if (user.hasUserRight(UserRight.EVENTGROUP_ARCHIVE) && hasRegion) {
boolean archived = FacadeProvider.getEventGroupFacade().isArchived(uuid);
Button archiveEventButton = ButtonHelper.createButton(archived ? Captions.actionDearchiveInfrastructure : Captions.actionArchiveInfrastructure, e -> {
archiveOrDearchiveEventGroup(uuid, !archived);
}, ValoTheme.BUTTON_LINK);
Button archiveEventButton =
ButtonHelper.createButton(archived ? Captions.actionDearchiveInfrastructure : Captions.actionArchiveInfrastructure, e -> {
archiveOrDearchiveEventGroup(uuid, !archived);
}, ValoTheme.BUTTON_LINK);

editView.getButtonsPanel().addComponentAsFirst(archiveEventButton);
editView.getButtonsPanel().setComponentAlignment(archiveEventButton, Alignment.BOTTOM_LEFT);
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.70.2</version>
<version>1.70.3</version>
<relativePath>../sormas-base</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down

0 comments on commit 60b5aba

Please sign in to comment.