Adds identifiers from a PersistentCollection to $groupedIds.

@param PersistentCollectionInterface $persistentCollection
766492
private function addManyReferences(PersistentCollectionInterface $persistentCollection)
    {
        $mapping = $persistentCollection->getMapping();
        $ap = $this->dm->getUnitOfWork()->getAssociationPersister();

        foreach ($persistentCollection->getRawData() as $reference) {
            /** @var Identifier $identifier */
            $identifier = $ap->loadReference($mapping, $reference);
            $document   = $this->uow->tryGetByIdentifier($identifier);

            if ($document === false || ($document instanceof Proxy && !$document->__isInitialized())) {
                $className = $identifier->class->getName();
                $key       = serialize($identifier);

                $this->groupedIds[$className][$key] = $identifier;
            }
        }
    }
1151720
public function scheduleCollectionDeletion(PersistentCollectionInterface $coll) : void
    {
        $oid = spl_object_hash($coll);
        unset($this->collectionUpdates[$oid]);
        if (isset($this->collectionDeletions[$oid])) {
            return;
        }

        $this->collectionDeletions[$oid] = $coll;
        $this->scheduleCollectionOwner($coll);
    }
60579
final protected function persistObjects(PersistenceContext $context, array $objects, array $rows)
    {
        $this->mapping->persistAll($context, $objects, $rows);
    }
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;
    }
991205
public <S extends SortedGrouping<?>> void add(int id, S set) {
		cacheSetType(id, SetType.SORTED_GROUPING);
		sortedGroupings.put(id, set);
	}
974889
public function update(PersistentCollectionInterface $coll)
    {
        $mapping = $coll->getMapping();

        if ($mapping->isInverseSide) {
            return; // ignore inverse side
        }

        switch ($mapping->strategy) {
            case PropertyMetadata::STORAGE_STRATEGY_ATOMIC_SET:
                throw new \UnexpectedValueException(sprintf('%s update collection strategy should have been handled by DocumentPersister. Please report a bug in issue tracker', $mapping->strategy));

            case PropertyMetadata::STORAGE_STRATEGY_SET:
                $this->setCollection($coll);
                break;

            case PropertyMetadata::STORAGE_STRATEGY_ADD_TO_SET:
            case PropertyMetadata::STORAGE_STRATEGY_LIST_APPEND:
                $coll->initialize();
                $this->deleteElements($coll);
                $this->insertElements($coll);
                break;

            default:
                throw new \UnexpectedValueException(sprintf('Unsupported collection strategy: %s', $mapping->strategy));
        }
    }
84820
public function createReferenceManyInverseSideQuery(PersistentCollection $collection)
    {
        $hints = $collection->getHints();
        $mapping = $collection->getMapping();
        $owner = $collection->getOwner();
        $ownerClass = $this->dm->getClassMetadata(get_class($owner));
        $targetClass = $this->dm->getClassMetadata($mapping['targetDocument']);
        $mappedByMapping = isset($targetClass->fieldMappings[$mapping['mappedBy']]) ? $targetClass->fieldMappings[$mapping['mappedBy']] : array();
        $mappedByFieldName = isset($mappedByMapping['simple']) && $mappedByMapping['simple'] ? $mapping['mappedBy'] : $mapping['mappedBy'] . '.$id';
        $criteria = $this->cm->merge(
            array($mappedByFieldName => $ownerClass->getIdentifierObject($owner)),
            $this->dm->getFilterCollection()->getFilterCriteria($targetClass),
            isset($mapping['criteria']) ? $mapping['criteria'] : array()
        );
        $criteria = $this->uow->getDocumentPersister($mapping['targetDocument'])->prepareQueryOrNewObj($criteria);
        $qb = $this->dm->createQueryBuilder($mapping['targetDocument'])
            ->setQueryArray($criteria);

        if (isset($mapping['sort'])) {
            $qb->sort($mapping['sort']);
        }
        if (isset($mapping['limit'])) {
            $qb->limit($mapping['limit']);
        }
        if (isset($mapping['skip'])) {
            $qb->skip($mapping['skip']);
        }
        if ( ! empty($hints[Query::HINT_SLAVE_OKAY])) {
            $qb->slaveOkay(true);
        }
        if ( ! empty($hints[Query::HINT_READ_PREFERENCE])) {
            $qb->setReadPreference($hints[Query::HINT_READ_PREFERENCE], $hints[Query::HINT_READ_PREFERENCE_TAGS]);
        }

        return $qb->getQuery();
    }
192156
private function setCollection(PersistentCollectionInterface $coll)
    {
        list($qb, $path, $parent) = $this->getQueryPathAndParent($coll);

        $coll->initialize();

        $path->set($coll);
        $this->executeQuery($qb, $parent);
    }
752825
public function loadCollection(PersistentCollectionInterface $collection) : void
    {
        if ($collection->getOwner() === null) {
            throw PersistentCollectionException::ownerRequiredToLoadCollection();
        }

        $this->getDocumentPersister(get_class($collection->getOwner()))->loadCollection($collection);
        $this->lifecycleEventManager->postCollectionLoad($collection);
    }
1214918
public function persistLocalization(GroupLocalization $localization)
	{
		if ( ! $localization->isPersistent()) {
			// Reset ID because for not persisted object it is equal with master ID
			$localization->regenerateId();
			$this->setLocalization($localization);
			$localization->setPersistent();
		}
	}
557115
private function collectJoinTableColumnParameters(PersistentCollection $collection, $element)
    {
        $params           = [];
        $association      = $collection->getMapping();
        $owningClass      = $this->em->getClassMetadata(get_class($collection->getOwner()));
        $targetClass      = $collection->getTypeClass();
        $owningIdentifier = $this->uow->getEntityIdentifier($collection->getOwner());
        $targetIdentifier = $this->uow->getEntityIdentifier($element);
        $joinTable        = $association->getJoinTable();

        foreach ($joinTable->getJoinColumns() as $joinColumn) {
            $fieldName = $owningClass->fieldNames[$joinColumn->getReferencedColumnName()];

            $params[] = $owningIdentifier[$fieldName];
        }

        foreach ($joinTable->getInverseJoinColumns() as $joinColumn) {
            $fieldName = $targetClass->fieldNames[$joinColumn->getReferencedColumnName()];

            $params[] = $targetIdentifier[$fieldName];
        }

        return $params;
    }
90507
GroupIds getGroupIds(Node groupNode) throws RepositoryException
   {
      String storagePath = getGroupStoragePath();
      String nodePath = groupNode.getPath();

      String groupId = nodePath.substring(storagePath.length());
      String parentId = groupId.substring(0, groupId.lastIndexOf("/"));

      return new GroupIds(groupId, parentId);
   }
1030003
private static function populateIds(&$insertModels, $pks, $lastPk, $insertedCount)
    {
        while($insertedCount > 0 && $insertedCount <= count($insertModels))
        {
            $insertedCount--;
            $model = $insertModels[$insertedCount];
            $model->{$pks[0]} = $lastPk;
            $lastPk = intval($lastPk) - 1;
        }
    }
1317748
protected void associateBatched(Collection owners, Collection children)
    {
        CollectionDescriptor cds = getCollectionDescriptor();
        PersistentField field = cds.getPersistentField();
        PersistenceBroker pb = getBroker();
        Class ownerTopLevelClass = pb.getTopLevelClass(getOwnerClassDescriptor().getClassOfObject());
        Class collectionClass = cds.getCollectionClass(); // this collection type will be used:
        HashMap ownerIdsToLists = new HashMap(owners.size());

        IdentityFactory identityFactory = pb.serviceIdentity();
        // initialize the owner list map
        for (Iterator it = owners.iterator(); it.hasNext();)
        {
            Object owner = it.next();
            ownerIdsToLists.put(identityFactory.buildIdentity(getOwnerClassDescriptor(), owner), new ArrayList());
        }

        // build the children lists for the owners
        for (Iterator it = children.iterator(); it.hasNext();)
        {
            Object child = it.next();
            // BRJ: use cld for real class, relatedObject could be Proxy
            ClassDescriptor cld = getDescriptorRepository().getDescriptorFor(ProxyHelper.getRealClass(child));

            Object[] fkValues = cds.getForeignKeyValues(child, cld);
            Identity ownerId = identityFactory.buildIdentity(null, ownerTopLevelClass, fkValues);
            List list = (List) ownerIdsToLists.get(ownerId);
            if (list != null)
            {
                list.add(child);
            }
        }

        // connect children list to owners
        for (Iterator it = owners.iterator(); it.hasNext();)
        {
            Object result;
            Object owner = it.next();
            Identity ownerId = identityFactory.buildIdentity(owner);
            List list = (List) ownerIdsToLists.get(ownerId);

            if ((collectionClass == null) && field.getType().isArray())
            {
                int length = list.size();
                Class itemtype = field.getType().getComponentType();
                result = Array.newInstance(itemtype, length);
                for (int j = 0; j < length; j++)
                {
                    Array.set(result, j, list.get(j));
                }
            }
            else
            {
                ManageableCollection col = createCollection(cds, collectionClass);
                for (Iterator it2 = list.iterator(); it2.hasNext();)
                {
                    col.ojbAdd(it2.next());
                }
                result = col;
            }

            Object value = field.get(owner);
            if ((value instanceof CollectionProxyDefaultImpl) && (result instanceof Collection))
            {
                ((CollectionProxyDefaultImpl) value).setData((Collection) result);
            }
            else
            {
                field.set(owner, result);
            }
        }
    }
804798
public function setAliasesId(Collection $pages)
    {
        $pages->each(function (PageInterface $page) {
            $page->setAliasId();

            if ($page->getPages()->count()) {
                $this->setAliasesId($page->getPages());
            }
        });
    }
1244445
public function loadTypesDataForGroup($groupId, $status)
    {
        try {
            return $this->innerGateway->loadTypesDataForGroup($groupId, $status);
        } catch (DBALException $e) {
            throw new RuntimeException('Database error', 0, $e);
        } catch (PDOException $e) {
            throw new RuntimeException('Database error', 0, $e);
        }
    }
543929
protected function updateIdentityMap(EntityCollection $collection)
    {
        if ($collection->isEmpty()) {
            return $this;
        }

        foreach ($collection as $entity)
        {
            $this->repository->getIdentityMap()->set($entity);
        }
        return $this;
    }