Skip to content

Commit

Permalink
[GITFLOW]merging 'hotfix-1.65.1' into 'master'
Browse files Browse the repository at this point in the history
  • Loading branch information
MateStrysewske committed Nov 19, 2021
2 parents 23586b9 + 6bbffef commit a8e00a8
Show file tree
Hide file tree
Showing 56 changed files with 733 additions and 302 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.65.0</version>
<version>1.65.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 @@ -24,6 +24,14 @@ public enum MeansOfImmunization {
VACCINATION_RECOVERY,
OTHER;

public static boolean isVaccination(MeansOfImmunization meansOfImmunization) {
return meansOfImmunization == VACCINATION || meansOfImmunization == VACCINATION_RECOVERY;
}

public static boolean isRecovery(MeansOfImmunization meansOfImmunization) {
return meansOfImmunization == RECOVERY || meansOfImmunization == VACCINATION_RECOVERY;
}

@Override
public String toString() {
return I18nProperties.getEnumCaption(this);
Expand Down
23 changes: 13 additions & 10 deletions sormas-api/src/main/java/de/symeda/sormas/api/person/PersonDto.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
/*******************************************************************************
/*
* SORMAS® - Surveillance Outbreak Response Management & Analysis System
* Copyright © 2016-2018 Helmholtz-Zentrum für Infektionsforschung GmbH (HZI)
*
* Copyright © 2016-2021 Helmholtz-Zentrum für Infektionsforschung GmbH (HZI)
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*******************************************************************************/
*/

package de.symeda.sormas.api.person;

import java.util.ArrayList;
Expand All @@ -24,6 +22,7 @@
import javax.validation.Valid;
import javax.validation.constraints.Size;

import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;

import com.fasterxml.jackson.annotation.JsonIgnore;
Expand Down Expand Up @@ -554,7 +553,7 @@ public String getPhone(boolean onlyPrimary) throws SeveralNonPrimaryContactDetai
return primaryPhone;
} else {
List<String> allPhones = getAllPhoneNumbers();
if (allPhones.size() == 0) {
if (CollectionUtils.isEmpty(allPhones)) {
return "";
} else if (allPhones.size() > 1) {
throw new SeveralNonPrimaryContactDetailsException("Too many results found, none of which is marked primary.");
Expand All @@ -565,7 +564,7 @@ public String getPhone(boolean onlyPrimary) throws SeveralNonPrimaryContactDetai
}

@JsonIgnore
public ArrayList<String> getAllPhoneNumbers() {
public List<String> getAllPhoneNumbers() {
ArrayList<String> result = new ArrayList<>();
for (PersonContactDetailDto pcd : getPersonContactDetails()) {
if (pcd.getPersonContactDetailType() == PersonContactDetailType.PHONE) {
Expand Down Expand Up @@ -619,7 +618,7 @@ public String getEmailAddress(boolean onlyPrimary) throws SeveralNonPrimaryConta
return primaryEmail;
} else {
List<String> allEmails = getAllEmailAddresses();
if (allEmails.size() == 0) {
if (CollectionUtils.isEmpty(allEmails)) {
return "";
} else if (allEmails.size() > 1) {
throw new SeveralNonPrimaryContactDetailsException("Too many results found, none of which is marked primary.");
Expand All @@ -630,7 +629,7 @@ public String getEmailAddress(boolean onlyPrimary) throws SeveralNonPrimaryConta
}

@JsonIgnore
public ArrayList<String> getAllEmailAddresses() {
public List<String> getAllEmailAddresses() {
ArrayList<String> result = new ArrayList<>();
for (PersonContactDetailDto pcd : getPersonContactDetails()) {
if (pcd.getPersonContactDetailType() == PersonContactDetailType.EMAIL) {
Expand Down Expand Up @@ -875,6 +874,10 @@ public void setAddresses(List<LocationDto> addresses) {
this.addresses = addresses;
}

public void addAddress(LocationDto address) {
addresses.add(address);
}

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

package de.symeda.sormas.api.person;

import java.text.Normalizer;
Expand All @@ -31,6 +29,7 @@
import de.symeda.sormas.api.caze.BurialInfoDto;
import de.symeda.sormas.api.i18n.I18nProperties;
import de.symeda.sormas.api.i18n.Validations;
import de.symeda.sormas.api.location.LocationDto;
import de.symeda.sormas.api.person.ApproximateAgeType.ApproximateAgeHelper;
import de.symeda.sormas.api.utils.DateFormatHelper;
import de.symeda.sormas.api.utils.DateHelper;
Expand Down Expand Up @@ -204,4 +203,13 @@ public static String buildEducationString(EducationType educationType, String ed
}
return result.toString();
}

public static void sanitizeNonHomeAddress(PersonDto person) {
if (person.getAddress() != null
&& person.getAddress().getAddressType() != null
&& person.getAddress().getAddressType() != PersonAddressType.HOME) {
person.addAddress(person.getAddress());
person.setAddress(LocationDto.build());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@

public final class DataHelper {

public static final String VALID_EMAIL_REGEX = "^([a-zA-Z0-9_\\.\\-+])+@[a-zA-Z0-9-.]+\\.[a-zA-Z0-9-]{2,}$";
public static final String NOT_A_VALID_PHONE_NUMBER_REGEX = ".*[a-zA-Z].*";

private DataHelper() {
// Hide Utility Class Constructor
}
Expand Down Expand Up @@ -441,11 +444,11 @@ public static String joinStrings(String separator, String... strings) {
return StringUtils.join(notEmptyValues, separator);
}

public static String getEmailValidationRegex() {
return "^([a-zA-Z0-9_\\.\\-+])+@[a-zA-Z0-9-.]+\\.[a-zA-Z0-9-]{2,}$";
public static boolean isValidPhoneNumber(String phoneNumber) {
return StringUtils.isBlank(phoneNumber) || !phoneNumber.matches(NOT_A_VALID_PHONE_NUMBER_REGEX);
}

public static String getPhoneNumberValidationRegex() {
return ".*[a-zA-Z].*";
public static boolean isValidEmailAddress(String emailAddress) {
return StringUtils.isBlank(emailAddress) || emailAddress.matches(VALID_EMAIL_REGEX);
}
}
Binary file modified sormas-api/src/main/resources/doc/SORMAS_Data_Dictionary.xlsx
Binary file not shown.
Binary file modified sormas-api/src/main/resources/doc/SORMAS_User_Rights.xlsx
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ private void setupDrawer(NavigationView navView) {
MenuItem contactMenu = menuNav.findItem(R.id.menu_item_contacts);
MenuItem eventMenu = menuNav.findItem(R.id.menu_item_events);
MenuItem sampleMenu = menuNav.findItem(R.id.menu_item_samples);
MenuItem immunizationMenu = menuNav.findItem(R.id.menu_item_samples);
MenuItem immunizationMenu = menuNav.findItem(R.id.menu_item_immunizations);
MenuItem reportMenu = menuNav.findItem(R.id.menu_item_reports);
MenuItem campaignMenu = menuNav.findItem(R.id.menu_item_campaigns);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

import de.symeda.sormas.api.i18n.I18nProperties;
import de.symeda.sormas.api.i18n.Validations;
import de.symeda.sormas.api.utils.DataHelper;
import de.symeda.sormas.api.utils.DateHelper;
import de.symeda.sormas.app.component.controls.ControlDateField;
import de.symeda.sormas.app.component.controls.ControlPropertyEditField;
import de.symeda.sormas.app.component.controls.ControlTextEditField;
import de.symeda.sormas.app.util.ResultCallback;
Expand Down Expand Up @@ -72,4 +72,35 @@ public static void initIntegerValidator(ControlTextEditField textEditField, Stri
return false;
});
}

public static void initEmailValidator(ControlTextEditField textEditField) {
textEditField.setValidationCallback(() -> {
String emailAddress = textEditField.getValue();
if (!DataHelper.isValidEmailAddress(emailAddress)) {
textEditField.enableErrorState(I18nProperties.getValidationError(Validations.validEmailAddress, textEditField.getCaption()));

return true;
}

return false;
});
}

public static void initPhoneNumberValidator(ControlTextEditField textEditField) {
textEditField.setValidationCallback(() -> {
String phoneNumber = textEditField.getValue();
if (!DataHelper.isValidPhoneNumber(phoneNumber)) {
textEditField.enableErrorState(I18nProperties.getValidationError(Validations.validPhoneNumber, textEditField.getCaption()));

return true;
}

return false;
});
}

public static void resetValidator(ControlTextEditField textEditField) {
textEditField.disableErrorState();
textEditField.setValidationCallback(null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,16 @@

package de.symeda.sormas.app.event.eventparticipant.edit;

import static de.symeda.sormas.app.core.notification.NotificationType.ERROR;
import static de.symeda.sormas.app.core.notification.NotificationType.WARNING;

import java.util.List;

import android.content.Context;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.Menu;

import androidx.annotation.NonNull;

import java.util.List;

import de.symeda.sormas.api.event.EventStatus;
import de.symeda.sormas.api.user.UserRight;
import de.symeda.sormas.api.utils.DataHelper;
Expand All @@ -35,6 +36,7 @@
import de.symeda.sormas.app.backend.common.DaoException;
import de.symeda.sormas.app.backend.common.DatabaseHelper;
import de.symeda.sormas.app.backend.config.ConfigProvider;
import de.symeda.sormas.app.backend.event.Event;
import de.symeda.sormas.app.backend.event.EventParticipant;
import de.symeda.sormas.app.component.menu.PageMenuItem;
import de.symeda.sormas.app.component.validation.FragmentValidator;
Expand All @@ -46,9 +48,6 @@
import de.symeda.sormas.app.immunization.edit.ImmunizationNewActivity;
import de.symeda.sormas.app.util.Bundler;

import static de.symeda.sormas.app.core.notification.NotificationType.ERROR;
import static de.symeda.sormas.app.core.notification.NotificationType.WARNING;

public class EventParticipantEditActivity extends BaseEditActivity<EventParticipant> {

private AsyncTask saveTask;
Expand Down Expand Up @@ -99,7 +98,8 @@ public boolean onCreateOptionsMenu(Menu menu) {
@Override
public List<PageMenuItem> getPageMenuData() {
List<PageMenuItem> menuItems = PageMenuItem.fromEnum(EventParticipantSection.values(), getContext());
if (!ConfigProvider.hasUserRight(UserRight.IMMUNIZATION_VIEW)) {
Event event = DatabaseHelper.getEventDao().queryUuid(eventUuid);
if (event.getDisease() == null || !ConfigProvider.hasUserRight(UserRight.IMMUNIZATION_VIEW)) {
menuItems.set(EventParticipantSection.IMMUNIZATIONS.ordinal(), null);
}
return menuItems;
Expand Down Expand Up @@ -129,7 +129,7 @@ public void goToNewView() {
EventParticipantSection activeSection = EventParticipantSection.fromOrdinal(getActivePage().getPosition());

if (activeSection == EventParticipantSection.IMMUNIZATIONS) {
ImmunizationNewActivity.startActivityFromCase(getContext(), getRootUuid());
ImmunizationNewActivity.startActivityFromEventParticipant(getContext(), getRootUuid());
}
}

Expand All @@ -142,8 +142,9 @@ protected int getActivityTitle() {
public void saveData() {

if (saveTask != null) {
// don't save multiple times
NotificationHelper.showNotification(this, WARNING, getString(R.string.message_already_saving));
return; // don't save multiple times
return;
}

final EventParticipant eventParticipant = (EventParticipant) getActiveFragment().getPrimaryData();
Expand Down Expand Up @@ -177,7 +178,8 @@ protected void onPostExecute(AsyncTaskResult<TaskResultHolder> taskResult) {
if (taskResult.getResultStatus().isSuccess()) {
finish();
} else {
onResume(); // reload data
// reload data
onResume();
}
saveTask = null;
}
Expand All @@ -188,7 +190,8 @@ protected void onPostExecute(AsyncTaskResult<TaskResultHolder> taskResult) {
public void onDestroy() {
super.onDestroy();

if (saveTask != null && !saveTask.isCancelled())
if (saveTask != null && !saveTask.isCancelled()) {
saveTask.cancel(true);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,12 @@

package de.symeda.sormas.app.event.eventparticipant.read;

import java.util.List;

import android.content.Context;
import android.os.Bundle;
import android.view.MenuItem;

import androidx.annotation.NonNull;

import java.util.List;

import de.symeda.sormas.api.event.EventParticipantReferenceDto;
import de.symeda.sormas.api.user.UserRight;
import de.symeda.sormas.api.utils.DataHelper;
Expand All @@ -31,6 +29,7 @@
import de.symeda.sormas.app.R;
import de.symeda.sormas.app.backend.common.DatabaseHelper;
import de.symeda.sormas.app.backend.config.ConfigProvider;
import de.symeda.sormas.app.backend.event.Event;
import de.symeda.sormas.app.backend.event.EventEditAuthorization;
import de.symeda.sormas.app.backend.event.EventParticipant;
import de.symeda.sormas.app.component.menu.PageMenuItem;
Expand Down Expand Up @@ -67,11 +66,11 @@ protected EventParticipant queryRootEntity(String recordUuid) {
return DatabaseHelper.getEventParticipantDao().queryUuid(recordUuid);
}


@Override
public List<PageMenuItem> getPageMenuData() {
List<PageMenuItem> menuItems = PageMenuItem.fromEnum(EventParticipantSection.values(), getContext());
if (!ConfigProvider.hasUserRight(UserRight.IMMUNIZATION_VIEW)) {
Event event = DatabaseHelper.getEventDao().queryUuid(eventUuid);
if (event.getDisease() == null || !ConfigProvider.hasUserRight(UserRight.IMMUNIZATION_VIEW)) {
menuItems.set(EventParticipantSection.IMMUNIZATIONS.ordinal(), null);
}
return menuItems;
Expand All @@ -84,14 +83,14 @@ protected BaseReadFragment buildReadFragment(PageMenuItem menuItem, EventPartici
BaseReadFragment fragment;
switch (section) {

case EVENT_PARTICIPANT_INFO:
fragment = EventParticipantReadFragment.newInstance(activityRootData);
break;
case IMMUNIZATIONS:
fragment = EventParticipantReadImmunizationListFragment.newInstance(activityRootData);
break;
default:
throw new IndexOutOfBoundsException(DataHelper.toStringNullable(section));
case EVENT_PARTICIPANT_INFO:
fragment = EventParticipantReadFragment.newInstance(activityRootData);
break;
case IMMUNIZATIONS:
fragment = EventParticipantReadImmunizationListFragment.newInstance(activityRootData);
break;
default:
throw new IndexOutOfBoundsException(DataHelper.toStringNullable(section));
}
return fragment;
}
Expand Down Expand Up @@ -121,11 +120,7 @@ protected void processActionbarMenu() {
DatabaseHelper.getEventParticipantDao().getByReferenceDto(new EventParticipantReferenceDto(getRootUuid()));

if (editMenu != null) {
if (EventEditAuthorization.isEventParticipantEditAllowed(selectedEventParticipant)) {
editMenu.setVisible(true);
} else {
editMenu.setVisible(false);
}
editMenu.setVisible(EventEditAuthorization.isEventParticipantEditAllowed(selectedEventParticipant));
}
}
}
Loading

0 comments on commit a8e00a8

Please sign in to comment.