use of org.datanucleus.flush.ListRemoveAtOperation in project datanucleus-core by datanucleus.
the class LinkedList method remove.
/**
* Method to remove an element from the LinkedList.
* @param index The element position.
* @return The object that was removed
*/
public E remove(int index) {
E element = delegate.remove(index);
if (ownerOP != null && ownerOP.getExecutionContext().getManageRelations()) {
ownerOP.getExecutionContext().getRelationshipManager(ownerOP).relationRemove(ownerMmd.getAbsoluteFieldNumber(), element);
}
if (ownerOP != null && SCOUtils.hasDependentElement(ownerMmd)) {
// Cascade delete
if (SCOUtils.useQueuedUpdate(ownerOP)) {
ownerOP.getExecutionContext().addOperationToQueue(new ListRemoveAtOperation(ownerOP, ownerMmd.getAbsoluteFieldNumber(), index, element));
} else if (SCOUtils.hasDependentElement(ownerMmd)) {
ownerOP.getExecutionContext().deleteObjectInternal(element);
}
}
makeDirty();
if (ownerOP != null && !ownerOP.getExecutionContext().getTransaction().isActive()) {
ownerOP.getExecutionContext().processNontransactionalUpdate();
}
return element;
}
use of org.datanucleus.flush.ListRemoveAtOperation in project datanucleus-core by datanucleus.
the class LinkedList method set.
/**
* Wrapper addition that allows turning off of the dependent-field checks
* when doing the position setting. This means that we can prevent the deletion of
* the object that was previously in that position. This particular feature is used
* when attaching a list field and where some elements have changed positions.
* @param index The position
* @param element The new element
* @return The element previously at that position
*/
public E set(int index, E element, boolean allowDependentField) {
E prevElement = delegate.set(index, element);
if (ownerOP != null && allowDependentField && !delegate.contains(prevElement)) {
// Cascade delete
if (SCOUtils.useQueuedUpdate(ownerOP)) {
ownerOP.getExecutionContext().addOperationToQueue(new ListRemoveAtOperation(ownerOP, ownerMmd.getAbsoluteFieldNumber(), index, prevElement));
} else if (SCOUtils.hasDependentElement(ownerMmd)) {
ownerOP.getExecutionContext().deleteObjectInternal(prevElement);
}
}
makeDirty();
if (ownerOP != null && !ownerOP.getExecutionContext().getTransaction().isActive()) {
ownerOP.getExecutionContext().processNontransactionalUpdate();
}
return prevElement;
}
use of org.datanucleus.flush.ListRemoveAtOperation in project datanucleus-core by datanucleus.
the class Stack method remove.
/**
* Method to remove an element from the Stack
* @param index The element position.
* @return The object that was removed
*/
public synchronized E remove(int index) {
E element = delegate.remove(index);
if (ownerOP != null && ownerOP.getExecutionContext().getManageRelations()) {
ownerOP.getExecutionContext().getRelationshipManager(ownerOP).relationRemove(ownerMmd.getAbsoluteFieldNumber(), element);
}
if (ownerOP != null) {
// Cascade delete
if (SCOUtils.useQueuedUpdate(ownerOP)) {
ownerOP.getExecutionContext().addOperationToQueue(new ListRemoveAtOperation(ownerOP, ownerMmd.getAbsoluteFieldNumber(), index, element));
} else if (SCOUtils.hasDependentElement(ownerMmd)) {
ownerOP.getExecutionContext().deleteObjectInternal(element);
}
}
makeDirty();
if (ownerOP != null && !ownerOP.getExecutionContext().getTransaction().isActive()) {
ownerOP.getExecutionContext().processNontransactionalUpdate();
}
return element;
}
use of org.datanucleus.flush.ListRemoveAtOperation in project datanucleus-core by datanucleus.
the class Vector method remove.
/**
* Method to remove an element from the Vector.
* @param index The element position.
* @return The object that was removed
*/
public synchronized E remove(int index) {
E element = delegate.remove(index);
if (ownerOP != null && ownerOP.getExecutionContext().getManageRelations()) {
ownerOP.getExecutionContext().getRelationshipManager(ownerOP).relationRemove(ownerMmd.getAbsoluteFieldNumber(), element);
}
if (ownerOP != null) {
// Cascade delete
if (SCOUtils.useQueuedUpdate(ownerOP)) {
ownerOP.getExecutionContext().addOperationToQueue(new ListRemoveAtOperation(ownerOP, ownerMmd.getAbsoluteFieldNumber(), index, element));
} else if (SCOUtils.hasDependentElement(ownerMmd)) {
ownerOP.getExecutionContext().deleteObjectInternal(element);
}
}
makeDirty();
if (ownerOP != null && !ownerOP.getExecutionContext().getTransaction().isActive()) {
ownerOP.getExecutionContext().processNontransactionalUpdate();
}
return element;
}
use of org.datanucleus.flush.ListRemoveAtOperation in project datanucleus-core by datanucleus.
the class Vector method set.
/**
* Wrapper addition that allows turning off of the dependent-field checks
* when doing the position setting. This means that we can prevent the deletion of
* the object that was previously in that position. This particular feature is used
* when attaching a list field and where some elements have changed positions.
* @param index The position
* @param element The new element
* @return The element previously at that position
*/
public E set(int index, E element, boolean allowDependentField) {
E prevElement = delegate.set(index, element);
if (ownerOP != null && allowDependentField && !delegate.contains(prevElement)) {
// Cascade delete
if (SCOUtils.useQueuedUpdate(ownerOP)) {
ownerOP.getExecutionContext().addOperationToQueue(new ListRemoveAtOperation(ownerOP, ownerMmd.getAbsoluteFieldNumber(), index, prevElement));
} else if (SCOUtils.hasDependentElement(ownerMmd)) {
ownerOP.getExecutionContext().deleteObjectInternal(prevElement);
}
}
makeDirty();
if (ownerOP != null && !ownerOP.getExecutionContext().getTransaction().isActive()) {
ownerOP.getExecutionContext().processNontransactionalUpdate();
}
return prevElement;
}
Aggregations