public void insertAlertItem(AlertItem ai, int type) { HostResolver.addRequest(ai); ai.getPolicyItem().addAlerts(1); if (ai.getStatus() == AlertItem.NEW) { ai.getPolicyItem().addNewAlerts(1); } synchronized (alerts) { alerts.add(ai); model.addAlert(ai); } }
private void markAlerts(int[] items, int mark) { List list = new ArrayList(); for (int i = 0; i < items.length; i++) { AlertItem item = model.getAlert(items[i]); if (item.getStatus() != mark) { if (item.getStatus() == AlertItem.NEW) { item.getPolicyItem().addNewAlerts(-1); } else { item.getPolicyItem().addNewAlerts(mark == AlertItem.NEW ? 1 : 0); } list.add(item); item.setStatus(mark); } } try { main.saveAlertList(list); } catch (IOException ex) { ex.printStackTrace(); } }
public void deleteAlertsForPolicy(PolicyItem pi) { List ids = new ArrayList(); synchronized (alerts) { Iterator it = alerts.iterator(); while (it.hasNext()) { AlertItem alert = (AlertItem) it.next(); if (alert.getPolicyItem() == pi) { ids.add(alert); } } } Iterator it = ids.iterator(); while (it.hasNext()) { AlertItem alert = (AlertItem) it.next(); model.removeAlert(alert); deleteFromSource(alert); } }