public List retrieveAttachmentsByCustomerId(long customerId) throws RemoteException { List attachments = new ArrayList(); AttachmentDAO attachmentDAO = new AttachmentDAO(conn); attachments = attachmentDAO.retrieveAttachmentsByCustomerId(customerId); USFEnv.getLog().writeDebug("attachments size is......" + attachments.size(), this, null); return attachments; }
// Get all attachments for incident public List<Attachment> getAllAttachmentsForIncident(long incident_id) { List<Attachment> attachments = new ArrayList<>(); String selectQuery = "SELECT Id, Incident_Id, Attachment_Id FROM " + Constants.TABLE_INCIDENT_ATTACHMENT; Log.e(LOG, selectQuery); db = dbHelper.getReadableDatabase(); // Cursor c = db.rawQuery(selectQuery, null); Cursor c = db.query( Constants.TABLE_INCIDENT_ATTACHMENT, // a. table new String[] {"Id", "Incident_Id", "Attachment_Id"}, // b. column names " Incident_Id = ?", // c. selections new String[] {String.valueOf(incident_id)}, // d. selections args null, // e. group by null, // f. having null, // g. order by null); // looping through all rows and adding to list if (c.moveToFirst()) { do { Attachment anAttachment = attachment_dao.getAttachment(c.getInt(c.getColumnIndex("Attachment_Id"))); // adding to incident list attachments.add(anAttachment); } while (c.moveToNext()); } c.close(); return attachments; }
// Deleting all attachments for an Incident public void deleteAllAttachmentsForIncident(Incident incident) { db = dbHelper.getWritableDatabase(); if (incident.getAttachments().size() > 0) { for (Attachment anAttachment : incident.getAttachments()) { attachment_dao.deleteSingleAttachment(anAttachment); } } db.delete( Constants.TABLE_INCIDENT_ATTACHMENT, "Incident_Id" + " = ?", new String[] {String.valueOf(incident.getId())}); }
public void storeAttachment(Attachment attachment) throws RemoteException { AttachmentDAO attachmentDAO = new AttachmentDAO(conn); attachmentDAO.storeAttachment(attachment); }
public Attachment retrieveAttachmentByAttachmentId(long attachmentId) throws RemoteException { Attachment attachment = new Attachment(); AttachmentDAO attachmentDAO = new AttachmentDAO(conn); attachment = attachmentDAO.retrieveAttachmentByAttachmentId(attachmentId); return attachment; }