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.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

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

Loading…
Cancel
Save