Esempio n. 1
0
  // Updating a Incident
  public void updateIncident(Incident incident) {
    db = dbHelper.getWritableDatabase();

    ContentValues values = new ContentValues();
    values.put("IncidentTypeId", incident.getIncidentType().getId());
    values.put("CreatedByContactId", incident.getCreatedBy().getId());
    values.put("IncidentDate", DateTimeHelper.formatToIS08601(incident.getIncidentDate()));
    values.put("Description", incident.getDescription());
    values.put("InitialAction", incident.getInitialAction());
    values.put("Reportable", incident.getReportable());

    // updating row
    db.update(
        Constants.TABLE_INCIDENT, values, "Id=?", new String[] {String.valueOf(incident.getId())});

    removeAllNotifyContactsFromIncident(incident.getId());

    if (incident.getNotifyContacts().size() > 0) {
      for (Contact c : incident.getNotifyContacts()) {
        addNotifyContactToIncident(incident, c);
      }
    }
  }
Esempio n. 2
0
  // *** Creating an Incident
  public long createIncident(Incident incident) {
    db = dbHelper.getWritableDatabase();

    ContentValues values = new ContentValues();
    values.put("IncidentTypeId", incident.getIncidentType().getId());
    values.put("CreatedByContactId", incident.getCreatedBy().getId());
    values.put("IncidentDate", DateTimeHelper.formatToIS08601(incident.getIncidentDate()));
    values.put("Description", incident.getDescription());
    values.put("InitialAction", incident.getInitialAction());
    values.put("Reportable", incident.getReportable());

    // insert row
    long incident_id = db.insert(Constants.TABLE_INCIDENT, null, values);

    incident.setId((int) incident_id);

    if (incident.getNotifyContacts().size() > 0) {
      for (Contact c : incident.getNotifyContacts()) {
        addNotifyContactToIncident(incident, c);
      }
    }

    return incident_id;
  }