@Override public void remove(Entry entry) throws Exception { if (!entries.containsKey(entry.getId())) { throw new DBException("Entry not found"); } long logid = entry.getLog().getId(); Log log = logDB.get(logid); log.removeEntry(entry); logDB.update(log); entries.remove(entry.getId()); }
@Override public Entry add(Entry entry) throws Exception { if (entries.containsValue(entry)) { throw new DBException("Entry is already in the collection"); } entry.setId(idCounter); entries.put(idCounter, entry); idCounter++; Log log = entry.getLog(); log.addEntry(entry); logDB.update(log); return entry; }