From a3b5b516d2152d9d27c5c952ba2d0183ebe333a6 Mon Sep 17 00:00:00 2001 From: Daniel Opitz Date: Mon, 16 Apr 2018 22:28:53 +0200 Subject: add getters + setters for feed entity --- lib/Db/Feed.php | 566 +++++++++++++++++++++++++---- tests/Integration/Fixtures/FeedFixture.php | 3 +- 2 files changed, 492 insertions(+), 77 deletions(-) diff --git a/lib/Db/Feed.php b/lib/Db/Feed.php index 7541ac545..b2ea7c66e 100644 --- a/lib/Db/Feed.php +++ b/lib/Db/Feed.php @@ -15,105 +15,64 @@ namespace OCA\News\Db; use \OCP\AppFramework\Db\Entity; -/** - * @method integer getId() - * @method void setId(integer $value) - * @method string getUserId() - * @method void setUserId(string $value) - * @method int getOrdering() - * @method void setOrdering(integer $value) - * @method string getUrlHash() - * @method void setUrlHash(string $value) - * @method string getLocation() - * @method void setLocation(string $value) - * @method string getUrl() - * @method string getTitle() - * @method void setTitle(string $value) - * @method string getLastModified() - * @method void setLastModified(string $value) - * @method string getHttpLastModified() - * @method void setHttpLastModified(string $value) - * @method string getHttpEtag() - * @method void setHttpEtag(string $value) - * @method string getFaviconLink() - * @method void setFaviconLink(string $value) - * @method integer getAdded() - * @method void setAdded(integer $value) - * @method boolean getPinned() - * @method void setPinned(boolean $value) - * @method integer getFolderId() - * @method void setFolderId(integer $value) - * @method integer getFullTextEnabled() - * @method void setFullTextEnabled(bool $value) - * @method integer getUnreadCount() - * @method void setUnreadCount(integer $value) - * @method string getLink() - * @method boolean getPreventUpdate() - * @method void setPreventUpdate(boolean $value) - * @method integer getDeletedAt() - * @method void setDeletedAt(integer $value) - * @method integer getArticlesPerUpdate() - * @method void setArticlesPerUpdate(integer $value) - * @method integer getUpdateErrorCount() - * @method void setUpdateErrorCount(integer $value) - * @method string getLastUpdateError() - * @method void setLastUpdateError(string $value) - * @method string getBasicAuthUser() - * @method void setBasicAuthUser(string $value) - * @method string getBasicAuthPassword() - * @method void setBasicAuthPassword(string $value) - */ class Feed extends Entity implements IAPI, \JsonSerializable { use EntityJSONSerializer; + /** @var string */ protected $userId; + /** @var string */ protected $urlHash; + /** @var string */ protected $url; + /** @var string */ protected $title; + /** @var string */ protected $faviconLink; + /** @var int */ protected $added; + /** @var int */ protected $folderId; + /** @var int */ protected $unreadCount; + /** @var string */ protected $link; + /** @var bool */ protected $preventUpdate; + /** @var int */ protected $deletedAt; + /** @var int */ protected $articlesPerUpdate; + /** @var string */ protected $httpLastModified; + /** @var string */ protected $lastModified; + /** @var string */ protected $httpEtag; + /** @var string */ protected $location; + /** @var int */ protected $ordering; + /** @var bool */ protected $fullTextEnabled; + /** @var bool */ protected $pinned; + /** @var int */ protected $updateMode; + /** @var int */ protected $updateErrorCount; + /** @var string */ protected $lastUpdateError; + /** @var string */ protected $basicAuthUser; + /** @var string */ protected $basicAuthPassword; - public function __construct() - { - $this->addType('parentId', 'integer'); - $this->addType('added', 'integer'); - $this->addType('folderId', 'integer'); - $this->addType('unreadCount', 'integer'); - $this->addType('preventUpdate', 'boolean'); - $this->addType('pinned', 'boolean'); - $this->addType('deletedAt', 'integer'); - $this->addType('articlesPerUpdate', 'integer'); - $this->addType('ordering', 'integer'); - $this->addType('fullTextEnabled', 'boolean'); - $this->addType('updateMode', 'integer'); - $this->addType('updateErrorCount', 'integer'); - } - - /** * Turns entitie attributes into an array */ - public function jsonSerialize() + public function jsonSerialize() { $serialized = $this->serializeFields( [ @@ -155,7 +114,7 @@ class Feed extends Entity implements IAPI, \JsonSerializable } - public function toAPI() + public function toAPI() { return $this->serializeFields( [ @@ -175,24 +134,481 @@ class Feed extends Entity implements IAPI, \JsonSerializable ); } + /** + * @return int + */ + public function getId() + { + return $this->id; + } + + /** + * @param int $id + */ + public function setId($id) + { + if ($this->id !== $id) { + $this->id = (int)$id; + $this->markFieldUpdated('id'); + } + } + + /** + * @return string + */ + public function getUserId() + { + return $this->userId; + } + + /** + * @param string $userId + */ + public function setUserId($userId) + { + if ($this->userId !== $userId) { + $this->userId = (string)$userId; + $this->markFieldUpdated('userId'); + } + } + + /** + * @return string + */ + public function getUrlHash() + { + return $this->urlHash; + } + + /** + * @param string $urlHash + */ + public function setUrlHash($urlHash) + { + if ($this->urlHash !== $urlHash) { + $this->urlHash = (string)$urlHash; + $this->markFieldUpdated('urlHash'); + } + } + + /** + * @return string + */ + public function getUrl() + { + return $this->url; + } - public function setUrl($url) + /** + * @param string $url + */ + public function setUrl($url) { - $url = trim($url); - if(strpos($url, 'http') === 0) { - parent::setUrl($url); + $url = trim((string)$url); + if(strpos($url, 'http') === 0 && $this->url !== $url) { + $this->url = $url; $this->setUrlHash(md5($url)); + $this->markFieldUpdated('url'); + } + } + + /** + * @return string + */ + public function getTitle() + { + return $this->title; + } + + /** + * @param string $title + */ + public function setTitle($title) + { + if ($this->title !== $title) { + $this->title = (string)$title; + $this->markFieldUpdated('title'); } } + /** + * @return string + */ + public function getFaviconLink() + { + return $this->faviconLink; + } - public function setLink($url) + /** + * @param string $faviconLink + */ + public function setFaviconLink($faviconLink) { - $url = trim($url); - if(strpos($url, 'http') === 0) { - parent::setLink($url); + if ($this->faviconLink !== $faviconLink) { + $this->faviconLink = (string)$faviconLink; + $this->markFieldUpdated('faviconLink'); } } + /** + * @return int + */ + public function getAdded() + { + return $this->added; + } + /** + * @param int $added + */ + public function setAdded($added) + { + if ($this->added !== $added) { + $this->added = (int)$added; + $this->markFieldUpdated('added'); + } + } + + /** + * @return int + */ + public function getFolderId() + { + return $this->folderId; + } + + /** + * @param int $folderId + */ + public function setFolderId($folderId) + { + if ($this->folderId !== $folderId) { + $this->folderId = (int)$folderId; + $this->markFieldUpdated('folderId'); + } + } + + /** + * @return int + */ + public function getUnreadCount() + { + return $this->unreadCount; + } + + /** + * @param int $unreadCount + */ + public function setUnreadCount($unreadCount) + { + if ($this->unreadCount !== $unreadCount) { + $this->unreadCount = (int)$unreadCount; + $this->markFieldUpdated('unreadCount'); + } + } + + /** + * @return string + */ + public function getLink() + { + return $this->link; + } + + /** + * @param string $link + */ + public function setLink($link) + { + $link = trim((string)$link); + if(strpos($link, 'http') === 0 && $this->link !== $link) { + $this->link = (string)$link; + $this->markFieldUpdated('link'); + } + } + + /** + * @return bool + */ + public function getPreventUpdate() + { + return $this->preventUpdate; + } + + /** + * @param bool $preventUpdate + */ + public function setPreventUpdate($preventUpdate) + { + if ($this->preventUpdate !== $preventUpdate) { + $this->preventUpdate = (bool)$preventUpdate; + $this->markFieldUpdated('preventUpdate'); + } + } + + /** + * @return int + */ + public function getDeletedAt() + { + return $this->deletedAt; + } + + /** + * @param int $deletedAt + */ + public function setDeletedAt($deletedAt) + { + if ($this->deletedAt !== $deletedAt) { + $this->deletedAt = (int)$deletedAt; + $this->markFieldUpdated('deletedAt'); + } + } + + /** + * @return int + */ + public function getArticlesPerUpdate() + { + return $this->articlesPerUpdate; + } + + /** + * @param int $articlesPerUpdate + */ + public function setArticlesPerUpdate($articlesPerUpdate) + { + if ($this->articlesPerUpdate !== $articlesPerUpdate) { + $this->articlesPerUpdate = (int)$articlesPerUpdate; + $this->markFieldUpdated('articlesPerUpdate'); + } + } + + /** + * @return string + */ + public function getHttpLastModified() + { + return $this->httpLastModified; + } + + /** + * @param string $httpLastModified + */ + public function setHttpLastModified($httpLastModified) + { + if ($this->httpLastModified !== $httpLastModified) { + $this->httpLastModified = (string)$httpLastModified; + $this->markFieldUpdated('httpLastModified'); + } + } + + /** + * @return string + */ + public function getLastModified() + { + return $this->lastModified; + } + + /** + * @param string $lastModified + */ + public function setLastModified($lastModified) + { + if ($this->lastModified !== $lastModified) { + $this->lastModified = (string)$lastModified; + $this->markFieldUpdated('lastModified'); + } + } + + /** + * @return string + */ + public function getHttpEtag() + { + return $this->httpEtag; + } + + /** + * @param string $httpEtag + */ + public function setHttpEtag($httpEtag) + { + if ($this->httpEtag !== $httpEtag) { + $this->httpEtag = (string)$httpEtag; + $this->markFieldUpdated('httpEtag'); + } + } + + /** + * @return string + */ + public function getLocation() + { + return $this->location; + } + + /** + * @param string $location + */ + public function setLocation($location) + { + if ($this->location !== $location) { + $this->location = (string)$location; + $this->markFieldUpdated('location'); + } + } + + /** + * @return int + */ + public function getOrdering() + { + return $this->ordering; + } + + /** + * @param int $ordering + */ + public function setOrdering($ordering) + { + if ($this->ordering !== $ordering) { + $this->ordering = (int)$ordering; + $this->markFieldUpdated('ordering'); + } + } + + /** + * @return bool + */ + public function getFullTextEnabled() + { + return $this->fullTextEnabled; + } + + /** + * @param bool $fullTextEnabled + */ + public function setFullTextEnabled($fullTextEnabled) + { + if ($this->fullTextEnabled !== $fullTextEnabled) { + $this->fullTextEnabled = (bool)$fullTextEnabled; + $this->markFieldUpdated('fullTextEnabled'); + } + } + + /** + * @return bool + */ + public function getPinned() + { + return $this->pinned; + } + + /** + * @param bool $pinned + */ + public function setPinned($pinned) + { + if ($this->pinned !== $pinned) { + $this->pinned = (bool)$pinned; + $this->markFieldUpdated('pinned'); + } + } + + /** + * @return int + */ + public function getUpdateMode() + { + return $this->updateMode; + } + + /** + * @param int $updateMode + */ + public function setUpdateMode($updateMode) + { + if ($this->updateMode !== $updateMode) { + $this->updateMode = (int)$updateMode; + $this->markFieldUpdated('updateMode'); + } + } + + /** + * @return int + */ + public function getUpdateErrorCount() + { + return $this->updateErrorCount; + } + + /** + * @param int $updateErrorCount + */ + public function setUpdateErrorCount($updateErrorCount) + { + if ($this->updateErrorCount !== $updateErrorCount) { + $this->updateErrorCount = (int)$updateErrorCount; + $this->markFieldUpdated('updateErrorCount'); + } + } + + /** + * @return string + */ + public function getLastUpdateError() + { + return $this->lastUpdateError; + } + + /** + * @param string $lastUpdateError + */ + public function setLastUpdateError($lastUpdateError) + { + if ($this->lastUpdateError !== $lastUpdateError) { + $this->lastUpdateError = (string)$lastUpdateError; + $this->markFieldUpdated('lastUpdateError'); + } + } + + /** + * @return string + */ + public function getBasicAuthUser() + { + return $this->basicAuthUser; + } + + /** + * @param string $basicAuthUser + */ + public function setBasicAuthUser($basicAuthUser) + { + if ($this->basicAuthUser !== $basicAuthUser) { + $this->basicAuthUser = (string)$basicAuthUser; + $this->markFieldUpdated('basicAuthUser'); + } + } + + /** + * @return string + */ + public function getBasicAuthPassword() + { + return $this->basicAuthPassword; + } + + /** + * @param string $basicAuthPassword + */ + public function setBasicAuthPassword($basicAuthPassword) + { + if ($this->basicAuthPassword !== $basicAuthPassword) { + $this->basicAuthPassword = (string)$basicAuthPassword; + $this->markFieldUpdated('basicAuthPassword'); + } + } } diff --git a/tests/Integration/Fixtures/FeedFixture.php b/tests/Integration/Fixtures/FeedFixture.php index 66461adbc..f0de6de2d 100644 --- a/tests/Integration/Fixtures/FeedFixture.php +++ b/tests/Integration/Fixtures/FeedFixture.php @@ -20,9 +20,8 @@ class FeedFixture extends Feed use Fixture; - public function __construct(array $defaults=[]) + public function __construct(array $defaults=[]) { - parent::__construct(); $defaults = array_merge( [ 'userId' => 'test', -- cgit v1.2.3