src/App/Entity/ExternalPartner/ExternalPartner.php line 41

Open in your IDE?
  1. <?php
  2. namespace App\Entity\ExternalPartner;
  3. use App\Entity\User;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Exception;
  8. use ReflectionClass;
  9. /**
  10. * This entity represents an external business partner of JOBOO!® which provides data that becomes recurrent jobs or external joboffers.
  11. *
  12. * The naming for this class is not optimal – a much better name would be something like "ExternalJobsDataSource".
  13. * It is important to not mix it with the concept of Customers. A Customer is the external party which ultimately
  14. * "owns" a recurrent job and wants to fill a job position. An External Partner is the provider of the data source
  15. * where recurrent job data (or, in the case of Joblift, external joboffer data) comes from.
  16. *
  17. * Put differently, an External Partner is where a recurrent job comes *from*, while the Customer is who the
  18. * recurrent job is *for*.
  19. *
  20. * We do have scenarios where External Partner and Customer are truly orthogonal – for example, GOhiring is a "pure"
  21. * data source provide who doesn't want to fill any positions through us itself, providing job data for Wisag, Edeka and
  22. * KFC who don't have a data source of their own (and thus use the services of GOhiring).
  23. *
  24. * But there are also scenarios where data source and employer – External Partner and Customer – are identical. For
  25. * example, REWE is an employer who wants to fill positions through us, and they have their own data feed to provide us
  26. * the required job data.
  27. *
  28. * We still need to keep these cleanly separated conceptually - thus, the ExternalPartner entity dubbed "REWE" means the
  29. * feed-based data source provided by REWE, while the sole Customer entity linked to this ExternalPartner, which is also
  30. * dubbed "REWE" means the employer that wants to fill job positions.
  31. *
  32. * @ORM\Entity
  33. *
  34. * @ORM\Table(
  35. * name="external_partners"
  36. * )
  37. */
  38. class ExternalPartner
  39. {
  40. // This id is used to create external partner objects that do not have an id initially.
  41. // This is important for creating quotas.
  42. public const int ID_PLACEHOLDER = -1;
  43. public const int ID_TANKUNDRAST_API_CLIENT = 0;
  44. public const int ID_JOBLIFT_FEED = 1;
  45. public const int ID_GOHIRING_API = 2;
  46. public const int ID_GERMAN_PERSONNEL_FEED = 3;
  47. public const int ID_REWE_FEED = 4;
  48. public const int ID_HAYS_FEED = 5;
  49. public const int ID_KAUFLAND_CRAWLER = 6;
  50. public const int ID_ONLYFY_CRAWLER = 7;
  51. public const int ID_JOBOO_VERTRIEB_DATENEINGABE = 8;
  52. public const int ID_MYSTAFFPILOT_FEED = 9;
  53. public const int ID_SOFTGARDEN_FEED = 10;
  54. public const int ID_JOBOO_HEADACCOUNTS = 11;
  55. public const int ID_CELLIT_FEED = 12;
  56. public const int ID_LENKZEIT_FEED = 13;
  57. public const int ID_ROSSMANN_CRAWLER = 14;
  58. public const int ID_MOEVENPICK_CRAWLER = 15;
  59. public const int ID_FAHR_ZEIT_CRAWLER = 16;
  60. public const int ID_GLOBETROTTER_CRAWLER = 17;
  61. public const int ID_KOETTER_CRAWLER = 18;
  62. public const int ID_CONCENTRIX_CRAWLER = 19;
  63. public const int ID_ARTEMIS_FEED = 20;
  64. public const int ID_EDEKA_CAREER_SITE_CRAWLER = 21;
  65. public const int ID_FLASCHENPOST_FEED = 22;
  66. public const int ID_BOFROST_CRAWLER = 23;
  67. public const int ID_HOFMANNS_CATERING_CRAWLER = 24;
  68. public const int ID_DEUTSCHE_BAHN_AG_FEED = 25;
  69. public const int ID_MILCH_UND_ZUCKER_FEED = 26;
  70. public const int ID_TENHIL_STELLENANZEIGEN_DE_FEED = 27;
  71. public const int ID_TENHIL_YOURFIRM_FEED = 28;
  72. public const int ID_TENHIL_REGIO_JOBANZEIGER_FEED = 29;
  73. public const int ID_TENHIL_JOBBLITZ_FEED = 30;
  74. public const int ID_TENHIL_KALAYDO_FEED = 31;
  75. public const int ID_TENHIL_IT_JOBS_FEED = 32;
  76. public const int ID_TALENT_FEED = 33;
  77. public const int ID_A_UND_H_ZEITARBEIT_CRAWLER = 34;
  78. public const int ID_KAUFLAND_FEED = 35;
  79. public const int ID_SMART_RECRUITERS_CRAWLER = 36;
  80. public const int ID_AVATURE_CRAWLER = 37;
  81. public const int ID_MEINESTADT_DE_FEED = 38;
  82. public const int ID_SUPERBIOMARKT_CRAWLER = 39;
  83. public const int ID_VION_CAREER_SITE_CRAWLER = 40;
  84. public const int ID_TALENTSCONNECT_CRAWLER = 41;
  85. public const int ID_EUROPERSONAL_CRAWLER = 42;
  86. public const int ID_JOHANNESBAD_CAREER_SITE_CRAWLER = 43;
  87. public const int ID_RANGER = 44;
  88. public const int ID_ADECCO_FEED = 45;
  89. public const int ID_A_UND_O_HOSTELS_CRAWLER = 46;
  90. public const int ID_KAEFER_FEED = 47;
  91. public const int ID_HELLOFRESH_CRAWLER = 48;
  92. public const int ID_PHENOM_FEED = 49;
  93. public const int ID_THYSSENKRUPP_CRAWLER = 50;
  94. public const int ID_EPOS_CRAWLER = 51;
  95. public const int ID_RUDOLF_WEBER_CRAWLER = 52;
  96. public const int ID_PIEPENBROCK_CRAWLER = 53;
  97. public const int ID_SMART_RECRUITERS_API_CLIENT = 54;
  98. public const int ID_WITHTEC_CRAWLER = 55;
  99. public const int ID_CONDOR_SICHERHEIT_CRAWLER = 56;
  100. public const int ID_ZVOOVE_FEED = 57;
  101. public const int ID_LIDL_CRAWLER = 58;
  102. public const int ID_ROFU_CRAWLER = 59;
  103. public const int ID_CLOPPENBURG_CRAWLER = 60;
  104. public const int ID_INTERNATIONALER_BUND_CRAWLER = 61;
  105. public const int ID_JOHANNITER_CRAWLER = 62;
  106. public const int ID_MHM_CRAWLER = 63;
  107. public const int ID_ALB_FILS_KLINIKUM_CRAWLER = 64;
  108. public const int ID_RUNMED_CRAWLER = 65;
  109. public const int ID_DEUTSCHE_BAHN_CRAWLER = 66;
  110. public const int ID_STEPSTONE_FEED = 67;
  111. public const int ID_APETITO_FEED = 68;
  112. public const int ID_VONQ_FEED = 69;
  113. public const int ID_A_UND_H_ZEITARBEIT_XML_FEED = 70;
  114. public const int ID_CONTACT_100_FEED = 71;
  115. public const int ID_A_I_FITNESS_FEED = 72;
  116. public const int ID_XING_FEED = 73;
  117. public const int ID_IMMOBILIEN_SERVICE_DEUTSCHLAND_FEED = 74;
  118. public const int ID_FUNKE_FEED = 75;
  119. /* IMPORTANT!
  120. * Whenever a new external partner is defined here,
  121. * it MUST be added to the documentation at
  122. * https://go-gastro.atlassian.net/wiki/spaces/SD/pages/1171783681/Austausch+fachlicher+Daten+mit+Dritten!
  123. */
  124. public const array IDS_INTEGRATED = [
  125. self::ID_PLACEHOLDER,
  126. self::ID_TANKUNDRAST_API_CLIENT,
  127. self::ID_GOHIRING_API,
  128. self::ID_GERMAN_PERSONNEL_FEED,
  129. self::ID_REWE_FEED,
  130. self::ID_HAYS_FEED,
  131. self::ID_KAUFLAND_CRAWLER,
  132. self::ID_ONLYFY_CRAWLER,
  133. self::ID_JOBOO_VERTRIEB_DATENEINGABE,
  134. self::ID_MYSTAFFPILOT_FEED,
  135. self::ID_SOFTGARDEN_FEED,
  136. self::ID_JOBOO_HEADACCOUNTS,
  137. self::ID_CELLIT_FEED,
  138. self::ID_LENKZEIT_FEED,
  139. self::ID_ROSSMANN_CRAWLER,
  140. self::ID_MOEVENPICK_CRAWLER,
  141. self::ID_FAHR_ZEIT_CRAWLER,
  142. self::ID_GLOBETROTTER_CRAWLER,
  143. self::ID_KOETTER_CRAWLER,
  144. self::ID_CONCENTRIX_CRAWLER,
  145. self::ID_ARTEMIS_FEED,
  146. self::ID_EDEKA_CAREER_SITE_CRAWLER,
  147. self::ID_FLASCHENPOST_FEED,
  148. self::ID_BOFROST_CRAWLER,
  149. self::ID_HOFMANNS_CATERING_CRAWLER,
  150. self::ID_DEUTSCHE_BAHN_AG_FEED,
  151. self::ID_MILCH_UND_ZUCKER_FEED,
  152. self::ID_A_UND_H_ZEITARBEIT_CRAWLER,
  153. self::ID_KAUFLAND_FEED,
  154. self::ID_CELLIT_FEED,
  155. self::ID_SMART_RECRUITERS_CRAWLER,
  156. self::ID_AVATURE_CRAWLER,
  157. self::ID_MEINESTADT_DE_FEED,
  158. self::ID_SUPERBIOMARKT_CRAWLER,
  159. self::ID_VION_CAREER_SITE_CRAWLER,
  160. self::ID_TALENTSCONNECT_CRAWLER,
  161. self::ID_EUROPERSONAL_CRAWLER,
  162. self::ID_JOHANNESBAD_CAREER_SITE_CRAWLER,
  163. self::ID_RANGER,
  164. self::ID_ADECCO_FEED,
  165. self::ID_A_UND_O_HOSTELS_CRAWLER,
  166. self::ID_KAEFER_FEED,
  167. self::ID_HELLOFRESH_CRAWLER,
  168. self::ID_PHENOM_FEED,
  169. self::ID_THYSSENKRUPP_CRAWLER,
  170. self::ID_EPOS_CRAWLER,
  171. self::ID_RUDOLF_WEBER_CRAWLER,
  172. self::ID_PIEPENBROCK_CRAWLER,
  173. self::ID_SMART_RECRUITERS_API_CLIENT,
  174. self::ID_WITHTEC_CRAWLER,
  175. self::ID_CONDOR_SICHERHEIT_CRAWLER,
  176. self::ID_ZVOOVE_FEED,
  177. self::ID_LIDL_CRAWLER,
  178. self::ID_ROFU_CRAWLER,
  179. self::ID_CLOPPENBURG_CRAWLER,
  180. self::ID_INTERNATIONALER_BUND_CRAWLER,
  181. self::ID_JOHANNITER_CRAWLER,
  182. self::ID_MHM_CRAWLER,
  183. self::ID_ALB_FILS_KLINIKUM_CRAWLER,
  184. self::ID_RUNMED_CRAWLER,
  185. self::ID_DEUTSCHE_BAHN_CRAWLER,
  186. self::ID_STEPSTONE_FEED,
  187. self::ID_APETITO_FEED,
  188. self::ID_VONQ_FEED,
  189. self::ID_A_UND_H_ZEITARBEIT_XML_FEED,
  190. self::ID_CONTACT_100_FEED,
  191. self::ID_A_I_FITNESS_FEED,
  192. self::ID_XING_FEED,
  193. self::ID_IMMOBILIEN_SERVICE_DEUTSCHLAND_FEED,
  194. self::ID_FUNKE_FEED
  195. ];
  196. public const array IDS_INTEGRATED_TO_NAMES = [
  197. self::ID_PLACEHOLDER => 'placeholder',
  198. self::ID_TANKUNDRAST_API_CLIENT => 'tank und rast api client',
  199. self::ID_GOHIRING_API => 'go hiring api',
  200. self::ID_GERMAN_PERSONNEL_FEED => 'german personnel feed',
  201. self::ID_REWE_FEED => 'rewe feed',
  202. self::ID_HAYS_FEED => 'hays feed',
  203. self::ID_KAUFLAND_CRAWLER => 'kaufland crawler',
  204. self::ID_ONLYFY_CRAWLER => 'onlyfy crawler',
  205. self::ID_JOBOO_VERTRIEB_DATENEINGABE => 'joboo vertrieb dateneingabe',
  206. self::ID_MYSTAFFPILOT_FEED => 'mystaffpilot feed',
  207. self::ID_SOFTGARDEN_FEED => 'softgarden feed',
  208. self::ID_JOBOO_HEADACCOUNTS => 'joboo headaccounts',
  209. self::ID_CELLIT_FEED => 'cellit feed',
  210. self::ID_LENKZEIT_FEED => 'lenkzeit feed',
  211. self::ID_ROSSMANN_CRAWLER => 'rossmann crawler',
  212. self::ID_MOEVENPICK_CRAWLER => 'moevenpick crawler',
  213. self::ID_FAHR_ZEIT_CRAWLER => 'fahr-zeit crawler',
  214. self::ID_GLOBETROTTER_CRAWLER => 'globetrotter crawler',
  215. self::ID_KOETTER_CRAWLER => 'koetter crawler',
  216. self::ID_CONCENTRIX_CRAWLER => 'concentrix crawler',
  217. self::ID_ARTEMIS_FEED => 'artemis feed',
  218. self::ID_EDEKA_CAREER_SITE_CRAWLER => 'edeka career-site crawler',
  219. self::ID_FLASCHENPOST_FEED => 'flaschenpost feed',
  220. self::ID_BOFROST_CRAWLER => 'bofrost crawler',
  221. self::ID_HOFMANNS_CATERING_CRAWLER => 'hofmanns catering crawler',
  222. self::ID_DEUTSCHE_BAHN_AG_FEED => 'deutsche bahn ag feed',
  223. self::ID_MILCH_UND_ZUCKER_FEED => 'milch und zucker feed',
  224. self::ID_TENHIL_STELLENANZEIGEN_DE_FEED => 'tenhil stellenanzeigen de feed',
  225. self::ID_TENHIL_YOURFIRM_FEED => 'tenhil yourfirm feed',
  226. self::ID_TENHIL_REGIO_JOBANZEIGER_FEED => 'tenhil regio jobanzeiger feed',
  227. self::ID_TENHIL_JOBBLITZ_FEED => 'tenhil jobblitz feed',
  228. self::ID_TENHIL_KALAYDO_FEED => 'tenhil kalaydo feed',
  229. self::ID_TENHIL_IT_JOBS_FEED => 'tenhil it-jobs feed',
  230. self::ID_TALENT_FEED => 'talent feed',
  231. self::ID_A_UND_H_ZEITARBEIT_CRAWLER => 'a und h zeitarbeit crawler',
  232. self::ID_KAUFLAND_FEED => 'kaufland feed',
  233. self::ID_SMART_RECRUITERS_CRAWLER => 'smart recruiters crawler',
  234. self::ID_AVATURE_CRAWLER => 'avature crawler',
  235. self::ID_MEINESTADT_DE_FEED => 'meinestadt.de feed',
  236. self::ID_SUPERBIOMARKT_CRAWLER => 'superbiomarkt crawler',
  237. self::ID_VION_CAREER_SITE_CRAWLER => 'vion career-site crawler',
  238. self::ID_TALENTSCONNECT_CRAWLER => 'talentsconnect crawler',
  239. self::ID_EUROPERSONAL_CRAWLER => 'europersonal crawler',
  240. self::ID_JOHANNESBAD_CAREER_SITE_CRAWLER => 'johannesbad career-site crawler',
  241. self::ID_RANGER => 'ranger',
  242. self::ID_ADECCO_FEED => 'adecco feed',
  243. self::ID_A_UND_O_HOSTELS_CRAWLER => 'a und o hostels crawler',
  244. self::ID_KAEFER_FEED => 'kaefer feed',
  245. self::ID_HELLOFRESH_CRAWLER => 'hellofresh crawler',
  246. self::ID_PHENOM_FEED => 'phenom feed',
  247. self::ID_THYSSENKRUPP_CRAWLER => 'thyssenkrupp crawler',
  248. self::ID_EPOS_CRAWLER => 'epos crawler',
  249. self::ID_RUDOLF_WEBER_CRAWLER => 'rudolf weber crawler',
  250. self::ID_PIEPENBROCK_CRAWLER => 'piepenbrock crawler',
  251. self::ID_SMART_RECRUITERS_API_CLIENT => 'smart recruiters api client',
  252. self::ID_WITHTEC_CRAWLER => 'withtec crawler',
  253. self::ID_CONDOR_SICHERHEIT_CRAWLER => 'condor sicherheit crawler',
  254. self::ID_ZVOOVE_FEED => 'zvoove feed',
  255. self::ID_LIDL_CRAWLER => 'lidl crawler',
  256. self::ID_ROFU_CRAWLER => 'rofu crawler',
  257. self::ID_CLOPPENBURG_CRAWLER => 'cloppenburg crawler',
  258. self::ID_INTERNATIONALER_BUND_CRAWLER => 'internationaler bund crawler',
  259. self::ID_JOHANNITER_CRAWLER => 'johanniter crawler',
  260. self::ID_MHM_CRAWLER => 'mhm crawler',
  261. self::ID_ALB_FILS_KLINIKUM_CRAWLER => 'alb fils klinikum crawler',
  262. self::ID_RUNMED_CRAWLER => 'runmed crawler',
  263. self::ID_DEUTSCHE_BAHN_CRAWLER => 'deutsche bahn crawler',
  264. self::ID_STEPSTONE_FEED => 'stepstone feed',
  265. self::ID_APETITO_FEED => 'apetito feed',
  266. self::ID_VONQ_FEED => 'vonq feed',
  267. self::ID_A_UND_H_ZEITARBEIT_XML_FEED => 'a und h zeitarbeit feed',
  268. self::ID_CONTACT_100_FEED => 'contact 100 feed',
  269. self::ID_A_I_FITNESS_FEED => 'ai fitness feed',
  270. self::ID_XING_FEED => 'xing feed',
  271. self::ID_IMMOBILIEN_SERVICE_DEUTSCHLAND_FEED => 'immobilien service deutschland feed',
  272. self::ID_FUNKE_FEED => 'funke feed'
  273. ];
  274. public function __construct()
  275. {
  276. $this->users = new ArrayCollection();
  277. $this->integratedExternalPartnerCustomers = new ArrayCollection();
  278. }
  279. /**
  280. * @var int
  281. *
  282. * @ORM\Column(name="id", type="smallint")
  283. *
  284. * @ORM\Id
  285. */
  286. protected $id;
  287. /** @throws Exception */
  288. public function setId(int $id): void
  289. {
  290. $refl = new ReflectionClass(ExternalPartner::class);
  291. $constants = $refl->getConstants();
  292. $found = false;
  293. foreach ($constants as $constantName => $constantValue) {
  294. if (substr($constantName, 0, 3) === 'ID_' && $constantValue === $id) {
  295. $found = true;
  296. }
  297. }
  298. if (!$found) {
  299. throw new Exception('Value ' . $id . ' not allowed for id.');
  300. }
  301. $this->id = $id;
  302. }
  303. public function getId(): int
  304. {
  305. return $this->id;
  306. }
  307. public function isIntegrated(): bool
  308. {
  309. if (in_array($this->getId(), self::IDS_INTEGRATED)) {
  310. return true;
  311. } else {
  312. return false;
  313. }
  314. }
  315. /**
  316. * @var User[]|Collection
  317. *
  318. * @ORM\OneToMany(targetEntity="\App\Entity\User", mappedBy="externalPartner", cascade={"persist", "remove"})
  319. */
  320. protected $users;
  321. public function getUsers(): Collection
  322. {
  323. return $this->users;
  324. }
  325. /**
  326. * @var IntegratedExternalPartnerCustomer[]|Collection
  327. *
  328. * @ORM\OneToMany(targetEntity="\App\Entity\ExternalPartner\IntegratedExternalPartnerCustomer", mappedBy="externalPartner", cascade={"persist", "remove"})
  329. */
  330. protected Collection $integratedExternalPartnerCustomers;
  331. public function getIntegratedExternalPartnerCustomers(): Collection
  332. {
  333. return $this->integratedExternalPartnerCustomers;
  334. }
  335. /**
  336. * @throws Exception
  337. */
  338. public function getNameById(int $id): string
  339. {
  340. if (array_key_exists($id, self::IDS_INTEGRATED_TO_NAMES)) {
  341. return self::IDS_INTEGRATED_TO_NAMES[$id];
  342. } else {
  343. throw new Exception('External partner with id ' . $id . ' was not found.');
  344. }
  345. }
  346. /**
  347. * @throws Exception
  348. */
  349. public function getHyphenatedNameById(int $id): string
  350. {
  351. $name = $this->getNameById($id);
  352. return mb_ereg_replace('[.\s]', '-', $name);
  353. }
  354. }