|
@@ -1307,17 +1307,37 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
|
|
|
*/
|
|
|
public synchronized void deleteAttacksByFilter(LogFilter filter){
|
|
|
String selectQuery = this.selectionQueryFromFilter(filter, "" + AttackEntry.COLUMN_NAME_ATTACK_ID);
|
|
|
- String deletePacketQuery = "DELETE FROM " +PacketEntry.TABLE_NAME + " WHERE "+ PacketEntry.TABLE_NAME + "."+ PacketEntry.COLUMN_NAME_ATTACK_ID+" in ( ";
|
|
|
+ String deletePacketQuery = "DELETE FROM " + PacketEntry.TABLE_NAME + " WHERE "+ PacketEntry.TABLE_NAME + "."+ PacketEntry.COLUMN_NAME_ATTACK_ID+" in ( ";
|
|
|
deletePacketQuery = deletePacketQuery + selectQuery + " )";
|
|
|
- String deleteAttacksQuery = "DELETE FROM " +AttackEntry.TABLE_NAME + " WHERE "+ AttackEntry.TABLE_NAME + "."+ AttackEntry.COLUMN_NAME_ATTACK_ID+" in ( ";
|
|
|
+ String deleteAttacksQuery = "DELETE FROM " + AttackEntry.TABLE_NAME + " WHERE "+ AttackEntry.TABLE_NAME + "."+ AttackEntry.COLUMN_NAME_ATTACK_ID+" in ( ";
|
|
|
deleteAttacksQuery =deleteAttacksQuery + selectQuery + " )";
|
|
|
|
|
|
SQLiteDatabase db = this.getReadableDatabase();
|
|
|
- db.execSQL(deletePacketQuery);
|
|
|
db.execSQL(deleteAttacksQuery);
|
|
|
+ db.execSQL(deletePacketQuery);
|
|
|
db.close();
|
|
|
}
|
|
|
|
|
|
+ public List<Long> getAllAttackIdsForFilter(LogFilter filter){
|
|
|
+ List<Long> results = new ArrayList<Long>();
|
|
|
+ SQLiteDatabase db = this.getReadableDatabase();
|
|
|
+ // Select All Query
|
|
|
+ String selectQuery = this.selectionQueryFromFilter(filter, "" + AttackEntry.COLUMN_NAME_ATTACK_ID);
|
|
|
+
|
|
|
+ Cursor cursor = db.rawQuery(selectQuery, null);
|
|
|
+
|
|
|
+ // looping through all rows and adding to list
|
|
|
+ if (cursor.moveToFirst()) {
|
|
|
+ do {
|
|
|
+ results.add(cursor.getLong(0));
|
|
|
+ } while (cursor.moveToNext());
|
|
|
+ }
|
|
|
+ cursor.close();
|
|
|
+ db.close();
|
|
|
+
|
|
|
+ return results;
|
|
|
+ }
|
|
|
+
|
|
|
public ArrayList<MessageRecord> getMessageRecords(AttackRecord attackRecord , SQLiteDatabase db){
|
|
|
ArrayList<MessageRecord> mr = new ArrayList<MessageRecord>();
|
|
|
|