public void persistIncidentTypes() { JSONArray jsonIncidentTypes = new JSONArray(); for (IncidentType incidentType : incidentTypes) { jsonIncidentTypes.add(incidentType.jsonify()); } json.put("incidentTypes", jsonIncidentTypes); }
public IncidentType getIncidentType(int id) { for (IncidentType type : incidentTypes) { if (type.getId() == id) { return type; } } return null; }
private void restoreIncidentTypes() { JSONArray jsonIncidentTypes = (JSONArray) json.get("incidentTypes"); int size = jsonIncidentTypes.size(); for (int i = 0; i < size; ++i) { JSONObject jsonIncidentType = (JSONObject) jsonIncidentTypes.get(i); JSONArray jsonRequiredVehicles = (JSONArray) jsonIncidentType.get("requiredVehicleTypes"); List<VehicleType> requiredVehicles = getVehicleTypesFromJSON(jsonRequiredVehicles); IncidentType incidentType = IncidentType.createFromJSON(jsonIncidentType, requiredVehicles); incidentTypes.add(incidentType); } }