use of org.datanucleus.store.types.SCOCollection in project datanucleus-core by datanucleus.
the class HashSet method initialise.
public void initialise(java.util.HashSet<E> newValue, Object oldValue) {
if (newValue != null) {
// Check for the case of serialised PC elements, and assign ObjectProviders to the elements without
if (SCOUtils.collectionHasSerialisedElements(ownerMmd) && ownerMmd.getCollection().elementIsPersistent()) {
ExecutionContext ec = ownerOP.getExecutionContext();
Iterator iter = newValue.iterator();
while (iter.hasNext()) {
Object pc = iter.next();
ObjectProvider objSM = ec.findObjectProvider(pc);
if (objSM == null) {
objSM = ec.getNucleusContext().getObjectProviderFactory().newForEmbedded(ec, pc, false, ownerOP, ownerMmd.getAbsoluteFieldNumber());
}
}
}
if (NucleusLogger.PERSISTENCE.isDebugEnabled()) {
NucleusLogger.PERSISTENCE.debug(Localiser.msg("023008", ownerOP.getObjectAsPrintable(), ownerMmd.getName(), "" + newValue.size()));
}
// Detect which objects are added and which are deleted
initialising = true;
if (useCache) {
Collection oldColl = (Collection) oldValue;
if (oldColl != null) {
delegate.addAll(oldColl);
}
isCacheLoaded = true;
SCOUtils.updateCollectionWithCollection(ownerOP.getExecutionContext().getApiAdapter(), this, newValue);
} else {
java.util.Collection oldColl = (java.util.Collection) oldValue;
if (oldColl instanceof SCOCollection) {
oldColl = (java.util.Collection) ((SCOCollection) oldColl).getValue();
}
for (E elem : newValue) {
if (oldColl == null || !oldColl.contains(elem)) {
add(elem);
}
}
if (oldColl != null) {
for (Object elem : oldColl) {
if (!newValue.contains(elem)) {
remove(elem);
}
}
}
}
initialising = false;
}
}
use of org.datanucleus.store.types.SCOCollection in project datanucleus-core by datanucleus.
the class LinkedHashSet method initialise.
public void initialise(java.util.LinkedHashSet<E> newValue, Object oldValue) {
if (newValue != null) {
// Check for the case of serialised PC elements, and assign ObjectProviders to the elements without
if (SCOUtils.collectionHasSerialisedElements(ownerMmd) && ownerMmd.getCollection().elementIsPersistent()) {
ExecutionContext ec = ownerOP.getExecutionContext();
Iterator iter = newValue.iterator();
while (iter.hasNext()) {
Object pc = iter.next();
ObjectProvider objSM = ec.findObjectProvider(pc);
if (objSM == null) {
objSM = ec.getNucleusContext().getObjectProviderFactory().newForEmbedded(ec, pc, false, ownerOP, ownerMmd.getAbsoluteFieldNumber());
}
}
}
if (NucleusLogger.PERSISTENCE.isDebugEnabled()) {
NucleusLogger.PERSISTENCE.debug(Localiser.msg("023008", ownerOP.getObjectAsPrintable(), ownerMmd.getName(), "" + newValue.size()));
}
// Detect which objects are added and which are deleted
initialising = true;
if (useCache) {
Collection oldColl = (Collection) oldValue;
if (oldColl != null) {
delegate.addAll(oldColl);
}
isCacheLoaded = true;
SCOUtils.updateCollectionWithCollection(ownerOP.getExecutionContext().getApiAdapter(), this, newValue);
} else {
java.util.Collection oldColl = (java.util.Collection) oldValue;
if (oldColl instanceof SCOCollection) {
oldColl = (java.util.Collection) ((SCOCollection) oldColl).getValue();
}
for (E elem : newValue) {
if (oldColl == null || !oldColl.contains(elem)) {
add(elem);
}
}
if (oldColl != null) {
Iterator iter = oldColl.iterator();
while (iter.hasNext()) {
Object elem = iter.next();
if (!newValue.contains(elem)) {
remove(elem);
}
}
}
}
initialising = false;
}
}
use of org.datanucleus.store.types.SCOCollection in project datanucleus-core by datanucleus.
the class Set method initialise.
public void initialise(java.util.Set<E> newValue, Object oldValue) {
if (newValue != null) {
// Check for the case of serialised PC elements, and assign ObjectProviders to the elements without
if (SCOUtils.collectionHasSerialisedElements(ownerMmd) && ownerMmd.getCollection().elementIsPersistent()) {
ExecutionContext ec = ownerOP.getExecutionContext();
Iterator iter = newValue.iterator();
while (iter.hasNext()) {
Object pc = iter.next();
ObjectProvider objSM = ec.findObjectProvider(pc);
if (objSM == null) {
objSM = ec.getNucleusContext().getObjectProviderFactory().newForEmbedded(ec, pc, false, ownerOP, ownerMmd.getAbsoluteFieldNumber());
}
}
}
if (NucleusLogger.PERSISTENCE.isDebugEnabled()) {
NucleusLogger.PERSISTENCE.debug(Localiser.msg("023008", ownerOP.getObjectAsPrintable(), ownerMmd.getName(), "" + newValue.size()));
}
// Detect which objects are added and which are deleted
initialising = true;
if (useCache) {
Collection oldColl = (Collection) oldValue;
if (oldColl != null) {
delegate.addAll(oldColl);
}
isCacheLoaded = true;
SCOUtils.updateCollectionWithCollection(ownerOP.getExecutionContext().getApiAdapter(), this, newValue);
} else {
java.util.Collection oldColl = (java.util.Collection) oldValue;
if (oldColl instanceof SCOCollection) {
oldColl = (java.util.Collection) ((SCOCollection) oldColl).getValue();
}
for (E elem : newValue) {
if (oldColl == null || !oldColl.contains(elem)) {
add(elem);
}
}
if (oldColl != null) {
Iterator iter = oldColl.iterator();
while (iter.hasNext()) {
Object elem = iter.next();
if (!newValue.contains(elem)) {
remove(elem);
}
}
}
}
initialising = false;
}
}
use of org.datanucleus.store.types.SCOCollection in project datanucleus-core by datanucleus.
the class TreeSet method initialise.
public void initialise(java.util.TreeSet<E> newValue, Object oldValue) {
if (newValue != null) {
// Check for the case of serialised PC elements, and assign ObjectProviders to the elements without
if (SCOUtils.collectionHasSerialisedElements(ownerMmd) && ownerMmd.getCollection().elementIsPersistent()) {
ExecutionContext ec = ownerOP.getExecutionContext();
Iterator iter = newValue.iterator();
while (iter.hasNext()) {
Object pc = iter.next();
ObjectProvider objSM = ec.findObjectProvider(pc);
if (objSM == null) {
objSM = ec.getNucleusContext().getObjectProviderFactory().newForEmbedded(ec, pc, false, ownerOP, ownerMmd.getAbsoluteFieldNumber());
}
}
}
if (NucleusLogger.PERSISTENCE.isDebugEnabled()) {
NucleusLogger.PERSISTENCE.debug(Localiser.msg("023008", ownerOP.getObjectAsPrintable(), ownerMmd.getName(), "" + newValue.size()));
}
// Detect which objects are added and which are deleted
initialising = true;
if (useCache) {
Collection oldColl = (Collection) oldValue;
if (oldColl != null) {
delegate.addAll(oldColl);
}
isCacheLoaded = true;
SCOUtils.updateCollectionWithCollection(ownerOP.getExecutionContext().getApiAdapter(), this, newValue);
} else {
java.util.Collection oldColl = (java.util.Collection) oldValue;
if (oldColl instanceof SCOCollection) {
oldColl = (java.util.Collection) ((SCOCollection) oldColl).getValue();
}
for (E elem : newValue) {
if (oldColl == null || !oldColl.contains(elem)) {
add(elem);
}
}
if (oldColl != null) {
Iterator iter = oldColl.iterator();
while (iter.hasNext()) {
Object elem = iter.next();
if (!newValue.contains(elem)) {
remove(elem);
}
}
}
}
initialising = false;
}
}
Aggregations