use of de.symeda.sormas.app.backend.event.Event in project SORMAS-Project by hzi-braunschweig.
the class CaseReadEventListFragment method onListItemClick.
@Override
public void onListItemClick(View v, int position, Object item) {
Event event = (Event) item;
EventReadActivity.startActivity(getActivity(), event.getUuid());
}
use of de.symeda.sormas.app.backend.event.Event 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.app.backend.event.Event 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();
}
use of de.symeda.sormas.app.backend.event.Event in project SORMAS-Project by hzi-braunschweig.
the class EventParticipantEditActivity method getPageMenuData.
@Override
public List<PageMenuItem> getPageMenuData() {
List<PageMenuItem> menuItems = PageMenuItem.fromEnum(EventParticipantSection.values(), getContext());
Event event = DatabaseHelper.getEventDao().queryUuid(eventUuid);
if (!ConfigProvider.hasUserRight(UserRight.IMMUNIZATION_VIEW) || DatabaseHelper.getFeatureConfigurationDao().isPropertyValueTrue(FeatureType.IMMUNIZATION_MANAGEMENT, FeatureTypeProperty.REDUCED)) {
menuItems.set(EventParticipantSection.IMMUNIZATIONS.ordinal(), null);
}
if (!ConfigProvider.hasUserRight(UserRight.IMMUNIZATION_VIEW) || !DatabaseHelper.getFeatureConfigurationDao().isPropertyValueTrue(FeatureType.IMMUNIZATION_MANAGEMENT, FeatureTypeProperty.REDUCED) || event.getDisease() == null) {
menuItems.set(EventParticipantSection.VACCINATIONS.ordinal(), null);
}
return menuItems;
}
use of de.symeda.sormas.app.backend.event.Event in project SORMAS-Project by hzi-braunschweig.
the class EventParticipantNewActivity 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 EventParticipant eventParticipantToSave = (EventParticipant) getActiveFragment().getPrimaryData();
EventParticipantNewFragment fragment = (EventParticipantNewFragment) getActiveFragment();
fragment.setLiveValidationDisabled(false);
try {
FragmentValidator.validate(getContext(), fragment.getContentBinding());
} catch (ValidationException e) {
NotificationHelper.showNotification(this, ERROR, e.getMessage());
return;
}
SelectOrCreatePersonDialog.selectOrCreatePerson(eventParticipantToSave.getPerson(), new Consumer<Person>() {
@Override
public void accept(Person person) {
eventParticipantToSave.setPerson(person);
saveTask = new SavingAsyncTask(getRootView(), eventParticipantToSave) {
@Override
protected void onPreExecute() {
showPreloader();
}
@Override
protected void doInBackground(TaskResultHolder resultHolder) throws Exception {
DatabaseHelper.getPersonDao().saveAndSnapshot(eventParticipantToSave.getPerson());
final Event event = DatabaseHelper.getEventDao().queryUuid(eventUuid);
eventParticipantToSave.setEvent(event);
DatabaseHelper.getEventParticipantDao().saveAndSnapshot(eventParticipantToSave);
}
@Override
protected void onPostExecute(AsyncTaskResult<TaskResultHolder> taskResult) {
hidePreloader();
super.onPostExecute(taskResult);
if (taskResult.getResultStatus().isSuccess()) {
EventParticipantEditActivity.startActivity(getContext(), getRootUuid(), eventUuid, EventParticipantSection.EVENT_PARTICIPANT_INFO);
}
saveTask = null;
}
}.executeOnThreadPool();
}
});
}
Aggregations