コード例 #1
0
 public function retrieveMultiple(MultipleEntityRetrieverCriteria $criteria)
 {
     try {
         $containerName = $criteria->getContainerName();
         $data = $this->entityDataRepository->retrieveMultiple($criteria);
         if (empty($data)) {
             return null;
         }
         return $this->dataIsHumanReadable ? $this->entityAdapter->fromHumanReadableDatasToEntities($data) : $this->entityAdapter->fromDatasToEntities($data);
     } catch (EntityException $exception) {
         throw new EntityRepositoryException('There was an exception while converting datas to Entity objects.', $exception);
     }
 }
コード例 #2
0
 public function retrieveMultiple(MultipleEntityRetrieverCriteria $criteria)
 {
     if (!$criteria->hasUuids()) {
         throw new EntityRepositoryException('There must be at least 1 retriever criteria in order to retrieve multiple entities data.');
     }
     try {
         $container = $criteria->getContainerName();
         $uri = '/' . $container;
         $uuids = $criteria->getUuids();
         $uuidStrings = $this->uuidAdapter->fromUuidsToHumanReadableStrings($uuids);
         $data = $this->executeRequest($httpRequest);
         foreach ($data as $index => $oneData) {
             $data[$index]['container'] = $container;
         }
         return $data;
     } catch (UuidException $exception) {
         throw new EntityRepositoryException('There was an exception while converting uuids to human readable strings.', $exception);
     } catch (HttpApplicationException $exception) {
         throw new EntityRepositoryException('There was an exception while using the HttpApplication.', $exception);
     }
 }
コード例 #3
0
 private function createMultipleQuery(MultipleEntityRetrieverCriteria $criteria, $containerName)
 {
     $orderingString = 'order by created_on asc';
     if ($criteria->hasOrdering()) {
         $ordering = $criteria->getOrdering();
         $orderingString = $this->createOrdering($ordering);
     }
     if ($criteria->hasUuids()) {
         $uuids = $criteria->getUuids();
         $binaries = $this->uuidAdapter->fromUuidsToBinaryStrings($uuids);
         $keys = array_keys($binaries);
         $keysWithSemiColon = array_map(function ($oneKeyname) {
             return ':' . $oneKeyname;
         }, $keys);
         return array('name' => 'select * from ' . $containerName . ' where uuid IN( ' . implode(', ', $keysWithSemiColon) . ' ) ' . $orderingString . ';', 'params' => $binaries);
     }
     if ($criteria->hasKeyname()) {
         $keyname = $criteria->getKeyname();
         $name = $keyname->getName();
         $nameWithSemicolon = ':' . $name;
         $value = $keyname->getValue();
         return array('name' => 'select * from ' . $containerName . ' where ' . $name . ' = ' . $nameWithSemicolon . ' ' . $orderingString . ';', 'params' => [$name => $value]);
     }
     throw new EntityRepositoryException('There must be at least 1 retriever criteria in order to retrieve multiple entities data.');
 }