Esempio n. 1
0
  /**
   * Method to remove an element from the List
   *
   * @param element The Element to remove
   * @return Whether it was removed successfully.
   */
  public boolean remove(Object element, boolean allowCascadeDelete) {
    boolean success = delegate.remove(element);
    if (ownerOP != null && ownerOP.getExecutionContext().getManageRelations()) {
      ownerOP
          .getExecutionContext()
          .getRelationshipManager(ownerOP)
          .relationRemove(ownerMmd.getAbsoluteFieldNumber(), element);
    }

    if (ownerOP != null && allowCascadeDelete) {
      // Cascade delete
      if (SCOUtils.useQueuedUpdate(ownerOP)) {
        // Queue the cascade delete
        ownerOP
            .getExecutionContext()
            .addOperationToQueue(
                new CollectionRemoveOperation(
                    ownerOP, ownerMmd.getAbsoluteFieldNumber(), element, allowCascadeDelete));
      } else if (SCOUtils.hasDependentElement(ownerMmd)) {
        // Perform the cascade delete
        ownerOP.getExecutionContext().deleteObjectInternal(element);
      }
    }

    if (success) {
      makeDirty();
      if (ownerOP != null && !ownerOP.getExecutionContext().getTransaction().isActive()) {
        ownerOP.getExecutionContext().processNontransactionalUpdate();
      }
    }

    return success;
  }
  /** Method to clear the Collection. */
  public synchronized void clear() {
    if (ownerOP != null && !delegate.isEmpty()) {
      // Cascade delete
      if (SCOUtils.hasDependentElement(ownerMmd)) {
        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();
    }
  }
  /**
   * Method to remove an element from the List
   *
   * @param element The Element to remove
   * @return Whether it was removed successfully.
   */
  public synchronized boolean remove(Object element, boolean allowCascadeDelete) {
    boolean success = delegate.remove(element);

    if (ownerOP != null && allowCascadeDelete) {
      // Cascade delete
      if (SCOUtils.hasDependentElement(ownerMmd)) {
        ownerOP.getExecutionContext().deleteObjectInternal(element);
      }
    }

    if (success) {
      makeDirty();
      if (ownerOP != null && !ownerOP.getExecutionContext().getTransaction().isActive()) {
        ownerOP.getExecutionContext().processNontransactionalUpdate();
      }
    }

    return success;
  }
Esempio n. 4
0
  /**
   * Method to remove all elements from the collection from the LinkedHashSet.
   *
   * @param elements The collection of elements to remove
   * @return Whether it was removed ok.
   */
  public boolean removeAll(java.util.Collection elements) {
    boolean success = delegate.removeAll(elements);
    if (ownerOP != null && ownerOP.getExecutionContext().getManageRelations()) {
      // Relationship management
      Iterator iter = elements.iterator();
      RelationshipManager relMgr = ownerOP.getExecutionContext().getRelationshipManager(ownerOP);
      while (iter.hasNext()) {
        relMgr.relationRemove(ownerMmd.getAbsoluteFieldNumber(), iter.next());
      }
    }

    if (ownerOP != null && elements != null && !elements.isEmpty()) {
      // Cascade delete
      if (SCOUtils.useQueuedUpdate(ownerOP)) {
        // Queue the cascade delete
        Iterator iter = elements.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 = 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;
  }
  /**
   * Method to remove a Collection of elements.
   *
   * @param elements The collection to remove
   * @return Whether they were removed successfully.
   */
  public synchronized boolean removeAll(java.util.Collection elements) {
    boolean success = delegate.removeAll(elements);

    if (ownerOP != null && elements != null && !elements.isEmpty()) {
      // Cascade delete
      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;
  }
Esempio n. 6
0
  /**
   * Method to retain a Collection of elements (and remove all others).
   *
   * @param c The collection to retain
   * @return Whether they were retained successfully.
   */
  public boolean retainAll(java.util.Collection c) {
    if (c == null) {
      throw new NullPointerException("Input collection was null");
    }
    Collection collToRemove = new java.util.LinkedHashSet();
    for (Object o : delegate) {
      if (!c.contains(o)) {
        collToRemove.add(o);
      }
    }

    boolean success = delegate.retainAll(c);
    if (success) {
      makeDirty();
      if (SCOUtils.useQueuedUpdate(ownerOP)) {
        // Queue any cascade delete
        Iterator iter = collToRemove.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 = collToRemove.iterator();
        while (iter.hasNext()) {
          ownerOP.getExecutionContext().deleteObjectInternal(iter.next());
        }
      }

      if (ownerOP != null && !ownerOP.getExecutionContext().getTransaction().isActive()) {
        ownerOP.getExecutionContext().processNontransactionalUpdate();
      }
    }
    return success;
  }