src/Entity/Document.php line 30

Open in your IDE?
  1. <?php
  2. namespace MedBrief\MSR\Entity;
  3. use DH\Auditor\Provider\Doctrine\Auditing\Annotation as Audit;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Gedmo\Mapping\Annotation as Gedmo;
  7. use JsonSerializable;
  8. use MedBrief\MSR\Repository\DocumentRepository;
  9. use MedBrief\MSR\Service\File\FileHandler\FileHandledInterface;
  10. use MedBrief\MSR\Service\MimeTypes;
  11. use MedBrief\MSR\Service\ProjectClosure\RemoveRecords\RemovableRecordInterface;
  12. use MedBrief\MSR\Service\VirusScan\Async\VirusScannableInterface;
  13. use MedBrief\MSR\Service\VirusScan\Async\Visitor\VirusScannerPathVisitorInterface;
  14. /**
  15. * Document
  16. *
  17. * @ORM\Table(name="Document", indexes={@ORM\Index(name="created_index", columns={"created"}), @ORM\Index(name="deletedAt_index", columns={"deletedAt"}), @ORM\Index(name="convertedToSwfStatus_index", columns={"convertedToSwfStatus"}), @ORM\Index(name="convertedToOptimizedPdfStatus_index", columns={"convertedToOptimizedPdfStatus"}), @ORM\Index(name="convertedToXodStatus_index", columns={"convertedToXodStatus"}), @ORM\Index(name="convertedToOcrStatus_index", columns={"convertedToOcrStatus"}), @ORM\Index(name="convertedToWebAVStatus_index", columns={"convertedToWebAVStatus"}), @ORM\Index(name="orthanc_store_response_id_index", columns={"orthanc_store_response_id"}), @ORM\Index(name="orthanc_parent_series_id_index", columns={"orthanc_parent_series_id"})})
  18. *
  19. * @ORM\Entity(repositoryClass=DocumentRepository::class)
  20. *
  21. * @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false)
  22. *
  23. * @Audit\Auditable
  24. *
  25. * @Audit\Security(view={"ROLE_ALLOWED_TO_AUDIT"})
  26. */
  27. class Document implements JsonSerializable, RemovableRecordInterface, VirusScannableInterface, FileHandledInterface
  28. {
  29. public const ORTHANC_STORAGE_STATUS_PENDING = 1;
  30. public const ORTHANC_STORAGE_STATUS_STORED = 2;
  31. public const ORTHANC_STORAGE_STATUS_FAILED = 3;
  32. public const ORTHANC_STORAGE_STATUS_DELETED = 4;
  33. public const CONVERSION_TO_SWF_PENDING = 0;
  34. public const CONVERSION_TO_SWF_COMPLETE = 1;
  35. public const CONVERSION_TO_SWF_FAILED = 2;
  36. public const CONVERSION_TO_SWF_CURRENT = 3;
  37. public const CONVERSION_TO_SWF_SKIPPED = 4;
  38. // These statuses control the Archive state of the Document,
  39. // which applies to SWF conversion.
  40. public const CONVERSION_TO_SWF_ARCHIVE_PENDING = 5;
  41. public const CONVERSION_TO_SWF_ARCHIVE_CURRENT = 6;
  42. public const CONVERSION_TO_SWF_ARCHIVED = 7;
  43. public const CONVERSION_TO_SWF_ARCHIVE_FAILED = 8;
  44. public const FILE_TYPE_PDF = 'pdf';
  45. public const FILE_TYPE_AUDIO = 'audio';
  46. public const FILE_TYPE_VIDEO = 'video';
  47. public const FILE_TYPE_DICOM = 'dicom';
  48. public const FILE_TYPE_MSWORD = 'msword';
  49. public const FILE_TYPE_MSEXCEL = 'msexcel';
  50. public const FILE_TYPE_MSPOWERPOINT = 'mspowerpoint';
  51. public const FILE_TYPE_FILE = 'generic';
  52. public const FILE_TYPE_IMAGE = 'image';
  53. public const FILE_TYPE_TEXT_HTML = 'text/html';
  54. public const FILE_TYPE_EML_MSG = 'email';
  55. // Converted to OptimizedPDF statuses.
  56. public const CONVERSION_TO_OPTIMIZED_PDF_PENDING = 1;
  57. public const CONVERSION_TO_OPTIMIZED_PDF_COMPLETE = 2;
  58. public const CONVERSION_TO_OPTIMIZED_PDF_FAILED = 3;
  59. public const CONVERSION_TO_OPTIMIZED_PDF_CURRENT = 4;
  60. public const CONVERSION_TO_OPTIMIZED_PDF_SKIPPED = 5;
  61. // Converted to XOD statuses.
  62. public const CONVERSION_TO_XOD_PENDING = 1;
  63. public const CONVERSION_TO_XOD_COMPLETE = 2;
  64. public const CONVERSION_TO_XOD_FAILED = 3;
  65. public const CONVERSION_TO_XOD_CURRENT = 4;
  66. public const CONVERSION_TO_XOD_SKIPPED = 5;
  67. public const CONVERSION_TO_XOD_ENCRYPTED = 6;
  68. // Converted to WEBAV statuses.
  69. public const CONVERSION_TO_WEBAV_PENDING = 1;
  70. public const CONVERSION_TO_WEBAV_COMPLETE = 2;
  71. public const CONVERSION_TO_WEBAV_FAILED = 3;
  72. public const CONVERSION_TO_WEBAV_CURRENT = 4;
  73. public const CONVERSION_TO_WEBAV_SKIPPED = 5;
  74. // Converted to OCR statuses.
  75. public const CONVERSION_TO_OCR_PENDING = 1;
  76. public const CONVERSION_TO_OCR_COMPLETE = 2;
  77. public const CONVERSION_TO_OCR_FAILED = 3;
  78. public const CONVERSION_TO_OCR_FAILED_AUTH = 31;
  79. public const CONVERSION_TO_OCR_FAILED_HTTP_TRANSPORT = 32;
  80. public const CONVERSION_TO_OCR_FAILED_NO_PDF_PATH = 33;
  81. public const CONVERSION_TO_OCR_CURRENT = 4;
  82. public const CONVERSION_TO_OCR_SKIPPED = 5;
  83. public const CONVERSION_TO_OCR_REQUEUED = 6;
  84. public const FILE_FIELD_LIST = [
  85. 'nativeFile',
  86. 'optimizedPdfFile',
  87. 'xodBlobFile',
  88. 'ocrFile',
  89. 'ocrXodBlobFile',
  90. 'webAVFile',
  91. ];
  92. public static $fileIcons = [
  93. 'afl' => ['iconClass' => 'mb-icon--video', 'type' => self::FILE_TYPE_VIDEO],
  94. 'aif' => ['iconClass' => 'mb-icon--audio', 'type' => self::FILE_TYPE_AUDIO],
  95. 'aifc' => ['iconClass' => 'mb-icon--audio', 'type' => self::FILE_TYPE_AUDIO],
  96. 'aiff' => ['iconClass' => 'mb-icon--audio', 'type' => self::FILE_TYPE_AUDIO],
  97. 'asf' => ['iconClass' => 'mb-icon--video', 'type' => self::FILE_TYPE_VIDEO],
  98. 'asx' => ['iconClass' => 'mb-icon--video', 'type' => self::FILE_TYPE_VIDEO],
  99. 'au' => ['iconClass' => 'mb-icon--audio', 'type' => self::FILE_TYPE_AUDIO],
  100. 'avi' => ['iconClass' => 'mb-icon--video', 'type' => self::FILE_TYPE_VIDEO],
  101. 'avs' => ['iconClass' => 'mb-icon--video', 'type' => self::FILE_TYPE_VIDEO],
  102. 'dif' => ['iconClass' => 'mb-icon--video', 'type' => self::FILE_TYPE_VIDEO],
  103. 'dl' => ['iconClass' => 'mb-icon--video', 'type' => self::FILE_TYPE_VIDEO],
  104. 'dv' => ['iconClass' => 'mb-icon--video', 'type' => self::FILE_TYPE_VIDEO],
  105. 'dvr-ms' => ['iconClass' => 'mb-icon--video', 'type' => self::FILE_TYPE_VIDEO],
  106. 'fli' => ['iconClass' => 'mb-icon--video', 'type' => self::FILE_TYPE_VIDEO],
  107. 'fmf' => ['iconClass' => 'mb-icon--video', 'type' => self::FILE_TYPE_VIDEO],
  108. 'funk' => ['iconClass' => 'mb-icon--audio', 'type' => self::FILE_TYPE_AUDIO],
  109. 'gl' => ['iconClass' => 'mb-icon--video', 'type' => self::FILE_TYPE_VIDEO],
  110. 'gsd' => ['iconClass' => 'mb-icon--audio', 'type' => self::FILE_TYPE_AUDIO],
  111. 'gsm' => ['iconClass' => 'mb-icon--audio', 'type' => self::FILE_TYPE_AUDIO],
  112. 'isu' => ['iconClass' => 'mb-icon--video', 'type' => self::FILE_TYPE_VIDEO],
  113. 'it' => ['iconClass' => 'mb-icon--audio', 'type' => self::FILE_TYPE_AUDIO],
  114. 'jam' => ['iconClass' => 'mb-icon--audio', 'type' => self::FILE_TYPE_AUDIO],
  115. 'kar' => ['iconClass' => 'mb-icon--audio', 'type' => self::FILE_TYPE_AUDIO],
  116. 'la' => ['iconClass' => 'mb-icon--audio', 'type' => self::FILE_TYPE_AUDIO],
  117. 'lam' => ['iconClass' => 'mb-icon--audio', 'type' => self::FILE_TYPE_AUDIO],
  118. 'lma' => ['iconClass' => 'mb-icon--audio', 'type' => self::FILE_TYPE_AUDIO],
  119. 'm1v' => ['iconClass' => 'mb-icon--video', 'type' => self::FILE_TYPE_VIDEO],
  120. 'm2a' => ['iconClass' => 'mb-icon--audio', 'type' => self::FILE_TYPE_AUDIO],
  121. 'm2v' => ['iconClass' => 'mb-icon--video', 'type' => self::FILE_TYPE_VIDEO],
  122. 'm3u' => ['iconClass' => 'mb-icon--audio', 'type' => self::FILE_TYPE_AUDIO],
  123. 'mid' => ['iconClass' => 'mb-icon--audio', 'type' => self::FILE_TYPE_AUDIO],
  124. 'midi' => ['iconClass' => 'mb-icon--audio', 'type' => self::FILE_TYPE_AUDIO],
  125. 'mjf' => ['iconClass' => 'mb-icon--audio', 'type' => self::FILE_TYPE_AUDIO],
  126. 'mjpg' => ['iconClass' => 'mb-icon--video', 'type' => self::FILE_TYPE_VIDEO],
  127. 'mkv' => ['iconClass' => 'mb-icon--video', 'type' => self::FILE_TYPE_VIDEO],
  128. 'mod' => ['iconClass' => 'mb-icon--audio', 'type' => self::FILE_TYPE_AUDIO],
  129. 'moov' => ['iconClass' => 'mb-icon--video', 'type' => self::FILE_TYPE_VIDEO],
  130. 'mov' => ['iconClass' => 'mb-icon--video', 'type' => self::FILE_TYPE_VIDEO],
  131. 'movie' => ['iconClass' => 'mb-icon--video', 'type' => self::FILE_TYPE_VIDEO],
  132. 'mp2' => ['iconClass' => 'mb-icon--audio', 'type' => self::FILE_TYPE_AUDIO],
  133. 'mp3' => ['iconClass' => 'mb-icon--audio', 'type' => self::FILE_TYPE_AUDIO],
  134. 'mp4' => ['iconClass' => 'mb-icon--video', 'type' => self::FILE_TYPE_VIDEO],
  135. 'mpa' => ['iconClass' => 'mb-icon--audio', 'type' => self::FILE_TYPE_AUDIO],
  136. 'mpe' => ['iconClass' => 'mb-icon--video', 'type' => self::FILE_TYPE_VIDEO],
  137. 'mpeg' => ['iconClass' => 'mb-icon--video', 'type' => self::FILE_TYPE_VIDEO],
  138. 'mpg' => ['iconClass' => 'mb-icon--audio', 'type' => self::FILE_TYPE_AUDIO],
  139. 'mpga' => ['iconClass' => 'mb-icon--audio', 'type' => self::FILE_TYPE_AUDIO],
  140. 'mv' => ['iconClass' => 'mb-icon--video', 'type' => self::FILE_TYPE_VIDEO],
  141. 'my' => ['iconClass' => 'mb-icon--audio', 'type' => self::FILE_TYPE_AUDIO],
  142. 'pfunk' => ['iconClass' => 'mb-icon--audio', 'type' => self::FILE_TYPE_AUDIO],
  143. 'qcp' => ['iconClass' => 'mb-icon--audio', 'type' => self::FILE_TYPE_AUDIO],
  144. 'qt' => ['iconClass' => 'mb-icon--video', 'type' => self::FILE_TYPE_VIDEO],
  145. 'qtc' => ['iconClass' => 'mb-icon--video', 'type' => self::FILE_TYPE_VIDEO],
  146. 'ra' => ['iconClass' => 'mb-icon--audio', 'type' => self::FILE_TYPE_AUDIO],
  147. 'ram' => ['iconClass' => 'mb-icon--audio', 'type' => self::FILE_TYPE_AUDIO],
  148. 'rm' => ['iconClass' => 'mb-icon--audio', 'type' => self::FILE_TYPE_AUDIO],
  149. 'rmi' => ['iconClass' => 'mb-icon--audio', 'type' => self::FILE_TYPE_AUDIO],
  150. 'rmm' => ['iconClass' => 'mb-icon--audio', 'type' => self::FILE_TYPE_AUDIO],
  151. 'rmp' => ['iconClass' => 'mb-icon--audio', 'type' => self::FILE_TYPE_AUDIO],
  152. 'rpm' => ['iconClass' => 'mb-icon--audio', 'type' => self::FILE_TYPE_AUDIO],
  153. 'rv' => ['iconClass' => 'mb-icon--video', 'type' => self::FILE_TYPE_VIDEO],
  154. 's3m' => ['iconClass' => 'mb-icon--audio', 'type' => self::FILE_TYPE_AUDIO],
  155. 'scm' => ['iconClass' => 'mb-icon--video', 'type' => self::FILE_TYPE_VIDEO],
  156. 'sid' => ['iconClass' => 'mb-icon--audio', 'type' => self::FILE_TYPE_AUDIO],
  157. 'snd' => ['iconClass' => 'mb-icon--audio', 'type' => self::FILE_TYPE_AUDIO],
  158. 'tsi' => ['iconClass' => 'mb-icon--audio', 'type' => self::FILE_TYPE_AUDIO],
  159. 'tsp' => ['iconClass' => 'mb-icon--audio', 'type' => self::FILE_TYPE_AUDIO],
  160. 'vdo' => ['iconClass' => 'mb-icon--video', 'type' => self::FILE_TYPE_VIDEO],
  161. 'viv' => ['iconClass' => 'mb-icon--video', 'type' => self::FILE_TYPE_VIDEO],
  162. 'vivo' => ['iconClass' => 'mb-icon--video', 'type' => self::FILE_TYPE_VIDEO],
  163. 'voc' => ['iconClass' => 'mb-icon--audio', 'type' => self::FILE_TYPE_AUDIO],
  164. 'vos' => ['iconClass' => 'mb-icon--video', 'type' => self::FILE_TYPE_VIDEO],
  165. 'vox' => ['iconClass' => 'mb-icon--audio', 'type' => self::FILE_TYPE_AUDIO],
  166. 'vqe' => ['iconClass' => 'mb-icon--audio', 'type' => self::FILE_TYPE_AUDIO],
  167. 'vqf' => ['iconClass' => 'mb-icon--audio', 'type' => self::FILE_TYPE_AUDIO],
  168. 'vql' => ['iconClass' => 'mb-icon--audio', 'type' => self::FILE_TYPE_AUDIO],
  169. 'wav' => ['iconClass' => 'mb-icon--audio', 'type' => self::FILE_TYPE_AUDIO],
  170. 'xdr' => ['iconClass' => 'mb-icon--video', 'type' => self::FILE_TYPE_VIDEO],
  171. 'xm' => ['iconClass' => 'mb-icon--audio', 'type' => self::FILE_TYPE_AUDIO],
  172. 'xsr' => ['iconClass' => 'mb-icon--video', 'type' => self::FILE_TYPE_VIDEO],
  173. 'wma' => ['iconClass' => 'mb-icon--audio', 'type' => self::FILE_TYPE_AUDIO],
  174. // PDF file
  175. 'pdf' => ['iconClass' => 'mb-icon--pdf', 'type' => self::FILE_TYPE_PDF],
  176. // generic file
  177. 'xps' => ['iconClass' => 'mb-icon--file', 'type' => self::FILE_TYPE_FILE],
  178. 'rtf' => ['iconClass' => 'mb-icon--file', 'type' => self::FILE_TYPE_FILE],
  179. 'csv' => ['iconClass' => 'mb-icon--file', 'type' => self::FILE_TYPE_FILE],
  180. 'vsd' => ['iconClass' => 'mb-icon--file', 'type' => self::FILE_TYPE_FILE],
  181. 'pub' => ['iconClass' => 'mb-icon--file', 'type' => self::FILE_TYPE_FILE],
  182. // Word files
  183. 'doc' => ['iconClass' => 'mb-icon--ms-word', 'type' => self::FILE_TYPE_MSWORD],
  184. 'dot' => ['iconClass' => 'mb-icon--ms-word', 'type' => self::FILE_TYPE_MSWORD],
  185. 'docx' => ['iconClass' => 'mb-icon--ms-word', 'type' => self::FILE_TYPE_MSWORD],
  186. 'dotx' => ['iconClass' => 'mb-icon--ms-word', 'type' => self::FILE_TYPE_MSWORD],
  187. // Excel files
  188. 'xls' => ['iconClass' => 'mb-icon--ms-excel', 'type' => self::FILE_TYPE_MSEXCEL],
  189. 'xlt' => ['iconClass' => 'mb-icon--ms-excel', 'type' => self::FILE_TYPE_MSEXCEL],
  190. 'xla' => ['iconClass' => 'mb-icon--ms-excel', 'type' => self::FILE_TYPE_MSEXCEL],
  191. 'xlsx' => ['iconClass' => 'mb-icon--ms-excel', 'type' => self::FILE_TYPE_MSEXCEL],
  192. 'ods' => ['iconClass' => 'mb-icon--ms-excel', 'type' => self::FILE_TYPE_MSEXCEL],
  193. // PowerPoint files
  194. 'ppt' => ['iconClass' => 'mb-icon--ms-powerpoint', 'type' => self::FILE_TYPE_MSPOWERPOINT],
  195. 'pot' => ['iconClass' => 'mb-icon--ms-powerpoint', 'type' => self::FILE_TYPE_MSPOWERPOINT],
  196. 'pps' => ['iconClass' => 'mb-icon--ms-powerpoint', 'type' => self::FILE_TYPE_MSPOWERPOINT],
  197. 'ppa' => ['iconClass' => 'mb-icon--ms-powerpoint', 'type' => self::FILE_TYPE_MSPOWERPOINT],
  198. 'pptx' => ['iconClass' => 'mb-icon--ms-powerpoint', 'type' => self::FILE_TYPE_MSPOWERPOINT],
  199. // Image files
  200. 'jpg' => ['iconClass' => 'mb-icon--image', 'type' => self::FILE_TYPE_IMAGE],
  201. 'jpeg' => ['iconClass' => 'mb-icon--image', 'type' => self::FILE_TYPE_IMAGE],
  202. 'tiff' => ['iconClass' => 'mb-icon--image', 'type' => self::FILE_TYPE_IMAGE],
  203. 'tif' => ['iconClass' => 'mb-icon--image', 'type' => self::FILE_TYPE_IMAGE],
  204. 'png' => ['iconClass' => 'mb-icon--image', 'type' => self::FILE_TYPE_IMAGE],
  205. // Html/Text files
  206. 'html' => ['iconClass' => 'mb-icon--html', 'type' => self::FILE_TYPE_TEXT_HTML],
  207. 'htm' => ['iconClass' => 'mb-icon--html', 'type' => self::FILE_TYPE_TEXT_HTML],
  208. 'txt' => ['iconClass' => 'mb-icon--text', 'type' => self::FILE_TYPE_TEXT_HTML],
  209. // eml/msg files
  210. 'eml' => ['iconClass' => 'mb-icon--mail', 'type' => self::FILE_TYPE_EML_MSG],
  211. 'msg' => ['iconClass' => 'mb-icon--mail', 'type' => self::FILE_TYPE_EML_MSG],
  212. ];
  213. /**
  214. * @var int
  215. *
  216. * @ORM\Column(name="id", type="integer")
  217. *
  218. * @ORM\Id
  219. *
  220. * @ORM\GeneratedValue(strategy="IDENTITY")
  221. */
  222. private $id;
  223. /**
  224. * @var \DateTime|null
  225. *
  226. * @ORM\Column(name="deletedAt", type="datetime", nullable=true)
  227. */
  228. private $deletedAt;
  229. /**
  230. * @var string
  231. *
  232. * @ORM\Column(name="filename", type="string")
  233. */
  234. private $filename;
  235. /**
  236. * @var string
  237. *
  238. * @ORM\Column(name="original_filename", type="string")
  239. */
  240. private $original_filename;
  241. /**
  242. * @var string
  243. *
  244. * @ORM\Column(name="mime_type", type="string")
  245. */
  246. private $mime_type;
  247. /**
  248. * @var string
  249. *
  250. * @ORM\Column(name="filesize", type="string")
  251. */
  252. private $filesize;
  253. /**
  254. * @var int|null
  255. *
  256. * @ORM\Column(name="orthanc_storage_status", type="integer", nullable=true)
  257. */
  258. private $orthanc_storage_status;
  259. /**
  260. * @var string|null
  261. *
  262. * @ORM\Column(name="orthanc_store_response_id", type="string", length=255, nullable=true)
  263. */
  264. private $orthanc_store_response_id;
  265. /**
  266. * @var string|null
  267. *
  268. * @ORM\Column(name="orthanc_store_response_path", type="string", length=255, nullable=true)
  269. */
  270. private $orthanc_store_response_path;
  271. /**
  272. * @var string|null
  273. *
  274. * @ORM\Column(name="orthanc_store_response_status", type="string", length=255, nullable=true)
  275. */
  276. private $orthanc_store_response_status;
  277. /**
  278. * @var string|null
  279. *
  280. * @ORM\Column(name="orthanc_parent_series_id", type="string", length=255, nullable=true)
  281. */
  282. private $orthanc_parent_series_id;
  283. /**
  284. * Used as the primary determinant in ordering a sequence of dicom files
  285. *
  286. * @var int|null
  287. *
  288. * @ORM\Column(name="orthanc_instance_number", type="integer", nullable=true)
  289. */
  290. private $orthanc_instance_number;
  291. /**
  292. * @var string
  293. *
  294. * @ORM\Column(name="status", type="string")
  295. */
  296. private $status;
  297. /**
  298. * @var \DateTime
  299. *
  300. * @ORM\Column(name="created", type="datetime")
  301. *
  302. * @Gedmo\Timestampable(on="create")
  303. */
  304. private $created;
  305. /**
  306. * @var \DateTime
  307. *
  308. * @ORM\Column(name="updated", type="datetime")
  309. *
  310. * @Gedmo\Timestampable(on="update")
  311. */
  312. private $updated;
  313. /**
  314. * @var int|null
  315. *
  316. * @ORM\Column(name="convertedToSwfStatus", type="integer", nullable=true)
  317. */
  318. private $convertedToSwfStatus;
  319. /**
  320. * @var string|null
  321. *
  322. * @ORM\Column(name="nativeFilename", type="string", length=255, nullable=true)
  323. */
  324. private $nativeFilename;
  325. /**
  326. * @var string|null
  327. *
  328. * @ORM\Column(name="swfFilename", type="string", length=255, nullable=true)
  329. */
  330. private $swfFilename;
  331. /**
  332. * @var int|null
  333. *
  334. * @ORM\Column(name="convertedToOptimizedPdfStatus", type="integer", nullable=true)
  335. */
  336. private $convertedToOptimizedPdfStatus;
  337. /**
  338. * @var string|null
  339. *
  340. * @ORM\Column(name="optimizedPdfFilename", type="string", length=255, nullable=true)
  341. */
  342. private $optimizedPdfFilename;
  343. /**
  344. * @var int|null
  345. *
  346. * @ORM\Column(name="convertedToXodStatus", type="integer", nullable=true)
  347. */
  348. private $convertedToXodStatus;
  349. /**
  350. * @var string|null
  351. *
  352. * @ORM\Column(name="xodFilename", type="string", length=255, nullable=true)
  353. */
  354. private $xodFilename;
  355. /**
  356. * @var int|null
  357. *
  358. * @ORM\Column(name="convertedToWebAVStatus", type="integer", nullable=true)
  359. */
  360. private $convertedToWebAVStatus;
  361. /**
  362. * @var string|null
  363. *
  364. * @ORM\Column(name="webAVFilename", type="string", length=255, nullable=true)
  365. */
  366. private $webAVFilename;
  367. /**
  368. * @var int|null
  369. *
  370. * @ORM\Column(name="convertedToOcrStatus", type="integer", nullable=true)
  371. */
  372. private $convertedToOcrStatus;
  373. /**
  374. * @var string|null
  375. *
  376. * @ORM\Column(name="ocrFilename", type="string", length=255, nullable=true)
  377. */
  378. private $ocrFilename;
  379. /**
  380. * @var string|null
  381. *
  382. * @ORM\Column(name="ocrXodFilename", type="string", length=255, nullable=true)
  383. */
  384. private $ocrXodFilename;
  385. /**
  386. * @var string
  387. *
  388. * @ORM\Column(name="md5hash", type="string", length=40, nullable=false)
  389. */
  390. private $md5hash;
  391. /**
  392. * @var string|null
  393. *
  394. * @ORM\Column(name="documentTypeFamily", type="string", length=255, nullable=true)
  395. */
  396. private $documentTypeFamily;
  397. /**
  398. * @var Upload
  399. *
  400. * @ORM\OneToOne(targetEntity="MedBrief\MSR\Entity\Upload")
  401. *
  402. * @ORM\JoinColumns({
  403. *
  404. * @ORM\JoinColumn(name="upload_id", referencedColumnName="id", unique=true)
  405. * })
  406. */
  407. private $upload;
  408. /**
  409. * @var Collection
  410. *
  411. * @ORM\OneToMany(targetEntity="MedBrief\MSR\Entity\OrthancTransaction", mappedBy="document", cascade={"all"})
  412. */
  413. private $orthancTransactions;
  414. /**
  415. * @var Project
  416. *
  417. * @ORM\ManyToOne(targetEntity="MedBrief\MSR\Entity\Project", inversedBy="documents")
  418. *
  419. * @ORM\JoinColumns({
  420. *
  421. * @ORM\JoinColumn(name="project_id", referencedColumnName="id")
  422. * })
  423. */
  424. private $project;
  425. /**
  426. * @var DocumentType
  427. *
  428. * @ORM\ManyToOne(targetEntity="MedBrief\MSR\Entity\DocumentType")
  429. *
  430. * @ORM\JoinColumns({
  431. *
  432. * @ORM\JoinColumn(name="documentType_id", referencedColumnName="id")
  433. * })
  434. */
  435. private $documentType;
  436. /**
  437. * @var User
  438. *
  439. * @ORM\ManyToOne(targetEntity="MedBrief\MSR\Entity\User", inversedBy="documents")
  440. *
  441. * @ORM\JoinColumns({
  442. *
  443. * @ORM\JoinColumn(name="creator_id", referencedColumnName="id", nullable=false)
  444. * })
  445. */
  446. private $creator;
  447. /**
  448. * @var Collection
  449. *
  450. * @ORM\ManyToMany(targetEntity="MedBrief\MSR\Entity\Collection", mappedBy="documents")
  451. */
  452. private $collections;
  453. /**
  454. * @var string
  455. */
  456. private $orthanc_response_raw_json;
  457. /**
  458. * @var string
  459. */
  460. private $orthanc_response_id;
  461. /**
  462. * @var string
  463. */
  464. private $orthanc_response_path;
  465. /**
  466. * @var string
  467. */
  468. private $orthanc_response_status;
  469. /**
  470. * @var int
  471. */
  472. private $orthanc_submission_status;
  473. /**
  474. * The below properties are unmapped and used by the VichUploader bundle
  475. * when utilising File injection.
  476. */
  477. /**
  478. * @var string
  479. */
  480. private $nativeFile;
  481. /**
  482. * @var string
  483. */
  484. private $optimizedPdfFile;
  485. /**
  486. * @var string
  487. */
  488. private $swfFile;
  489. /**
  490. * @var string
  491. */
  492. private $webAVFile;
  493. /**
  494. * @var string
  495. */
  496. private $xodFile;
  497. /**
  498. * @var string
  499. */
  500. private $xodBlobFile;
  501. /**
  502. * @var string
  503. */
  504. private $ocrXodFile;
  505. /**
  506. * @var string
  507. */
  508. private $ocrXodBlobFile;
  509. /**
  510. * @var string
  511. */
  512. private $ocrFile;
  513. /**
  514. * @ORM\OneToOne(targetEntity=VirusScanItem::class, mappedBy="document")
  515. */
  516. private ?VirusScanItem $virusScanItem = null;
  517. /**
  518. * Constructor
  519. */
  520. public function __construct()
  521. {
  522. $this->orthancTransactions = new \Doctrine\Common\Collections\ArrayCollection();
  523. $this->collections = new \Doctrine\Common\Collections\ArrayCollection();
  524. }
  525. public function __clone()
  526. {
  527. if ($this->id) {
  528. $this->project = null;
  529. $this->orthancTransactions = new \Doctrine\Common\Collections\ArrayCollection();
  530. $this->collections = new \Doctrine\Common\Collections\ArrayCollection();
  531. }
  532. }
  533. public function __toString()
  534. {
  535. return (string) $this->getFilename();
  536. }
  537. /**
  538. * Get id
  539. *
  540. * @return int
  541. */
  542. public function getId(): ?int
  543. {
  544. return $this->id;
  545. }
  546. /**
  547. * Set filename
  548. *
  549. * @param string $filename
  550. *
  551. * @return Document
  552. */
  553. public function setFilename($filename)
  554. {
  555. $this->filename = $filename;
  556. return $this;
  557. }
  558. /**
  559. * Get filename
  560. *
  561. * @return string
  562. */
  563. public function getFilename()
  564. {
  565. return $this->filename;
  566. }
  567. /**
  568. * Get filename with PDF extension.
  569. *
  570. * @return string
  571. */
  572. public function getFilenameAsPdf()
  573. {
  574. $filename = pathinfo($this->getFilename(), PATHINFO_FILENAME);
  575. if (isset($filename)) {
  576. return $filename . '.pdf';
  577. }
  578. return $this->filename . '.pdf';
  579. }
  580. /**
  581. * Set mime_type
  582. *
  583. * @param string $mimeType
  584. *
  585. * @return Document
  586. */
  587. public function setMimeType($mimeType)
  588. {
  589. $this->mime_type = $mimeType;
  590. return $this;
  591. }
  592. /**
  593. * Get mime_type
  594. *
  595. * @return string
  596. */
  597. public function getMimeType()
  598. {
  599. return $this->mime_type;
  600. }
  601. /**
  602. * Set filesize
  603. *
  604. * @param string $filesize
  605. *
  606. * @return Document
  607. */
  608. public function setFilesize($filesize)
  609. {
  610. $this->filesize = $filesize;
  611. return $this;
  612. }
  613. /**
  614. * Get filesize
  615. *
  616. * @return string
  617. */
  618. public function getFilesize()
  619. {
  620. return $this->filesize;
  621. }
  622. /**
  623. * Set status
  624. *
  625. * @param string $status
  626. *
  627. * @return Document
  628. */
  629. public function setStatus($status)
  630. {
  631. $this->status = $status;
  632. return $this;
  633. }
  634. /**
  635. * Get status
  636. *
  637. * @return string
  638. */
  639. public function getStatus()
  640. {
  641. return $this->status;
  642. }
  643. /**
  644. * Set created
  645. *
  646. * @param \DateTime $created
  647. *
  648. * @return Document
  649. */
  650. public function setCreated($created)
  651. {
  652. $this->created = $created;
  653. return $this;
  654. }
  655. /**
  656. * Get created
  657. *
  658. * @return \DateTime
  659. */
  660. public function getCreated()
  661. {
  662. return $this->created;
  663. }
  664. /**
  665. * Set updated
  666. *
  667. * @param \DateTime $updated
  668. *
  669. * @return Document
  670. */
  671. public function setUpdated($updated)
  672. {
  673. $this->updated = $updated;
  674. return $this;
  675. }
  676. /**
  677. * Get updated
  678. *
  679. * @return \DateTime
  680. */
  681. public function getUpdated()
  682. {
  683. return $this->updated;
  684. }
  685. /**
  686. * Set upload
  687. *
  688. * @param Upload $upload
  689. *
  690. * @return Document
  691. */
  692. public function setUpload(?Upload $upload = null)
  693. {
  694. $this->upload = $upload;
  695. return $this;
  696. }
  697. /**
  698. * Get upload
  699. *
  700. * @return Upload
  701. */
  702. public function getUpload()
  703. {
  704. return $this->upload;
  705. }
  706. /**
  707. * Set project
  708. *
  709. * @param Project $project
  710. *
  711. * @return Document
  712. */
  713. public function setProject(?Project $project = null)
  714. {
  715. $this->project = $project;
  716. return $this;
  717. }
  718. /**
  719. * Get project
  720. *
  721. * @return Project
  722. */
  723. public function getProject()
  724. {
  725. return $this->project;
  726. }
  727. /**
  728. * Set documentType
  729. *
  730. * @param DocumentType $documentType
  731. *
  732. * @return Document
  733. */
  734. public function setDocumentType(?DocumentType $documentType = null)
  735. {
  736. $this->documentType = $documentType;
  737. return $this;
  738. }
  739. /**
  740. * Get documentType
  741. *
  742. * @return DocumentType
  743. */
  744. public function getDocumentType()
  745. {
  746. return $this->documentType;
  747. }
  748. /**
  749. * Add collections
  750. *
  751. * @param \MedBrief\MSR\Entity\Collection $collections
  752. *
  753. * @return Document
  754. */
  755. public function addCollection(Collection $collections)
  756. {
  757. $this->collections[] = $collections;
  758. return $this;
  759. }
  760. /**
  761. * Remove collections
  762. *
  763. * @param \MedBrief\MSR\Entity\Collection $collections
  764. */
  765. public function removeCollection(Collection $collections)
  766. {
  767. $this->collections->removeElement($collections);
  768. }
  769. /**
  770. * Get collections
  771. *
  772. * @return Collection|Collection[]
  773. */
  774. public function getCollections()
  775. {
  776. return $this->collections;
  777. }
  778. /**
  779. * Set creator
  780. *
  781. * @param User $creator
  782. *
  783. * @return Document
  784. */
  785. public function setCreator(User $creator)
  786. {
  787. $this->creator = $creator;
  788. return $this;
  789. }
  790. /**
  791. * Get creator
  792. *
  793. * @return User
  794. */
  795. public function getCreator()
  796. {
  797. return $this->creator;
  798. }
  799. /**
  800. * Set nativeFilename
  801. *
  802. * @param string $nativeFilename
  803. *
  804. * @return Document
  805. */
  806. public function setNativeFilename($nativeFilename)
  807. {
  808. $this->nativeFilename = $nativeFilename;
  809. return $this;
  810. }
  811. /**
  812. * Get nativeFilename
  813. *
  814. * @return string
  815. */
  816. public function getNativeFilename()
  817. {
  818. return $this->nativeFilename;
  819. }
  820. /**
  821. * Set nativeFile
  822. *
  823. * @param string $nativeFile
  824. *
  825. * @return Document
  826. */
  827. public function setNativeFile($nativeFile)
  828. {
  829. $this->nativeFile = $nativeFile;
  830. return $this;
  831. }
  832. /**
  833. * Get nativeFile
  834. *
  835. * @return string
  836. */
  837. public function getNativeFile()
  838. {
  839. return $this->nativeFile;
  840. }
  841. /**
  842. * Returns an array of this documents data
  843. *
  844. * @return array
  845. *
  846. *@todo add more data Of maybe even just use the symfony serializer component
  847. *
  848. */
  849. public function jsonSerialize(): mixed
  850. {
  851. return [
  852. 'created' => $this->getCreated()->format('j F Y, H:ia'),
  853. 'filename' => $this->getFilename(),
  854. 'filesize' => number_format($this->getFilesize(), 0),
  855. ];
  856. }
  857. /**
  858. * Given the orthancTransaction (which is assumed to be of type STORE)
  859. * We update the appropriate values on this Document to indicate the various
  860. * orthanc data returned by the storage transaction
  861. *
  862. * @param OrthancTransaction $orthancTransaction
  863. */
  864. public function processOrthancStoreTransaction(OrthancTransaction $orthancTransaction)
  865. {
  866. // first - set the submissions status to pending at the outset
  867. $this->setOrthancStorageStatus(self::ORTHANC_STORAGE_STATUS_PENDING);
  868. // if the given transaction wasn't a success, the storage status of this
  869. // document is automatically also a fail
  870. if ($orthancTransaction->getTransactionStatus() != OrthancTransaction::TRANSACTION_STATUS_SUCCESS) {
  871. $this->setOrthancStorageStatus(self::ORTHANC_STORAGE_STATUS_FAILED);
  872. return false;
  873. }
  874. // if we get here, then everything is in order!
  875. $jsonObject = json_decode($orthancTransaction->getTransactionResponse());
  876. // set the individual values on the document
  877. $orthancStoreResponseId = $jsonObject->ID;
  878. $orthancStoreResponsePath = $jsonObject->Path;
  879. $orthancStoreResponseStatus = $jsonObject->Status;
  880. $this->setOrthancStoreResponseId($orthancStoreResponseId);
  881. $this->setOrthancStoreResponsePath($orthancStoreResponsePath);
  882. $this->setOrthancStoreResponseStatus($orthancStoreResponseStatus);
  883. // set the status as successful
  884. $this->setOrthancStorageStatus(self::ORTHANC_STORAGE_STATUS_STORED);
  885. }
  886. /**
  887. * Given the orthancTransaction (which is assumed to be of type INSTANCE_DETAILS) we
  888. * update the parent series id of this document
  889. *
  890. * @param OrthancTransaction $orthancTransaction
  891. *
  892. * @return void
  893. */
  894. public function processOrthancInstanceDetailsTransaction(OrthancTransaction $orthancTransaction): void
  895. {
  896. if ($orthancTransaction->getTransactionStatus() == OrthancTransaction::TRANSACTION_STATUS_SUCCESS) {
  897. $jsonObject = json_decode($orthancTransaction->getTransactionResponse());
  898. $this->setOrthancParentSeriesId($jsonObject->ParentSeries);
  899. // we anticipate that InstanceNumbers from Othanc will always be
  900. // integers (we hope) we cast them to Ints because our database
  901. // field is an integer. We have to use an integer field for
  902. // ordering purposes (varchar doesnt order correctly)
  903. if (isset($jsonObject->MainDicomTags) && isset($jsonObject->MainDicomTags->InstanceNumber)) {
  904. $this->setOrthancInstanceNumber(intval($jsonObject->MainDicomTags->InstanceNumber));
  905. }
  906. }
  907. }
  908. /**
  909. * Given the orthancTransaction (which is assumed to be of type DELETE) we
  910. * update the orthancStorage status of this document
  911. *
  912. * @param OrthancTransaction $orthancTransaction
  913. *
  914. * @return bool
  915. */
  916. public function processOrthancDeleteTransaction(OrthancTransaction $orthancTransaction): bool
  917. {
  918. // first - set the submissions status to pending at the outset
  919. $this->setOrthancStorageStatus(self::ORTHANC_STORAGE_STATUS_PENDING);
  920. // if the transaction status is not SUCCESS then set this status as FAILED
  921. if ($orthancTransaction->getTransactionStatus() != OrthancTransaction::TRANSACTION_STATUS_SUCCESS) {
  922. $this->setOrthancStorageStatus(self::ORTHANC_STORAGE_STATUS_FAILED);
  923. return false;
  924. }
  925. // set the status as successful
  926. $this->setOrthancStorageStatus(self::ORTHANC_STORAGE_STATUS_DELETED);
  927. return true;
  928. }
  929. /**
  930. * Add orthancTransaction. When a orthancTransaction is assigned to this
  931. * Document using this function, then the associated orthanc values on this
  932. * Document will be updated with th assumption that this transaction is the
  933. * latest one to have run on the document
  934. *
  935. * @param OrthancTransaction $orthancTransaction
  936. *
  937. * @return Document
  938. */
  939. public function addOrthancTransaction(OrthancTransaction $orthancTransaction)
  940. {
  941. $this->orthancTransactions[] = $orthancTransaction;
  942. // based on the type of the transaction, we run the appropriate function
  943. // on this document
  944. switch ($orthancTransaction->getType()) {
  945. case OrthancTransaction::TYPE_STORE_INSTANCE:
  946. $this->processOrthancStoreTransaction($orthancTransaction);
  947. break;
  948. case OrthancTransaction::TYPE_DELETE_INSTANCE:
  949. $this->processOrthancDeleteTransaction($orthancTransaction);
  950. break;
  951. case OrthancTransaction::TYPE_INSTANCE_DETAILS:
  952. $this->processOrthancInstanceDetailsTransaction($orthancTransaction);
  953. break;
  954. default:
  955. throw new \Exception('Invalid OrthancTransaction Type: ' . $orthancTransaction->getType());
  956. }
  957. return $this;
  958. }
  959. /**
  960. * Remove orthancTransaction
  961. *
  962. * @param OrthancTransaction $orthancTransaction
  963. */
  964. public function removeOrthancTransaction(OrthancTransaction $orthancTransaction)
  965. {
  966. $this->orthancTransactions->removeElement($orthancTransaction);
  967. }
  968. /**
  969. * Get orthancTransactions
  970. *
  971. * @return Collection
  972. */
  973. public function getOrthancTransactions()
  974. {
  975. return $this->orthancTransactions;
  976. }
  977. /**
  978. * Set orthancStorageStatus
  979. *
  980. * @param int $orthancStorageStatus
  981. *
  982. * @return Document
  983. */
  984. public function setOrthancStorageStatus($orthancStorageStatus)
  985. {
  986. $this->orthanc_storage_status = $orthancStorageStatus;
  987. return $this;
  988. }
  989. /**
  990. * Get orthancStorageStatus
  991. *
  992. * @return int
  993. */
  994. public function getOrthancStorageStatus()
  995. {
  996. return $this->orthanc_storage_status;
  997. }
  998. /**
  999. * Set orthancStoreResponseId
  1000. *
  1001. * @param string $orthancStoreResponseId
  1002. *
  1003. * @return Document
  1004. */
  1005. public function setOrthancStoreResponseId($orthancStoreResponseId)
  1006. {
  1007. $this->orthanc_store_response_id = $orthancStoreResponseId;
  1008. return $this;
  1009. }
  1010. /**
  1011. * Get orthancStoreResponseId
  1012. *
  1013. * @return string
  1014. */
  1015. public function getOrthancStoreResponseId()
  1016. {
  1017. return $this->orthanc_store_response_id;
  1018. }
  1019. /**
  1020. * Set orthancStoreResponsePath
  1021. *
  1022. * @param string $orthancStoreResponsePath
  1023. *
  1024. * @return Document
  1025. */
  1026. public function setOrthancStoreResponsePath($orthancStoreResponsePath)
  1027. {
  1028. $this->orthanc_store_response_path = $orthancStoreResponsePath;
  1029. return $this;
  1030. }
  1031. /**
  1032. * Get orthancStoreResponsePath
  1033. *
  1034. * @return string
  1035. */
  1036. public function getOrthancStoreResponsePath()
  1037. {
  1038. return $this->orthanc_store_response_path;
  1039. }
  1040. /**
  1041. * Set orthancStoreResponseStatus
  1042. *
  1043. * @param string $orthancStoreResponseStatus
  1044. *
  1045. * @return Document
  1046. */
  1047. public function setOrthancStoreResponseStatus($orthancStoreResponseStatus)
  1048. {
  1049. $this->orthanc_store_response_status = $orthancStoreResponseStatus;
  1050. return $this;
  1051. }
  1052. /**
  1053. * Get orthancStoreResponseStatus
  1054. *
  1055. * @return string
  1056. */
  1057. public function getOrthancStoreResponseStatus()
  1058. {
  1059. return $this->orthanc_store_response_status;
  1060. }
  1061. /**
  1062. * Set deletedAt
  1063. *
  1064. * @param \DateTime $deletedAt
  1065. *
  1066. * @return Document
  1067. */
  1068. public function setDeletedAt($deletedAt)
  1069. {
  1070. $this->deletedAt = $deletedAt;
  1071. return $this;
  1072. }
  1073. /**
  1074. * Get deletedAt
  1075. *
  1076. * @return \DateTime
  1077. */
  1078. public function getDeletedAt()
  1079. {
  1080. return $this->deletedAt;
  1081. }
  1082. /**
  1083. * Set orthancParentSeriesId
  1084. *
  1085. * @param string $orthancParentSeriesId
  1086. *
  1087. * @return Document
  1088. */
  1089. public function setOrthancParentSeriesId($orthancParentSeriesId)
  1090. {
  1091. $this->orthanc_parent_series_id = $orthancParentSeriesId;
  1092. return $this;
  1093. }
  1094. /**
  1095. * Get orthancParentSeriesId
  1096. *
  1097. * @return string
  1098. */
  1099. public function getOrthancParentSeriesId()
  1100. {
  1101. return $this->orthanc_parent_series_id;
  1102. }
  1103. /**
  1104. * Set md5hash
  1105. *
  1106. * @param string $md5hash
  1107. *
  1108. * @return Document
  1109. */
  1110. public function setMd5hash($md5hash)
  1111. {
  1112. $this->md5hash = $md5hash;
  1113. return $this;
  1114. }
  1115. /**
  1116. * Get md5hash
  1117. *
  1118. * @return string
  1119. */
  1120. public function getMd5hash()
  1121. {
  1122. return $this->md5hash;
  1123. }
  1124. /**
  1125. * Returns this Document as a jsTree formatted node
  1126. *
  1127. * @param string $replacementNodeText
  1128. * @param array $additionalLiAttributes
  1129. *
  1130. * @return array
  1131. */
  1132. public function getJsTreeFormattedNode($replacementNodeText = null, $additionalLiAttributes = [])
  1133. {
  1134. if ($this->isWebAV()) {
  1135. $dataConversionProgress = $this->getConvertedToWebAVStatusLabel(true);
  1136. } else {
  1137. $dataConversionProgress = $this->getConvertedToXodStatusLabel(true);
  1138. }
  1139. $node = [
  1140. 'text' => $replacementNodeText ?: $this->getFilename(),
  1141. //'children' => array(),
  1142. 'type' => 'file', // we give the node a type because we will be distinguishing between node types on the JS side
  1143. // @Todo update icon libray to use the google material icons - replace getFaIcon with getIconType.
  1144. 'icon' => ' mb-icon ' . $this->getIconClassName(), // override the default icon
  1145. 'valid_children' => null, // Rowan: I assume this specifies that this kind of node may not have children?
  1146. 'li_attr' => [
  1147. 'data-document-id' => $this->getId(),
  1148. 'data-controller' => 'fullrow-foldertree',
  1149. 'data-creator-id' => $this->getCreator() ? $this->getCreator()->getId() : '',
  1150. 'data-conversion-progress' => $dataConversionProgress,
  1151. 'title' => $replacementNodeText ?: $this->getFilename(),
  1152. 'data-document-type-family' => $this->getDocumentTypeFamily(),
  1153. 'data-document-mime-type' => $this->getMimeType(),
  1154. ],
  1155. ];
  1156. // any additional attributes passed through should be assigned to the node
  1157. foreach ($additionalLiAttributes as $key => $value) {
  1158. $node['li_attr'][$key] = $value;
  1159. }
  1160. return $node;
  1161. }
  1162. /**
  1163. * Set originalFilename
  1164. *
  1165. * @param string $originalFilename
  1166. *
  1167. * @return Document
  1168. */
  1169. public function setOriginalFilename($originalFilename)
  1170. {
  1171. $this->original_filename = $originalFilename;
  1172. return $this;
  1173. }
  1174. /**
  1175. * Get originalFilename
  1176. *
  1177. * @return string
  1178. */
  1179. public function getOriginalFilename()
  1180. {
  1181. return $this->original_filename;
  1182. }
  1183. /**
  1184. * Set swfFilename
  1185. *
  1186. * @param string $swfFilename
  1187. *
  1188. * @return Document
  1189. */
  1190. public function setSwfFilename($swfFilename)
  1191. {
  1192. $this->swfFilename = $swfFilename;
  1193. return $this;
  1194. }
  1195. /**
  1196. * Get swfFilename
  1197. *
  1198. * @return string
  1199. */
  1200. public function getSwfFilename()
  1201. {
  1202. return $this->swfFilename;
  1203. }
  1204. /**
  1205. * Set swfFile
  1206. *
  1207. * @param string $swfFile
  1208. *
  1209. * @return Document
  1210. */
  1211. public function setSwfFile($swfFile)
  1212. {
  1213. $this->swfFile = $swfFile;
  1214. return $this;
  1215. }
  1216. /**
  1217. * Get swfFile
  1218. *
  1219. * @return string
  1220. */
  1221. public function getSwfFile()
  1222. {
  1223. return $this->swfFile;
  1224. }
  1225. /**
  1226. * Set convertedToSwfStatus
  1227. *
  1228. * @param string $convertedToSwfStatus
  1229. *
  1230. * @return Document
  1231. */
  1232. public function setConvertedToSwfStatus($convertedToSwfStatus)
  1233. {
  1234. $this->convertedToSwfStatus = $convertedToSwfStatus;
  1235. return $this;
  1236. }
  1237. /**
  1238. * Get convertedToSwfStatus
  1239. *
  1240. * @return string
  1241. */
  1242. public function getConvertedToSwfStatus()
  1243. {
  1244. return $this->convertedToSwfStatus;
  1245. }
  1246. /**
  1247. * Set orthancInstanceNumber
  1248. *
  1249. * @param string $orthancInstanceNumber
  1250. *
  1251. * @return Document
  1252. */
  1253. public function setOrthancInstanceNumber($orthancInstanceNumber)
  1254. {
  1255. $this->orthanc_instance_number = $orthancInstanceNumber;
  1256. return $this;
  1257. }
  1258. /**
  1259. * Get orthancInstanceNumber
  1260. *
  1261. * @return string
  1262. */
  1263. public function getOrthancInstanceNumber()
  1264. {
  1265. return $this->orthanc_instance_number;
  1266. }
  1267. // @Todo remove getIconClassName function once all aspects of font-awesome has been removed.
  1268. /**
  1269. * returns fa icon class
  1270. */
  1271. public function getIconClassName()
  1272. {
  1273. // determine file extension
  1274. $extension = strtolower(pathinfo($this->getFilename(), PATHINFO_EXTENSION));
  1275. // If the file extension on the filename is empty, check the native filename.
  1276. if (!$extension) {
  1277. $extension = strtolower(pathinfo($this->getNativeFilename(), PATHINFO_EXTENSION));
  1278. }
  1279. return 'mb-icon ' . (array_key_exists($extension, self::$fileIcons) ? self::$fileIcons[$extension]['iconClass'] : 'mb-icon--file');
  1280. }
  1281. /**
  1282. * determines the file type using a convoluted route of checking the file's
  1283. * fa icon class.
  1284. */
  1285. public function getFileFamilyType()
  1286. {
  1287. // determine file extension
  1288. $extension = strtolower(pathinfo($this->getFilename(), PATHINFO_EXTENSION));
  1289. // If the file extension on the filename is empty, check the native filename.
  1290. if (!$extension) {
  1291. $extension = strtolower(pathinfo($this->getNativeFilename(), PATHINFO_EXTENSION));
  1292. }
  1293. return self::guessFileFamilyType($extension);
  1294. }
  1295. /**
  1296. * Guesses the fileFamilyType fiven an extension.
  1297. *
  1298. * @param string $extension
  1299. *
  1300. * @return string
  1301. */
  1302. public static function guessFileFamilyType($extension)
  1303. {
  1304. return (array_key_exists($extension, self::$fileIcons) ? self::$fileIcons[$extension]['type'] : 'false');
  1305. }
  1306. /**
  1307. * Helper function to return if the file is a pdf.
  1308. */
  1309. public function isPdf()
  1310. {
  1311. return $this->getFileFamilyType() === self::FILE_TYPE_PDF;
  1312. }
  1313. /**
  1314. * Helper function to return true if the file is a Image.
  1315. */
  1316. public function isImage()
  1317. {
  1318. return $this->getFileFamilyType() === self::FILE_TYPE_IMAGE;
  1319. }
  1320. /**
  1321. * Helper function to return true if the file is Text or Html.
  1322. */
  1323. public function isTextOrHtml()
  1324. {
  1325. return $this->getFileFamilyType() === self::FILE_TYPE_TEXT_HTML;
  1326. }
  1327. /**
  1328. * Helper function to return true if the file is Msg or Eml.
  1329. */
  1330. public function isEmlOrMsg()
  1331. {
  1332. return $this->getFileFamilyType() === self::FILE_TYPE_EML_MSG;
  1333. }
  1334. /**
  1335. * Helper function to return if the file is an ms office document.
  1336. */
  1337. public function isMSOffice()
  1338. {
  1339. return in_array($this->getFileFamilyType(), [
  1340. self::FILE_TYPE_MSWORD,
  1341. self::FILE_TYPE_MSEXCEL,
  1342. self::FILE_TYPE_MSPOWERPOINT,
  1343. ]);
  1344. }
  1345. /**
  1346. * Helper function to return if the file is a WebAV.
  1347. */
  1348. public function isWebAV()
  1349. {
  1350. return in_array($this->getFileFamilyType(), [self::FILE_TYPE_AUDIO, self::FILE_TYPE_VIDEO]);
  1351. }
  1352. /**
  1353. * Returns true if we support viewing of this document type.
  1354. *
  1355. * @return bool
  1356. */
  1357. public function supportsViewing()
  1358. {
  1359. $allowedTypes = self::getSupportedViewingTypes();
  1360. return in_array($this->getDocumentTypeFamily(), $allowedTypes);
  1361. }
  1362. /**
  1363. * Returns true if we support webAV playback of this document type
  1364. *
  1365. * @return bool
  1366. */
  1367. public function supportsWebAVPlayback()
  1368. {
  1369. $allowedTypes = self::getSupportedWebAVPlaybackTypes();
  1370. $allowedMimeTypes = self::getSupportedWebAVMimeTypes();
  1371. return
  1372. in_array($this->getDocumentTypeFamily(), $allowedTypes)
  1373. && in_array($this->getMimeType(), $allowedMimeTypes);
  1374. }
  1375. /**
  1376. * Returns the documentFamilyTypes we support for viewing.
  1377. *
  1378. * @return array
  1379. */
  1380. public static function getSupportedViewingTypes()
  1381. {
  1382. return [
  1383. self::FILE_TYPE_MSEXCEL,
  1384. self::FILE_TYPE_MSPOWERPOINT,
  1385. self::FILE_TYPE_MSWORD,
  1386. self::FILE_TYPE_PDF,
  1387. self::FILE_TYPE_IMAGE,
  1388. self::FILE_TYPE_TEXT_HTML,
  1389. self::FILE_TYPE_EML_MSG,
  1390. ];
  1391. }
  1392. /**
  1393. * Returns the documentFamilyTypes we support for viewing.
  1394. *
  1395. * @return array
  1396. */
  1397. public static function getSupportedWebAVPlaybackTypes()
  1398. {
  1399. return [
  1400. self::FILE_TYPE_AUDIO,
  1401. self::FILE_TYPE_VIDEO,
  1402. ];
  1403. }
  1404. /**
  1405. * Returns the mime types we support for playing webAV.
  1406. *
  1407. * @return array
  1408. */
  1409. public static function getSupportedWebAVMimeTypes()
  1410. {
  1411. return [
  1412. 'video/mp4',
  1413. //'video/dvr-ms', This is not the actual mime type for DVR, video/x-ms-asf is.
  1414. 'video/x-ms-asf',
  1415. 'audio/mpeg',
  1416. 'audio/x-wav',
  1417. ];
  1418. }
  1419. /**
  1420. * Set documentTypeFamily
  1421. *
  1422. * @param string $documentTypeFamily
  1423. *
  1424. * @return Document
  1425. */
  1426. public function setDocumentTypeFamily($documentTypeFamily)
  1427. {
  1428. $this->documentTypeFamily = $documentTypeFamily;
  1429. return $this;
  1430. }
  1431. /**
  1432. * Get documentTypeFamily
  1433. *
  1434. * @return string
  1435. */
  1436. public function getDocumentTypeFamily()
  1437. {
  1438. return $this->documentTypeFamily;
  1439. }
  1440. /**
  1441. * Set convertedToOptimizedPdfStatus
  1442. *
  1443. * @param int $convertedToOptimizedPdfStatus
  1444. *
  1445. * @return Document
  1446. */
  1447. public function setConvertedToOptimizedPdfStatus($convertedToOptimizedPdfStatus)
  1448. {
  1449. $this->convertedToOptimizedPdfStatus = $convertedToOptimizedPdfStatus;
  1450. return $this;
  1451. }
  1452. /**
  1453. * Get convertedToOptimizedPdfStatus
  1454. *
  1455. * @return int
  1456. */
  1457. public function getConvertedToOptimizedPdfStatus()
  1458. {
  1459. return $this->convertedToOptimizedPdfStatus;
  1460. }
  1461. /**
  1462. * Get ConvertedToOptimizedPdfStatus options
  1463. *
  1464. * @return array
  1465. */
  1466. public static function getConvertedToOptimizedPdfStatusOptions()
  1467. {
  1468. return [
  1469. self::CONVERSION_TO_OPTIMIZED_PDF_PENDING => 'Pending',
  1470. self::CONVERSION_TO_OPTIMIZED_PDF_COMPLETE => 'Complete',
  1471. self::CONVERSION_TO_OPTIMIZED_PDF_FAILED => 'Failed',
  1472. self::CONVERSION_TO_OPTIMIZED_PDF_CURRENT => 'Current',
  1473. self::CONVERSION_TO_OPTIMIZED_PDF_SKIPPED => 'Skipped',
  1474. ];
  1475. }
  1476. /**
  1477. * Get ConvertedToOptimizedPdfStatus label
  1478. *
  1479. * @param bool $markupFriendly - If the label returned should be markup friendly.
  1480. * Used for when you want to use the label as a CSS class.
  1481. *
  1482. * @return string
  1483. */
  1484. public function getConvertedToOptimizedPdfStatusLabel($markupFriendly = false)
  1485. {
  1486. $options = self::getConvertedToOptimizedPdfStatusOptions();
  1487. $label = $options[$this->getConvertedToOptimizedPdfStatus()] ?? '';
  1488. if ($markupFriendly) {
  1489. return strtolower(str_replace(' ', '-', $label));
  1490. }
  1491. return $label;
  1492. }
  1493. /**
  1494. * Returns true if the Document's ConvertedToOptimizedPdf status is Pending.
  1495. *
  1496. * @return bool
  1497. */
  1498. public function isConvertedToOptimizedPdfPending()
  1499. {
  1500. return $this->getConvertedToOptimizedPdfStatus() === self::CONVERSION_TO_OPTIMIZED_PDF_PENDING;
  1501. }
  1502. /**
  1503. * Returns true if the Document's ConvertedToOptimizedPdf status is Complete.
  1504. *
  1505. * @return bool
  1506. */
  1507. public function isConvertedToOptimizedPdfComplete()
  1508. {
  1509. return $this->getConvertedToOptimizedPdfStatus() === self::CONVERSION_TO_OPTIMIZED_PDF_COMPLETE;
  1510. }
  1511. /**
  1512. * Returns true if the Document's ConvertedToOptimizedPdf status is Failed.
  1513. *
  1514. * @return bool
  1515. */
  1516. public function isConvertedToOptimizedPdfFailed()
  1517. {
  1518. return $this->getConvertedToOptimizedPdfStatus() === self::CONVERSION_TO_OPTIMIZED_PDF_FAILED;
  1519. }
  1520. /**
  1521. * Returns true if the Document's ConvertedToOptimizedPdf status is Current.
  1522. *
  1523. * @return bool
  1524. */
  1525. public function isConvertedToOptimizedPdfCurrent()
  1526. {
  1527. return $this->getConvertedToOptimizedPdfStatus() === self::CONVERSION_TO_OPTIMIZED_PDF_CURRENT;
  1528. }
  1529. /**
  1530. * Returns true if the Document's ConvertedToOptimizedPdf status is Skipped.
  1531. *
  1532. * @return bool
  1533. */
  1534. public function isConvertedToOptimizedPdfSkipped()
  1535. {
  1536. return $this->getConvertedToOptimizedPdfStatus() === self::CONVERSION_TO_OPTIMIZED_PDF_SKIPPED;
  1537. }
  1538. /**
  1539. * Set optimizedPdfFilename
  1540. *
  1541. * @param string $optimizedPdfFilename
  1542. *
  1543. * @return Document
  1544. */
  1545. public function setOptimizedPdfFilename($optimizedPdfFilename)
  1546. {
  1547. $this->optimizedPdfFilename = $optimizedPdfFilename;
  1548. return $this;
  1549. }
  1550. /**
  1551. * Get optimizedPdfFilename
  1552. *
  1553. * @return string
  1554. */
  1555. public function getOptimizedPdfFilename()
  1556. {
  1557. return $this->optimizedPdfFilename;
  1558. }
  1559. /**
  1560. * Set optimizedPdfFile
  1561. *
  1562. * @param string $optimizedPdfFile
  1563. *
  1564. * @return Document
  1565. */
  1566. public function setOptimizedPdfFile($optimizedPdfFile)
  1567. {
  1568. $this->optimizedPdfFile = $optimizedPdfFile;
  1569. return $this;
  1570. }
  1571. /**
  1572. * Get optimizedPdfFile
  1573. *
  1574. * @return string
  1575. */
  1576. public function getOptimizedPdfFile()
  1577. {
  1578. return $this->optimizedPdfFile;
  1579. }
  1580. /**
  1581. * Set convertedToXodStatus
  1582. *
  1583. * @param int $convertedToXodStatus
  1584. *
  1585. * @return Document
  1586. */
  1587. public function setConvertedToXodStatus($convertedToXodStatus)
  1588. {
  1589. $this->convertedToXodStatus = $convertedToXodStatus;
  1590. return $this;
  1591. }
  1592. /**
  1593. * Get convertedToXodStatus
  1594. *
  1595. * @return int
  1596. */
  1597. public function getConvertedToXodStatus()
  1598. {
  1599. return $this->convertedToXodStatus;
  1600. }
  1601. /**
  1602. * Get ConvertedToXodStatus options
  1603. *
  1604. * @return array
  1605. */
  1606. public static function getConvertedToXodStatusOptions()
  1607. {
  1608. return [
  1609. self::CONVERSION_TO_XOD_PENDING => 'Pending',
  1610. self::CONVERSION_TO_XOD_COMPLETE => 'Complete',
  1611. self::CONVERSION_TO_XOD_FAILED => 'Failed',
  1612. self::CONVERSION_TO_XOD_CURRENT => 'Current',
  1613. self::CONVERSION_TO_XOD_SKIPPED => 'Skipped',
  1614. self::CONVERSION_TO_XOD_ENCRYPTED => 'Encrypted',
  1615. ];
  1616. }
  1617. /**
  1618. * Get ConvertedToXodStatus label
  1619. *
  1620. * @param bool $markupFriendly - If the label returned should be markup friendly.
  1621. * Used for when you want to use the label as a CSS class.
  1622. *
  1623. * @return string
  1624. */
  1625. public function getConvertedToXodStatusLabel($markupFriendly = false)
  1626. {
  1627. $options = self::getConvertedToXodStatusOptions();
  1628. $label = $options[$this->getConvertedToXodStatus()] ?? '';
  1629. if ($markupFriendly) {
  1630. return strtolower(str_replace(' ', '-', $label));
  1631. }
  1632. return $label;
  1633. }
  1634. /**
  1635. * Get ConvertedToWebAVStatus options
  1636. *
  1637. * @return array
  1638. */
  1639. public static function getConvertedToWebAVStatusOptions()
  1640. {
  1641. return [
  1642. self::CONVERSION_TO_WEBAV_PENDING => 'Pending',
  1643. self::CONVERSION_TO_WEBAV_COMPLETE => 'Complete',
  1644. self::CONVERSION_TO_WEBAV_FAILED => 'Failed',
  1645. self::CONVERSION_TO_WEBAV_CURRENT => 'Current',
  1646. self::CONVERSION_TO_WEBAV_SKIPPED => 'Skipped',
  1647. ];
  1648. }
  1649. /**
  1650. * Get ConvertedToWebAVStatus label
  1651. *
  1652. * @param bool $markupFriendly - If the label returned should be markup friendly.
  1653. * Used for when you want to use the label as a CSS class.
  1654. *
  1655. * @return string
  1656. */
  1657. public function getConvertedToWebAVStatusLabel($markupFriendly = false)
  1658. {
  1659. $options = self::getConvertedToWebAVStatusOptions();
  1660. $label = $options[$this->getConvertedToWebAVStatus()] ?? '';
  1661. if ($markupFriendly) {
  1662. return strtolower(str_replace(' ', '-', $label));
  1663. }
  1664. return $label;
  1665. }
  1666. /**
  1667. * Returns true if the Document's ConvertedToXod status is Pending.
  1668. *
  1669. * @return bool
  1670. */
  1671. public function isConvertedToXodPending()
  1672. {
  1673. return $this->getConvertedToXodStatus() === self::CONVERSION_TO_XOD_PENDING;
  1674. }
  1675. /**
  1676. * Returns true if the Document's ConvertedToXod status is Complete.
  1677. *
  1678. * @return bool
  1679. */
  1680. public function isConvertedToXodComplete()
  1681. {
  1682. return $this->getConvertedToXodStatus() === self::CONVERSION_TO_XOD_COMPLETE;
  1683. }
  1684. /**
  1685. * Returns true if the Document's ConvertedToXod status is Failed.
  1686. *
  1687. * @return bool
  1688. */
  1689. public function isConvertedToXodFailed()
  1690. {
  1691. return $this->getConvertedToXodStatus() === self::CONVERSION_TO_XOD_FAILED;
  1692. }
  1693. /**
  1694. * Returns true if the Document's ConvertedToXod status is Current.
  1695. *
  1696. * @return bool
  1697. */
  1698. public function isConvertedToXodCurrent()
  1699. {
  1700. return $this->getConvertedToXodStatus() === self::CONVERSION_TO_XOD_CURRENT;
  1701. }
  1702. /**
  1703. * Returns true if the Document's ConvertedToXod status is Skipped.
  1704. *
  1705. * @return bool
  1706. */
  1707. public function isConvertedToXodSkipped()
  1708. {
  1709. return $this->getConvertedToXodStatus() === self::CONVERSION_TO_XOD_SKIPPED;
  1710. }
  1711. /**
  1712. * Returns true if the Document's ConvertedToXod status is Encrypted.
  1713. *
  1714. * @return bool
  1715. */
  1716. public function isConvertedToXodEncrypted()
  1717. {
  1718. return $this->getConvertedToXodStatus() === self::CONVERSION_TO_XOD_ENCRYPTED;
  1719. }
  1720. /**
  1721. * Set xodFilename
  1722. *
  1723. * @param string $xodFilename
  1724. *
  1725. * @return Document
  1726. */
  1727. public function setXodFilename($xodFilename)
  1728. {
  1729. $this->xodFilename = $xodFilename;
  1730. return $this;
  1731. }
  1732. /**
  1733. * Get xodFilename
  1734. *
  1735. * @return string
  1736. */
  1737. public function getXodFilename()
  1738. {
  1739. return $this->xodFilename;
  1740. }
  1741. /**
  1742. * Set xodFile
  1743. *
  1744. * @param string $xodFile
  1745. *
  1746. * @return Document
  1747. */
  1748. public function setXodFile($xodFile)
  1749. {
  1750. $this->xodFile = $xodFile;
  1751. return $this;
  1752. }
  1753. /**
  1754. * Set WebAVFile
  1755. *
  1756. * @param string $webAVFile
  1757. *
  1758. * @return Document
  1759. */
  1760. public function setWebAVFile($webAVFile)
  1761. {
  1762. $this->webAVFile = $webAVFile;
  1763. return $this;
  1764. }
  1765. /**
  1766. * Get WebAVFile
  1767. *
  1768. * @return string
  1769. */
  1770. public function getWebAVFile()
  1771. {
  1772. return $this->webAVFile;
  1773. }
  1774. /**
  1775. * Get xodFile
  1776. *
  1777. * @return string
  1778. */
  1779. public function getXodFile()
  1780. {
  1781. return $this->xodFile;
  1782. }
  1783. /**
  1784. * Set ocrFilename
  1785. *
  1786. * @param string $ocrFilename
  1787. *
  1788. * @return Document
  1789. */
  1790. public function setOcrFilename($ocrFilename)
  1791. {
  1792. $this->ocrFilename = $ocrFilename;
  1793. return $this;
  1794. }
  1795. /**
  1796. * Get ocrFilename
  1797. *
  1798. * @return string
  1799. */
  1800. public function getOcrFilename()
  1801. {
  1802. return $this->ocrFilename;
  1803. }
  1804. /**
  1805. * Set ocrFile
  1806. *
  1807. * @param string $ocrFile
  1808. *
  1809. * @return Document
  1810. */
  1811. public function setOcrFile($ocrFile)
  1812. {
  1813. $this->ocrFile = $ocrFile;
  1814. return $this;
  1815. }
  1816. /**
  1817. * Get ocrFile
  1818. *
  1819. * @return string
  1820. */
  1821. public function getOcrFile()
  1822. {
  1823. return $this->ocrFile;
  1824. }
  1825. /**
  1826. * Set convertedToOcrStatus
  1827. *
  1828. * @param int $convertedToOcrStatus
  1829. *
  1830. * @return Document
  1831. */
  1832. public function setConvertedToOcrStatus($convertedToOcrStatus)
  1833. {
  1834. $this->convertedToOcrStatus = $convertedToOcrStatus;
  1835. return $this;
  1836. }
  1837. /**
  1838. * Get convertedToOcrStatus
  1839. *
  1840. * @return int
  1841. */
  1842. public function getConvertedToOcrStatus()
  1843. {
  1844. return $this->convertedToOcrStatus;
  1845. }
  1846. /**
  1847. * Get ConvertedToOcrStatus options
  1848. *
  1849. * @return array
  1850. */
  1851. public static function getConvertedToOcrStatusOptions()
  1852. {
  1853. return [
  1854. self::CONVERSION_TO_OCR_PENDING => 'Pending',
  1855. self::CONVERSION_TO_OCR_COMPLETE => 'Complete',
  1856. self::CONVERSION_TO_OCR_FAILED => 'Failed',
  1857. self::CONVERSION_TO_OCR_CURRENT => 'In Progress',
  1858. self::CONVERSION_TO_OCR_SKIPPED => 'Skipped',
  1859. ];
  1860. }
  1861. /**
  1862. * Get ConvertedToOcrStatus label
  1863. *
  1864. * @param bool $markupFriendly - If the label returned should be markup friendly.
  1865. * Used for when you want to use the label as a CSS class.
  1866. *
  1867. * @return string
  1868. */
  1869. public function getConvertedToOcrStatusLabel($markupFriendly = false)
  1870. {
  1871. $options = self::getConvertedToOcrStatusOptions();
  1872. $label = $options[$this->getConvertedToOcrStatus()] ?? '';
  1873. if ($markupFriendly) {
  1874. return strtolower(str_replace(' ', '-', $label));
  1875. }
  1876. return $label;
  1877. }
  1878. /**
  1879. * Returns true if the Document's ConvertedToOcr status is Pending.
  1880. *
  1881. * @return bool
  1882. */
  1883. public function isConvertedToOcrPending()
  1884. {
  1885. return $this->getConvertedToOcrStatus() === self::CONVERSION_TO_OCR_PENDING;
  1886. }
  1887. /**
  1888. * Returns true if the Document's ConvertedToOcr status is Complete.
  1889. *
  1890. * @return bool
  1891. */
  1892. public function isConvertedToOcrComplete()
  1893. {
  1894. return $this->getConvertedToOcrStatus() === self::CONVERSION_TO_OCR_COMPLETE;
  1895. }
  1896. /**
  1897. * Returns true if the Document's ConvertedToOcr status is Failed.
  1898. *
  1899. * @return bool
  1900. */
  1901. public function isConvertedToOcrFailed()
  1902. {
  1903. return $this->getConvertedToOcrStatus() === self::CONVERSION_TO_OCR_FAILED;
  1904. }
  1905. /**
  1906. * Returns true if the Document's ConvertedToOcr status is Current.
  1907. *
  1908. * @return bool
  1909. */
  1910. public function isConvertedToOcrCurrent()
  1911. {
  1912. return $this->getConvertedToOcrStatus() === self::CONVERSION_TO_OCR_CURRENT;
  1913. }
  1914. /**
  1915. * Returns true if the Document's ConvertedToOcr status is Skipped.
  1916. *
  1917. * @return bool
  1918. */
  1919. public function isConvertedToOcrSkipped()
  1920. {
  1921. return $this->getConvertedToOcrStatus() === self::CONVERSION_TO_OCR_SKIPPED;
  1922. }
  1923. /**
  1924. * Returns true if we support OCR on this document type.
  1925. *
  1926. * @return bool
  1927. */
  1928. public function supportsOCR()
  1929. {
  1930. $allowedTypes = self::getSupportedTypesForOCR();
  1931. return in_array($this->getMimeType(), $allowedTypes);
  1932. }
  1933. /**
  1934. * Returns the MIME types we support for OCR.
  1935. *
  1936. * @return array
  1937. */
  1938. public static function getSupportedTypesForOCR()
  1939. {
  1940. return MimeTypes::PDF_MIME_TYPES;
  1941. }
  1942. /**
  1943. * Returns true if the Document can go ahead with OCR
  1944. *
  1945. * @return bool
  1946. */
  1947. public function ocrCanContinue()
  1948. {
  1949. return (!$this->isConvertedToOcrSkipped()
  1950. && !$this->isConvertedToOcrFailed()
  1951. && !$this->isConvertedToOcrCurrent()
  1952. );
  1953. }
  1954. /**
  1955. * Set ocrXodFilename
  1956. *
  1957. * @param string $ocrXodFilename
  1958. *
  1959. * @return Document
  1960. */
  1961. public function setOcrXodFilename($ocrXodFilename)
  1962. {
  1963. $this->ocrXodFilename = $ocrXodFilename;
  1964. return $this;
  1965. }
  1966. /**
  1967. * Get ocrXodFilename
  1968. *
  1969. * @return string|null
  1970. */
  1971. public function getOcrXodFilename()
  1972. {
  1973. return $this->ocrXodFilename;
  1974. }
  1975. /**
  1976. * Set ocrXodFile
  1977. *
  1978. * @param string $ocrXodFile
  1979. *
  1980. * @return Document
  1981. */
  1982. public function setOcrXodFile($ocrXodFile)
  1983. {
  1984. $this->ocrXodFile = $ocrXodFile;
  1985. return $this;
  1986. }
  1987. /**
  1988. * Get ocrXodFile
  1989. *
  1990. * @return string|null
  1991. */
  1992. public function getOcrXodFile()
  1993. {
  1994. return $this->ocrXodFile;
  1995. }
  1996. /**
  1997. * Set convertedToWebAVStatus.
  1998. *
  1999. * @param int|null $convertedToWebAVStatus
  2000. *
  2001. * @return Document
  2002. */
  2003. public function setConvertedToWebAVStatus($convertedToWebAVStatus = null)
  2004. {
  2005. $this->convertedToWebAVStatus = $convertedToWebAVStatus;
  2006. return $this;
  2007. }
  2008. /**
  2009. * Get convertedToWebAVStatus.
  2010. *
  2011. * @return int|null
  2012. */
  2013. public function getConvertedToWebAVStatus()
  2014. {
  2015. return $this->convertedToWebAVStatus;
  2016. }
  2017. /**
  2018. * Set webAVFilename.
  2019. *
  2020. * @param string|null $webAVFilename
  2021. *
  2022. * @return Document
  2023. */
  2024. public function setWebAVFilename($webAVFilename = null)
  2025. {
  2026. $this->webAVFilename = $webAVFilename;
  2027. return $this;
  2028. }
  2029. /**
  2030. * Get webAVFilename.
  2031. *
  2032. * @return string|null
  2033. */
  2034. public function getWebAVFilename()
  2035. {
  2036. return $this->webAVFilename;
  2037. }
  2038. /**
  2039. * Set xodBlobFile
  2040. *
  2041. * @param string $xodBlobFile
  2042. *
  2043. * @return Document
  2044. */
  2045. public function setXodBlobFile($xodBlobFile): self
  2046. {
  2047. $this->xodBlobFile = $xodBlobFile;
  2048. return $this;
  2049. }
  2050. /**
  2051. *
  2052. * @return VirusScanItem|null
  2053. */
  2054. public function getVirusScanItem(): ?VirusScanItem
  2055. {
  2056. return $this->virusScanItem;
  2057. }
  2058. /**
  2059. * @param VirusScanItem|null $virusScanItem
  2060. *
  2061. * @return self
  2062. */
  2063. public function setVirusScanItem(?VirusScanItem $virusScanItem): self
  2064. {
  2065. // unset the owning side of the relation if necessary
  2066. if ($virusScanItem === null && $this->virusScanItem !== null) {
  2067. $this->virusScanItem->setDocument(null);
  2068. }
  2069. // set the owning side of the relation if necessary
  2070. if ($virusScanItem !== null && $virusScanItem->getDocument() !== $this) {
  2071. $virusScanItem->setDocument($this);
  2072. }
  2073. $this->virusScanItem = $virusScanItem;
  2074. return $this;
  2075. }
  2076. /**
  2077. * @param VirusScannerPathVisitorInterface $virusScannerPathVisitor
  2078. *
  2079. * @return VirusScannerVisitorInterface
  2080. */
  2081. public function acceptVirusScannerPathVisitor(VirusScannerPathVisitorInterface $virusScannerPathVisitor): string
  2082. {
  2083. return $virusScannerPathVisitor->visitDocument($this);
  2084. }
  2085. /**
  2086. * Get xodBlobFile
  2087. *
  2088. * @return string
  2089. */
  2090. public function getXodBlobFile()
  2091. {
  2092. return $this->xodBlobFile;
  2093. }
  2094. /**
  2095. * We return the xodFilename, as the file is mapped to the same filename field.
  2096. *
  2097. * @return string
  2098. */
  2099. public function getXodBlobFilename()
  2100. {
  2101. return $this->xodFilename;
  2102. }
  2103. /**
  2104. * Set ocrXodBlobFile
  2105. *
  2106. * @param string $ocrXodBlobFile
  2107. *
  2108. * @return Document
  2109. */
  2110. public function setOcrXodBlobFile($ocrXodBlobFile): self
  2111. {
  2112. $this->ocrXodBlobFile = $ocrXodBlobFile;
  2113. return $this;
  2114. }
  2115. /**
  2116. * Get ocrXodBlobFile
  2117. *
  2118. * @return string
  2119. */
  2120. public function getOcrXodBlobFile()
  2121. {
  2122. return $this->ocrXodBlobFile;
  2123. }
  2124. /**
  2125. * We return the xodFilename, as the file is mapped to the same filename field.
  2126. *
  2127. * @return string
  2128. */
  2129. public function getOcrXodBlobFilename()
  2130. {
  2131. return $this->ocrXodFilename;
  2132. }
  2133. }