Delete outstanding entries for entities that don't exist anymore

pull/14/head
Sam Bosley 12 years ago
parent c6e7bc852e
commit f297a3475c

@ -80,6 +80,8 @@ public class ChangesHappened<TYPE extends RemoteModel, OE extends OutstandingEnt
this.outstandingDao = outstandingDao; this.outstandingDao = outstandingDao;
this.changes = new ArrayList<OE>(); this.changes = new ArrayList<OE>();
if (!foundEntity) // Stop sending changes for entities that don't exist anymore
outstandingDao.deleteWhere(OutstandingEntry.ENTITY_ID_PROPERTY.eq(id));
} }
@Override @Override

@ -20,6 +20,7 @@ public abstract class ClientToServerMessage<TYPE extends RemoteModel> {
protected final long id; protected final long id;
protected final String uuid; protected final String uuid;
protected final long pushedAt; protected final long pushedAt;
protected final boolean foundEntity;
public static final String TYPE_KEY = "type"; public static final String TYPE_KEY = "type";
public static final String TABLE_KEY = "table"; public static final String TABLE_KEY = "table";
@ -32,6 +33,7 @@ public abstract class ClientToServerMessage<TYPE extends RemoteModel> {
this.table = NameMaps.getServerNameForTable(tableClass); this.table = NameMaps.getServerNameForTable(tableClass);
this.uuid = uuid; this.uuid = uuid;
this.pushedAt = pushedAt; this.pushedAt = pushedAt;
this.foundEntity = true;
this.id = AbstractModel.NO_ID; this.id = AbstractModel.NO_ID;
} }
@ -42,6 +44,7 @@ public abstract class ClientToServerMessage<TYPE extends RemoteModel> {
this.table = NameMaps.getServerNameForTable(tableClass); this.table = NameMaps.getServerNameForTable(tableClass);
TYPE entity = getEntity(id, modelDao); TYPE entity = getEntity(id, modelDao);
this.foundEntity = entity != null;
if (entity == null) { if (entity == null) {
this.uuid = RemoteModel.NO_UUID; this.uuid = RemoteModel.NO_UUID;
this.pushedAt = 0; this.pushedAt = 0;

Loading…
Cancel
Save