Replace all object ids in an array with the umis according to
the given umiPrefix.
@param $oids The array of oids
@param $umiPrefix The umi prefix
@return The array of umis
191039
protected function makeUmis($oids, $umiPrefix) {
    $result = [];
    foreach ($oids as $oid) {
      if (strlen($oid->getPrefix()) == 0) {
        $umi = new ObjectId($oid->getType(), $oid->getId(), $umiPrefix);
        $result[] = $umi;
      }
    }
    return $result;
  }
624370
public function has(string ...$oids): bool
    {
        foreach ($oids as $oid) {
            if (!in_array($oid, $this->_purposes)) {
                return false;
            }
        }
        return true;
    }
953241
def filter_oids(self, oids):
        '''
        
        '''
        oids = set(oids)
        return self[self['_oid'].map(lambda x: x in oids)]
598766
protected function initExport($oids) {
    $persistenceFacade = $this->getPersistenceFacade();
    $message = $this->getMessage();

    // get document definition
    $docFile = $this->getDownloadFile();

    // delete export file
    if (file_exists($docFile)) {
      unlink($docFile);
    }

    // get the query
    $queryTerm = urldecode($this->getRequestValue('query'));

    // add sort term
    $sortArray = null;
    $orderBy = $this->getRequestValue('sortFieldName');
    if (strlen($orderBy) > 0) {
      $sortArray = [$orderBy." ".$this->getRequestValue('sortDirection')];
    }

    // determine the type
    $type =  $this->getRequestValue('className');
    $sourceId = $this->getRequestValue('sourceId');
    $relation = $this->getRequestValue('relation');
    if ($sourceId && $relation) {
      // type is determined by the other end of the relation
      $sourceNode = $persistenceFacade->load(new ObjectId($type, $sourceId));
      $relationDescription = $sourceNode->getMapper()->getRelation($relation);
      $type = $relationDescription->getOtherType();
    }

    // get object ids of all nodes to export
    $query = new StringQuery($type);
    $query->setRQLConditionString($queryTerm);

    // add relation query, if requested
    if ($relation && $sourceNode) {
      $existingQuery = $query->getConditionString();
      $query->setConditionString((strlen($existingQuery) > 0 ? $existingQuery.' AND ' : '').NodeUtil::getRelationQueryCondition($sourceNode, $relation));
    }

    $oids = $query->execute(false, $sortArray);

    // get csv columns
    $names = [];
    $mapper = $persistenceFacade->getMapper($type);
    foreach($mapper->getAttributes() as $attribute) {
      $names[] = $attribute->getName();
    }

    // initialize export file
    $fileHandle = fopen($docFile, "a");
    fputcsv($fileHandle, $names);
    fclose($fileHandle);

    // create work packages for nodes
    $nodesPerCall = $this->getRequestValue('nodesPerCall');
    $this->addWorkPackage(
            $message->getText('Exporting %0%', [$type]),
            $nodesPerCall, $oids, 'exportNodes');
  }
258503
protected function index($oids) {
    $persistenceFacade = $this->getPersistenceFacade();
    foreach($oids as $oid) {
      if (ObjectId::isValid($oid)) {
        $obj = $persistenceFacade->load($oid);
        if ($obj) {
          $this->search->addToIndex($obj);
        }
      }
    }
    $this->search->commitIndex(false);

    if ($this->getStepNumber() == $this->getNumberOfSteps()) {
      $this->addWorkPackage($this->getMessage()->getText('Optimizing index'),
              1, [0], 'optimize');
    }
  }
137396
public static byte[] getIids(final List<String> ids, final UniqueIds uids) {
        final int size = ids.size();
        final byte[] iids = new byte[IID_WIDTH * size];
        for (int i = 0; i < size; i++) {
            final String instanceId = ids.get(i);
            final byte[] iid = uids.getUiid().getId(instanceId);
            System.arraycopy(iid, 0, iids, i * IID_WIDTH, IID_WIDTH);
        }
        return iids;
    }
373805
public function objectFromIndex(IObjectSetWithIdentityByIndex $objects) : ObjectFieldBuilder
    {
        return new ObjectFieldBuilder(
            $this->type(new ObjectIdType(new ObjectIndexOptions($objects), $loadAsObjects = true))
        );
    }
64182
public function objectsFromIndexes(IObjectSetWithIdentityByIndex $objects) : ObjectArrayFieldBuilder
    {
        return (new ObjectArrayFieldBuilder($this
            ->type(new ArrayOfObjectIdsType(
                $objects,
                Field::element()->objectFromIndex($objects)->required()->build(),
                $loadAsObjects = true
            ))
        ));
    }
1322837
public function getIndexes( $oid )
    {

        // load primary keys
        $query = new Query(
            "SELECT string_to_array( indkey::text, ' ') AS keys, * FROM pg_index WHERE indrelid = %oid:int%",
            array( 'oid' => $this->get('oid') )
        );

        $indexes = $this->db->query( $query )->fetch(Result::TYPE_DETECT);

        foreach( $this->indexes as &$index ) {

            $index['columns'] = array();

            foreach( $index['keys'] as $columnIndex ) {
                $index['columns'][] = sprintf(
                    '%s.%s',
                    $oid,
                    $columnIndex
                );
            }

        }

        return $indexes;

    }
1284089
public function setId($parameterIndex, ObjectIdInterface $id)
    {
        $this->setParameter($parameterIndex, $this->escape($id->getId()));
    }
472687
private function getMappingByUuidPrefix($uuidPrefix)
    {
        $expr = Expr::startsWith($uuidPrefix, AssetMapping::UUID);

        $mappings = $this->assetManager->findAssetMappings($expr);

        if (!$mappings) {
            throw new RuntimeException(sprintf(
                'The mapping with the UUID prefix "%s" does not exist.',
                $uuidPrefix
            ));
        }

        if (count($mappings) > 1) {
            throw new RuntimeException(sprintf(
                'More than one mapping matches the UUID prefix "%s".',
                $uuidPrefix
            ));
        }

        return reset($mappings);
    }
85550
protected function exportNodes($oids) {
    // Export starts from root oids and iterates over all children.
    // On every call we have to decide what to do:
    // - If there is an iterator stored in the session we are inside a tree and continue iterating (_NODES_PER_CALL nodes)
    //   until the iterator finishes
    // - If the oids array holds one value!=null this is assumed to be an root oid and a new iterator is constructed
    // - If there is no iterator and no oid given, we return

    $session = $this->getSession();
    $persistenceFacade = $this->getPersistenceFacade();
    $message = $this->getMessage();

    // get document definition
    $docFile = $this->getDownloadFile();
    $nodesPerCall = $this->getRequestValue('nodesPerCall');
    $cacheSection = $this->getRequestValue('cacheSection');

    // check for iterator in session
    $iterator = PersistentIterator::load($this->ITERATOR_ID_VAR, $persistenceFacade, $session);
    // no iterator but oid given, start with new root oid
    if ($iterator == null && sizeof($oids) > 0 && $oids[0] != null) {
      $iterator = new PersistentIterator($this->ITERATOR_ID_VAR, $persistenceFacade, $session, $oids[0]);
    }
    // no iterator, no oid, finish
    if ($iterator == null) {
      $this->addWorkPackage($message->getText('Finish'), 1, [null], 'finishExport');
      return;
    }

    // process nodes
    $fileHandle = fopen($docFile, "a");
    $counter = 0;
    while ($iterator->valid() && $counter < $nodesPerCall) {
      // write node
      $this->writeNode($fileHandle, $iterator->current(), $iterator->key()+1);
      $iterator->next();
      $counter++;
    }
    $this->endTags($fileHandle, 0);
    fclose($fileHandle);

    // decide what to do next
    $rootOIDs = $this->cache->get($cacheSection, self::CACHE_KEY_ROOT_OIDS);
    if (!$iterator->valid() && sizeof($rootOIDs) > 0) {
      // if the current iterator is finished, reset the iterator and proceed with the next root oid
      $nextOID = array_shift($rootOIDs);
      // store remaining root oids in the cache
      $this->cache->put($cacheSection, self::CACHE_KEY_ROOT_OIDS, $rootOIDs);
      // delete iterator to start with new root oid
      PersistentIterator::reset($this->ITERATOR_ID_VAR, $session);

      $name = $message->getText('Exporting tree: start with %0%', [$nextOID]);
      $this->addWorkPackage($name, 1, [$nextOID], 'exportNodes');
    }
    elseif ($iterator->valid()) {
      // proceed with current iterator
      $iterator->save();

      $name = $message->getText('Exporting tree: continue with %0%', [$iterator->current()]);
      $this->addWorkPackage($name, 1, [null], 'exportNodes');
    }
    else {
      // finish
      $this->addWorkPackage($message->getText('Finish'), 1, [null], 'finishExport');
    }
  }
250175
public function batchBlackList(array $openids)
    {
        $url = "https://api.weixin.qq.com/cgi-bin/tags/members/batchblacklist?access_token=ACCESS_TOKEN";
        $this->registerApi($url, __FUNCTION__, func_get_args());
        return $this->httpPostForJson($url, ['openid_list' => $openids]);
    }
845286
protected function initImport($oids) {
    $message = $this->getMessage();

    // get document definition
    $type =  $this->getRequestValue('className');
    $docFile = $this->getRequestValue('uploadFile');
    $cacheSection = $this->getRequestValue('cacheSection');

    // get stats from cache
    $stats = $this->cache->get($cacheSection, self::CACHE_KEY_STATS);
    $this->getResponse()->setValue('stats', $stats);

    // oids are line numbers
    $oids = [];
    $file = new \SplFileObject($docFile);
    $file->seek(1); // skip header
    $eof = false;
    while (!$eof) {
      $content = $file->current();
      if (strlen(trim($content)) > 0) {
        $oids[] = $file->key();
      }
      $file->next();
      $eof = $file->eof();
    }

    // create work packages for nodes
    $nodesPerCall = $this->getRequestValue('nodesPerCall');
    $this->addWorkPackage(
            $message->getText('Importing %0%', [$type]),
            $nodesPerCall, $oids, 'importNodes');
  }
341702
protected static function prepareBinding(array $replacements = [], $prefix = '{', $suffix = '}')
    {
        $replacements = Arr::dot($replacements);
        $bindings     = [];

        foreach ($replacements as $key => $value) {
            $bindings["{$prefix}{$key}{$suffix}"] = $value;
        }

        return $bindings;
    }
1251026
public function update($identifiers)
    {
        $parents = func_get_args();

        $id = array_pop($parents);

        $entity = $parents ? $this->resource->singleByParent(end($parents), $id) : $this->resource->single($id);

        if ($this->failsSecurity($entity)) {
            return $this->responseDenied();
        }

        if (!$entity || $this->failsParentMatch($parents)) {
            return $this->responseNotFound();
        }

        $input = $this->getInput();

        if ($this->failsValidation($input)) {
            return $this->responseBadInput();
        }

        $this->resource->update($id, $input);

        return $this->response(null, 204);
    }
588961
public function getIndex($listUuid = null)
    {
        $indexKey = ListRepositoryInterface::INDEX;
        $index = $this->client->hgetall($indexKey);
        $this->removeExpiredListsFromIndex($index);

        if ($listUuid) {
            return (isset($index[(string) $listUuid])) ? unserialize($this->client->hget($indexKey, $listUuid)) : null;
        }

        return array_map('unserialize', $this->client->hgetall($indexKey));
    }