use of m.co.rh.id.a_medic_log.base.entity.NoteAttachment 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 m.co.rh.id.a_medic_log.base.entity.NoteAttachment in project a-medic-log by rh-id.
the class NewNoteAttachmentCmd method valid.
public boolean valid(NoteAttachmentState noteAttachmentState) {
boolean isValid = false;
if (noteAttachmentState != null) {
NoteAttachment noteAttachment = noteAttachmentState.getNoteAttachment();
boolean nameValid;
if (noteAttachment.name != null && !noteAttachment.name.isEmpty()) {
nameValid = true;
mNameValidSubject.onNext("");
} else {
nameValid = false;
mNameValidSubject.onNext(mAppContext.getString(R.string.name_is_required));
}
isValid = nameValid;
}
return isValid;
}
use of m.co.rh.id.a_medic_log.base.entity.NoteAttachment in project a-medic-log by rh-id.
the class QueryNoteCmd method queryNoteAttachmentStateList.
private void queryNoteAttachmentStateList(NoteState noteState) {
Long noteId = noteState.getNoteId();
List<NoteAttachment> noteAttachments = mNoteDao.findNoteAttachmentsByNoteId(noteId);
if (!noteAttachments.isEmpty()) {
List<NoteAttachmentState> noteAttachmentStates = new ArrayList<>();
for (NoteAttachment noteAttachment : noteAttachments) {
List<NoteAttachmentFile> noteAttachmentFiles = mNoteDao.findNoteAttachmentFilesByAttachmentId(noteAttachment.id);
NoteAttachmentState noteAttachmentState = new NoteAttachmentState();
noteAttachmentState.updateNoteAttachment(noteAttachment);
noteAttachmentState.updateNoteAttachmentFileList(noteAttachmentFiles);
noteAttachmentStates.add(noteAttachmentState);
}
noteState.updateNoteAttachments(noteAttachmentStates);
}
}
use of m.co.rh.id.a_medic_log.base.entity.NoteAttachment in project a-medic-log by rh-id.
the class NoteDao method deleteNote.
@Transaction
public void deleteNote(NoteState noteState) {
Note note = noteState.getNote();
delete(note);
long noteId = note.id;
deleteNoteTagByNoteId(noteId);
List<NoteAttachment> noteAttachments = findNoteAttachmentsByNoteId(noteId);
if (noteAttachments != null && !noteAttachments.isEmpty()) {
deleteNoteAttachmentsByNoteId(noteId);
for (NoteAttachment noteAttachment : noteAttachments) {
deleteNoteAttachmentFilesByAttachmentId(noteAttachment.id);
}
}
List<Medicine> medicines = findMedicinesByNoteId(noteId);
if (medicines != null && !medicines.isEmpty()) {
deleteMedicinesByNoteId(noteId);
for (Medicine medicine : medicines) {
long medicineId = medicine.id;
deleteMedicineReminderByMedicineId(medicineId);
deleteMedicineIntakeByMedicineId(medicineId);
}
}
}
use of m.co.rh.id.a_medic_log.base.entity.NoteAttachment in project a-medic-log by rh-id.
the class NoteDao method deleteNoteAttachment.
@Transaction
public void deleteNoteAttachment(NoteAttachmentState noteAttachmentState) {
NoteAttachment noteAttachment = noteAttachmentState.getNoteAttachment();
Long noteAttachmentId = noteAttachment.id;
if (noteAttachmentId != null) {
deleteNoteAttachmentFilesByAttachmentId(noteAttachmentId);
delete(noteAttachment);
}
}
Aggregations