src/App/Entity/Profession.php line 23

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Service\OccupationalFieldsAndProfessionsSearchService;
  4. use App\Utility\GenderNeutralizer;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8. * @ORM\Entity
  9. *
  10. * @ORM\Table(
  11. * name="professions",
  12. * indexes={
  13. *
  14. * @ORM\Index(name="occupational_fields_id_idx", columns={"occupational_fields_id"}),
  15. * @ORM\Index(name="title_idx", columns={"title"}),
  16. * @ORM\Index(name="normalized_title_variant_c_idx", columns={"normalized_title_variant_c"})
  17. * }
  18. * )
  19. */
  20. class Profession
  21. {
  22. /**
  23. * @var int
  24. *
  25. * @ORM\Column(type="integer")
  26. *
  27. * @ORM\Id
  28. *
  29. * @ORM\GeneratedValue(strategy="AUTO")
  30. */
  31. protected $id;
  32. public function setId(string $id)
  33. {
  34. $this->id = $id;
  35. return $this;
  36. }
  37. public function getId(): string
  38. {
  39. return $this->id;
  40. }
  41. /**
  42. * @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
  43. *
  44. * @ORM\Column(name="ba_id", type="string", length=12, nullable=true)
  45. */
  46. protected $baId;
  47. public function setBaId(?string $baId)
  48. {
  49. $this->baId = $baId;
  50. return $this;
  51. }
  52. public function getBaId(): ?string
  53. {
  54. return $this->baId;
  55. }
  56. /**
  57. * @var OccupationalField
  58. *
  59. * @ORM\ManyToOne(targetEntity="App\Entity\OccupationalField", inversedBy="professions", cascade={"persist"})
  60. *
  61. * @ORM\JoinColumn(name="occupational_fields_id", referencedColumnName="id", nullable=false, onDelete="CASCADE")
  62. */
  63. protected $occupationalField;
  64. /**
  65. * @return OccupationalField
  66. */
  67. public function getOccupationalField()
  68. {
  69. return $this->occupationalField;
  70. }
  71. public function setOccupationalField(OccupationalField $occupationalField)
  72. {
  73. $this->occupationalField = $occupationalField;
  74. }
  75. /**
  76. * @var RecurrentJob|Collection
  77. *
  78. * @ORM\ManyToMany(targetEntity="App\Entity\RecurrentJob", mappedBy="relevantProfessions", cascade={"persist"})
  79. */
  80. protected $recurrentJobsForWhichImRelevant;
  81. public function getRecurrentJobsForWhichImRelevant(): Collection
  82. {
  83. return $this->recurrentJobsForWhichImRelevant;
  84. }
  85. /**
  86. * @var string
  87. *
  88. * @ORM\Column(name="title", type="string", length=1024, nullable=false)
  89. */
  90. protected $title;
  91. public function setTitle(string $title)
  92. {
  93. $this->title = $title;
  94. return $this;
  95. }
  96. public function getTitle(): string
  97. {
  98. return $this->title;
  99. }
  100. public function getTitleForDisplay(): string
  101. {
  102. return GenderNeutralizer::neutralize($this->getTitle());
  103. }
  104. public function getTitleForFulltextsearchVariantA(): string
  105. {
  106. return OccupationalFieldsAndProfessionsSearchService::normalizeText($this->getTitle()) . ' ' . mb_ereg_replace(' ', '', OccupationalFieldsAndProfessionsSearchService::normalizeText($this->getTitle()));
  107. }
  108. public function getTitleForFulltextsearchVariantB(): string
  109. {
  110. $text = OccupationalFieldsAndProfessionsSearchService::normalizeText($this->getTitle());
  111. $words = explode(' ', $text);
  112. $soundexes = [];
  113. foreach ($words as $word) {
  114. $soundexes[] = OccupationalFieldsAndProfessionsSearchService::soundexGerman($word);
  115. }
  116. return implode(' ', $soundexes);
  117. }
  118. /**
  119. * Variant C is simply the title normalized as if it was an entered searchterm, used for matching searchterms that are a
  120. * longer/more-specialized version of a job to shorter job titles (e.g. Oberkellner -> Kellner).
  121. * The difference is that this is stored in the DB, not in Elasticsearch, because it is used for DB-based
  122. * LIKE comparisons e.g. in @see OccupationalFieldsAndProfessionsSearchService::getProfessionsWithShorterTitleMatchingSearchterm().
  123. */
  124. public function getTitleForFulltextsearchVariantC(): string
  125. {
  126. return OccupationalFieldsAndProfessionsSearchService::normalizeSearchterm($this->getTitle());
  127. }
  128. /**
  129. * @var string
  130. *
  131. * @ORM\Column(name="normalized_title_variant_c", type="string", length=1024, nullable=false)
  132. */
  133. protected $normalizedTitleVariantC;
  134. public function setNormalizedTitleVariantC(string $normalizedTitleVariantC)
  135. {
  136. $this->normalizedTitleVariantC = $normalizedTitleVariantC;
  137. return $this;
  138. }
  139. public function getNormalizedTitleVariantC(): string
  140. {
  141. return $this->normalizedTitleVariantC;
  142. }
  143. }