src/JuridicusBundle/Entity/PrueferPruefung.php line 13

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. /**
  7. * PrueferPruefung
  8. * @UniqueEntity(fields={"pruefung","pruefer"}, message="Ein Prüfer kann nur einmal an einer Prüfung teilnehmen.")
  9. */
  10. class PrueferPruefung
  11. {
  12. const CLASSNAME = __CLASS__;
  13. /**
  14. *
  15. * @var array
  16. */
  17. private static $fach_map = array(
  18. 'Strafrecht' => array(
  19. 's', 'sr', 'srecht', 'srav' ,'str', 'strr', 'strafr', 'strafrp', 'starfrecht', 'wahlsrecht',
  20. 'strafr', 'srafr', 'srtrafr', 'stafr', 'srafrecht'
  21. ),
  22. 'Zivilrecht' => array(
  23. 'z', 'zrecht', 'zr', 'zrav', 'zruvortrag', 'zrecht', 'zivi', 'zivil', 'zivilr', 'zivr', 'zivillr',
  24. 'zraktenvortrag', 'zivilerecht'
  25. ),
  26. 'Öffentliches Recht' => array(
  27. 'ö', 'ör', 'örav', 'örecht', 'öfrecht', 'öff', 'öffr', 'öffrecht', 'örsteuerr', 'öffentlichesr',
  28. 'öffentrech', 'öffentlr', 'öffentlich', 'öffentliche', 'öffentliches',
  29. 'öfftlrecht', 'öffentlrecht',
  30. 'örpflicht', 'örwahl', 'öffentlichesrecht',
  31. ),
  32. 'Arbeitsrecht' => array(
  33. 'arbeitsrecht', 'arecht', 'arbeitsr',
  34. ),
  35. 'Verwaltungsrecht' => array(
  36. 'verwaltungsrecht', 'vrecht', 'verwaltungsr'
  37. )
  38. );
  39. /**
  40. * Vereinheitlicht den Namen eines Faches (Auto-Korrektur)
  41. *
  42. * @param string $fach
  43. * @return string|null
  44. */
  45. public static function unifyFach($fach)
  46. {
  47. if (empty($fach)) {
  48. return null;
  49. }
  50. $fach2 = mb_strtolower($fach,'UTF-8');
  51. $fach2 = preg_replace('#[^a-zäöüß]#', '', $fach2);
  52. foreach(self::$fach_map as $key => $array) {
  53. if (in_array($fach2, $array)) {
  54. return $key;
  55. }
  56. $key2 = mb_strtolower($key, 'UTF-8');
  57. $key2 = preg_replace('#[^a-zäöüß]#', '', $key2);
  58. if (strpos($fach2, $key2) !== false) {
  59. return $key;
  60. }
  61. $n = similar_text($fach2, $key2, $percent);
  62. if ($percent > 80) {
  63. return $key;
  64. }
  65. }
  66. return $fach;
  67. }
  68. /**
  69. * @var integer
  70. */
  71. private $id;
  72. /**
  73. * @var boolean
  74. * @Assert\NotNull()
  75. */
  76. private $vorsitz = false;
  77. /**
  78. * @var integer
  79. */
  80. private $sortierung;
  81. /**
  82. * @var string
  83. * @Assert\Length(max="18")
  84. */
  85. private $fach;
  86. /**
  87. * @var \JF\JuridicusBundle\Entity\Pruefer
  88. * @Assert\Valid()
  89. * @Assert\NotNull()
  90. */
  91. private $pruefer;
  92. /**
  93. * @var \JF\JuridicusBundle\Entity\Pruefung
  94. * @Assert\Valid()
  95. * @Assert\NotNull()
  96. */
  97. private $pruefung;
  98. /**
  99. * Get id
  100. *
  101. * @return integer
  102. */
  103. public function getId()
  104. {
  105. return $this->id;
  106. }
  107. /**
  108. * Set vorsitz
  109. *
  110. * @param boolean $vorsitz
  111. * @return PrueferPruefung
  112. */
  113. public function setVorsitz($vorsitz = true)
  114. {
  115. $this->vorsitz = (bool) $vorsitz;
  116. return $this;
  117. }
  118. /**
  119. * Get vorsitz
  120. *
  121. * @return boolean
  122. */
  123. public function getVorsitz()
  124. {
  125. return $this->vorsitz;
  126. }
  127. /**
  128. * Set sortierung
  129. *
  130. * @param integer $sortierung
  131. * @return PrueferPruefung
  132. */
  133. public function setSortierung($sortierung)
  134. {
  135. $this->sortierung = $sortierung;
  136. return $this;
  137. }
  138. /**
  139. * Get sortierung
  140. *
  141. * @return integer
  142. */
  143. public function getSortierung()
  144. {
  145. return $this->sortierung;
  146. }
  147. /**
  148. * Set fach - impliziert Auto-Korrektur
  149. *
  150. * @param string $fach
  151. * @return PrueferPruefung
  152. */
  153. public function setFach($fach)
  154. {
  155. $this->fach = self::unifyFach($fach);
  156. return $this;
  157. }
  158. /**
  159. * Get fach
  160. *
  161. * @return string
  162. */
  163. public function getFach()
  164. {
  165. return $this->fach;
  166. }
  167. /**
  168. * Set pruefer [OWNING SIDE]
  169. *
  170. * @param \JF\JuridicusBundle\Entity\Pruefer $pruefer
  171. * @return PrueferPruefung
  172. */
  173. public function setPruefer(Pruefer $pruefer = null)
  174. {
  175. $this->pruefer = $pruefer;
  176. return $this;
  177. }
  178. /**
  179. * Get pruefer
  180. *
  181. * @return \JF\JuridicusBundle\Entity\Pruefer
  182. */
  183. public function getPruefer()
  184. {
  185. return $this->pruefer;
  186. }
  187. /**
  188. * Set pruefung [OWNING SIDE]
  189. *
  190. * @param \JF\JuridicusBundle\Entity\Pruefung $pruefung
  191. * @return PrueferPruefung
  192. */
  193. public function setPruefung(Pruefung $pruefung = null)
  194. {
  195. $this->pruefung = $pruefung;
  196. return $this;
  197. }
  198. /**
  199. * Get pruefung
  200. *
  201. * @return \JF\JuridicusBundle\Entity\Pruefung
  202. */
  203. public function getPruefung()
  204. {
  205. return $this->pruefung;
  206. }
  207. /**
  208. *
  209. * @param \JF\JuridicusBundle\Entity\PrueferPruefung $compare
  210. * @return boolean
  211. */
  212. public function equals(PrueferPruefung $compare)
  213. {
  214. return true
  215. && $this->getVorsitz() == $compare->getVorsitz()
  216. && $this->getSortierung() == $compare->getSortierung()
  217. && $this->getFach() == $compare->getFach()
  218. && $this->getPruefer()->getId() == $compare->getPruefer()->getId()
  219. && $this->getPruefung()->getId() == $compare->getPruefung()->getId()
  220. ;
  221. }
  222. /**
  223. * String Representation
  224. *
  225. * @return string
  226. */
  227. public function __toString()
  228. {
  229. return $this->getPruefer() ? $this->getPruefer()->getFullText() : 'n-a';
  230. }
  231. }