return;
}
// Retrieve the current elements from the store
Collection coll = new java.util.HashSet();
ApiAdapter api = ownerSM.getObjectManager().getApiAdapter();
Iterator iter = store.iterator(ownerSM);
while (iter.hasNext())
{
coll.add(iter.next());
}
// Remove all elements no longer in the store
iter = coll.iterator();
while (iter.hasNext())
{
Object element = iter.next();
if (api.isPersistable(element))
{
Object id = api.getIdForObject(element);
if (id != null)
{
// Element has an id so compare the id
boolean present = false;
Iterator newIter = newColl.iterator();
while (newIter.hasNext())
{
Object newElement = newIter.next();
Object newId = api.getIdForObject(newElement);
if (id.equals(newId))
{
present = true;
break;
}
}
if (!present)
{
store.remove(ownerSM, element, -1, true);
}
}
else
{
if (!newColl.contains(element))
{
store.remove(ownerSM, element, -1, true);
}
}
}
else
{
if (!newColl.contains(element))
{
store.remove(ownerSM, element, -1, true);
}
}
}
// Add all new elements to the store
Iterator newIter = newColl.iterator();
while (newIter.hasNext())
{
Object newElement = newIter.next();
if (api.isPersistable(newElement))
{
Object newId = api.getIdForObject(newElement);
if (newId != null)
{
boolean present = false;
iter = coll.iterator();
while (iter.hasNext())
{
Object element = iter.next();
Object id = api.getIdForObject(element);
if (newId.equals(id))
{
present = true;
break;
}