@@ -73,13 +73,13 @@ |
||
| 73 | 73 | /** |
| 74 | 74 | * OcrStatus constructor. |
| 75 | 75 | * |
| 76 | - * @param null $status |
|
| 76 | + * @param string $status |
|
| 77 | 77 | * @param null $fileId |
| 78 | - * @param null $newName |
|
| 78 | + * @param string $newName |
|
| 79 | 79 | * @param null $tempFile |
| 80 | - * @param null $type |
|
| 80 | + * @param string $type |
|
| 81 | 81 | * @param null $userId |
| 82 | - * @param null $errorDisplayed |
|
| 82 | + * @param boolean $errorDisplayed |
|
| 83 | 83 | */ |
| 84 | 84 | public function __construct($status = null, $fileId = null, $newName = null, $tempFile = null, $type = null, $userId = null, $errorDisplayed = null) { |
| 85 | 85 | $this->setStatus($status); |
@@ -91,24 +91,24 @@ |
||
| 91 | 91 | $this->setErrorDisplayed($errorDisplayed); |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - /** |
|
| 95 | - * Specify data which should be serialized to JSON |
|
| 96 | - * @link http://php.net/manual/en/jsonserializable.jsonserialize.php |
|
| 97 | - * @return mixed data which can be serialized by <b>json_encode</b>, |
|
| 98 | - * which is a value of any type other than a resource. |
|
| 99 | - * @since 5.4.0 |
|
| 100 | - */ |
|
| 101 | - function jsonSerialize() |
|
| 102 | - { |
|
| 103 | - return [ |
|
| 104 | - 'id' => $this->id, |
|
| 105 | - 'status' => $this->status, |
|
| 106 | - 'fileId' => $this->fileId, |
|
| 107 | - 'newName' => $this->newName, |
|
| 108 | - 'tempFile' => $this->tempFile, |
|
| 109 | - 'type' => $this->type, |
|
| 110 | - 'userId' => $this->userId, |
|
| 111 | - 'errorDisplayed' => $this->errorDisplayed |
|
| 112 | - ]; |
|
| 113 | - } |
|
| 94 | + /** |
|
| 95 | + * Specify data which should be serialized to JSON |
|
| 96 | + * @link http://php.net/manual/en/jsonserializable.jsonserialize.php |
|
| 97 | + * @return mixed data which can be serialized by <b>json_encode</b>, |
|
| 98 | + * which is a value of any type other than a resource. |
|
| 99 | + * @since 5.4.0 |
|
| 100 | + */ |
|
| 101 | + function jsonSerialize() |
|
| 102 | + { |
|
| 103 | + return [ |
|
| 104 | + 'id' => $this->id, |
|
| 105 | + 'status' => $this->status, |
|
| 106 | + 'fileId' => $this->fileId, |
|
| 107 | + 'newName' => $this->newName, |
|
| 108 | + 'tempFile' => $this->tempFile, |
|
| 109 | + 'type' => $this->type, |
|
| 110 | + 'userId' => $this->userId, |
|
| 111 | + 'errorDisplayed' => $this->errorDisplayed |
|
| 112 | + ]; |
|
| 113 | + } |
|
| 114 | 114 | } |
| 115 | 115 | \ No newline at end of file |
@@ -240,6 +240,7 @@ discard block |
||
| 240 | 240 | * The PersonalSettingsController will have the opportunity to delete ocr status objects. |
| 241 | 241 | * |
| 242 | 242 | * @param $statusId |
| 243 | + * @param string $userId |
|
| 243 | 244 | * @return OcrStatus |
| 244 | 245 | */ |
| 245 | 246 | public function deleteStatus($statusId, $userId) { |
@@ -269,7 +270,7 @@ discard block |
||
| 269 | 270 | /** |
| 270 | 271 | * Gets all status objects for a specific user in order to list them on the personal settings page. |
| 271 | 272 | * |
| 272 | - * @param $userId |
|
| 273 | + * @param string $userId |
|
| 273 | 274 | * @return array |
| 274 | 275 | */ |
| 275 | 276 | public function getAllForPersonal($userId) { |
@@ -16,7 +16,6 @@ |
||
| 16 | 16 | use OCA\Ocr\Db\OcrStatus; |
| 17 | 17 | use OCA\Ocr\Db\OcrStatusMapper; |
| 18 | 18 | use OCP\AppFramework\Db\DoesNotExistException; |
| 19 | -use OCP\AppFramework\Db\Entity; |
|
| 20 | 19 | use OCP\Files; |
| 21 | 20 | use OCP\Files\FileInfo; |
| 22 | 21 | use OCP\IConfig; |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | try { |
| 201 | 201 | // TODO: release lock |
| 202 | 202 | |
| 203 | - // returns user specific processed files |
|
| 203 | + // returns user specific processed files |
|
| 204 | 204 | $processed = $this->handleProcessed(); |
| 205 | 205 | |
| 206 | 206 | $pending = $this->statusMapper->findAllPending($this->userId); |
@@ -251,18 +251,18 @@ discard block |
||
| 251 | 251 | $status = $this->statusMapper->delete($status); |
| 252 | 252 | } |
| 253 | 253 | $status->setNewName($this->removeFileExtension($status)); |
| 254 | - $status->setFileId(null); |
|
| 255 | - $status->setTempFile(null); |
|
| 256 | - $status->setType(null); |
|
| 257 | - $status->setErrorDisplayed(null); |
|
| 254 | + $status->setFileId(null); |
|
| 255 | + $status->setTempFile(null); |
|
| 256 | + $status->setType(null); |
|
| 257 | + $status->setErrorDisplayed(null); |
|
| 258 | 258 | return $status; |
| 259 | 259 | } catch (Exception $e) { |
| 260 | - if ($e instanceof DoesNotExistException) { |
|
| 261 | - $ex = new NotFoundException($this->l10n->t('Cannot delete. Wrong id.')); |
|
| 262 | - $this->handleException($ex); |
|
| 263 | - } else { |
|
| 264 | - $this->handleException($e); |
|
| 265 | - } |
|
| 260 | + if ($e instanceof DoesNotExistException) { |
|
| 261 | + $ex = new NotFoundException($this->l10n->t('Cannot delete. Wrong id.')); |
|
| 262 | + $this->handleException($ex); |
|
| 263 | + } else { |
|
| 264 | + $this->handleException($e); |
|
| 265 | + } |
|
| 266 | 266 | } |
| 267 | 267 | } |
| 268 | 268 | |
@@ -273,9 +273,9 @@ discard block |
||
| 273 | 273 | * @return array |
| 274 | 274 | */ |
| 275 | 275 | public function getAllForPersonal($userId) { |
| 276 | - try { |
|
| 277 | - $status = $this->statusMapper->findAll($userId); |
|
| 278 | - $statusNew = array(); |
|
| 276 | + try { |
|
| 277 | + $status = $this->statusMapper->findAll($userId); |
|
| 278 | + $statusNew = array(); |
|
| 279 | 279 | for ($x = 0; $x < count($status); $x++) { |
| 280 | 280 | $newName = $this->removeFileExtension($status[$x]); |
| 281 | 281 | $status[$x]->setNewName($newName); |
@@ -285,11 +285,11 @@ discard block |
||
| 285 | 285 | $status[$x]->setErrorDisplayed(null); |
| 286 | 286 | array_push($statusNew, $status[$x]); |
| 287 | 287 | } |
| 288 | - return $statusNew; |
|
| 289 | - } catch (Exception $e) { |
|
| 290 | - $this->handleException($e); |
|
| 291 | - } |
|
| 292 | - } |
|
| 288 | + return $statusNew; |
|
| 289 | + } catch (Exception $e) { |
|
| 290 | + $this->handleException($e); |
|
| 291 | + } |
|
| 292 | + } |
|
| 293 | 293 | |
| 294 | 294 | /** |
| 295 | 295 | * Finishes all Processed files by copying them to the right path and deleteing the temp files. |
@@ -46,11 +46,11 @@ discard block |
||
| 46 | 46 | $this->service = $service; |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | - /** |
|
| 50 | - * @NoAdminRequired |
|
| 51 | - * |
|
| 52 | - * @return Template |
|
| 53 | - */ |
|
| 49 | + /** |
|
| 50 | + * @NoAdminRequired |
|
| 51 | + * |
|
| 52 | + * @return Template |
|
| 53 | + */ |
|
| 54 | 54 | public function displayPanel() { |
| 55 | 55 | $tmpl = new Template('ocr', 'settings-personal'); |
| 56 | 56 | return $tmpl; |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | */ |
| 64 | 64 | public function getAll() { |
| 65 | 65 | return $this->handleNotFound(function () { |
| 66 | - return $this->service->getAllForPersonal($this->userId); |
|
| 66 | + return $this->service->getAllForPersonal($this->userId); |
|
| 67 | 67 | }); |
| 68 | 68 | } |
| 69 | 69 | |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | * @return \OCP\AppFramework\Http\DataResponse |
| 63 | 63 | */ |
| 64 | 64 | public function getAll() { |
| 65 | - return $this->handleNotFound(function () { |
|
| 65 | + return $this->handleNotFound(function() { |
|
| 66 | 66 | return $this->service->getAllForPersonal($this->userId); |
| 67 | 67 | }); |
| 68 | 68 | } |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | * @return \OCP\AppFramework\Http\DataResponse |
| 74 | 74 | */ |
| 75 | 75 | public function deleteStatus($id) { |
| 76 | - return $this->handleNotFound(function () use ($id) { |
|
| 76 | + return $this->handleNotFound(function() use ($id) { |
|
| 77 | 77 | return $this->service->deleteStatus($id, $this->userId); |
| 78 | 78 | }); |
| 79 | 79 | } |
@@ -41,16 +41,16 @@ |
||
| 41 | 41 | return $this->findEntity($sql, [$id]); |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * Finds all user specific status entities |
|
| 46 | - * |
|
| 47 | - * @param $userId |
|
| 48 | - * @return OcrStatus[] |
|
| 49 | - */ |
|
| 50 | - public function findAll($userId) { |
|
| 51 | - $sql = 'SELECT * FROM *PREFIX*ocr_status WHERE user_id = ?'; |
|
| 52 | - return $this->findEntities($sql, [$userId]); |
|
| 53 | - } |
|
| 44 | + /** |
|
| 45 | + * Finds all user specific status entities |
|
| 46 | + * |
|
| 47 | + * @param $userId |
|
| 48 | + * @return OcrStatus[] |
|
| 49 | + */ |
|
| 50 | + public function findAll($userId) { |
|
| 51 | + $sql = 'SELECT * FROM *PREFIX*ocr_status WHERE user_id = ?'; |
|
| 52 | + return $this->findEntities($sql, [$userId]); |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | 55 | /** |
| 56 | 56 | * Finds all status PROCESSED entities for a given userid |
@@ -72,9 +72,9 @@ discard block |
||
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | /** |
| 75 | - * TODO: in the future this function could be used to give an admin information |
|
| 75 | + * TODO: in the future this function could be used to give an admin information |
|
| 76 | 76 | * Counts the messages in the message queue. |
| 77 | - * |
|
| 77 | + * |
|
| 78 | 78 | * @return mixed |
| 79 | 79 | */ |
| 80 | 80 | public function countMessages() { |
@@ -87,13 +87,13 @@ discard block |
||
| 87 | 87 | } |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - /** |
|
| 91 | - * TODO: in the future this function could be used to give an admin information |
|
| 92 | - * Counts the at this point processed files |
|
| 93 | - * |
|
| 94 | - * @return mixed |
|
| 95 | - */ |
|
| 96 | - public function countActiveProcesses() { |
|
| 90 | + /** |
|
| 91 | + * TODO: in the future this function could be used to give an admin information |
|
| 92 | + * Counts the at this point processed files |
|
| 93 | + * |
|
| 94 | + * @return mixed |
|
| 95 | + */ |
|
| 96 | + public function countActiveProcesses() { |
|
| 97 | 97 | try { |
| 98 | 98 | $stats = msg_stat_queue($this->statusqueue); |
| 99 | 99 | $this->logger->debug('Current active processing count: ' . json_encode($stats['msg_qnum']), ['app' => 'ocr']); |
@@ -44,7 +44,7 @@ |
||
| 44 | 44 | */ |
| 45 | 45 | public function run(IOutput $output) { |
| 46 | 46 | $output->startProgress(1); |
| 47 | - if ($this->connection->tableExists('ocr_status')){ |
|
| 47 | + if ($this->connection->tableExists('ocr_status')) { |
|
| 48 | 48 | $this->connection->dropTable('ocr_status'); |
| 49 | 49 | } |
| 50 | 50 | $output->advance(1, "Drop old database table: ocr_status"); |
@@ -128,7 +128,7 @@ |
||
| 128 | 128 | * Registers the Personal Settings Page for deletion of status objects and such things. |
| 129 | 129 | * @codeCoverageIgnore |
| 130 | 130 | */ |
| 131 | - public function registerPersonal(){ |
|
| 131 | + public function registerPersonal() { |
|
| 132 | 132 | \OCP\App::registerPersonal($this->getContainer()->getAppName(), 'personal'); |
| 133 | 133 | } |
| 134 | 134 | |