<?php
namespace App\Entity;
use App\Service\OccupationalFieldsAndProfessionsSearchService;
use App\Utility\GenderNeutralizer;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
*
* @ORM\Table(
* name="professions",
* indexes={
*
* @ORM\Index(name="occupational_fields_id_idx", columns={"occupational_fields_id"}),
* @ORM\Index(name="title_idx", columns={"title"}),
* @ORM\Index(name="normalized_title_variant_c_idx", columns={"normalized_title_variant_c"})
* }
* )
*/
class Profession
{
/**
* @var int
*
* @ORM\Column(type="integer")
*
* @ORM\Id
*
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
public function setId(string $id)
{
$this->id = $id;
return $this;
}
public function getId(): string
{
return $this->id;
}
/**
* @var string|null The Bundesagentur für Arbeit id for the group to which this profession belongs. This is not a unique value - professions themselves don't have a BA id, and multiple professions can belong to the same BA id
*
* @ORM\Column(name="ba_id", type="string", length=12, nullable=true)
*/
protected $baId;
public function setBaId(?string $baId)
{
$this->baId = $baId;
return $this;
}
public function getBaId(): ?string
{
return $this->baId;
}
/**
* @var OccupationalField
*
* @ORM\ManyToOne(targetEntity="App\Entity\OccupationalField", inversedBy="professions", cascade={"persist"})
*
* @ORM\JoinColumn(name="occupational_fields_id", referencedColumnName="id", nullable=false, onDelete="CASCADE")
*/
protected $occupationalField;
/**
* @return OccupationalField
*/
public function getOccupationalField()
{
return $this->occupationalField;
}
public function setOccupationalField(OccupationalField $occupationalField)
{
$this->occupationalField = $occupationalField;
}
/**
* @var RecurrentJob|Collection
*
* @ORM\ManyToMany(targetEntity="App\Entity\RecurrentJob", mappedBy="relevantProfessions", cascade={"persist"})
*/
protected $recurrentJobsForWhichImRelevant;
public function getRecurrentJobsForWhichImRelevant(): Collection
{
return $this->recurrentJobsForWhichImRelevant;
}
/**
* @var string
*
* @ORM\Column(name="title", type="string", length=1024, nullable=false)
*/
protected $title;
public function setTitle(string $title)
{
$this->title = $title;
return $this;
}
public function getTitle(): string
{
return $this->title;
}
public function getTitleForDisplay(): string
{
return GenderNeutralizer::neutralize($this->getTitle());
}
public function getTitleForFulltextsearchVariantA(): string
{
return OccupationalFieldsAndProfessionsSearchService::normalizeText($this->getTitle()) . ' ' . mb_ereg_replace(' ', '', OccupationalFieldsAndProfessionsSearchService::normalizeText($this->getTitle()));
}
public function getTitleForFulltextsearchVariantB(): string
{
$text = OccupationalFieldsAndProfessionsSearchService::normalizeText($this->getTitle());
$words = explode(' ', $text);
$soundexes = [];
foreach ($words as $word) {
$soundexes[] = OccupationalFieldsAndProfessionsSearchService::soundexGerman($word);
}
return implode(' ', $soundexes);
}
/**
* Variant C is simply the title normalized as if it was an entered searchterm, used for matching searchterms that are a
* longer/more-specialized version of a job to shorter job titles (e.g. Oberkellner -> Kellner).
* The difference is that this is stored in the DB, not in Elasticsearch, because it is used for DB-based
* LIKE comparisons e.g. in @see OccupationalFieldsAndProfessionsSearchService::getProfessionsWithShorterTitleMatchingSearchterm().
*/
public function getTitleForFulltextsearchVariantC(): string
{
return OccupationalFieldsAndProfessionsSearchService::normalizeSearchterm($this->getTitle());
}
/**
* @var string
*
* @ORM\Column(name="normalized_title_variant_c", type="string", length=1024, nullable=false)
*/
protected $normalizedTitleVariantC;
public function setNormalizedTitleVariantC(string $normalizedTitleVariantC)
{
$this->normalizedTitleVariantC = $normalizedTitleVariantC;
return $this;
}
public function getNormalizedTitleVariantC(): string
{
return $this->normalizedTitleVariantC;
}
}