public function retrieveSet(EntitySetRetrieverCriteria $criteria) { try { $containerName = $criteria->getContainerName(); $data = $this->entityDataRepository->retrieveSet($criteria); if (empty($data)) { return null; } $entities = $this->dataIsHumanReadable ? $this->entityAdapter->fromHumanReadableDatasToEntities($data['entities']) : $this->entityAdapter->fromDatasToEntities($data['entities']); return new ConcreteMultipleEntityOutput($entities, $data['index'], $data['amount'], $data['total_amount']); } catch (EntityException $exception) { throw new EntityRepositoryException('There was an exception while converting data to an Entity objects.', $exception); } catch (MultipleEntityOutputException $exception) { throw new EntityRepositoryException('There was an exception while creating a MultipleEntityOutput object.', $exception); } }
public function retrieveSet(EntitySetRetrieverCriteria $criteria) { $container = $criteria->getContainerName(); $index = $criteria->getIndex(); $amount = $criteria->getAmount(); $uri = '/' . $container; try { $httpRequest = $this->httpRequestAdapter->fromDataToHttpRequest(['uri' => $uri, 'method' => 'get', 'port' => $this->port, 'query_parameters' => ['index' => $index, 'amount' => $amount], 'headers' => $this->headers]); $data = $this->executeRequest($httpRequest); if (!isset($data['entities']) || empty($data['entities'])) { $data['entities'] = []; } foreach ($data['entities'] as $index => $oneData) { $data['entities'][$index]['container'] = $container; } return $data; } catch (HttpApplicationException $exception) { throw new EntityRepositoryException('There was an exception while using the HttpApplication.', $exception); } }
private function createSetQuery(EntitySetRetrieverCriteria $criteria, $containerName) { $index = $criteria->getIndex(); $amount = $criteria->getAmount(); $totalAmount = $this->fetchFirst('select count(*) as amount from ' . $containerName); return array('name' => 'select * from ' . $containerName . ' order by created_on asc limit ' . $index . ',' . $amount . ';', 'index' => $index, 'total_amount' => $this->retrieveTotalAmount($containerName)); }