ViewAudit.php 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  1. <?php
  2. namespace AppBundle\Entity\Core;
  3. use AppBundle\Entity\AccessAndFunction\Access;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Symfony\Component\Validator\Constraints as Assert;
  6. use AppBundle\Annotation\ORM as OpentalentORM;
  7. use Symfony\Component\Serializer\Annotation\Groups;
  8. /**
  9. * @OpentalentORM\View(query="
  10. CREATE OR REPLACE VIEW opentalent.view_audit AS
  11. (SELECT
  12. init_var_session() as identifier,
  13. null as rev,
  14. a.id,
  15. null as createDate,
  16. null as updateDate,
  17. null as createdBy_id,
  18. null as updatedBy_id,
  19. null as revType,
  20. null as organizationId,
  21. 'INIT' as tableName
  22. FROM
  23. Audit_Organization a
  24. LIMIT 1)
  25. UNION
  26. (SELECT
  27. func_inc_var_session() as identifier,
  28. person.rev,
  29. person.id,
  30. person.createDate,
  31. person.updateDate,
  32. person.createdBy as createdBy_id,
  33. person.updatedBy as updatedBy_id,
  34. person.revType,
  35. IF(Access.organization_id IS NOT NULL,
  36. Access.organization_id,
  37. accessPerson2.organization_id) as organizationId,
  38. 'person' as tableName
  39. FROM
  40. opentalent.Audit_Person AS person
  41. LEFT JOIN
  42. Access ON Access.id = person.createdBy
  43. LEFT JOIN
  44. Access as accessPerson2 ON accessPerson2.id = person.updatedBy
  45. WHERE
  46. (Access.organization_id IS NOT NULL
  47. OR accessPerson2.organization_id IS NOT NULL))
  48. UNION
  49. (SELECT
  50. func_inc_var_session() as identifier,
  51. donor.rev,
  52. donor.id,
  53. donor.createDate,
  54. donor.updateDate,
  55. donor.createdBy as createdBy_id,
  56. donor.updatedBy as updatedBy_id,
  57. donor.revType,
  58. Access.organization_id,
  59. 'donor' as tableName
  60. FROM
  61. opentalent.Audit_Donor as donor
  62. INNER JOIN
  63. Access ON donor.access_id = Access.id)
  64. ORDER BY updateDate DESC , createDate DESC")
  65. */
  66. #[ORM\Entity(readOnly: true)]
  67. #[ORM\Table(name: 'view_audit')]
  68. class ViewAudit
  69. {
  70. /**
  71. * @var int
  72. */
  73. #[ORM\Column(type: 'integer')]
  74. #[ORM\Id]
  75. #[ORM\GeneratedValue(strategy: 'AUTO')]
  76. #[Groups(['viewaudit', 'viewaudit_list'])]
  77. private $identifier;
  78. /**
  79. * @var int
  80. */
  81. #[ORM\Column(type: 'integer')]
  82. #[Groups(['viewaudit', 'viewaudit_list'])]
  83. private $id;
  84. /**
  85. * @var int
  86. */
  87. #[ORM\Column(type: 'integer')]
  88. #[Groups(['viewaudit', 'viewaudit_list'])]
  89. private $rev;
  90. /**
  91. * @var \DateTime
  92. */
  93. #[ORM\Column(type: 'datetime')]
  94. #[Assert\Date]
  95. #[Groups(['viewaudit', 'viewaudit_list'])]
  96. private $createDate;
  97. /**
  98. * @var \DateTime
  99. */
  100. #[ORM\Column(type: 'datetime')]
  101. #[Assert\Date]
  102. #[Groups(['viewaudit', 'viewaudit_list'])]
  103. private $updateDate;
  104. /**
  105. * @var Access
  106. */
  107. #[ORM\ManyToOne(targetEntity: 'AppBundle\Entity\AccessAndFunction\Access')]
  108. #[ORM\JoinColumn(nullable: true)]
  109. #[Groups(['viewaudit', 'viewaudit_list'])]
  110. private $createdBy;
  111. /**
  112. * @var Access
  113. */
  114. #[ORM\ManyToOne(targetEntity: 'AppBundle\Entity\AccessAndFunction\Access')]
  115. #[ORM\JoinColumn(nullable: true)]
  116. #[Groups(['viewaudit', 'viewaudit_list'])]
  117. private $updatedBy;
  118. /**
  119. *
  120. * @var string
  121. */
  122. #[ORM\Column(type: 'string', length: 40)]
  123. #[Assert\Type(type: 'string')]
  124. #[Groups(['viewaudit', 'viewaudit_list'])]
  125. private $revType;
  126. /**
  127. * @var int
  128. */
  129. #[ORM\Column(type: 'integer')]
  130. #[ORM\GeneratedValue(strategy: 'AUTO')]
  131. #[Groups(['viewaudit', 'viewaudit_list'])]
  132. private $organizationId;
  133. /**
  134. *
  135. * @var string
  136. */
  137. #[ORM\Column(type: 'string', length: 40)]
  138. #[Assert\Type(type: 'string')]
  139. #[Groups(['viewaudit', 'viewaudit_list'])]
  140. private $tableName;
  141. /**
  142. * @return int
  143. */
  144. public function getId()
  145. {
  146. return $this->id;
  147. }
  148. /**
  149. * @param int $id
  150. */
  151. public function setId($id)
  152. {
  153. $this->id = $id;
  154. }
  155. /**
  156. * Set rev
  157. *
  158. * @param integer $rev
  159. *
  160. * @return ViewAudit
  161. */
  162. public function setRev($rev)
  163. {
  164. $this->rev = $rev;
  165. return $this;
  166. }
  167. /**
  168. * Get rev
  169. *
  170. * @return integer
  171. */
  172. public function getRev()
  173. {
  174. return $this->rev;
  175. }
  176. /**
  177. * Set createDate
  178. *
  179. * @param \DateTime $createDate
  180. *
  181. * @return ViewAudit
  182. */
  183. public function setCreateDate($createDate)
  184. {
  185. $this->createDate = $createDate;
  186. return $this;
  187. }
  188. /**
  189. * Get createDate
  190. *
  191. * @return \DateTime
  192. */
  193. public function getCreateDate()
  194. {
  195. return $this->createDate;
  196. }
  197. /**
  198. * Set updateDate
  199. *
  200. * @param \DateTime $updateDate
  201. *
  202. * @return ViewAudit
  203. */
  204. public function setUpdateDate($updateDate)
  205. {
  206. $this->updateDate = $updateDate;
  207. return $this;
  208. }
  209. /**
  210. * Get updateDate
  211. *
  212. * @return \DateTime
  213. */
  214. public function getUpdateDate()
  215. {
  216. return $this->updateDate;
  217. }
  218. /**
  219. * Set revType
  220. *
  221. * @param string $revType
  222. *
  223. * @return ViewAudit
  224. */
  225. public function setRevType($revType)
  226. {
  227. $this->revType = $revType;
  228. return $this;
  229. }
  230. /**
  231. * Get revType
  232. *
  233. * @return string
  234. */
  235. public function getRevType()
  236. {
  237. return $this->revType;
  238. }
  239. /**
  240. * Set organizationId
  241. *
  242. * @param integer $organizationId
  243. *
  244. * @return ViewAudit
  245. */
  246. public function setOrganizationId($organizationId)
  247. {
  248. $this->organizationId = $organizationId;
  249. return $this;
  250. }
  251. /**
  252. * Get organizationId
  253. *
  254. * @return integer
  255. */
  256. public function getOrganizationId()
  257. {
  258. return $this->organizationId;
  259. }
  260. /**
  261. * Set tableName
  262. *
  263. * @param string $tableName
  264. *
  265. * @return ViewAudit
  266. */
  267. public function setTableName($tableName)
  268. {
  269. $this->tableName = $tableName;
  270. return $this;
  271. }
  272. /**
  273. * Get tableName
  274. *
  275. * @return string
  276. */
  277. public function getTableName()
  278. {
  279. return $this->tableName;
  280. }
  281. /**
  282. * Set createdBy
  283. *
  284. * @param \AppBundle\Entity\AccessAndFunction\Access $createdBy
  285. *
  286. * @return ViewAudit
  287. */
  288. public function setCreatedBy(\AppBundle\Entity\AccessAndFunction\Access $createdBy = null)
  289. {
  290. $this->createdBy = $createdBy;
  291. return $this;
  292. }
  293. /**
  294. * Get createdBy
  295. *
  296. * @return \AppBundle\Entity\AccessAndFunction\Access
  297. */
  298. public function getCreatedBy()
  299. {
  300. return $this->createdBy;
  301. }
  302. /**
  303. * Set updatedBy
  304. *
  305. * @param \AppBundle\Entity\AccessAndFunction\Access $updatedBy
  306. *
  307. * @return ViewAudit
  308. */
  309. public function setUpdatedBy(\AppBundle\Entity\AccessAndFunction\Access $updatedBy = null)
  310. {
  311. $this->updatedBy = $updatedBy;
  312. return $this;
  313. }
  314. /**
  315. * Get updatedBy
  316. *
  317. * @return \AppBundle\Entity\AccessAndFunction\Access
  318. */
  319. public function getUpdatedBy()
  320. {
  321. return $this->updatedBy;
  322. }
  323. /**
  324. * Get identifier
  325. *
  326. * @return integer
  327. */
  328. public function getIdentifier()
  329. {
  330. return $this->identifier;
  331. }
  332. }