Search in sources :

Example 1 with Transaction

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;
}
Also used : Medicine(m.co.rh.id.a_medic_log.base.entity.Medicine) MedicineState(m.co.rh.id.a_medic_log.base.state.MedicineState) MedicineReminder(m.co.rh.id.a_medic_log.base.entity.MedicineReminder) Transaction(androidx.room.Transaction)

Example 2 with Transaction

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);
            }
        }
    }
}
Also used : MedicineReminder(m.co.rh.id.a_medic_log.base.entity.MedicineReminder) Transaction(androidx.room.Transaction)

Example 3 with Transaction

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);
                }
            }
        }
    }
}
Also used : NoteAttachmentState(m.co.rh.id.a_medic_log.base.state.NoteAttachmentState) NoteAttachment(m.co.rh.id.a_medic_log.base.entity.NoteAttachment) Medicine(m.co.rh.id.a_medic_log.base.entity.Medicine) MedicineState(m.co.rh.id.a_medic_log.base.state.MedicineState) Note(m.co.rh.id.a_medic_log.base.entity.Note) NoteTag(m.co.rh.id.a_medic_log.base.entity.NoteTag) MedicineReminder(m.co.rh.id.a_medic_log.base.entity.MedicineReminder) Transaction(androidx.room.Transaction)

Example 4 with Transaction

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);
}
Also used : Note(m.co.rh.id.a_medic_log.base.entity.Note) Transaction(androidx.room.Transaction)

Example 5 with Transaction

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);
}
Also used : ModificationSignatureEntity(com.github.dedis.popstellar.repository.local.entities.ModificationSignatureEntity) Transaction(androidx.room.Transaction)

Aggregations

Transaction (androidx.room.Transaction)12 MedicineReminder (m.co.rh.id.a_medic_log.base.entity.MedicineReminder)4 NoteAttachment (m.co.rh.id.a_medic_log.base.entity.NoteAttachment)4 Medicine (m.co.rh.id.a_medic_log.base.entity.Medicine)3 Note (m.co.rh.id.a_medic_log.base.entity.Note)3 ModificationSignatureEntity (com.github.dedis.popstellar.repository.local.entities.ModificationSignatureEntity)2 Date (java.util.Date)2 MedicineState (m.co.rh.id.a_medic_log.base.state.MedicineState)2 NoteAttachmentFile (m.co.rh.id.a_medic_log.base.entity.NoteAttachmentFile)1 NoteTag (m.co.rh.id.a_medic_log.base.entity.NoteTag)1 NoteAttachmentState (m.co.rh.id.a_medic_log.base.state.NoteAttachmentState)1