<?php
namespace App\Entity;
use App\Entity\Profile\JobseekerProfile;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Exception;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity
*
* @ORM\Table(
* name="occupational_fields",
* uniqueConstraints={
*
* @ORM\UniqueConstraint(name="title_unique_idx", columns={"title"}),
* @ORM\UniqueConstraint(name="ba_id_idx", columns={"ba_id"})
* },
* indexes={
*
* @ORM\Index(name="area_priority_idx", columns={"area", "priority"})
* }
* )
*
* @ORM\Entity(repositoryClass="App\Repository\OccupationalFieldRepository")
*/
class OccupationalField
{
public const AREA_UNDEFINED = 0;
public const AREA_SERVICE = 1;
public const AREA_KITCHEN = 2;
public const AREA_OTHER = 3;
public const AREAS = [self::AREA_UNDEFINED, self::AREA_SERVICE, self::AREA_KITCHEN, self::AREA_OTHER];
public const OCCUPATIONAL_FIELD_ID_SERVICEKELLNER = 1;
public const OCCUPATIONAL_FIELD_ID_THEKENKRAFT = 2;
public const OCCUPATIONAL_FIELD_ID_ABRAEUMHELFER = 3;
public const OCCUPATIONAL_FIELD_ID_RESTAURANTLEITER = 4;
public const OCCUPATIONAL_FIELD_ID_SOMMELIER = 5;
public const OCCUPATIONAL_FIELD_ID_KOCH = 6;
public const OCCUPATIONAL_FIELD_ID_BEIKOCH = 7;
public const OCCUPATIONAL_FIELD_ID_PATISSIER = 8;
public const OCCUPATIONAL_FIELD_ID_KUECHENHILFE = 9;
public const OCCUPATIONAL_FIELD_ID_SPUELKRAFT = 10;
public const OCCUPATIONAL_FIELD_ID_GARDEROBENPERSONAL = 11;
public const OCCUPATIONAL_FIELD_ID_VERKAUFSKRAFT = 12;
public const OCCUPATIONAL_FIELD_ID_KASSENKRAFT = 13;
public const OCCUPATIONAL_FIELD_ID_LIEFERFAHRER = 14;
public const OCCUPATIONAL_FIELD_ID_BARKEEPER = 17;
public const OCCUPATIONAL_FIELD_ID_HOUSEKEEPING = 18;
public const OCCUPATIONAL_FIELD_ID_BARISTA = 19;
public const OCCUPATIONAL_FIELD_ID_PIZZABAECKER = 20;
public const OCCUPATIONAL_FIELD_ID_EMPFANGREZEPTION = 21;
public const OCCUPATIONAL_FIELD_ID_JUNGKOCH = 22;
public const OCCUPATIONAL_FIELD_ID_NEBENJOB = 23;
public const OCCUPATIONAL_FIELD_ID_REINIGUNGSKRAFT = 24;
public const POSSIBLE_CAREER_LEVELS = [
WantedJob::CAREER_LEVEL_TRAINEE,
WantedJob::CAREER_LEVEL_ASSISTANT,
WantedJob::CAREER_LEVEL_EXPERT,
WantedJob::CAREER_LEVEL_EXECUTIVE
];
public const POSSIBLE_EMPLOYMENT_TYPES = [
WantedJob::EMPLOYMENT_TYPE_ONCE,
WantedJob::EMPLOYMENT_TYPE_HELP,
WantedJob::EMPLOYMENT_TYPE_PART_TIME,
WantedJob::EMPLOYMENT_TYPE_FULL_TIME,
WantedJob::EMPLOYMENT_TYPE_UNDEFINED
];
/**
* @var int
*
* @ORM\Column(type="integer")
*
* @ORM\Id
*
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
public function setId(int $id)
{
$this->id = $id;
return $this;
}
public function getId()
{
return $this->id;
}
/**
* @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
*
* @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 JobseekerProfile|Collection
*
* @ORM\ManyToMany(targetEntity="App\Entity\Profile\JobseekerProfile", cascade={"persist"}, mappedBy="occupationalFields")
*/
protected $jobseekerProfiles;
public function setJobseekerProfiles(Collection $jobseekerProfiles)
{
$this->jobseekerProfiles = $jobseekerProfiles;
}
public function getJobseekerProfiles(): Collection
{
return $this->jobseekerProfiles;
}
/**
* @var RecurrentJob|Collection
*
* @ORM\ManyToMany(targetEntity="App\Entity\RecurrentJob", mappedBy="occupationalFields", cascade={"persist"})
*/
protected $recurrentJobs;
public function setRecurrentJobs(Collection $recurrentJobs)
{
$this->recurrentJobs = $recurrentJobs;
}
public function getRecurrentJobs(): Collection
{
return $this->recurrentJobs;
}
/**
* @var RecurrentJob|Collection
*
* @ORM\ManyToMany(targetEntity="App\Entity\RecurrentJob", mappedBy="relevantOccupationalFields", cascade={"persist"})
*/
protected $recurrentJobsForWhichImRelevant;
public function getRecurrentJobsForWhichImRelevant(): Collection
{
return $this->recurrentJobsForWhichImRelevant;
}
/**
* @var Profession|Collection
*
* @ORM\OneToMany(targetEntity="\App\Entity\Profession", mappedBy="occupationalField", cascade={"persist", "remove"})
*/
protected $professions;
public function addProfession(Profession $professions): void
{
$this->professions[] = $professions;
}
public function getProfessions()
{
return $this->professions;
}
/**
* @var WantedJob|Collection
*
* @ORM\ManyToMany(targetEntity="App\Entity\WantedJob", mappedBy="occupationalFields", cascade={"persist"})
*/
protected $wantedJobs;
public function setWantedJobs(Collection $wantedJobs)
{
$this->wantedJobs = $wantedJobs;
}
public function getWantedJobs(): Collection
{
return $this->wantedJobs;
}
/**
* @var string
*
* @ORM\Column(name="title", type="string", length=128, nullable=false)
*
* @Assert\NotBlank()
*
* @Assert\Length(
* min = 2,
* max = 255,
* )
*/
protected $title;
public function setTitle(string $title)
{
$this->title = $title;
return $this;
}
public function getTitle()
{
return $this->title;
}
/**
* @var int
*
* @ORM\Column(name="area", type="smallint", nullable=false)
*/
protected $area;
public function setArea(int $area)
{
if (!in_array($area, self::AREAS)) {
throw new Exception('Unknown area ' . $area);
}
$this->area = $area;
}
public function getArea()
{
return $this->area;
}
/**
* @var array
*
* @ORM\Column(name="possible_career_levels", type="array", nullable=true)
*/
protected $possibleCareerLevels;
public function setPossibleCareerLevels(array $possibleCareerLevels)
{
foreach ($possibleCareerLevels as $possibleCareerLevel) {
if (!in_array($possibleCareerLevel, self::POSSIBLE_CAREER_LEVELS)) {
throw new Exception('Unknown career level ' . $possibleCareerLevel);
}
}
$this->possibleCareerLevels = $possibleCareerLevels;
}
/**
* @var array
*
* @ORM\Column(name="possible_employment_types", type="array", nullable=true)
*/
protected $possibleEmploymentTypes;
public function setPossibleEmploymentTypes(array $possibleEmploymentTypes)
{
foreach ($possibleEmploymentTypes as $possibleEmploymentType) {
if (!in_array($possibleEmploymentType, self::POSSIBLE_EMPLOYMENT_TYPES)) {
throw new Exception('Unknown employment type ' . $possibleEmploymentType);
}
}
$this->possibleEmploymentTypes = $possibleEmploymentTypes;
}
public function getPossibleEmploymentTypes(): ?array
{
return $this->possibleEmploymentTypes;
}
/**
* @var int
*
* @ORM\Column(name="priority", type="smallint", nullable=false)
*/
protected $priority;
public function setPriority(int $priority)
{
if ($priority < 0) {
throw new Exception('Priority ' . $priority . ' is lower than 0');
}
$this->priority = $priority;
}
public function getPriority()
{
return $this->priority;
}
/**
* @var string
*
* @ORM\Column(type="string", nullable=true)
*/
public $slug;
public function getSlug(): ?string
{
return $this->slug;
}
public function setSlug(?string $slug)
{
$this->slug = $slug;
}
public function __construct()
{
$this->jobseekerProfiles = new ArrayCollection();
$this->area = self::AREA_UNDEFINED;
}
public function __toString()
{
return (string)$this->title;
}
}