diff options
author | Maxence Lange <maxence@artificial-owl.com> | 2018-05-12 16:06:51 +0300 |
---|---|---|
committer | Maxence Lange <maxence@artificial-owl.com> | 2018-05-12 16:06:51 +0300 |
commit | 08cbbe46f3d6f671e90a200ae471fc2d736044d1 (patch) | |
tree | 3141aeb55ea99f6d3cc6b4fda74332bfacd468ee | |
parent | 7bde6ba45b885f4475844eb8252081f34a7de8c6 (diff) |
set source into index
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
-rw-r--r-- | appinfo/database.xml | 7 | ||||
-rw-r--r-- | lib/Db/IndexesRequest.php | 2 | ||||
-rw-r--r-- | lib/Db/IndexesRequestBuilder.php | 4 | ||||
-rw-r--r-- | lib/Model/Index.php | 39 |
4 files changed, 50 insertions, 2 deletions
diff --git a/appinfo/database.xml b/appinfo/database.xml index f636c6c..1c93323 100644 --- a/appinfo/database.xml +++ b/appinfo/database.xml @@ -51,6 +51,13 @@ </field> <field> + <name>source</name> + <type>text</type> + <length>64</length> + <notnull>true</notnull> + </field> + + <field> <name>owner_id</name> <type>text</type> <length>64</length> diff --git a/lib/Db/IndexesRequest.php b/lib/Db/IndexesRequest.php index 0e6a97f..312eefb 100644 --- a/lib/Db/IndexesRequest.php +++ b/lib/Db/IndexesRequest.php @@ -48,6 +48,7 @@ class IndexesRequest extends IndexesRequestBuilder { $qb->setValue('owner_id', $qb->createNamedParameter($index->getOwnerId())) ->setValue('provider_id', $qb->createNamedParameter($index->getProviderId())) ->setValue('document_id', $qb->createNamedParameter($index->getDocumentId())) + ->setValue('source', $qb->createNamedParameter($index->getSource())) ->setValue('err', $qb->createNamedParameter($index->getError())) ->setValue('message', $qb->createNamedParameter($index->getMessage())) ->setValue('status', $qb->createNamedParameter($index->getStatus())) @@ -78,6 +79,7 @@ class IndexesRequest extends IndexesRequestBuilder { $qb = $this->getIndexesUpdateSql(); $qb->set('status', $qb->createNamedParameter($index->getStatus())); + $qb->set('source', $qb->createNamedParameter($index->getSource())); $qb->set('options', $qb->createNamedParameter(json_encode($index->getOptions()))); if ($index->getOwnerId() !== '') { diff --git a/lib/Db/IndexesRequestBuilder.php b/lib/Db/IndexesRequestBuilder.php index 4557886..647bb17 100644 --- a/lib/Db/IndexesRequestBuilder.php +++ b/lib/Db/IndexesRequestBuilder.php @@ -86,7 +86,8 @@ class IndexesRequestBuilder extends CoreRequestBuilder { /** @noinspection PhpMethodParametersCountMismatchInspection */ $qb->select( - 'li.owner_id', 'li.provider_id', 'li.document_id', 'li.status', 'li.options', 'li.err', + 'li.owner_id', 'li.provider_id', 'li.document_id', 'li.source', 'li.status', + 'li.options', 'li.err', 'li.message', 'li.indexed' ) ->from(self::TABLE_INDEXES, 'li'); @@ -118,6 +119,7 @@ class IndexesRequestBuilder extends CoreRequestBuilder { protected function parseIndexesSelectSql($data) { $index = new ExtendedIndex($data['provider_id'], $data['document_id']); $index->setStatus($data['status']) + ->setSource($data['source']) ->setOptions(json_decode($data['options'], true)) ->setError($data['err']) ->setMessage($data['message']) diff --git a/lib/Model/Index.php b/lib/Model/Index.php index a390e6a..0c01171 100644 --- a/lib/Model/Index.php +++ b/lib/Model/Index.php @@ -51,6 +51,9 @@ class Index implements \JsonSerializable { private $documentId; /** @var string */ + private $source = ''; + + /** @var string */ private $ownerId = ''; /** @var int */ @@ -91,6 +94,25 @@ class Index implements \JsonSerializable { /** + * @param string $source + * + * @return $this + */ + public function setSource($source) { + $this->source = $source; + + return $this; + } + + /** + * @return string + */ + public function getSource() { + return $this->source; + } + + + /** * @param string $ownerId * * @return $this @@ -159,7 +181,7 @@ class Index implements \JsonSerializable { * * @return $this */ - public function setOption($option, $value) { + public function addOption($option, $value) { $this->options[$option] = $value; return $this; @@ -185,6 +207,21 @@ class Index implements \JsonSerializable { /** + * @param string $option + * @param string $default + * + * @return mixed|string + */ + public function getOption($option, $default = '') { + if (!array_key_exists($option, $this->options)) { + return $default; + } + + return $this->options[$option]; + } + + + /** * @param int $err * * @return $this |