use of de.symeda.sormas.app.backend.contact.Contact in project SORMAS-Project by hzi-braunschweig.
the class CaseReadContactListFragment method onListItemClick.
@Override
public void onListItemClick(View view, int position, Object item) {
Contact contact = (Contact) item;
ContactReadActivity.startActivity(getActivity(), contact.getUuid(), true);
}
use of de.symeda.sormas.app.backend.contact.Contact 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.app.backend.contact.Contact in project SORMAS-Project by hzi-braunschweig.
the class ExposureDtoHelper method fillInnerFromAdo.
@Override
protected void fillInnerFromAdo(ExposureDto target, Exposure source) {
if (source.getLocation() != null) {
Location location = DatabaseHelper.getLocationDao().queryForId(source.getLocation().getId());
target.setLocation(locationDtoHelper.adoToDto(location));
} else {
target.setLocation(null);
}
if (source.getContactToCase() != null) {
Contact contactToCase = DatabaseHelper.getContactDao().queryForId(source.getContactToCase().getId());
target.setContactToCase(ContactDtoHelper.toReferenceDto(contactToCase));
} else {
target.setContactToCase(null);
}
if (source.getReportingUser() != null) {
User reportingUser = DatabaseHelper.getUserDao().queryForId(source.getReportingUser().getId());
target.setReportingUser(UserDtoHelper.toReferenceDto(reportingUser));
} else {
target.setReportingUser(null);
}
target.setAnimalCondition(source.getAnimalCondition());
target.setTypeOfAnimal(source.getTypeOfAnimal());
target.setTypeOfAnimalDetails(source.getTypeOfAnimalDetails());
target.setExposureRole(source.getExposureRole());
target.setAnimalContactType(source.getAnimalContactType());
target.setAnimalContactTypeDetails(source.getAnimalContactTypeDetails());
target.setAnimalMarket(source.getAnimalMarket());
target.setAnimalVaccinated(source.getAnimalVaccinated());
target.setContactToBodyFluids(source.getContactToBodyFluids());
target.setDeceasedPersonIll(source.getDeceasedPersonIll());
target.setDeceasedPersonName(source.getDeceasedPersonName());
target.setDeceasedPersonRelation(source.getDeceasedPersonRelation());
target.setDescription(source.getDescription());
target.setEatingRawAnimalProducts(source.getEatingRawAnimalProducts());
target.setEndDate(source.getEndDate());
target.setExposureType(source.getExposureType());
target.setExposureTypeDetails(source.getExposureTypeDetails());
target.setGatheringDetails(source.getGatheringDetails());
target.setGatheringType(source.getGatheringType());
target.setHabitationDetails(source.getHabitationDetails());
target.setHabitationType(source.getHabitationType());
target.setHandlingAnimals(source.getHandlingAnimals());
target.setHandlingSamples(source.getHandlingSamples());
target.setIndoors(source.getIndoors());
target.setLongFaceToFaceContact(source.getLongFaceToFaceContact());
target.setOtherProtectiveMeasures(source.getOtherProtectiveMeasures());
target.setProtectiveMeasuresDetails(source.getProtectiveMeasuresDetails());
target.setOutdoors(source.getOutdoors());
target.setPercutaneous(source.getPercutaneous());
target.setPhysicalContactDuringPreparation(source.getPhysicalContactDuringPreparation());
target.setPhysicalContactWithBody(source.getPhysicalContactWithBody());
target.setShortDistance(source.getShortDistance());
target.setProbableInfectionEnvironment(source.isProbableInfectionEnvironment());
target.setStartDate(source.getStartDate());
target.setWearingMask(source.getWearingMask());
target.setWearingPpe(source.getWearingPpe());
target.setTypeOfPlace(source.getTypeOfPlace());
target.setTypeOfPlaceDetails(source.getTypeOfPlaceDetails());
target.setMeansOfTransport(source.getMeansOfTransport());
target.setMeansOfTransportDetails(source.getMeansOfTransportDetails());
target.setConnectionNumber(source.getConnectionNumber());
target.setSeatNumber(source.getSeatNumber());
target.setWorkEnvironment(source.getWorkEnvironment());
target.setBodyOfWater(source.getBodyOfWater());
target.setWaterSource(source.getWaterSource());
target.setWaterSourceDetails(source.getWaterSourceDetails());
target.setProphylaxis(source.getProphylaxis());
target.setProphylaxisDate(source.getProphylaxisDate());
target.setRiskArea(source.getRiskArea());
target.setLargeAttendanceNumber(source.getLargeAttendanceNumber());
}
use of de.symeda.sormas.app.backend.contact.Contact in project SORMAS-Project by hzi-braunschweig.
the class AbstractAdoDaoTest method testQueryForNew.
@Test
public void testQueryForNew() throws DaoException {
CaseDao caseDao = DatabaseHelper.getCaseDao();
// Case with change date 0 should be included
Case caseChangeDate0 = TestEntityCreator.createCase();
List<Case> newCases = caseDao.queryForNew();
assertEquals(1, newCases.size());
// Case with newer change date should not be included
Case caseNewChangeDate = TestEntityCreator.createCase();
caseNewChangeDate.setChangeDate(new Date());
caseDao.saveAndSnapshot(caseNewChangeDate);
newCases = caseDao.queryForNew();
assertEquals(1, newCases.size());
// Additional tests for other entities
Contact contact = TestEntityCreator.createContact(caseChangeDate0);
Visit visit = TestEntityCreator.createVisit(contact);
Sample sample = TestEntityCreator.createSample(caseChangeDate0);
Event event = TestEntityCreator.createEvent();
EventParticipant eventParticipant = TestEntityCreator.createEventParticipant(event);
assertEquals(1, DatabaseHelper.getContactDao().queryForNew().size());
assertEquals(1, DatabaseHelper.getVisitDao().queryForNew().size());
assertEquals(1, DatabaseHelper.getSampleDao().queryForNew().size());
assertEquals(1, DatabaseHelper.getEventDao().queryForNew().size());
assertEquals(1, DatabaseHelper.getEventParticipantDao().queryForNew().size());
}
use of de.symeda.sormas.app.backend.contact.Contact in project SORMAS-Project by hzi-braunschweig.
the class CaseBackendTest method shouldDeleteWithDependingEntities.
@Test
public void shouldDeleteWithDependingEntities() throws DaoException, SQLException {
// Assure that there are no cases or depending entities in the app to start with
assertThat(DatabaseHelper.getCaseDao().queryForAll().size(), is(0));
assertThat(DatabaseHelper.getContactDao().queryForAll().size(), is(0));
assertThat(DatabaseHelper.getVisitDao().queryForAll().size(), is(0));
assertThat(DatabaseHelper.getSampleDao().queryForAll().size(), is(0));
assertThat(DatabaseHelper.getSampleTestDao().queryForAll().size(), is(0));
assertThat(DatabaseHelper.getTaskDao().queryForAll().size(), is(0));
Case caze = TestEntityCreator.createCase();
Contact contact = TestEntityCreator.createContact(caze);
TestEntityCreator.createVisit(contact);
Sample sample = TestEntityCreator.createSample(caze);
TestEntityCreator.createSampleTest(sample);
TestEntityCreator.createCaseTask(caze, TaskStatus.PENDING, caze.getReportingUser());
// Assure that the case and depending entities have been successfully created
assertThat(DatabaseHelper.getCaseDao().queryForAll().size(), is(1));
assertThat(DatabaseHelper.getContactDao().queryForAll().size(), is(1));
assertThat(DatabaseHelper.getVisitDao().queryForAll().size(), is(1));
assertThat(DatabaseHelper.getSampleDao().queryForAll().size(), is(1));
assertThat(DatabaseHelper.getSampleTestDao().queryForAll().size(), is(1));
assertThat(DatabaseHelper.getTaskDao().queryForAll().size(), is(1));
DatabaseHelper.getCaseDao().deleteCaseAndAllDependingEntities(caze.getUuid());
// Assure that there are no cases or depending entities in the app after the deletion
assertThat(DatabaseHelper.getCaseDao().queryForAll().size(), is(0));
assertThat(DatabaseHelper.getContactDao().queryForAll().size(), is(0));
assertThat(DatabaseHelper.getVisitDao().queryForAll().size(), is(0));
assertThat(DatabaseHelper.getSampleDao().queryForAll().size(), is(0));
assertThat(DatabaseHelper.getSampleTestDao().queryForAll().size(), is(0));
assertThat(DatabaseHelper.getTaskDao().queryForAll().size(), is(0));
}
Aggregations