use of androidx.room.Transaction in project a-medic-log by rh-id.
the class MedicineDao method findMedicineStateByMedicineId.
@Transaction
public MedicineState findMedicineStateByMedicineId(long medicineId) {
MedicineState medicineState = new MedicineState();
Medicine medicine = findMedicineById(medicineId);
List<MedicineReminder> medicineReminders = findMedicineRemindersByMedicineId(medicineId);
medicineState.updateMedicine(medicine);
medicineState.updateMedicineReminderList(medicineReminders);
return medicineState;
}
use of androidx.room.Transaction in project a-medic-log by rh-id.
the class MedicineDao method updateMedicine.
@Transaction
public void updateMedicine(Medicine medicine, ArrayList<MedicineReminder> medicineReminders) {
update(medicine);
long medsId = medicine.id;
if (medicineReminders != null && !medicineReminders.isEmpty()) {
for (MedicineReminder medicineReminder : medicineReminders) {
medicineReminder.medicineId = medsId;
if (medicineReminder.id == null) {
insertMedicineReminder(medicineReminder);
} else {
update(medicineReminder);
}
}
}
}
use of androidx.room.Transaction in project a-medic-log by rh-id.
the class NoteDao method insertNote.
@Transaction
public void insertNote(NoteState noteState) {
Note note = noteState.getNote();
Set<NoteTag> noteTags = noteState.getNoteTagSet();
List<NoteAttachmentState> noteAttachmentStates = noteState.getNoteAttachmentStates();
List<MedicineState> medicineStates = noteState.getMedicineList();
long noteId = insert(note);
note.id = noteId;
if (noteTags != null && !noteTags.isEmpty()) {
for (NoteTag noteTag : noteTags) {
noteTag.noteId = noteId;
noteTag.id = insert(noteTag);
}
}
if (noteAttachmentStates != null && !noteAttachmentStates.isEmpty()) {
for (NoteAttachmentState noteAttachmentState : noteAttachmentStates) {
NoteAttachment noteAttachment = noteAttachmentState.getNoteAttachment();
noteAttachment.noteId = noteId;
insertNoteAttachment(noteAttachmentState);
}
}
if (medicineStates != null && !medicineStates.isEmpty()) {
for (MedicineState medicineState : medicineStates) {
Medicine medicine = medicineState.getMedicine();
medicine.noteId = noteId;
long medicineId = insert(medicine);
medicine.id = medicineId;
List<MedicineReminder> medicineReminders = medicineState.getMedicineReminderList();
if (medicineReminders != null && !medicineReminders.isEmpty()) {
for (MedicineReminder medicineReminder : medicineReminders) {
medicineReminder.medicineId = medicineId;
medicineReminder.id = insert(medicineReminder);
}
}
}
}
}
use of androidx.room.Transaction in project a-medic-log by rh-id.
the class NoteDao method updateNote.
@Transaction
public void updateNote(NoteState noteState) {
// only updating note information, medicine and others are updated,deleted,inserted fom UI
Note note = noteState.getNote();
update(note);
}
use of androidx.room.Transaction in project popstellar by dedis.
the class LAODao method updateLAO.
@Transaction
public void updateLAO(LAOEntity lao, List<PersonEntity> witnesses, List<ModificationSignatureEntity> signatures) {
// update the LAO
_updateLAO(lao);
// update witness
_updateWitness(lao, witnesses);
// add modification signatures
for (ModificationSignatureEntity signature : signatures) {
signature.identifier = lao.id;
}
_addModificationSignature(signatures);
}
Aggregations