Mark for creation all objects that were included into dependent collections.
Mark for deletion all objects that were excluded from dependent collections.
762133
private ArrayList handleDependentCollections(Identity oid, Object obj,
            Object[] origCollections, Object[] newCollections,
            Object[] newCollectionsOfObjects)
            throws LockingException
    {
        ClassDescriptor mif = _pb.getClassDescriptor(obj.getClass());
        Collection colDescs = mif.getCollectionDescriptors();
        ArrayList newObjects = new ArrayList();
        int count = 0;

        for (Iterator it = colDescs.iterator(); it.hasNext(); count++)
        {
            CollectionDescriptor cds = (CollectionDescriptor) it.next();

            if (cds.getOtmDependent())
            {
                ArrayList origList = (origCollections == null ? null
                                        : (ArrayList) origCollections[count]);
                ArrayList newList = (ArrayList) newCollections[count];

                if (origList != null)
                {
                    for (Iterator it2 = origList.iterator(); it2.hasNext(); )
                    {
                        Identity origOid = (Identity) it2.next();

                        if ((newList == null) || !newList.contains(origOid))
                        {
                            markDelete(origOid, oid, true);
                        }
                    }
                }

                if (newList != null)
                {
                    int countElem = 0;
                    for (Iterator it2 = newList.iterator(); it2.hasNext(); countElem++)
                    {
                        Identity newOid = (Identity) it2.next();

                        if ((origList == null) || !origList.contains(newOid))
                        {
                            ContextEntry entry = (ContextEntry) _objects.get(newOid);

                            if (entry == null)
                            {
                                ArrayList relCol = (ArrayList)
                                        newCollectionsOfObjects[count];
                                Object relObj = relCol.get(countElem);
                                insertInternal(newOid, relObj, LockType.WRITE_LOCK,
                                               true, null, new Stack());
                                newObjects.add(newOid);
                            }
                        }
                    }
                }
            }
        }

        return newObjects;
    }
692882
private static void includeAffected(Set<String> allClasses, Set<String> affectedClasses, List<File> sortedFiles) {
        Storer storer = Config.createStorer();
        Hasher hasher = Config.createHasher();

        NameBasedCheck classCheck = Config.DEBUG_MODE_V != Config.DebugMode.NONE ?
            new DebugNameCheck(storer, hasher, DependencyAnalyzer.CLASS_EXT) :
            new NameBasedCheck(storer, hasher, DependencyAnalyzer.CLASS_EXT);
        NameBasedCheck covCheck = new NameBasedCheck(storer, hasher, DependencyAnalyzer.COV_EXT);
        MethodCheck methodCheck = new MethodCheck(storer, hasher);
        String prevClassName = null;
        for (File file : sortedFiles) {
            String fileName = file.getName();
            String dirName = file.getParent();
            String className = null;
            if (file.isDirectory()) {
                continue;
            }
            if (fileName.endsWith(DependencyAnalyzer.COV_EXT)) {
                className = covCheck.includeAll(fileName, dirName);
            } else if (fileName.endsWith(DependencyAnalyzer.CLASS_EXT)) {
                className = classCheck.includeAll(fileName, dirName);
            } else {
                className = methodCheck.includeAll(fileName, dirName);
            }
            // Reset after some time to free space.
            if (prevClassName != null && className != null && !prevClassName.equals(className)) {
                methodCheck.includeAffected(affectedClasses);
                methodCheck = new MethodCheck(Config.createStorer(), Config.createHasher());
            }
            if (className != null) {
                allClasses.add(className);
                prevClassName = className;
            }
        }
        classCheck.includeAffected(affectedClasses);
        covCheck.includeAffected(affectedClasses);
        methodCheck.includeAffected(affectedClasses);
    }
517329
public function markClean()
    {
        foreach ($this->__adapters as $model) {
            $model->markClean();
        }
        $annotations = $this->annotations()['properties'];
        foreach ($annotations as $prop => $anns) {
            if (isset($anns['Private']) || $prop{0} == '_') {
                continue;
            }
            $value = $this->$prop;
            if (is_object($value) and method_exists($value, 'markClean')) {
                $value->markClean();
            }
        }
        $this->__state = 'clean';
    }
576358
public void clear()
    {
        // clear out ref queue. We don't need to expunge entries
        // since gc'ed entries won't get copied.
        emptyReferenceQueue();

        for (int i = 0; i < table.length; i++)
        {
            Entry e = table[i];
            Entry first = null;
            Entry prev = null;
            while (e != null)
            {
                Object candidate = e.get();
                if (candidate != null)
                {
                    Entry dirty = e.makeDirtyAndWeak(queue);
                    if (first == null)
                    {
                        first = dirty;
                    }
                    if (prev != null)
                    {
                        prev.setNext(dirty);
                    }
                    prev = dirty;
                }
                else
                {
                    if (prev != null)
                    {
                        prev.setNext(e.getState().next);
                    }
                    size--;
                }
                e = e.getState().next;
            }
            table[i] = first;
        }

        // Allocation of array may have caused GC, which may have caused
        // additional entries to go stale.  Removing these entries from the
        // reference queue will make them eligible for reclamation.
        expungeStaleEntries();
    }
1323953
public void markAsToBeDeleted(Transaction transaction) throws SIResourceException 
  {
    if (tc.isEntryEnabled())
      SibTr.entry(tc, "markAsToBeDeleted", transaction);
      
    toBeDeleted = Boolean.TRUE;  
    
    try
    {
      requestUpdate(transaction);
    }
    catch (MessageStoreException e)
    {
      // MessageStoreException shouldn't occur so FFDC.
      FFDCFilter.processException(
        e,
        "com.ibm.ws.sib.processor.impl.store.itemstreams.MQLinkPubSubBridgeItemStream.markAsToBeDeleted",
        "1:151:1.16",
        this);
        
      SibTr.exception(tc, e);
      
      if (tc.isEntryEnabled())
        SibTr.exit(tc, "markAsToBeDeleted", e);
      
      throw new SIResourceException(e);
    }
    
    if (tc.isEntryEnabled())
      SibTr.exit(tc, "markAsToBeDeleted");
      
    return;
  }
767405
function() {
            for (var cid in madeMap) {
                if (madeMap[cid].added) {
                    delete madeMap[cid].obj._cid;
                }
            }
            madeMap = null;
        }
466369
@Deprecated
    public static void markForDeletion(UIComponent component)
    {
        // flag this component as deleted
        component.getAttributes().put(MARK_DELETED, Boolean.TRUE);

        Iterator<UIComponent> iter = component.getFacetsAndChildren();
        while (iter.hasNext())
        {
            UIComponent child = iter.next();
            if (child.getAttributes().containsKey(MARK_CREATED))
            {
                child.getAttributes().put(MARK_DELETED, Boolean.TRUE);
            }
        }
    }
808560
protected void associateBatched(Collection owners, Collection children)
    {
        ObjectReferenceDescriptor ord = getObjectReferenceDescriptor();
        ClassDescriptor cld = getOwnerClassDescriptor();
        Object owner;
        Object relatedObject;
        Object fkValues[];
        Identity id;
        PersistenceBroker pb = getBroker();
        PersistentField field = ord.getPersistentField();
        Class topLevelClass = pb.getTopLevelClass(ord.getItemClass());
        HashMap childrenMap = new HashMap(children.size());


        for (Iterator it = children.iterator(); it.hasNext(); )
        {
            relatedObject = it.next();
            childrenMap.put(pb.serviceIdentity().buildIdentity(relatedObject), relatedObject);
        }

        for (Iterator it = owners.iterator(); it.hasNext(); )
        {
            owner = it.next();
            fkValues = ord.getForeignKeyValues(owner,cld);
            if (isNull(fkValues))
            {
                field.set(owner, null);
                continue;
            }
            id = pb.serviceIdentity().buildIdentity(null, topLevelClass, fkValues);
            relatedObject = childrenMap.get(id);
            field.set(owner, relatedObject);
        }
    }
1237507
def assign_to_or_mark_for_destruction(record, attributes, allow_destroy, assignment_opts)
      record.assign_attributes(attributes.except(*unassignable_keys(assignment_opts)), assignment_opts)
      record.mark_for_destruction if has_destroy_flag?(attributes) && allow_destroy
    end
1131951
function(local_record, referenced_record) {

		if (!Firestorm.Array.exclude(this._collections_by_foreign_guid[referenced_record.guid], local_record)) Lava.t();
		this._fire('removed_child', {
			collection_owner: referenced_record,
			child: local_record
		});

	}
1249860
@Override
    public void clear() {
        readOnlyGuardCondition();

        for (D item : this) {
            instance.removeRelation(entity, writeAttributeName, item);
        }
        entity.save();
    }
35549
private Object retainAll(Schema schema, MarkSet markSet, ProtoType type, Object o) {
    if (!markSet.contains(type)) {
      return null; // Prune this type.

    } else if (o instanceof Map) {
      ImmutableMap.Builder<ProtoMember, Object> builder = ImmutableMap.builder();
      for (Map.Entry<?, ?> entry : ((Map<?, ?>) o).entrySet()) {
        ProtoMember protoMember = (ProtoMember) entry.getKey();
        if (!markSet.contains(protoMember)) continue; // Prune this field.
        Field field = schema.getField(protoMember);
        Object retainedValue = retainAll(schema, markSet, field.type(), entry.getValue());
        if (retainedValue != null) {
          builder.put(protoMember, retainedValue); // This retained field is non-empty.
        }
      }
      ImmutableMap<ProtoMember, Object> map = builder.build();
      return !map.isEmpty() ? map : null;

    } else if (o instanceof List) {
      ImmutableList.Builder<Object> builder = ImmutableList.builder();
      for (Object value : ((List) o)) {
        Object retainedValue = retainAll(schema, markSet, type, value);
        if (retainedValue != null) {
          builder.add(retainedValue); // This retained value is non-empty.
        }
      }
      ImmutableList<Object> list = builder.build();
      return !list.isEmpty() ? list : null;

    } else {
      return o;
    }
  }
715007
def _remove_dep(self, dep):
        
        refcount = self._deps[dep]
        if refcount == 1:
            self._deps.pop(dep)
            dep._dependents.pop(self)
        else:
            self._deps[dep] -= 1
692354
@Override
    protected void ignoreDuplicatedChangeItemRequests() {
        if (getItems() != null) {
            final List<RESTCSRelatedNodeCollectionItemV1> items = new ArrayList<RESTCSRelatedNodeCollectionItemV1>(getItems());
        
            /* on the second loop, remove any items that are marked for both add and remove is separate items */
            for (int i = 0; i < items.size(); ++i) {
                final RESTCSRelatedNodeCollectionItemV1 child1 = items.get(i);
                final RESTCSRelatedNodeV1 childItem1 = child1.getItem();

                // New Entity so ignore it
                if (childItem1.getId() == null) continue;
                
                /* at this point we know that either add1 or remove1 will be true, but not both */
                final boolean add1 = child1.getState().equals(ADD_STATE);
                final boolean remove1 = child1.getState().equals(REMOVE_STATE);
                final boolean update1 = child1.getState().equals(UPDATE_STATE);
                
                /* Loop a second time, looking for duplicates */
                for (int j = i + 1; j < items.size(); ++j) {
                    final RESTCSRelatedNodeCollectionItemV1 child2 = items.get(j);
                    final RESTCSRelatedNodeV1 childItem2 = child2.getItem();

                    // New Entity so ignore it
                    if (childItem2.getId() == null) continue;

                    final boolean relationshipIdEqual = childItem1.getRelationshipId() == null && childItem2.getRelationshipId() == null
                            || childItem1.getRelationshipId() != null && childItem1.getRelationshipId().equals(
                            childItem2.getRelationshipId());
                    
                    /* Check the RelatedNode objects for their value as well as their IDs to ensure duplicates are removed*/
                    if (childItem1.getId().equals(childItem2.getId()) && relationshipIdEqual) {
                        final boolean add2 = child2.getState().equals(ADD_STATE);
                        final boolean remove2 = child2.getState().equals(REMOVE_STATE);
                        final boolean update2 = child2.getState().equals(UPDATE_STATE);
                        
                        /* Do some checks on values that could be null */
                        final boolean typeEqual = childItem1.getRelationshipType() == null && childItem2.getRelationshipType() == null ||
                                childItem1.getRelationshipType() != null && childItem1.getRelationshipType().equals(
                                childItem2.getRelationshipType());
                        
                        /* check for double add, double remove, double update, and remove one instance */
                        if ((add1 && add2) || (remove1 && remove2) || (update1 && update2)) {
                            /* 
                             * If the relationship types are equal then we only need to remove one item. If
                             * the are different then both should be removed. 
                             */
                            if (typeEqual) {
                                getItems().remove(child1);
                            } else {
                                getItems().remove(child1);
                                getItems().remove(child2);
                            }
                        }
                        
                        /* check for double add, double remove, add and remove, remove and add */
                        if ((add1 && remove2) || (remove1 && add2) || (update1 && remove2) || (update2 && remove1) || (update1 && add2)
                                || (update2 && add1)) {
                            getItems().remove(child1);
                            getItems().remove(child2);
                        }
                    }
                }
            }
        }
    }
1255270
protected void clearDependentsWriteCount() {

        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "clearDependentsWriteCount entry: for this node: " + this);
        }

        dependentWriteCount = 0;

        if ((dependents == null) || (dependents.size() == 0)) {
            return;
        }

        for (int i = 0; i < dependents.size(); i++) {
            dependents.get(i).setWriteCount(0);
        }

    }
1334582
public function markReferenced(){
		$this->isReferenced = true;
		if( $this->rules ){
			Less_Tree::ReferencedArray($this->rules->rules);
		}
	}
200681
public function markClean()
    {
        foreach ($this as $model) {
            if (is_object($model)) {
                $model->markClean();
            }
        }
        $this->_original = count($this);
    }