use of de.symeda.sormas.api.utils.ValidationException in project SORMAS-Project by hzi-braunschweig.
the class ClinicalVisitEditActivity method saveData.
@Override
public void saveData() {
if (saveTask != null) {
NotificationHelper.showNotification(this, WARNING, getString(R.string.message_already_saving));
// don't save multiple times
return;
}
final ClinicalVisit clinicalVisit = getStoredRootEntity();
try {
FragmentValidator.validate(getContext(), getActiveFragment().getContentBinding());
} catch (ValidationException e) {
NotificationHelper.showNotification(this, ERROR, e.getMessage());
return;
}
saveTask = new SavingAsyncTask(getRootView(), clinicalVisit) {
@Override
protected void onPreExecute() {
showPreloader();
}
@Override
public void doInBackground(TaskResultHolder resultHolder) throws Exception {
DatabaseHelper.getClinicalVisitDao().saveAndSnapshot(clinicalVisit);
}
@Override
protected void onPostExecute(AsyncTaskResult<TaskResultHolder> taskResult) {
hidePreloader();
super.onPostExecute(taskResult);
if (taskResult.getResultStatus().isSuccess()) {
goToNextPage();
} else {
// reload data
onResume();
}
saveTask = null;
}
}.executeOnThreadPool();
}
use of de.symeda.sormas.api.utils.ValidationException in project SORMAS-Project by hzi-braunschweig.
the class ClinicalVisitNewActivity method saveData.
@Override
public void saveData() {
if (saveTask != null) {
NotificationHelper.showNotification(this, WARNING, getString(R.string.message_already_saving));
// don't save multiple times
return;
}
final ClinicalVisit clinicalVisit = getStoredRootEntity();
ClinicalVisitEditFragment fragment = (ClinicalVisitEditFragment) getActiveFragment();
fragment.setLiveValidationDisabled(false);
try {
FragmentValidator.validate(getContext(), getActiveFragment().getContentBinding());
} catch (ValidationException e) {
NotificationHelper.showNotification(this, ERROR, e.getMessage());
return;
}
saveTask = new SavingAsyncTask(getRootView(), clinicalVisit) {
@Override
protected void onPreExecute() {
showPreloader();
}
@Override
public void doInBackground(TaskResultHolder resultHolder) throws Exception {
DatabaseHelper.getClinicalVisitDao().saveAndSnapshot(clinicalVisit);
}
@Override
protected void onPostExecute(AsyncTaskResult<TaskResultHolder> taskResult) {
hidePreloader();
super.onPostExecute(taskResult);
if (taskResult.getResultStatus().isSuccess()) {
finish();
ClinicalVisitEditActivity.startActivity(getContext(), clinicalVisit.getUuid(), caseUuid, ClinicalVisitSection.CLINICAL_MEASUREMENTS);
}
saveTask = null;
}
}.executeOnThreadPool();
}
use of de.symeda.sormas.api.utils.ValidationException in project SORMAS-Project by hzi-braunschweig.
the class ContactEditActivity method saveData.
@Override
public void saveData() {
if (saveTask != null) {
NotificationHelper.showNotification(this, WARNING, getString(R.string.message_already_saving));
// don't save multiple times
return;
}
final Contact contactToSave = getStoredRootEntity();
if (ContactEditAuthorization.isContactEditAllowed(contactToSave)) {
try {
FragmentValidator.validate(getContext(), getActiveFragment().getContentBinding());
} catch (ValidationException e) {
NotificationHelper.showNotification(this, ERROR, e.getMessage());
return;
}
saveTask = new SavingAsyncTask(getRootView(), contactToSave) {
@Override
public void doInBackground(TaskResultHolder resultHolder) throws DaoException {
DatabaseHelper.getPersonDao().saveAndSnapshot(contactToSave.getPerson());
DatabaseHelper.getContactDao().saveAndSnapshot(contactToSave);
}
@Override
protected void onPostExecute(AsyncTaskResult<TaskResultHolder> taskResult) {
super.onPostExecute(taskResult);
if (taskResult.getResultStatus().isSuccess()) {
if (getActivePage().getPosition() == ContactSection.PERSON_INFO.ordinal()) {
finish();
} else {
goToNextPage();
}
} else {
// reload data
onResume();
}
saveTask = null;
}
}.executeOnThreadPool();
} else {
NotificationHelper.showNotification(this, WARNING, getString(R.string.message_edit_forbidden));
}
}
use of de.symeda.sormas.api.utils.ValidationException in project SORMAS-Project by hzi-braunschweig.
the class EventEditActivity method saveData.
@Override
public void saveData() {
if (saveTask != null) {
NotificationHelper.showNotification(this, WARNING, getString(R.string.message_already_saving));
// don't save multiple times
return;
}
final Event eventToSave = (Event) getActiveFragment().getPrimaryData();
EventEditFragment fragment = (EventEditFragment) getActiveFragment();
try {
FragmentValidator.validate(getContext(), fragment.getContentBinding());
} catch (ValidationException e) {
NotificationHelper.showNotification(this, ERROR, e.getMessage());
return;
}
if (eventToSave.getTypeOfPlace() == TypeOfPlace.OTHER) {
eventToSave.getEventLocation().setFacility(null);
eventToSave.getEventLocation().setFacilityDetails(null);
eventToSave.getEventLocation().setFacilityType(null);
}
saveTask = new SavingAsyncTask(getRootView(), eventToSave) {
@Override
protected void onPreExecute() {
showPreloader();
}
@Override
public void doInBackground(TaskResultHolder resultHolder) throws DaoException {
DatabaseHelper.getEventDao().saveAndSnapshot(eventToSave);
}
@Override
protected void onPostExecute(AsyncTaskResult<TaskResultHolder> taskResult) {
hidePreloader();
super.onPostExecute(taskResult);
if (taskResult.getResultStatus().isSuccess()) {
goToNextPage();
} else {
// reload data
onResume();
}
saveTask = null;
}
}.executeOnThreadPool();
}
use of de.symeda.sormas.api.utils.ValidationException in project SORMAS-Project by hzi-braunschweig.
the class EventNewActivity method saveData.
@Override
public void saveData() {
if (saveTask != null) {
NotificationHelper.showNotification(this, WARNING, getString(R.string.message_already_saving));
// don't save multiple times
return;
}
final Event eventToSave = (Event) getActiveFragment().getPrimaryData();
EventEditFragment fragment = (EventEditFragment) getActiveFragment();
if (caseUuid != null) {
Case linkedCase = DatabaseHelper.getCaseDao().getByReferenceDto(new CaseReferenceDto(caseUuid));
if (eventToSave.getDisease() != null && !eventToSave.getDisease().equals(linkedCase.getDisease())) {
NotificationHelper.showNotification(this, WARNING, getString(R.string.message_Event_and_Case_disease_mismatch) + " " + linkedCase.getDisease());
return;
}
}
fragment.setLiveValidationDisabled(false);
try {
FragmentValidator.validate(getContext(), fragment.getContentBinding());
} catch (ValidationException e) {
NotificationHelper.showNotification(this, ERROR, e.getMessage());
return;
}
saveTask = new SavingAsyncTask(getRootView(), eventToSave) {
@Override
protected void onPreExecute() {
showPreloader();
}
@Override
public void doInBackground(TaskResultHolder resultHolder) throws DaoException {
DatabaseHelper.getEventDao().saveAndSnapshot(eventToSave);
}
@Override
protected void onPostExecute(AsyncTaskResult<TaskResultHolder> taskResult) {
hidePreloader();
super.onPostExecute(taskResult);
if (taskResult.getResultStatus().isSuccess()) {
finish();
if (caseUuid != null) {
EventParticipant eventParticipantToSave = DatabaseHelper.getEventParticipantDao().build();
Case linkedCase = DatabaseHelper.getCaseDao().getByReferenceDto(new CaseReferenceDto(caseUuid));
eventParticipantToSave.setPerson(linkedCase.getPerson());
eventParticipantToSave.setEvent(eventToSave);
eventParticipantToSave.setResultingCaseUuid(linkedCase.getUuid());
EventParticipantSaver eventParticipantSaver = new EventParticipantSaver(EventNewActivity.this);
eventParticipantSaver.saveEventParticipantLinkedToCase(eventParticipantToSave);
} else {
EventEditActivity.startActivity(getContext(), eventToSave.getUuid(), EventSection.EVENT_PARTICIPANTS);
}
}
saveTask = null;
}
}.executeOnThreadPool();
}
Aggregations