public void execute() { T bullet = null; try { bullet = bullets.take(); } catch (InterruptedException e) { System.out.println("Thread was interrupted"); } if (bullet != null) { List<Victim> victims = bulletVictimMap.get(bullet.getBulletClass()); for (Victim victim : victims) { victim.take(bullet); } } }
public Victim getVictim(String victimName) { SQLiteDatabase db = this.getReadableDatabase(); Victim v = new Victim(); String query = "SELECT * FROM " + TABLE_VICTIM + " WHERE " + GPS_VICTIMNAME + " = " + victimName; Cursor c = db.rawQuery(query, null); if (c != null) c.moveToFirst(); v.setName(c.getString(c.getColumnIndex(GPS_VICTIMNAME))); v.setName(c.getString(c.getColumnIndex(VICTIM_NAME))); v.setPassword(c.getString(c.getColumnIndex(VICTIM_PASSWORD))); v.setPinCode(c.getInt(c.getColumnIndex(VICTIM_PIN))); return v; }
public String createVictim(Victim victim) { SQLiteDatabase db = this.getWritableDatabase(); int id = 0; Log.e("TABLE", CREATE_TABLE_VICTIM); ContentValues values = new ContentValues(); // values.put(VICTIM_ID,victim.getId()); values.put(VICTIM_NAME, victim.getName()); values.put(VICTIM_PASSWORD, victim.getPassword()); values.put(VICTIM_PIN, victim.getPinCode()); values.put(VICTIM_GPS, victim.getGps()); values.put(VICTIM_VIDEO, victim.getVideo()); values.put(VICTIM_PHOTO, victim.getPhoto()); values.put(VICTIM_MIC, victim.getMic()); values.put(VICTIM_PHONE, victim.getPhone()); db.insert(TABLE_VICTIM, null, values); String query = "SELECT * FROM " + TABLE_VICTIM; Cursor c = db.rawQuery(query, null); if (c != null) c.moveToLast(); return c.getString(c.getColumnIndex(GPS_VICTIMNAME)); }
@Override public Report updateReport(Report report, boolean redacted) { Victim victim = report.getVictim(); String disability = ""; String comNeeds = ""; if (victim.id != null) { victim.id = null; } victim.setFirstName(firstNameText.getText()); victim.setLastName(lastNameText.getText()); victim.setAddress(addressTextArea.getText()); victim.setPhoneNumber( phoneAreaCode.getText().concat(phoneFirstThree.getText().concat(phoneLastFour.getText()))); victim.setSex(sexCombo.getSelectedItem().toString()); victim.setDob(dayText.getText().concat(monthText.getText().concat(yearText.getText()))); victim.setAge(ageText.getText()); victim.setMaritalStatus(maritalStatusText.getText()); // Get the names of each checkbox to determine the disability to add to string. for (int i = 0; i < disabilityCbPanel.getComponentCount(); i++) { if (disabilityCbPanel.getComponent(i) instanceof JCheckBox) { JCheckBox myCb = (JCheckBox) disabilityCbPanel.getComponent(i); if (myCb.isSelected()) { // Special case for the "other" option. if (!myCb.equals(chckbxOtherspecify)) { disability = disability.concat(myCb.getText() + " "); } else { // Instead of grabbing text from the checkbox, grab it from the text field // when "other" is selected. disability = disability.concat(disabilityOtherTextField.getText()); } } } } victim.setDisability(disability); // Disability and ethnicity are similar. If other is set, must take the other text field. for (int i = 0; i < ethnicityCbPanel.getComponentCount(); i++) { if (ethnicityCbPanel.getComponent(i) instanceof JCheckBox) { JCheckBox myCb = (JCheckBox) ethnicityCbPanel.getComponent(i); if (myCb.isSelected()) { // Special case for the "other" option. if (!myCb.equals(otherEthnicityCheckBox)) { victim.setEthnicity(myCb.getText()); } else { // Instead of grabbing text from the checkbox, grab it from the text field // when "other" is selected. victim.setEthnicity(otherEthnicityTextField.getText()); } } } } for (int i = 0; i < comNeedsCbPanel.getComponentCount(); i++) { if (comNeedsCbPanel.getComponent(i) instanceof JCheckBox) { JCheckBox cb = (JCheckBox) comNeedsCbPanel.getComponent(i); if (cb.isSelected()) { // Special case for "other" option. if (!cb.equals(otherComNeedsCheckBox)) { comNeeds = comNeeds.concat(cb.getText()); } else { comNeeds = comNeeds.concat(otherComNeedsTextField.getText()); } } } } victim.setCommunicationNeeds(comNeeds); report.setVictim(victim); return report; }