use of org.datanucleus.state.RelationshipManager in project datanucleus-core by datanucleus.
the class Stack method addAll.
/**
* Method to add a Collection to a position in the Stack
* @param index Position to insert the collection.
* @param elements The collection
* @return Whether it was added ok.
*/
public synchronized boolean addAll(int index, Collection elements) {
boolean success = delegate.addAll(index, elements);
if (ownerOP != null && ownerOP.getExecutionContext().getManageRelations()) {
// Relationship management
Iterator iter = elements.iterator();
RelationshipManager relMgr = ownerOP.getExecutionContext().getRelationshipManager(ownerOP);
while (iter.hasNext()) {
relMgr.relationAdd(ownerMmd.getAbsoluteFieldNumber(), iter.next());
}
}
if (success) {
if (SCOUtils.useQueuedUpdate(ownerOP)) {
int pos = index;
for (Object element : elements) {
ownerOP.getExecutionContext().addOperationToQueue(new ListAddAtOperation(ownerOP, ownerMmd.getAbsoluteFieldNumber(), pos++, element));
}
}
makeDirty();
if (ownerOP != null && !ownerOP.getExecutionContext().getTransaction().isActive()) {
ownerOP.getExecutionContext().processNontransactionalUpdate();
}
}
return success;
}
use of org.datanucleus.state.RelationshipManager in project datanucleus-core by datanucleus.
the class TreeSet method clear.
/**
* Method to clear the TreeSet
*/
public void clear() {
if (ownerOP != null && ownerOP.getExecutionContext().getManageRelations()) {
// Relationship management
Iterator iter = delegate.iterator();
RelationshipManager relMgr = ownerOP.getExecutionContext().getRelationshipManager(ownerOP);
while (iter.hasNext()) {
relMgr.relationRemove(ownerMmd.getAbsoluteFieldNumber(), iter.next());
}
}
if (ownerOP != null && !delegate.isEmpty()) {
// Cascade delete
if (SCOUtils.useQueuedUpdate(ownerOP)) {
// Queue the cascade delete
Iterator iter = delegate.iterator();
while (iter.hasNext()) {
ownerOP.getExecutionContext().addOperationToQueue(new CollectionRemoveOperation(ownerOP, ownerMmd.getAbsoluteFieldNumber(), iter.next(), true));
}
} else if (SCOUtils.hasDependentElement(ownerMmd)) {
// Perform the cascade delete
Iterator iter = delegate.iterator();
while (iter.hasNext()) {
ownerOP.getExecutionContext().deleteObjectInternal(iter.next());
}
}
}
delegate.clear();
makeDirty();
if (ownerOP != null && !ownerOP.getExecutionContext().getTransaction().isActive()) {
ownerOP.getExecutionContext().processNontransactionalUpdate();
}
}
use of org.datanucleus.state.RelationshipManager in project datanucleus-core by datanucleus.
the class Vector method removeAll.
/**
* Method to remove a Collection of elements from the Vector.
* @param elements The collection
* @return Whether it was removed ok.
*/
public synchronized boolean removeAll(Collection elements) {
if (elements == null) {
throw new NullPointerException();
} else if (elements.isEmpty()) {
return true;
}
boolean success = delegate.removeAll(elements);
if (ownerOP != null) {
if (ownerOP.getExecutionContext().getManageRelations()) {
// Relationship management
Iterator iter = elements.iterator();
RelationshipManager relMgr = ownerOP.getExecutionContext().getRelationshipManager(ownerOP);
while (iter.hasNext()) {
relMgr.relationRemove(ownerMmd.getAbsoluteFieldNumber(), iter.next());
}
}
// Cascade delete
if (SCOUtils.useQueuedUpdate(ownerOP)) {
Iterator iter = elements.iterator();
while (iter.hasNext()) {
ownerOP.getExecutionContext().addOperationToQueue(new CollectionRemoveOperation(ownerOP, ownerMmd.getAbsoluteFieldNumber(), iter.next(), true));
}
} else if (SCOUtils.hasDependentElement(ownerMmd)) {
Iterator iter = elements.iterator();
while (iter.hasNext()) {
ownerOP.getExecutionContext().deleteObjectInternal(iter.next());
}
}
}
if (success) {
makeDirty();
if (ownerOP != null && !ownerOP.getExecutionContext().getTransaction().isActive()) {
ownerOP.getExecutionContext().processNontransactionalUpdate();
}
}
return success;
}
use of org.datanucleus.state.RelationshipManager in project datanucleus-core by datanucleus.
the class Vector method clear.
/**
* Method to clear the Vector.
*/
public synchronized void clear() {
if (ownerOP != null && ownerOP.getExecutionContext().getManageRelations()) {
// Relationship management
Iterator iter = delegate.iterator();
RelationshipManager relMgr = ownerOP.getExecutionContext().getRelationshipManager(ownerOP);
while (iter.hasNext()) {
relMgr.relationRemove(ownerMmd.getAbsoluteFieldNumber(), iter.next());
}
}
if (ownerOP != null && !delegate.isEmpty()) {
// Cascade delete
if (SCOUtils.useQueuedUpdate(ownerOP)) {
java.util.List copy = new java.util.ArrayList(delegate);
Iterator iter = copy.iterator();
while (iter.hasNext()) {
ownerOP.getExecutionContext().addOperationToQueue(new CollectionRemoveOperation(ownerOP, ownerMmd.getAbsoluteFieldNumber(), iter.next(), true));
}
} else if (SCOUtils.hasDependentElement(ownerMmd)) {
java.util.List copy = new java.util.ArrayList(delegate);
Iterator iter = copy.iterator();
while (iter.hasNext()) {
ownerOP.getExecutionContext().deleteObjectInternal(iter.next());
}
}
}
delegate.clear();
makeDirty();
if (ownerOP != null && !ownerOP.getExecutionContext().getTransaction().isActive()) {
ownerOP.getExecutionContext().processNontransactionalUpdate();
}
}
use of org.datanucleus.state.RelationshipManager in project datanucleus-core by datanucleus.
the class Vector method addAll.
/**
* Method to add a Collection to a position in the Vector.
* @param index Position to insert the collection.
* @param elements The collection
* @return Whether it was added ok.
*/
public synchronized boolean addAll(int index, Collection elements) {
boolean success = delegate.addAll(index, elements);
if (ownerOP != null && ownerOP.getExecutionContext().getManageRelations()) {
// Relationship management
Iterator iter = elements.iterator();
RelationshipManager relMgr = ownerOP.getExecutionContext().getRelationshipManager(ownerOP);
while (iter.hasNext()) {
relMgr.relationAdd(ownerMmd.getAbsoluteFieldNumber(), iter.next());
}
}
if (success) {
if (SCOUtils.useQueuedUpdate(ownerOP)) {
int pos = index;
for (Object element : elements) {
ownerOP.getExecutionContext().addOperationToQueue(new ListAddAtOperation(ownerOP, ownerMmd.getAbsoluteFieldNumber(), pos++, element));
}
}
makeDirty();
if (ownerOP != null && !ownerOP.getExecutionContext().getTransaction().isActive()) {
ownerOP.getExecutionContext().processNontransactionalUpdate();
}
}
return success;
}
Aggregations