<?php
namespace JF\JuridicusBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* PrueferPruefung
* @UniqueEntity(fields={"pruefung","pruefer"}, message="Ein Prüfer kann nur einmal an einer Prüfung teilnehmen.")
*/
class PrueferPruefung
{
const CLASSNAME = __CLASS__;
/**
*
* @var array
*/
private static $fach_map = array(
'Strafrecht' => array(
's', 'sr', 'srecht', 'srav' ,'str', 'strr', 'strafr', 'strafrp', 'starfrecht', 'wahlsrecht',
'strafr', 'srafr', 'srtrafr', 'stafr', 'srafrecht'
),
'Zivilrecht' => array(
'z', 'zrecht', 'zr', 'zrav', 'zruvortrag', 'zrecht', 'zivi', 'zivil', 'zivilr', 'zivr', 'zivillr',
'zraktenvortrag', 'zivilerecht'
),
'Öffentliches Recht' => array(
'ö', 'ör', 'örav', 'örecht', 'öfrecht', 'öff', 'öffr', 'öffrecht', 'örsteuerr', 'öffentlichesr',
'öffentrech', 'öffentlr', 'öffentlich', 'öffentliche', 'öffentliches',
'öfftlrecht', 'öffentlrecht',
'örpflicht', 'örwahl', 'öffentlichesrecht',
),
'Arbeitsrecht' => array(
'arbeitsrecht', 'arecht', 'arbeitsr',
),
'Verwaltungsrecht' => array(
'verwaltungsrecht', 'vrecht', 'verwaltungsr'
)
);
/**
* Vereinheitlicht den Namen eines Faches (Auto-Korrektur)
*
* @param string $fach
* @return string|null
*/
public static function unifyFach($fach)
{
if (empty($fach)) {
return null;
}
$fach2 = mb_strtolower($fach,'UTF-8');
$fach2 = preg_replace('#[^a-zäöüß]#', '', $fach2);
foreach(self::$fach_map as $key => $array) {
if (in_array($fach2, $array)) {
return $key;
}
$key2 = mb_strtolower($key, 'UTF-8');
$key2 = preg_replace('#[^a-zäöüß]#', '', $key2);
if (strpos($fach2, $key2) !== false) {
return $key;
}
$n = similar_text($fach2, $key2, $percent);
if ($percent > 80) {
return $key;
}
}
return $fach;
}
/**
* @var integer
*/
private $id;
/**
* @var boolean
* @Assert\NotNull()
*/
private $vorsitz = false;
/**
* @var integer
*/
private $sortierung;
/**
* @var string
* @Assert\Length(max="18")
*/
private $fach;
/**
* @var \JF\JuridicusBundle\Entity\Pruefer
* @Assert\Valid()
* @Assert\NotNull()
*/
private $pruefer;
/**
* @var \JF\JuridicusBundle\Entity\Pruefung
* @Assert\Valid()
* @Assert\NotNull()
*/
private $pruefung;
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set vorsitz
*
* @param boolean $vorsitz
* @return PrueferPruefung
*/
public function setVorsitz($vorsitz = true)
{
$this->vorsitz = (bool) $vorsitz;
return $this;
}
/**
* Get vorsitz
*
* @return boolean
*/
public function getVorsitz()
{
return $this->vorsitz;
}
/**
* Set sortierung
*
* @param integer $sortierung
* @return PrueferPruefung
*/
public function setSortierung($sortierung)
{
$this->sortierung = $sortierung;
return $this;
}
/**
* Get sortierung
*
* @return integer
*/
public function getSortierung()
{
return $this->sortierung;
}
/**
* Set fach - impliziert Auto-Korrektur
*
* @param string $fach
* @return PrueferPruefung
*/
public function setFach($fach)
{
$this->fach = self::unifyFach($fach);
return $this;
}
/**
* Get fach
*
* @return string
*/
public function getFach()
{
return $this->fach;
}
/**
* Set pruefer [OWNING SIDE]
*
* @param \JF\JuridicusBundle\Entity\Pruefer $pruefer
* @return PrueferPruefung
*/
public function setPruefer(Pruefer $pruefer = null)
{
$this->pruefer = $pruefer;
return $this;
}
/**
* Get pruefer
*
* @return \JF\JuridicusBundle\Entity\Pruefer
*/
public function getPruefer()
{
return $this->pruefer;
}
/**
* Set pruefung [OWNING SIDE]
*
* @param \JF\JuridicusBundle\Entity\Pruefung $pruefung
* @return PrueferPruefung
*/
public function setPruefung(Pruefung $pruefung = null)
{
$this->pruefung = $pruefung;
return $this;
}
/**
* Get pruefung
*
* @return \JF\JuridicusBundle\Entity\Pruefung
*/
public function getPruefung()
{
return $this->pruefung;
}
/**
*
* @param \JF\JuridicusBundle\Entity\PrueferPruefung $compare
* @return boolean
*/
public function equals(PrueferPruefung $compare)
{
return true
&& $this->getVorsitz() == $compare->getVorsitz()
&& $this->getSortierung() == $compare->getSortierung()
&& $this->getFach() == $compare->getFach()
&& $this->getPruefer()->getId() == $compare->getPruefer()->getId()
&& $this->getPruefung()->getId() == $compare->getPruefung()->getId()
;
}
/**
* String Representation
*
* @return string
*/
public function __toString()
{
return $this->getPruefer() ? $this->getPruefer()->getFullText() : 'n-a';
}
}