src/App/Entity/OccupationalField.php line 30

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Profile\JobseekerProfile;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Exception;
  8. use Symfony\Component\Validator\Constraints as Assert;
  9. /**
  10. * @ORM\Entity
  11. *
  12. * @ORM\Table(
  13. * name="occupational_fields",
  14. * uniqueConstraints={
  15. *
  16. * @ORM\UniqueConstraint(name="title_unique_idx", columns={"title"}),
  17. * @ORM\UniqueConstraint(name="ba_id_idx", columns={"ba_id"})
  18. * },
  19. * indexes={
  20. *
  21. * @ORM\Index(name="area_priority_idx", columns={"area", "priority"})
  22. * }
  23. * )
  24. *
  25. * @ORM\Entity(repositoryClass="App\Repository\OccupationalFieldRepository")
  26. */
  27. class OccupationalField
  28. {
  29. public const AREA_UNDEFINED = 0;
  30. public const AREA_SERVICE = 1;
  31. public const AREA_KITCHEN = 2;
  32. public const AREA_OTHER = 3;
  33. public const AREAS = [self::AREA_UNDEFINED, self::AREA_SERVICE, self::AREA_KITCHEN, self::AREA_OTHER];
  34. public const OCCUPATIONAL_FIELD_ID_SERVICEKELLNER = 1;
  35. public const OCCUPATIONAL_FIELD_ID_THEKENKRAFT = 2;
  36. public const OCCUPATIONAL_FIELD_ID_ABRAEUMHELFER = 3;
  37. public const OCCUPATIONAL_FIELD_ID_RESTAURANTLEITER = 4;
  38. public const OCCUPATIONAL_FIELD_ID_SOMMELIER = 5;
  39. public const OCCUPATIONAL_FIELD_ID_KOCH = 6;
  40. public const OCCUPATIONAL_FIELD_ID_BEIKOCH = 7;
  41. public const OCCUPATIONAL_FIELD_ID_PATISSIER = 8;
  42. public const OCCUPATIONAL_FIELD_ID_KUECHENHILFE = 9;
  43. public const OCCUPATIONAL_FIELD_ID_SPUELKRAFT = 10;
  44. public const OCCUPATIONAL_FIELD_ID_GARDEROBENPERSONAL = 11;
  45. public const OCCUPATIONAL_FIELD_ID_VERKAUFSKRAFT = 12;
  46. public const OCCUPATIONAL_FIELD_ID_KASSENKRAFT = 13;
  47. public const OCCUPATIONAL_FIELD_ID_LIEFERFAHRER = 14;
  48. public const OCCUPATIONAL_FIELD_ID_BARKEEPER = 17;
  49. public const OCCUPATIONAL_FIELD_ID_HOUSEKEEPING = 18;
  50. public const OCCUPATIONAL_FIELD_ID_BARISTA = 19;
  51. public const OCCUPATIONAL_FIELD_ID_PIZZABAECKER = 20;
  52. public const OCCUPATIONAL_FIELD_ID_EMPFANGREZEPTION = 21;
  53. public const OCCUPATIONAL_FIELD_ID_JUNGKOCH = 22;
  54. public const OCCUPATIONAL_FIELD_ID_NEBENJOB = 23;
  55. public const OCCUPATIONAL_FIELD_ID_REINIGUNGSKRAFT = 24;
  56. public const POSSIBLE_CAREER_LEVELS = [
  57. WantedJob::CAREER_LEVEL_TRAINEE,
  58. WantedJob::CAREER_LEVEL_ASSISTANT,
  59. WantedJob::CAREER_LEVEL_EXPERT,
  60. WantedJob::CAREER_LEVEL_EXECUTIVE
  61. ];
  62. public const POSSIBLE_EMPLOYMENT_TYPES = [
  63. WantedJob::EMPLOYMENT_TYPE_ONCE,
  64. WantedJob::EMPLOYMENT_TYPE_HELP,
  65. WantedJob::EMPLOYMENT_TYPE_PART_TIME,
  66. WantedJob::EMPLOYMENT_TYPE_FULL_TIME,
  67. WantedJob::EMPLOYMENT_TYPE_UNDEFINED
  68. ];
  69. /**
  70. * @var int
  71. *
  72. * @ORM\Column(type="integer")
  73. *
  74. * @ORM\Id
  75. *
  76. * @ORM\GeneratedValue(strategy="AUTO")
  77. */
  78. protected $id;
  79. public function setId(int $id)
  80. {
  81. $this->id = $id;
  82. return $this;
  83. }
  84. public function getId()
  85. {
  86. return $this->id;
  87. }
  88. /**
  89. * @var string|null The id used by Bundesagentur für Arbeit for this occupational field; note the difference to Profession::$baId - here, this id is unique: the occupationalField does not *belong to* a BA id, it *has* the BA id
  90. *
  91. * @ORM\Column(name="ba_id", type="string", length=12, nullable=true)
  92. */
  93. protected $baId;
  94. public function setBaId(?string $baId)
  95. {
  96. $this->baId = $baId;
  97. return $this;
  98. }
  99. public function getBaId(): ?string
  100. {
  101. return $this->baId;
  102. }
  103. /**
  104. * @var JobseekerProfile|Collection
  105. *
  106. * @ORM\ManyToMany(targetEntity="App\Entity\Profile\JobseekerProfile", cascade={"persist"}, mappedBy="occupationalFields")
  107. */
  108. protected $jobseekerProfiles;
  109. public function setJobseekerProfiles(Collection $jobseekerProfiles)
  110. {
  111. $this->jobseekerProfiles = $jobseekerProfiles;
  112. }
  113. public function getJobseekerProfiles(): Collection
  114. {
  115. return $this->jobseekerProfiles;
  116. }
  117. /**
  118. * @var RecurrentJob|Collection
  119. *
  120. * @ORM\ManyToMany(targetEntity="App\Entity\RecurrentJob", mappedBy="occupationalFields", cascade={"persist"})
  121. */
  122. protected $recurrentJobs;
  123. public function setRecurrentJobs(Collection $recurrentJobs)
  124. {
  125. $this->recurrentJobs = $recurrentJobs;
  126. }
  127. public function getRecurrentJobs(): Collection
  128. {
  129. return $this->recurrentJobs;
  130. }
  131. /**
  132. * @var RecurrentJob|Collection
  133. *
  134. * @ORM\ManyToMany(targetEntity="App\Entity\RecurrentJob", mappedBy="relevantOccupationalFields", cascade={"persist"})
  135. */
  136. protected $recurrentJobsForWhichImRelevant;
  137. public function getRecurrentJobsForWhichImRelevant(): Collection
  138. {
  139. return $this->recurrentJobsForWhichImRelevant;
  140. }
  141. /**
  142. * @var Profession|Collection
  143. *
  144. * @ORM\OneToMany(targetEntity="\App\Entity\Profession", mappedBy="occupationalField", cascade={"persist", "remove"})
  145. */
  146. protected $professions;
  147. public function addProfession(Profession $professions): void
  148. {
  149. $this->professions[] = $professions;
  150. }
  151. public function getProfessions()
  152. {
  153. return $this->professions;
  154. }
  155. /**
  156. * @var WantedJob|Collection
  157. *
  158. * @ORM\ManyToMany(targetEntity="App\Entity\WantedJob", mappedBy="occupationalFields", cascade={"persist"})
  159. */
  160. protected $wantedJobs;
  161. public function setWantedJobs(Collection $wantedJobs)
  162. {
  163. $this->wantedJobs = $wantedJobs;
  164. }
  165. public function getWantedJobs(): Collection
  166. {
  167. return $this->wantedJobs;
  168. }
  169. /**
  170. * @var string
  171. *
  172. * @ORM\Column(name="title", type="string", length=128, nullable=false)
  173. *
  174. * @Assert\NotBlank()
  175. *
  176. * @Assert\Length(
  177. * min = 2,
  178. * max = 255,
  179. * )
  180. */
  181. protected $title;
  182. public function setTitle(string $title)
  183. {
  184. $this->title = $title;
  185. return $this;
  186. }
  187. public function getTitle()
  188. {
  189. return $this->title;
  190. }
  191. /**
  192. * @var int
  193. *
  194. * @ORM\Column(name="area", type="smallint", nullable=false)
  195. */
  196. protected $area;
  197. public function setArea(int $area)
  198. {
  199. if (!in_array($area, self::AREAS)) {
  200. throw new Exception('Unknown area ' . $area);
  201. }
  202. $this->area = $area;
  203. }
  204. public function getArea()
  205. {
  206. return $this->area;
  207. }
  208. /**
  209. * @var array
  210. *
  211. * @ORM\Column(name="possible_career_levels", type="array", nullable=true)
  212. */
  213. protected $possibleCareerLevels;
  214. public function setPossibleCareerLevels(array $possibleCareerLevels)
  215. {
  216. foreach ($possibleCareerLevels as $possibleCareerLevel) {
  217. if (!in_array($possibleCareerLevel, self::POSSIBLE_CAREER_LEVELS)) {
  218. throw new Exception('Unknown career level ' . $possibleCareerLevel);
  219. }
  220. }
  221. $this->possibleCareerLevels = $possibleCareerLevels;
  222. }
  223. /**
  224. * @var array
  225. *
  226. * @ORM\Column(name="possible_employment_types", type="array", nullable=true)
  227. */
  228. protected $possibleEmploymentTypes;
  229. public function setPossibleEmploymentTypes(array $possibleEmploymentTypes)
  230. {
  231. foreach ($possibleEmploymentTypes as $possibleEmploymentType) {
  232. if (!in_array($possibleEmploymentType, self::POSSIBLE_EMPLOYMENT_TYPES)) {
  233. throw new Exception('Unknown employment type ' . $possibleEmploymentType);
  234. }
  235. }
  236. $this->possibleEmploymentTypes = $possibleEmploymentTypes;
  237. }
  238. public function getPossibleEmploymentTypes(): ?array
  239. {
  240. return $this->possibleEmploymentTypes;
  241. }
  242. /**
  243. * @var int
  244. *
  245. * @ORM\Column(name="priority", type="smallint", nullable=false)
  246. */
  247. protected $priority;
  248. public function setPriority(int $priority)
  249. {
  250. if ($priority < 0) {
  251. throw new Exception('Priority ' . $priority . ' is lower than 0');
  252. }
  253. $this->priority = $priority;
  254. }
  255. public function getPriority()
  256. {
  257. return $this->priority;
  258. }
  259. /**
  260. * @var string
  261. *
  262. * @ORM\Column(type="string", nullable=true)
  263. */
  264. public $slug;
  265. public function getSlug(): ?string
  266. {
  267. return $this->slug;
  268. }
  269. public function setSlug(?string $slug)
  270. {
  271. $this->slug = $slug;
  272. }
  273. public function __construct()
  274. {
  275. $this->jobseekerProfiles = new ArrayCollection();
  276. $this->area = self::AREA_UNDEFINED;
  277. }
  278. public function __toString()
  279. {
  280. return (string)$this->title;
  281. }
  282. }