Skip to content

Commit

Permalink
#183 added validations
Browse files Browse the repository at this point in the history
  • Loading branch information
Anthony4m committed Nov 18, 2024
1 parent 235f053 commit ef1bf49
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

package de.symeda.sormas.app.riskAssessment.edit;

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

import android.content.Context;
Expand All @@ -37,6 +38,7 @@
import de.symeda.sormas.app.backend.ebs.riskAssessment.RiskAssessment;
import de.symeda.sormas.app.component.dialog.InfoDialog;
import de.symeda.sormas.app.component.menu.PageMenuItem;
import de.symeda.sormas.app.component.validation.FragmentValidator;
import de.symeda.sormas.app.core.async.AsyncTaskResult;
import de.symeda.sormas.app.core.async.SavingAsyncTask;
import de.symeda.sormas.app.core.async.TaskResultHolder;
Expand Down Expand Up @@ -157,6 +159,13 @@ public void saveData() {

final RiskAssessment riskToSave = getStoredRootEntity();

try {
FragmentValidator.validate(getContext(), getActiveFragment().getContentBinding());
} catch (ValidationException e) {
NotificationHelper.showNotification(this, ERROR, e.getMessage());
return;
}

saveTask = new SavingAsyncTask(getRootView(), riskToSave) {
@Override
public void doInBackground(TaskResultHolder resultHolder) throws DaoException, ValidationException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

package de.symeda.sormas.app.signalVerification.edit;

import static de.symeda.sormas.api.utils.DataHelper.isNullOrEmpty;
import static de.symeda.sormas.app.core.notification.NotificationType.ERROR;
import static de.symeda.sormas.app.core.notification.NotificationType.WARNING;

import android.app.AlertDialog;
Expand All @@ -39,6 +41,7 @@
import de.symeda.sormas.app.backend.ebs.signalVerification.SignalVerification;
import de.symeda.sormas.app.backend.ebs.triaging.Triaging;
import de.symeda.sormas.app.component.menu.PageMenuItem;
import de.symeda.sormas.app.component.validation.FragmentValidator;
import de.symeda.sormas.app.core.async.AsyncTaskResult;
import de.symeda.sormas.app.core.async.SavingAsyncTask;
import de.symeda.sormas.app.core.async.TaskResultHolder;
Expand Down Expand Up @@ -158,6 +161,14 @@ public void saveData() {

final SignalVerification signalToSave = getStoredRootEntity();

try {
FragmentValidator.validate(getContext(), getActiveFragment().getContentBinding());
callDeathCount(signalToSave);
} catch (ValidationException e) {
NotificationHelper.showNotification(this, ERROR, e.getMessage());
return;
}

saveTask = new SavingAsyncTask(getRootView(), signalToSave) {

@Override
Expand All @@ -182,6 +193,16 @@ protected void onPostExecute(AsyncTaskResult<TaskResultHolder> taskResult) {
}.executeOnThreadPool();
}

public static void callDeathCount(SignalVerification signalVerification) {
if (!isNullOrEmpty(signalVerification.getNumberOfDeathPerson()) && isNullOrEmpty(signalVerification.getNumberOfPersonCases())){
signalVerification.setNumberOfPersonCases(signalVerification.getNumberOfDeathPerson());
}
if (!isNullOrEmpty(signalVerification.getNumberOfDeath()) && isNullOrEmpty(signalVerification.getNumberOfPersonAnimal())){
signalVerification.setNumberOfPersonAnimal(signalVerification.getNumberOfDeath());
}
}


@Override
public void onDestroy() {
super.onDestroy();
Expand Down

0 comments on commit ef1bf49

Please sign in to comment.