Cascades the postUpdate and postPersist events to embedded documents.
497786
private function cascadePostUpdate(ClassMetadata $class, object $document) : void
    {
        foreach ($class->getEmbeddedFieldsMappings() as $mapping) {
            $value = $class->reflFields[$mapping['fieldName']]->getValue($document);
            if ($value === null) {
                continue;
            }
            $values = $mapping['type'] === ClassMetadata::ONE ? [$value] : $value;

            foreach ($values as $entry) {
                if (empty($this->uow->getDocumentChangeSet($entry)) && ! $this->uow->hasScheduledCollections($entry)) {
                    continue;
                }
                $entryClass = $this->dm->getClassMetadata(get_class($entry));
                $event      = $this->uow->isScheduledForInsert($entry) ? Events::postPersist : Events::postUpdate;
                $entryClass->invokeLifecycleCallbacks($event, $entry, [new LifecycleEventArgs($entry, $this->dm)]);
                $this->evm->dispatchEvent($event, new LifecycleEventArgs($entry, $this->dm));

                $this->cascadePostUpdate($entryClass, $entry);
            }
        }
    }
1359189
private function mergePartial(array &$document, array $updatedDocument, $prefix = null)
    {
        foreach ($updatedDocument as $key => $newValue) {
            // if original data is embedded document and value also - then merge
            if (is_array($newValue) && isset($document[$key]) && $this->isEmbeddedDocument($document[$key])) {
                $this->mergePartial($document[$key], $newValue, $prefix . $key . '.');
            } // in other cases just set new value
            else {
                $document[$key] = $newValue;
                $this->modifiedFields[] = $prefix . $key;
            }
        }
    }
502834
function incrementDocument(params) {
  var doc = (collections[params.collection] || {})[params.id]

  if (doc !== undefined) {
    doc[params.key] = (doc[params.key] || 0) + (params.by || 1)

    eventEmitter.emit('documentIncremented', params.collection, doc)
  }
}
784142
public function onPostSerialize(ObjectEvent $event)
    {
        $document = $event->getObject();

        if (!$document instanceof ChildrenBehavior || !$this->documentRegistry->hasDocument($document)) {
            return;
        }

        $visitor = $event->getVisitor();
        $visitor->addData('hasSub', $this->documentInspector->hasChildren($document));
    }
164077
private void publishEvent(WSJobExecution objectToPublish, String eventToPublishTo, String correlationId) {
        if (eventsPublisher != null) {
            eventsPublisher.publishJobExecutionEvent(objectToPublish, eventToPublishTo, correlationId);
        }
    }
1123788
private void onParticipantUpdated(ParticipantUpdatedEvent event) {
        handler.post(() -> listener.onParticipantUpdated(event));
        log("Event published " + event.toString());
    }
100032
function insertAttachmentMappings(docInfo, seq, callback) {

    var attsAdded = 0;
    var attsToAdd = Object.keys(docInfo.data._attachments || {});

    if (!attsToAdd.length) {
      return callback();
    }

    function checkDone() {
      if (++attsAdded === attsToAdd.length) {
        callback();
      }
    }

    function add(att) {
      var digest = docInfo.data._attachments[att].digest;
      var req = attachAndSeqStore.put({
        seq: seq,
        digestSeq: digest + '::' + seq
      });

      req.onsuccess = checkDone;
      req.onerror = function (e) {
        // this callback is for a constaint error, which we ignore
        // because this docid/rev has already been associated with
        // the digest (e.g. when new_edits == false)
        e.preventDefault(); // avoid transaction abort
        e.stopPropagation(); // avoid transaction onerror
        checkDone();
      };
    }
    for (var i = 0; i < attsToAdd.length; i++) {
      add(attsToAdd[i]); // do in parallel
    }
  }
92481
protected function postStoreProcess()
    {
        $aggregate = $this->aggregate;

        // Create any related object that doesn't exist in the database.
        $foreignRelationships = $aggregate->getEntityMap()->getForeignRelationships();

        $this->createRelatedEntities($foreignRelationships);

        // Update any pivot tables that has been modified.
        $aggregate->updatePivotRecords();

        // Update any dirty relationship. This include relationships that already exists, have
        // dirty attributes / newly created related entities / dirty related entities.
        $dirtyRelatedAggregates = $aggregate->getDirtyRelationships();

        foreach ($dirtyRelatedAggregates as $related) {
            $this->createStoreCommand($related)->execute();
        }

        // Now we can sync the related collections
        //
        // TODO (note) : not sure this check is needed, as we can assume
        // the aggregate exists in the Post Store Process
        if ($this->aggregate->exists()) {
            $this->aggregate->syncRelationships($foreignRelationships);
        }

        // TODO be move it to the wrapper class
        // so it's the same code for the entity builder
        $aggregate->setProxies();

        // Update Entity Cache
        $aggregate->getMapper()->getEntityCache()->refresh($aggregate);
    }
1192774
def _recursive_upsert(context, params, data):
    """"""
    children = params.get("children", {})
    nested_calls = []
    for child_params in children:
        key = child_params.get("key")
        child_data_list = ensure_list(data.pop(key))
        if isinstance(child_data_list, dict):
            child_data_list = [child_data_list]
        if not (isinstance(child_data_list, list) and
                all(isinstance(i, dict) for i in child_data_list)):
            context.log.warn(
                "Expecting a dict or a lost of dicts as children for key", key
            )
            continue
        if child_data_list:
            table_suffix = child_params.get("table_suffix", key)
            child_params["table"] = params.get("table") + "_" + table_suffix
            # copy some properties over from parent to child
            inherit = child_params.get("inherit", {})
            for child_data in child_data_list:
                for dest, src in inherit.items():
                    child_data[dest] = data.get(src)
                nested_calls.append((child_params, child_data))
    # Insert or update data
    _upsert(context, params, data)
    for child_params, child_data in nested_calls:
        _recursive_upsert(context, child_params, child_data)
697182
private function cascadeRefresh($document, array &$visited)
    {
        $class = $this->dm->getClassMetadata(get_class($document));
        foreach ($class->fieldMappings as $mapping) {
            if ( ! $mapping['isCascadeRefresh']) {
                continue;
            }
            if (isset($mapping['embedded'])) {
                $relatedDocuments = $class->reflFields[$mapping['fieldName']]->getValue($document);
                if (($relatedDocuments instanceof Collection || is_array($relatedDocuments))) {
                    if ($relatedDocuments instanceof PersistentCollection) {
                        // Unwrap so that foreach() does not initialize
                        $relatedDocuments = $relatedDocuments->unwrap();
                    }
                    foreach ($relatedDocuments as $relatedDocument) {
                        $this->cascadeRefresh($relatedDocument, $visited);
                    }
                } elseif ($relatedDocuments !== null) {
                    $this->cascadeRefresh($relatedDocuments, $visited);
                }
            } elseif (isset($mapping['reference'])) {
                $relatedDocuments = $class->reflFields[$mapping['fieldName']]->getValue($document);
                if (($relatedDocuments instanceof Collection || is_array($relatedDocuments))) {
                    if ($relatedDocuments instanceof PersistentCollection) {
                        // Unwrap so that foreach() does not initialize
                        $relatedDocuments = $relatedDocuments->unwrap();
                    }
                    foreach ($relatedDocuments as $relatedDocument) {
                        $this->doRefresh($relatedDocument, $visited);
                    }
                } elseif ($relatedDocuments !== null) {
                    $this->doRefresh($relatedDocuments, $visited);
                }
            }
        }
    }
212517
function triggerMultiSelectEvents ( collection, prevSelected, options, reselected ) {
        function mapCidsToModels ( cids, collection, previousSelection ) {
            function mapper ( cid ) {
                // Find the model in the collection. If not found, it has been removed, so get it from the array of
                // previously selected models.
                return collection.get( cid ) || previousSelection[cid];
            }

            return _.map( cids, mapper );
        }

        if ( options.silent || options["@bbs:silentLocally"] ) return;

        var diff,
            label = getLabel( options, collection ),

            selectionSize = getSelectionSize( collection, label ),
            length = collection.length,

            prevSelectedCids = _.keys( prevSelected ),
            selectedCids = _.keys( collection[label] ),
            addedCids = _.difference( selectedCids, prevSelectedCids ),
            removedCids = _.difference( prevSelectedCids, selectedCids ),

            unchanged = (selectionSize === prevSelectedCids.length && addedCids.length === 0 && removedCids.length === 0);

        if ( reselected && reselected.length && !options["@bbs:silentReselect"] ) {
            queueEventSet( "reselect:any", label, [ reselected, collection, toEventOptions( options, label, collection ) ], collection, options );
        }

        if ( unchanged ) return;

        diff = {
            selected: mapCidsToModels( addedCids, collection, prevSelected ),
            deselected: mapCidsToModels( removedCids, collection, prevSelected )
        };

        if ( selectionSize === 0 ) {
            queueEventSet( "select:none", label, [ diff, collection, toEventOptions( options, label, collection ) ], collection, options );
            return;
        }

        if ( selectionSize === length ) {
            queueEventSet( "select:all", label, [ diff, collection, toEventOptions( options, label, collection ) ], collection, options );
            return;
        }

        if ( selectionSize > 0 && selectionSize < length ) {
            queueEventSet( "select:some", label, [ diff, collection, toEventOptions( options, label, collection ) ], collection, options );
            return;
        }
    }
429136
def add_or_update(uid, post_data):
        '''
        
        '''
        cur_rec = MPost.get_by_uid(uid)
        if cur_rec:
            MPost.update(uid, post_data)
        else:
            MPost.create_post(uid, post_data)
375631
def bulk_insert(self, resource, docs, **kwargs):
        """"""
        kwargs.update(self._es_args(resource))
        parent_type = self._get_parent_type(resource)
        if parent_type:
            for doc in docs:
                if doc.get(parent_type.get('field')):
                    doc['_parent'] = doc.get(parent_type.get('field'))

        res = bulk(self.elastic(resource), docs, stats_only=False, **kwargs)
        self._refresh_resource_index(resource)
        return res
711053
function setModifiedDate (subj, kb, doc) {
      if (SET_MODIFIED_DATES) {
        if (!getOption(tracker, 'trackLastModified')) return
        var deletions = kb.statementsMatching(subject, DCT('modified'))
        deletions = deletions.concat(kb.statementsMatching(subject, WF('modifiedBy')))
        var insertions = [ $rdf.st(subject, DCT('modified'), new Date(), doc) ]
        if (me) insertions.push($rdf.st(subject, WF('modifiedBy'), me, doc))
        updater.update(deletions, insertions, function (uri, ok, body) {})
      }
    }
623075
private Component applyPostProcessors(Component in, Context context, Arguments args)
    {
        Component out = in;

        for (final PostProcessor postProcessor : postProcessors)
        {
            out = postProcessor.process(out, context, args);
        }

        return out;
    }
1045597
private void publishEvent(WSJobInstance objectToPublish, String eventToPublishTo, String correlationId) {
        if (eventsPublisher != null) {
            eventsPublisher.publishJobInstanceEvent(objectToPublish, eventToPublishTo, correlationId);
        }
    }
267654
def populate(self, blueprint, documents):
        """"""

        # Finish the documents
        documents = self.finish(blueprint, documents)

        # Convert the documents to frame instances
        frames = []
        for document in documents:
            # Separate out any meta fields
            meta_document = {}
            for field_name in blueprint._meta_fields:
                meta_document[field_name] = document[field_name]
                document.pop(field_name)

            # Initialize the frame
            frame = blueprint.get_frame_cls()(document)

            # Apply any meta fields
            for key, value in meta_document.items():
                setattr(frame, key, value)

            frames.append(frame)

        # Insert the documents
        blueprint.on_fake(frames)
        frames = blueprint.get_frame_cls().insert_many(frames)
        blueprint.on_faked(frames)

        return frames