use of de.symeda.sormas.app.backend.person.Person in project SORMAS-Project by hzi-braunschweig.
the class ContactDtoHelper method fillInnerFromAdo.
@Override
public void fillInnerFromAdo(ContactDto target, Contact source) {
if (source.getPerson() != null) {
Person person = DatabaseHelper.getPersonDao().queryForId(source.getPerson().getId());
target.setPerson(PersonDtoHelper.toReferenceDto(person));
} else {
target.setPerson(null);
}
if (source.getRegion() != null) {
Region region = DatabaseHelper.getRegionDao().queryForId(source.getRegion().getId());
target.setRegion(RegionDtoHelper.toReferenceDto(region));
} else {
target.setRegion(null);
}
if (source.getDistrict() != null) {
District district = DatabaseHelper.getDistrictDao().queryForId(source.getDistrict().getId());
target.setDistrict(DistrictDtoHelper.toReferenceDto(district));
} else {
target.setDistrict(null);
}
if (source.getCommunity() != null) {
Community community = DatabaseHelper.getCommunityDao().queryForId(source.getCommunity().getId());
target.setCommunity(CommunityDtoHelper.toReferenceDto(community));
} else {
target.setCommunity(null);
}
if (source.getCaseUuid() != null) {
target.setCaze(new CaseReferenceDto(source.getCaseUuid()));
} else {
target.setCaze(null);
}
if (source.getResultingCaseUuid() != null) {
target.setResultingCase(new CaseReferenceDto(source.getResultingCaseUuid()));
} else {
target.setResultingCase(null);
}
target.setDisease(source.getDisease());
target.setDiseaseDetails(source.getDiseaseDetails());
if (source.getReportingUser() != null) {
User user = DatabaseHelper.getUserDao().queryForId(source.getReportingUser().getId());
target.setReportingUser(UserDtoHelper.toReferenceDto(user));
} else {
target.setReportingUser(null);
}
target.setReportDateTime(source.getReportDateTime());
target.setMultiDayContact(source.isMultiDayContact());
target.setFirstContactDate(source.getFirstContactDate());
target.setLastContactDate(source.getLastContactDate());
target.setContactIdentificationSource(source.getContactIdentificationSource());
target.setContactIdentificationSourceDetails(source.getContactIdentificationSourceDetails());
target.setTracingApp(source.getTracingApp());
target.setTracingAppDetails(source.getTracingAppDetails());
target.setContactProximity(source.getContactProximity());
target.setContactClassification(source.getContactClassification());
target.setContactStatus(source.getContactStatus());
target.setRelationToCase(source.getRelationToCase());
target.setRelationDescription(source.getRelationDescription());
target.setFollowUpStatus(source.getFollowUpStatus());
target.setFollowUpComment(source.getFollowUpComment());
target.setFollowUpUntil(source.getFollowUpUntil());
if (source.getContactOfficer() != null) {
User user = DatabaseHelper.getUserDao().queryForId(source.getContactOfficer().getId());
target.setContactOfficer(UserDtoHelper.toReferenceDto(user));
} else {
target.setContactOfficer(null);
}
target.setDescription(source.getDescription());
target.setReportLat(source.getReportLat());
target.setReportLon(source.getReportLon());
target.setReportLatLonAccuracy(source.getReportLatLonAccuracy());
target.setExternalID(source.getExternalID());
target.setExternalToken(source.getExternalToken());
target.setInternalToken(source.getInternalToken());
target.setHighPriority(source.isHighPriority());
target.setImmunosuppressiveTherapyBasicDisease(source.getImmunosuppressiveTherapyBasicDisease());
target.setImmunosuppressiveTherapyBasicDiseaseDetails(source.getImmunosuppressiveTherapyBasicDiseaseDetails());
target.setCareForPeopleOver60(source.getCareForPeopleOver60());
target.setQuarantine(source.getQuarantine());
target.setQuarantineTypeDetails(source.getQuarantineTypeDetails());
target.setQuarantineFrom(source.getQuarantineFrom());
target.setQuarantineTo(source.getQuarantineTo());
target.setCaseIdExternalSystem(source.getCaseIdExternalSystem());
target.setCaseOrEventInformation(source.getCaseOrEventInformation());
target.setQuarantineHelpNeeded(source.getQuarantineHelpNeeded());
target.setQuarantineOrderedVerbally(source.isQuarantineOrderedVerbally());
target.setQuarantineOrderedOfficialDocument(source.isQuarantineOrderedOfficialDocument());
target.setQuarantineOrderedVerballyDate(source.getQuarantineOrderedVerballyDate());
target.setQuarantineOrderedOfficialDocumentDate(source.getQuarantineOrderedOfficialDocumentDate());
target.setQuarantineExtended(source.isQuarantineExtended());
target.setQuarantineReduced(source.isQuarantineReduced());
target.setQuarantineHomePossible(source.getQuarantineHomePossible());
target.setQuarantineHomePossibleComment(source.getQuarantineHomePossibleComment());
target.setQuarantineHomeSupplyEnsured(source.getQuarantineHomeSupplyEnsured());
target.setQuarantineHomeSupplyEnsuredComment(source.getQuarantineHomeSupplyEnsuredComment());
target.setQuarantineOfficialOrderSent(source.isQuarantineOfficialOrderSent());
target.setQuarantineOfficialOrderSentDate(source.getQuarantineOfficialOrderSentDate());
target.setAdditionalDetails(source.getAdditionalDetails());
if (source.getEpiData() != null) {
EpiData epiData = DatabaseHelper.getEpiDataDao().queryForId(source.getEpiData().getId());
target.setEpiData(epiDataDtoHelper.adoToDto(epiData));
} else {
target.setEpiData(null);
}
if (source.getHealthConditions() != null) {
HealthConditions healthConditions = DatabaseHelper.getHealthConditionsDao().queryForId(source.getHealthConditions().getId());
target.setHealthConditions(healthConditionsDtoHelper.adoToDto(healthConditions));
} else {
target.setHealthConditions(null);
}
if (source.getSormasToSormasOriginInfo() != null) {
target.setSormasToSormasOriginInfo(sormasToSormasOriginInfoDtoHelper.adoToDto(source.getSormasToSormasOriginInfo()));
}
target.setEndOfQuarantineReason(source.getEndOfQuarantineReason());
target.setEndOfQuarantineReasonDetails(source.getEndOfQuarantineReasonDetails());
target.setPseudonymized(source.isPseudonymized());
target.setReturningTraveler(source.getReturningTraveler());
target.setProhibitionToWork(source.getProhibitionToWork());
target.setProhibitionToWorkFrom(source.getProhibitionToWorkFrom());
target.setProhibitionToWorkUntil(source.getProhibitionToWorkUntil());
if (source.getReportingDistrict() != null) {
District district = DatabaseHelper.getDistrictDao().queryForId(source.getReportingDistrict().getId());
target.setReportingDistrict(DistrictDtoHelper.toReferenceDto(district));
} else {
target.setReportingDistrict(null);
}
target.setFollowUpStatusChangeDate(source.getFollowUpStatusChangeDate());
target.setFollowUpStatusChangeUser(UserDtoHelper.toReferenceDto(source.getFollowUpStatusChangeUser()));
target.setVaccinationStatus(source.getVaccinationStatus());
}
use of de.symeda.sormas.app.backend.person.Person in project SORMAS-Project by hzi-braunschweig.
the class DatabaseHelper method migratePersonContactDetails.
private void migratePersonContactDetails() throws SQLException {
GenericRawResults<Object[]> newPersons = getDao(Person.class).queryRaw("SELECT id, phone, phoneOwner, emailAddress, generalPractitionerDetails FROM person WHERE changeDate = 0 AND snapshot = 0;", new DataType[] { DataType.BIG_INTEGER, DataType.STRING, DataType.STRING, DataType.STRING, DataType.STRING });
for (Object[] pcd : newPersons) {
final String insertQuery = "INSERT INTO personContactDetail " + "(" + " uuid, changeDate, localChangeDate, creationDate, person_id, primaryContact, " + " personContactDetailType, phoneNumberType, contactInformation, additionalInformation, " + " thirdParty, thirdPartyRole, thirdPartyName, snapshot" + ") " + "VALUES (?, ?, " + generateDateNowSQL() + ", " + generateDateNowSQL() + ", ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);";
BigInteger personId = (BigInteger) pcd[0];
String phone = (String) pcd[1];
String phoneOwner = (String) pcd[2];
String emailAddress = (String) pcd[3];
String generalPractitionerDetails = (String) pcd[4];
if (StringUtils.isNotEmpty(phone)) {
boolean phoneOwnerEmpty = StringUtils.isEmpty(phoneOwner);
executeRaw(PersonContactDetail.class, insertQuery, DataHelper.createUuid(), 0, personId, (phoneOwnerEmpty ? 1 : 0), PersonContactDetailType.PHONE.name(), null, phone, null, (phoneOwnerEmpty ? 0 : 1), null, (phoneOwnerEmpty ? null : phoneOwner), 0);
}
if (StringUtils.isNotEmpty(emailAddress)) {
executeRaw(PersonContactDetail.class, insertQuery, DataHelper.createUuid(), 0, personId, 1, PersonContactDetailType.EMAIL.name(), null, emailAddress, null, 0, null, null, 0);
}
if (StringUtils.isNotEmpty(generalPractitionerDetails)) {
executeRaw(PersonContactDetail.class, insertQuery, DataHelper.createUuid(), 0, personId, 0, PersonContactDetailType.OTHER.name(), null, null, generalPractitionerDetails, 1, "General practitioner", generalPractitionerDetails, 0);
}
}
}
use of de.symeda.sormas.app.backend.person.Person 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();
}
});
}
use of de.symeda.sormas.app.backend.person.Person in project SORMAS-Project by hzi-braunschweig.
the class CaseDtoHelper method fillInnerFromAdo.
@Override
public void fillInnerFromAdo(CaseDataDto target, Case source) {
target.setClinicalConfirmation(source.getClinicalConfirmation());
target.setEpidemiologicalConfirmation(source.getEpidemiologicalConfirmation());
target.setLaboratoryDiagnosticConfirmation(source.getLaboratoryDiagnosticConfirmation());
target.setCaseClassification(source.getCaseClassification());
target.setCaseIdentificationSource(source.getCaseIdentificationSource());
target.setScreeningType(source.getScreeningType());
if (source.getClassificationUser() != null) {
User user = DatabaseHelper.getUserDao().queryForId(source.getClassificationUser().getId());
target.setClassificationUser(UserDtoHelper.toReferenceDto(user));
} else {
target.setClassificationUser(null);
}
target.setClassificationDate(source.getClassificationDate());
target.setClassificationComment(source.getClassificationComment());
target.setInvestigationStatus(source.getInvestigationStatus());
target.setDisease(source.getDisease());
target.setDiseaseVariant(source.getDiseaseVariant());
target.setDiseaseDetails(source.getDiseaseDetails());
target.setDiseaseVariantDetails(source.getDiseaseVariantDetails());
target.setPlagueType(source.getPlagueType());
target.setDengueFeverType(source.getDengueFeverType());
if (source.getHealthFacility() != null) {
Facility facility = DatabaseHelper.getFacilityDao().queryForId(source.getHealthFacility().getId());
target.setHealthFacility(FacilityDtoHelper.toReferenceDto(facility));
} else {
target.setHealthFacility(null);
}
target.setHealthFacilityDetails(source.getHealthFacilityDetails());
if (source.getPerson() != null) {
Person person = DatabaseHelper.getPersonDao().queryForId(source.getPerson().getId());
target.setPerson(PersonDtoHelper.toReferenceDto(person));
}
target.setInvestigatedDate(source.getInvestigatedDate());
target.setReportDate(source.getReportDate());
target.setDistrictLevelDate(source.getDistrictLevelDate());
if (source.getReportingUser() != null) {
User user = DatabaseHelper.getUserDao().queryForId(source.getReportingUser().getId());
target.setReportingUser(UserDtoHelper.toReferenceDto(user));
} else {
target.setReportingUser(null);
}
if (source.getSymptoms() != null) {
Symptoms symptoms = DatabaseHelper.getSymptomsDao().queryForId(source.getSymptoms().getId());
SymptomsDto symptomsDto = symptomsDtoHelper.adoToDto(symptoms);
target.setSymptoms(symptomsDto);
} else {
target.setSymptoms(null);
}
if (source.getResponsibleRegion() != null) {
Region region = DatabaseHelper.getRegionDao().queryForId(source.getResponsibleRegion().getId());
target.setResponsibleRegion(RegionDtoHelper.toReferenceDto(region));
} else {
target.setResponsibleRegion(null);
}
if (source.getResponsibleDistrict() != null) {
District district = DatabaseHelper.getDistrictDao().queryForId(source.getResponsibleDistrict().getId());
target.setResponsibleDistrict(DistrictDtoHelper.toReferenceDto(district));
} else {
target.setResponsibleDistrict(null);
}
if (source.getResponsibleCommunity() != null) {
Community community = DatabaseHelper.getCommunityDao().queryForId(source.getResponsibleCommunity().getId());
target.setResponsibleCommunity(CommunityDtoHelper.toReferenceDto(community));
} else {
target.setResponsibleCommunity(null);
}
if (source.getRegion() != null) {
Region region = DatabaseHelper.getRegionDao().queryForId(source.getRegion().getId());
target.setRegion(RegionDtoHelper.toReferenceDto(region));
} else {
target.setRegion(null);
}
if (source.getDistrict() != null) {
District district = DatabaseHelper.getDistrictDao().queryForId(source.getDistrict().getId());
target.setDistrict(DistrictDtoHelper.toReferenceDto(district));
} else {
target.setDistrict(null);
}
if (source.getCommunity() != null) {
Community community = DatabaseHelper.getCommunityDao().queryForId(source.getCommunity().getId());
target.setCommunity(CommunityDtoHelper.toReferenceDto(community));
} else {
target.setCommunity(null);
}
if (source.getPointOfEntry() != null) {
PointOfEntry pointOfEntry = DatabaseHelper.getPointOfEntryDao().queryForId(source.getPointOfEntry().getId());
target.setPointOfEntry(PointOfEntryDtoHelper.toReferenceDto(pointOfEntry));
} else {
target.setPointOfEntry(null);
}
target.setPointOfEntryDetails(source.getPointOfEntryDetails());
if (source.getSurveillanceOfficer() != null) {
User user = DatabaseHelper.getUserDao().queryForId(source.getSurveillanceOfficer().getId());
target.setSurveillanceOfficer(UserDtoHelper.toReferenceDto(user));
} else {
target.setSurveillanceOfficer(null);
}
if (source.getHospitalization() != null) {
Hospitalization hospitalization = DatabaseHelper.getHospitalizationDao().queryForId(source.getHospitalization().getId());
target.setHospitalization(hospitalizationDtoHelper.adoToDto(hospitalization));
} else {
target.setHospitalization(null);
}
if (source.getEpiData() != null) {
EpiData epiData = DatabaseHelper.getEpiDataDao().queryForId(source.getEpiData().getId());
target.setEpiData(epiDataDtoHelper.adoToDto(epiData));
} else {
target.setEpiData(null);
}
if (source.getTherapy() != null) {
Therapy therapy = DatabaseHelper.getTherapyDao().queryForId(source.getTherapy().getId());
target.setTherapy(therapyDtoHelper.adoToDto(therapy));
} else {
target.setTherapy(null);
}
if (source.getClinicalCourse() != null) {
ClinicalCourse clinicalCourse = DatabaseHelper.getClinicalCourseDao().queryForId(source.getClinicalCourse().getId());
target.setClinicalCourse(clinicalCourseDtoHelper.adoToDto(clinicalCourse));
} else {
target.setClinicalCourse(null);
}
if (source.getMaternalHistory() != null) {
target.setMaternalHistory(maternalHistoryDtoHelper.adoToDto(DatabaseHelper.getMaternalHistoryDao().queryForId(source.getMaternalHistory().getId())));
} else {
target.setMaternalHistory(null);
}
if (source.getPortHealthInfo() != null) {
target.setPortHealthInfo(portHealthInfoDtoHelper.adoToDto(DatabaseHelper.getPortHealthInfoDao().queryForId(source.getPortHealthInfo().getId())));
} else {
target.setPortHealthInfo(null);
}
target.setClinicianName(source.getClinicianName());
target.setClinicianPhone(source.getClinicianPhone());
target.setClinicianEmail(source.getClinicianEmail());
target.setPregnant(source.getPregnant());
target.setVaccinationStatus(source.getVaccinationStatus());
target.setSmallpoxVaccinationScar(source.getSmallpoxVaccinationScar());
target.setSmallpoxVaccinationReceived(source.getSmallpoxVaccinationReceived());
target.setSmallpoxLastVaccinationDate(source.getSmallpoxLastVaccinationDate());
target.setEpidNumber(source.getEpidNumber());
target.setCaseOrigin(source.getCaseOrigin());
target.setReportLat(source.getReportLat());
target.setReportLon(source.getReportLon());
target.setReportLatLonAccuracy(source.getReportLatLonAccuracy());
target.setOutcome(source.getOutcome());
target.setOutcomeDate(source.getOutcomeDate());
target.setSequelae(source.getSequelae());
target.setSequelaeDetails(source.getSequelaeDetails());
target.setNotifyingClinic(source.getNotifyingClinic());
target.setNotifyingClinicDetails(source.getNotifyingClinicDetails());
target.setRabiesType(source.getRabiesType());
target.setCreationVersion(source.getCreationVersion());
target.setAdditionalDetails(source.getAdditionalDetails());
target.setExternalID(source.getExternalID());
target.setExternalToken(source.getExternalToken());
target.setInternalToken(source.getInternalToken());
target.setQuarantine(source.getQuarantine());
target.setQuarantineTypeDetails(source.getQuarantineTypeDetails());
target.setQuarantineFrom(source.getQuarantineFrom());
target.setQuarantineTo(source.getQuarantineTo());
target.setQuarantineHelpNeeded(source.getQuarantineHelpNeeded());
target.setQuarantineOrderedVerbally(source.isQuarantineOrderedVerbally());
target.setQuarantineOrderedOfficialDocument(source.isQuarantineOrderedOfficialDocument());
target.setQuarantineOrderedVerballyDate(source.getQuarantineOrderedVerballyDate());
target.setQuarantineOrderedOfficialDocumentDate(source.getQuarantineOrderedOfficialDocumentDate());
target.setQuarantineExtended(source.isQuarantineExtended());
target.setQuarantineReduced(source.isQuarantineReduced());
target.setQuarantineHomePossible(source.getQuarantineHomePossible());
target.setQuarantineHomePossibleComment(source.getQuarantineHomePossibleComment());
target.setQuarantineHomeSupplyEnsured(source.getQuarantineHomeSupplyEnsured());
target.setQuarantineHomeSupplyEnsuredComment(source.getQuarantineHomeSupplyEnsuredComment());
target.setQuarantineOfficialOrderSent(source.isQuarantineOfficialOrderSent());
target.setQuarantineOfficialOrderSentDate(source.getQuarantineOfficialOrderSentDate());
target.setPostpartum(source.getPostpartum());
target.setTrimester(source.getTrimester());
target.setPseudonymized(source.isPseudonymized());
target.setFacilityType(source.getFacilityType());
target.setCaseIdIsm(source.getCaseIdIsm());
target.setContactTracingFirstContactType(source.getContactTracingFirstContactType());
target.setContactTracingFirstContactDate(source.getContactTracingFirstContactDate());
target.setWasInQuarantineBeforeIsolation(source.getWasInQuarantineBeforeIsolation());
target.setQuarantineReasonBeforeIsolation(source.getQuarantineReasonBeforeIsolation());
target.setQuarantineReasonBeforeIsolationDetails(source.getQuarantineReasonBeforeIsolationDetails());
target.setEndOfIsolationReason(source.getEndOfIsolationReason());
target.setEndOfIsolationReasonDetails(source.getEndOfIsolationReasonDetails());
target.setNosocomialOutbreak(source.isNosocomialOutbreak());
target.setInfectionSetting(source.getInfectionSetting());
target.setProhibitionToWork(source.getProhibitionToWork());
target.setProhibitionToWorkFrom(source.getProhibitionToWorkFrom());
target.setProhibitionToWorkUntil(source.getProhibitionToWorkUntil());
target.setReInfection(source.getReInfection());
target.setPreviousInfectionDate(source.getPreviousInfectionDate());
target.setBloodOrganOrTissueDonated(source.getBloodOrganOrTissueDonated());
if (source.getSormasToSormasOriginInfo() != null) {
target.setSormasToSormasOriginInfo(sormasToSormasOriginInfoDtoHelper.adoToDto(source.getSormasToSormasOriginInfo()));
}
target.setOwnershipHandedOver(source.isOwnershipHandedOver());
target.setNotACaseReasonNegativeTest(source.isNotACaseReasonNegativeTest());
target.setNotACaseReasonPhysicianInformation(source.isNotACaseReasonPhysicianInformation());
target.setNotACaseReasonDifferentPathogen(source.isNotACaseReasonDifferentPathogen());
target.setNotACaseReasonOther(source.isNotACaseReasonOther());
target.setNotACaseReasonDetails(source.getNotACaseReasonDetails());
target.setFollowUpStatusChangeDate(source.getFollowUpStatusChangeDate());
target.setFollowUpStatusChangeUser(UserDtoHelper.toReferenceDto(source.getFollowUpStatusChangeUser()));
if (source.getHealthConditions() != null) {
HealthConditions healthConditions = DatabaseHelper.getHealthConditionsDao().queryForId(source.getHealthConditions().getId());
target.setHealthConditions(healthConditionsDtoHelper.adoToDto(healthConditions));
} else {
target.setHealthConditions(null);
}
}
use of de.symeda.sormas.app.backend.person.Person in project SORMAS-Project by hzi-braunschweig.
the class SettingsFragment method showRepullDataConfirmationDialog.
private void showRepullDataConfirmationDialog() {
final ConfirmationDialog confirmationDialog = new ConfirmationDialog(getActivity(), R.string.heading_confirmation_dialog, R.string.info_resync_duration);
confirmationDialog.setPositiveCallback(() -> {
// Collect unsynchronized changes
final List<Case> modifiedCases = DatabaseHelper.getCaseDao().getModifiedEntities();
final List<Contact> modifiedContacts = DatabaseHelper.getContactDao().getModifiedEntities();
final List<Person> modifiedPersons = DatabaseHelper.getPersonDao().getModifiedEntities();
final List<Event> modifiedEvents = DatabaseHelper.getEventDao().getModifiedEntities();
final List<EventParticipant> modifiedEventParticipants = DatabaseHelper.getEventParticipantDao().getModifiedEntities();
final List<Sample> modifiedSamples = DatabaseHelper.getSampleDao().getModifiedEntities();
final List<Visit> modifiedVisits = DatabaseHelper.getVisitDao().getModifiedEntities();
getBaseActivity().synchronizeData(SynchronizeDataAsync.SyncMode.CompleteAndRepull, true, true, null, new Callback() {
@Override
public void call() {
// Add deleted entities that had unsynchronized changes to sync log
for (Case caze : modifiedCases) {
if (DatabaseHelper.getCaseDao().queryUuidReference(caze.getUuid()) == null) {
DatabaseHelper.getSyncLogDao().createWithParentStack(caze.toString(), getResources().getString(R.string.caption_changed_data_lost));
}
}
for (Contact contact : modifiedContacts) {
if (DatabaseHelper.getContactDao().queryUuidReference(contact.getUuid()) == null) {
DatabaseHelper.getSyncLogDao().createWithParentStack(contact.toString(), getResources().getString(R.string.caption_changed_data_lost));
}
}
for (Person person : modifiedPersons) {
if (DatabaseHelper.getPersonDao().queryUuidReference(person.getUuid()) == null) {
DatabaseHelper.getSyncLogDao().createWithParentStack(person.toString(), getResources().getString(R.string.caption_changed_data_lost));
}
}
for (Event event : modifiedEvents) {
if (DatabaseHelper.getEventDao().queryUuidReference(event.getUuid()) == null) {
DatabaseHelper.getSyncLogDao().createWithParentStack(event.toString(), getResources().getString(R.string.caption_changed_data_lost));
}
}
for (EventParticipant eventParticipant : modifiedEventParticipants) {
if (DatabaseHelper.getEventParticipantDao().queryUuidReference(eventParticipant.getUuid()) == null) {
DatabaseHelper.getSyncLogDao().createWithParentStack(eventParticipant.toString(), getResources().getString(R.string.caption_changed_data_lost));
}
}
for (Sample sample : modifiedSamples) {
if (DatabaseHelper.getSampleDao().queryUuidReference(sample.getUuid()) == null) {
DatabaseHelper.getSyncLogDao().createWithParentStack(sample.toString(), getResources().getString(R.string.caption_changed_data_lost));
}
}
for (Visit visit : modifiedVisits) {
if (DatabaseHelper.getVisitDao().queryUuidReference(visit.getUuid()) == null) {
DatabaseHelper.getSyncLogDao().createWithParentStack(visit.toString(), getResources().getString(R.string.caption_changed_data_lost));
}
}
}
}, new Callback() {
@Override
public void call() {
DatabaseHelper.clearTables(false);
}
});
});
confirmationDialog.show();
}
Aggregations