Skip to content

Commit

Permalink
#12794 - Display proper message if only the event participant was lin…
Browse files Browse the repository at this point in the history
…ked not the event
  • Loading branch information
carina29 committed Jan 11, 2024
1 parent 6d478f5 commit afccd9f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,15 @@
import android.content.Context;
import android.os.AsyncTask;
import android.view.Menu;

import de.symeda.sormas.api.Disease;
import de.symeda.sormas.api.caze.CaseClassification;
import de.symeda.sormas.api.caze.CaseOrigin;
import de.symeda.sormas.api.caze.CaseReferenceDto;
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.Strings;
import de.symeda.sormas.api.user.UserRight;
import de.symeda.sormas.api.utils.DataHelper;
import de.symeda.sormas.api.utils.ValidationException;
Expand Down Expand Up @@ -351,9 +354,15 @@ private void linkEventToCase() {
eventParticipantToSave.setResultingCaseUuid(caze.getUuid());
EventParticipantSaver eventParticipantSaver = new EventParticipantSaver(this);

if (!isEventLinkedToCase(caze, event)
&& !DatabaseHelper.getEventParticipantDao().eventParticipantAlreadyExists(event, caze.getPerson())) {
eventParticipantSaver.saveEventParticipantLinkedToCase(eventParticipantToSave);
if (!isEventLinkedToCase(caze, event)) {
boolean eventParticipantAlreadyExists =
DatabaseHelper.getEventParticipantDao().eventParticipantAlreadyExists(event, caze.getPerson());
eventParticipantSaver.saveEventParticipantLinkedToCase(eventParticipantToSave, eventParticipantAlreadyExists);

if (eventParticipantAlreadyExists) {
NotificationHelper.showNotification(this, WARNING, I18nProperties.getString(Strings.messagePersonAlreadyEventParticipant));
}

} else {
NotificationHelper
.showNotification(this, WARNING, getString(R.string.message_Event_already_linked_to_Case) + " " + caze.getUuid());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ protected void onPostExecute(AsyncTaskResult<TaskResultHolder> taskResult) {
eventParticipantToSave.setEvent(eventToSave);
eventParticipantToSave.setResultingCaseUuid(linkedCase.getUuid());
EventParticipantSaver eventParticipantSaver = new EventParticipantSaver(EventNewActivity.this);
eventParticipantSaver.saveEventParticipantLinkedToCase(eventParticipantToSave);
eventParticipantSaver.saveEventParticipantLinkedToCase(eventParticipantToSave, false);
} else {
EventEditActivity.startActivity(getContext(), eventToSave.getUuid(), EventSection.EVENT_PARTICIPANTS);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public EventParticipantSaver(BaseActivity parentActivity) {
this.parentActivity = parentActivity;
}

public void saveEventParticipantLinkedToCase(EventParticipant eventParticipantToSave) {
public void saveEventParticipantLinkedToCase(EventParticipant eventParticipantToSave, boolean eventParticipantAlreadyExists) {

new SavingAsyncTask(parentActivity.getRootView(), eventParticipantToSave) {

Expand All @@ -32,7 +32,11 @@ protected void doInBackground(TaskResultHolder resultHolder) throws Exception {
@Override
protected void onPostExecute(AsyncTaskResult<TaskResultHolder> taskResult) {
parentActivity.hidePreloader();
super.onPostExecute(taskResult);

if (!eventParticipantAlreadyExists) {
super.onPostExecute(taskResult);
}

if (taskResult.getResultStatus().isSuccess()) {
parentActivity.finish();
}
Expand Down

0 comments on commit afccd9f

Please sign in to comment.