public function getAll() { if ($this->notificationType === null) { throw new \Exception("Not set notification Type"); } $query = new Query(); $query->setQuery(new EqNode(AllNotificationDataStoreFactory::KEY_EBAY_NOTIFICATION_TYPE, $this->notificationType)); return $this->dataByType($this->dataStore->query($query)); }
public function getConfiguration() { if ($this->dataStore instanceof ConfigurableInterface) { return $this->dataStore->getConfiguration(); } $query = new Query(); $query->setLimit(new LimitNode(1)); $data = $this->dataStore->query($query); $config = []; if (count($data) > 0 and isset($data[0])) { foreach ($data[0] as $key => $value) { $config[] = ['label' => $key, 'field' => $key]; } } return $config; }
protected function methodPatchWithId(Request $request, Response $response) { $cdsId = $request->getAttribute('Primary-Key-Value'); $cdsConf = $this->getCdsConf($cdsId); if (empty($cdsConf)) { throw new \Exception("this cds id not found"); } if ($cdsConf['query'] !== '') { $query = RqlParser::rqlDecode($cdsConf['query']); } else { $query = new Query(); } $data = $this->getData($cdsConf['script_name'], $query); $query = new Query(); $query->setQuery(new EqNode('cds_id', $cdsId)); $items = $this->cds->query($query); foreach ($items as $item) { $this->cds->delete($item['id']); } foreach ($data as &$item) { $item['cds_id'] = $cdsId; $item['data_id'] = $item['id']; unset($item['id']); } $this->cds->create($data); $this->cdsManagerStore->update(['id' => $cdsConf['id'], 'freshness_date' => (new \DateTime())->format("Y-m-d H:i:s")]); $request = $request->withAttribute('CDS-ID', $cdsId); $request = $request->withAttribute('Response-Body', ['cdsId' => $cdsId]); $response = $response->withStatus(200); return array($request, $response); }
public function __construct(DataStoresInterface $cachingDbTable, $cdsId) { $this->cachingDbTable = $cachingDbTable; $query = new Query(); $query->setQuery(new EqNode($this->cdsIdentifierString, $cdsId)); $this->items = $this->cachingDbTable->query($query); foreach ($this->items as &$item) { $item[$this->cachingDbTable->getIdentifier()] = $item[$this->dataIdentifierString]; unset($item[$this->dataIdentifierString]); unset($item[$this->cdsIdentifierString]); $item = array_filter($item); foreach ($item as $key => $value) { switch ($key) { case in_array($key, $this->fieldType['int']): if (is_numeric($value)) { $item[$key] = (int) $value; } else { throw new \Exception('Can\'t parse to int value:' . $value . 'from field: ' . $key); } break; case in_array($key, $this->fieldType['float']): if (is_numeric($value)) { $item[$key] = (double) $value; } else { throw new \Exception('Can\'t parse to float value:' . $value . 'from field: ' . $key); } break; case in_array($key, $this->fieldType['string']): $item[$key] = (string) $value; break; default: throw new \Exception('Type not set for field: ' . $key); } } } parent::__construct(); }
public function query(Query $query) { return $this->cashStore->query($query); }
/** * {@inheritdoc} * * {@inheritdoc} */ public function query(Query $query) { $this->preQuery($query); $result = $this->dataStore->query($query); return $this->postQuery($result, $query); }