src/JuridicusBundle/Entity/Pruefungsamt.php line 14

Open in your IDE?
  1. <?php
  2. namespace JF\JuridicusBundle\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Symfony\Component\Validator\Constraints as Assert;
  5. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use \JF\JuridicusBundle\Entity\Gebuehr;
  8. /**
  9. * Pruefungsamt
  10. */
  11. class Pruefungsamt
  12. {
  13. const CLASSNAME = __CLASS__;
  14. const BESTAND_KEIN = 1;
  15. const BESTAND_KLEIN = 2;
  16. const BESTAND_ANFANG = 3;
  17. const BESTAND_VOLL = 4;
  18. private static $bestand_options = array(
  19. self::BESTAND_KEIN => 'Kein Bestand',
  20. self::BESTAND_KLEIN => 'Kleiner Anfangsbestand',
  21. self::BESTAND_ANFANG => 'Anfangsbestand',
  22. self::BESTAND_VOLL => 'Bestand'
  23. );
  24. public static function getBestandOptions()
  25. {
  26. return self::$bestand_options;
  27. }
  28. public static function getBestandKeys()
  29. {
  30. return array_keys(self::$bestand_options);
  31. }
  32. /**
  33. * @var integer
  34. */
  35. private $id;
  36. /**
  37. * @var string
  38. * @Assert\NotNull
  39. * @Assert\Length(max="64")
  40. */
  41. private $bezeichnung;
  42. /**
  43. * @var integer
  44. * @Assert\NotNull
  45. * @Assert\Choice(choices = {1, 2})
  46. */
  47. private $examen;
  48. /**
  49. * @var integer
  50. * @Assert\NotNull()
  51. * @Assert\Choice(callback="getBestandKeys")
  52. */
  53. private $bestand;
  54. /**
  55. * @var integer maximale Anzahl der Prüfer bei einer Prüfung
  56. * @Assert\NotNull()
  57. * @Assert\Type(type="integer")
  58. * @Assert\Range(min = "1")
  59. */
  60. private $anzahl_pruefer;
  61. /**
  62. * @var integer maximale Anzahl der Kandidaten bei einer Prüfung
  63. * @Assert\NotNull()
  64. * @Assert\Type(type="integer")
  65. * @Assert\Range(min = "1")
  66. */
  67. private $anzahl_kandidaten;
  68. /**
  69. * @var string
  70. * @Assert\Length(max="32")
  71. */
  72. private $termine;
  73. /**
  74. * @var integer
  75. * @Assert\NotNull
  76. */
  77. private $noten_options;
  78. /**
  79. * @var integer
  80. */
  81. private $wahlfach_noten_options;
  82. /**
  83. * @var string
  84. * @Assert\Length(max="255")
  85. */
  86. private $import_url;
  87. /**
  88. * @var integer
  89. * @Assert\Type(type="integer")
  90. * @Assert\Range(min="0")
  91. * @Assert\NotNull
  92. */
  93. private $kennziffer_parts;
  94. /**
  95. * @var boolean
  96. * @Assert\NotNull
  97. */
  98. private $wahlfach;
  99. /**
  100. * @var \Doctrine\Common\Collections\Collection
  101. */
  102. private $bundeslaender;
  103. /**
  104. * @var \Doctrine\Common\Collections\Collection
  105. */
  106. private $pruefer;
  107. /**
  108. * @var \Doctrine\Common\Collections\Collection
  109. */
  110. private $gebuehren;
  111. /**
  112. * @var \Doctrine\Common\Collections\Collection
  113. */
  114. private $pruefungen;
  115. /**
  116. * Constructor
  117. */
  118. public function __construct()
  119. {
  120. $this->bundeslaender = new ArrayCollection();
  121. $this->gebuehren = new ArrayCollection();
  122. $this->pruefer = new ArrayCollection();
  123. $this->pruefungen = new ArrayCollection();
  124. }
  125. /**
  126. * Get id
  127. *
  128. * @return integer
  129. */
  130. public function getId()
  131. {
  132. return $this->id;
  133. }
  134. /**
  135. * Set examen
  136. *
  137. * @param integer $examen
  138. * @return Pruefungsamt
  139. */
  140. public function setExamen($examen)
  141. {
  142. $this->examen = $examen;
  143. return $this;
  144. }
  145. /**
  146. * Get examen
  147. *
  148. * @return integer
  149. */
  150. public function getExamen()
  151. {
  152. return $this->examen;
  153. }
  154. /**
  155. * Add bundeslaender [OWNING SIDE]
  156. *
  157. * @param Bundesland $bundeslaender
  158. * @return Pruefungsamt
  159. */
  160. public function addBundeslaender(Bundesland $bundeslaender)
  161. {
  162. $this->bundeslaender[] = $bundeslaender;
  163. $bundeslaender->addPruefungsaemter($this); // synchronously updating inverse side
  164. return $this;
  165. }
  166. /**
  167. * Remove bundeslaender [OWNING SIDE]
  168. *
  169. * @param Bundesland $bundeslaender
  170. */
  171. public function removeBundeslaender(Bundesland $bundeslaender)
  172. {
  173. $this->bundeslaender->removeElement($bundeslaender);
  174. $bundeslaender->removePruefungsaemter($this); // synchronously updating inverse side
  175. }
  176. /**
  177. * Get bundeslaender
  178. *
  179. * @return \Doctrine\Common\Collections\Collection
  180. */
  181. public function getBundeslaender()
  182. {
  183. return $this->bundeslaender;
  184. }
  185. /**
  186. * Set anzahl_pruefer
  187. *
  188. * @param integer $anzahlPruefer
  189. * @return Pruefungsamt
  190. */
  191. public function setAnzahlPruefer($anzahlPruefer)
  192. {
  193. $this->anzahl_pruefer = $anzahlPruefer;
  194. return $this;
  195. }
  196. /**
  197. * Get anzahl_pruefer
  198. *
  199. * @return integer
  200. */
  201. public function getAnzahlPruefer()
  202. {
  203. return $this->anzahl_pruefer;
  204. }
  205. /**
  206. * Set bestand
  207. *
  208. * @param integer $bestand
  209. * @return Pruefungsamt
  210. */
  211. public function setBestand($bestand)
  212. {
  213. $this->bestand = $bestand;
  214. return $this;
  215. }
  216. /**
  217. * Get bestand
  218. *
  219. * @return integer
  220. */
  221. public function getBestand()
  222. {
  223. return $this->bestand;
  224. }
  225. /**
  226. *
  227. * @return string
  228. */
  229. public function getBestandString()
  230. {
  231. if ($this->bestand) {
  232. return self::$bestand_options[$this->bestand];
  233. } else {
  234. return 'nicht verfügbar';
  235. }
  236. }
  237. /**
  238. * hat/hatte das Prüfungsamt zum gegebenen Zeitpunkt Vollbastand und eine Grundgebühr?
  239. *
  240. * @param \DateTime $datum
  241. * @return boolean
  242. */
  243. public function hasVollbestand(\DateTime $datum = null)
  244. {
  245. $grundGebuehr = $this->getCurrentGebuehrByTyp(Gebuehr::TYP_GRUNDGEBUEHR, $datum);
  246. return $grundGebuehr && $this->bestand == self::BESTAND_VOLL;
  247. }
  248. /**
  249. * Set anzahl_kandidaten
  250. *
  251. * @param integer $anzahlKandidaten
  252. * @return Pruefungsamt
  253. */
  254. public function setAnzahlKandidaten($anzahlKandidaten)
  255. {
  256. $this->anzahl_kandidaten = $anzahlKandidaten;
  257. return $this;
  258. }
  259. /**
  260. * Get anzahl_kandidaten
  261. *
  262. * @return integer
  263. */
  264. public function getAnzahlKandidaten()
  265. {
  266. return $this->anzahl_kandidaten;
  267. }
  268. /**
  269. * Set termine
  270. *
  271. * @param string $termine
  272. * @return Pruefungsamt
  273. */
  274. public function setTermine($termine)
  275. {
  276. $this->termine = $termine;
  277. return $this;
  278. }
  279. /**
  280. * Get termine
  281. *
  282. * @return string
  283. */
  284. public function getTermine()
  285. {
  286. return $this->termine;
  287. }
  288. /**
  289. * Add pruefer [INVERSE SIDE]
  290. *
  291. * @param Pruefer $pruefer
  292. * @return Pruefungsamt
  293. */
  294. public function addPruefer(Pruefer $pruefer)
  295. {
  296. $this->pruefer[] = $pruefer;
  297. return $this;
  298. }
  299. /**
  300. * Remove pruefer [INVERSE SIDE]
  301. *
  302. * @param Pruefer $pruefer
  303. */
  304. public function removePruefer(Pruefer $pruefer)
  305. {
  306. $this->pruefer->removeElement($pruefer);
  307. }
  308. /**
  309. * Get pruefer
  310. *
  311. * @return \Doctrine\Common\Collections\Collection
  312. */
  313. public function getPruefer()
  314. {
  315. return $this->pruefer;
  316. }
  317. /**
  318. * Add pruefungen [INVERSE SIDE]
  319. *
  320. * @param Pruefung $pruefungen
  321. * @return Pruefungsamt
  322. */
  323. public function addPruefungen(Pruefung $pruefungen)
  324. {
  325. $this->pruefungen[] = $pruefungen;
  326. $pruefungen->setPruefungsamt($this);
  327. return $this;
  328. }
  329. /**
  330. * Remove pruefungen [INVERSE SIDE]
  331. *
  332. * @param Pruefung $pruefungen
  333. */
  334. public function removePruefungen(Pruefung $pruefungen)
  335. {
  336. $this->pruefungen->removeElement($pruefungen);
  337. $pruefungen->setPruefungsamt(null);
  338. }
  339. /**
  340. * Add gebuehren [OWNING SIDE]
  341. *
  342. * @param Gebuehr $gebuehren
  343. * @return Pruefungsamt
  344. */
  345. public function addGebuehren(Gebuehr $gebuehren)
  346. {
  347. $this->gebuehren[] = $gebuehren;
  348. $gebuehren->addPruefungsaemter($this); // keep inverse side synced
  349. return $this;
  350. }
  351. /**
  352. * Remove gebuehren [OWNING SIDE]
  353. *
  354. * @param Gebuehr $gebuehren
  355. */
  356. public function removeGebuehren(Gebuehr $gebuehren)
  357. {
  358. $this->gebuehren->removeElement($gebuehren);
  359. $gebuehren->removePruefungsaemter($this); // keep inverse side synced
  360. }
  361. /**
  362. * Get gebuehren
  363. *
  364. * @return \Doctrine\Common\Collections\Collection
  365. */
  366. public function getGebuehren()
  367. {
  368. return $this->gebuehren;
  369. }
  370. /**
  371. *
  372. * @param integer $typ
  373. * @param \DateTime $datum
  374. * @return \JF\JuridicusBundle\Entity\Gebuehr
  375. */
  376. public function getCurrentGebuehrByTyp($typ, \DateTime $datum = null)
  377. {
  378. if (!$datum) {
  379. $datum = new \DateTime("today 00:00:00");
  380. }
  381. $current_gebuehr = null;
  382. foreach ($this->getGebuehren() as $gebuehr) {
  383. if ($gebuehr->getTyp() !== $typ || $gebuehr->getDatum() >= $datum) {
  384. continue;
  385. }
  386. if (!$current_gebuehr || $gebuehr->getDatum() > $current_gebuehr->getDatum()) {
  387. $current_gebuehr = $gebuehr;
  388. }
  389. }
  390. return $current_gebuehr;
  391. }
  392. /**
  393. *
  394. * @param integer $typ
  395. * @param \DateTime $datum
  396. * @return Gebuehr
  397. */
  398. public function getComingGebuehrByTyp($typ, \DateTime $datum = null)
  399. {
  400. if (!$datum) {
  401. $datum = new \DateTime("today 00:00:00");
  402. }
  403. $coming_gebuehr = null;
  404. foreach ($this->getGebuehren() as $gebuehr) {
  405. if ($gebuehr->getTyp() !== $typ or $gebuehr->getDatum() < $datum) {
  406. continue;
  407. }
  408. if (!$coming_gebuehr || $gebuehr->getDatum() < $comming_gebuehr->getDatum()) {
  409. $coming_gebuehr = $gebuehr;
  410. }
  411. }
  412. return $coming_gebuehr;
  413. }
  414. /**
  415. * Get pruefungen
  416. *
  417. * @return \Doctrine\Common\Collections\Collection
  418. */
  419. public function getPruefungen()
  420. {
  421. return $this->pruefungen;
  422. }
  423. /**
  424. * Set kennziffer_format
  425. *
  426. * @param string $kennzifferFormat
  427. * @return Pruefungsamt
  428. */
  429. public function setKennzifferFormat($kennzifferFormat)
  430. {
  431. $this->kennziffer_format = $kennzifferFormat;
  432. return $this;
  433. }
  434. /**
  435. * Get kennziffer_format
  436. *
  437. * @return string
  438. */
  439. public function getKennzifferFormat()
  440. {
  441. return $this->kennziffer_format;
  442. }
  443. /**
  444. * Set noten_options
  445. *
  446. * @param integer $notenOptions
  447. * @return Pruefungsamt
  448. */
  449. public function setNotenOptions($notenOptions)
  450. {
  451. $this->noten_options = $notenOptions;
  452. return $this;
  453. }
  454. /**
  455. * Get noten_options
  456. *
  457. * @return integer
  458. */
  459. public function getNotenOptions()
  460. {
  461. return $this->noten_options;
  462. }
  463. /**
  464. *
  465. * @param integer $option
  466. * @return boolean
  467. */
  468. public function hasNotenOption($option)
  469. {
  470. return (bool) ($this->noten_options & $option);
  471. }
  472. /**
  473. * Set wahlfach_noten_options
  474. *
  475. * @param integer $wahlfachNotenOptions
  476. * @return Pruefungsamt
  477. */
  478. public function setWahlfachNotenOptions($wahlfachNotenOptions)
  479. {
  480. $this->wahlfach_noten_options = $wahlfachNotenOptions;
  481. return $this;
  482. }
  483. /**
  484. * Get wahlfach_noten_options
  485. *
  486. * @return integer
  487. */
  488. public function getWahlfachNotenOptions()
  489. {
  490. return $this->wahlfach_noten_options;
  491. }
  492. /**
  493. * Set wahlfach
  494. *
  495. * @param boolean $wahlfach
  496. * @return Pruefungsamt
  497. */
  498. public function setWahlfach($wahlfach)
  499. {
  500. $this->wahlfach = $wahlfach;
  501. return $this;
  502. }
  503. /**
  504. * Get wahlfach
  505. *
  506. * @return boolean
  507. */
  508. public function getWahlfach()
  509. {
  510. return $this->wahlfach;
  511. }
  512. /**
  513. * Set import_url
  514. *
  515. * @param string $importUrl
  516. * @return Pruefungsamt
  517. */
  518. public function setImportUrl($importUrl)
  519. {
  520. $this->import_url = $importUrl;
  521. return $this;
  522. }
  523. /**
  524. * Get import_url
  525. *
  526. * @return string
  527. */
  528. public function getImportUrl()
  529. {
  530. return $this->import_url;
  531. }
  532. /**
  533. * Set bezeichnung
  534. *
  535. * @param string $bezeichnung
  536. * @return Pruefungsamt
  537. */
  538. public function setBezeichnung($bezeichnung)
  539. {
  540. $this->bezeichnung = $bezeichnung;
  541. return $this;
  542. }
  543. /**
  544. * Get bezeichnung
  545. *
  546. * @return string
  547. */
  548. public function getBezeichnung()
  549. {
  550. return $this->bezeichnung;
  551. }
  552. /**
  553. * Set kennziffer_parts
  554. *
  555. * @param integer $kennzifferParts
  556. * @return Pruefungsamt
  557. */
  558. public function setKennzifferParts($kennzifferParts)
  559. {
  560. $this->kennziffer_parts = $kennzifferParts;
  561. return $this;
  562. }
  563. /**
  564. * Get kennziffer_parts
  565. *
  566. * @return integer
  567. */
  568. public function getKennzifferParts()
  569. {
  570. return $this->kennziffer_parts;
  571. }
  572. /**
  573. * String Representation
  574. *
  575. * @return string
  576. */
  577. public function __toString()
  578. {
  579. $kuerzel = $this->bundeslaender->map(function($bundesland) {
  580. return $bundesland->getKuerzel();
  581. });
  582. return sprintf('Prüfungsamt %s (%d. Examen) ', join('/', $kuerzel->toArray()), $this->examen);
  583. }
  584. /**
  585. * Prüfungsämter sind connected, wenn sie in einem Bundesland übereinstimmen
  586. *
  587. * @param \JF\JuridicusBundle\Entity\Pruefungsamt $p
  588. * @return bool
  589. */
  590. public function isConnected(Pruefungsamt $p)
  591. {
  592. foreach ($this->getBundeslaender() as $b) {
  593. if ($p->getBundeslaender()->contains($b)) {
  594. return true;
  595. }
  596. }
  597. return false;
  598. }
  599. }