<?php
namespace App\BackendBundle\Helper;
use App\Entity\JobWorkField;
use DateTime;
use Doctrine\ORM\EntityManagerInterface;
use App\BackendBundle\Interfaces\ProfileInterface;
use App\BackendBundle\Model\GraphQL\CompanyProfileSimple;
use App\BackendBundle\Model\GraphQL\InterestField as InterestFieldGQL;
use App\BackendBundle\Model\GraphQL\Job as JobGQL;
use App\BackendBundle\Model\GraphQL\JobEducationalPath as JobEducationalPathGQL;
use App\BackendBundle\Model\GraphQL\JobExpertTerm as JobExpertTermGQL;
use App\BackendBundle\Model\GraphQL\JobLinkMapping as JobLinkMappingGQL;
use App\BackendBundle\Model\GraphQL\JobLinkMappingCategory as JobLinkMappingCategoryGQL;
use App\BackendBundle\Model\GraphQL\JobLinkMappingType as JobLinkMappingTypeGQL;
use App\BackendBundle\Model\GraphQL\JobLink as JobLinkGQL;
use App\BackendBundle\Model\GraphQL\JobMarketDistricts as JobMarketDistrictsGQL;
use App\BackendBundle\Model\GraphQL\JobMarketDistrict as JobMarketDistrictGQL;
use App\BackendBundle\Model\GraphQL\JobSimple as JobSimpleGQL;
use App\BackendBundle\Model\GraphQL\JobPreview as JobPreviewGQL;
use App\BackendBundle\Model\GraphQL\JobRedirect as JobRedirectGQL;
use App\BackendBundle\Model\GraphQL\JobRequirement as JobRequirementGQL;
use App\BackendBundle\Model\GraphQL\JobRequirementCollection as JobRequirementCollectionGQL;
use App\BackendBundle\Model\GraphQL\JobRequirementType as JobRequirementTypeGQL;
use App\BackendBundle\Model\GraphQL\JobRequirementTypeCollection as JobRequirementTypeCollectionGQL;
use App\BackendBundle\Model\GraphQL\JobSalary as JobSalaryGQL;
use App\BackendBundle\Model\GraphQL\JobSalaryEntry as JobSalaryEntryGQL;
use App\BackendBundle\Model\GraphQL\JobSchool as JobSchoolGQL;
use App\BackendBundle\Model\GraphQL\JobScholasticDuration as JobScholasticDurationGQL;
use App\BackendBundle\Model\GraphQL\JobSchoolSubjectMapping as JobSchoolSubjectMappingGQL;
use App\BackendBundle\Model\GraphQL\JobSchoolSubject as JobSchoolSubjectGQL;
use App\BackendBundle\Model\GraphQL\JobSector as JobSectorGQL;
use App\BackendBundle\Model\GraphQL\JobWorkField as JobWorkFieldGQL;
use App\BackendBundle\Model\GraphQL\School as SchoolGQL;
use App\Entity\AddressDistrict;
use App\Entity\CompanyProfile;
use App\Entity\CompanyLocation;
use App\Entity\InterestField;
use App\Entity\Job;
use App\Entity\JobDailyRoutine;
use App\Entity\JobEducationalPath;
use App\Entity\JobLink;
use App\Entity\JobLinkMapping;
use App\Entity\JobLinkMappingCategory;
use App\Entity\JobLinkMappingType;
use App\Entity\JobMarket;
use App\Entity\JobPDF;
use App\Entity\JobRedirect;
use App\Entity\JobRedirectType;
use App\Entity\JobRequirement;
use App\Entity\JobRequirementMapping;
use App\Entity\JobRequirementType;
use App\Entity\JobSalary;
use App\Entity\JobSalaryEntry;
use App\Entity\JobSalaryType;
use App\Entity\JobScholasticDuration;
use App\Entity\JobSchool;
use App\Entity\JobSchoolSubjectMapping;
use App\Entity\JobSchoolSubject;
use App\Entity\School;
use App\Entity\SearchTag;
class GraphQlJobHelper
{
private EntityManagerInterface $em;
private GraphQlCommonHelper $graphqlCommonHelper;
private JobHelper $jobHelper;
private JobMarketHelper $jobMarketHelper;
private MediaHelper $mediaHelper;
private StoryHelper $storyHelper;
private VideoHelper $videoHelper;
private $backendDomain;
public function __construct(EntityManagerInterface $em, AddressHelper $addressHelper, GraphQlCommonHelper $graphqlCommonHelper,
JobMarketHelper $jobMarketHelper, JobHelper $jobHelper, MediaHelper $mediaHelper, StoryHelper $storyHelper,
VideoHelper $videoHelper, $backendDomain)
{
$this->em = $em;
$this->addressHelper = $addressHelper;
$this->graphqlCommonHelper = $graphqlCommonHelper;
$this->jobHelper = $jobHelper;
$this->jobMarketHelper = $jobMarketHelper;
$this->mediaHelper = $mediaHelper;
$this->storyHelper = $storyHelper;
$this->videoHelper = $videoHelper;
$this->backendDomain = $backendDomain;
}
public function getDateString(DateTime $dateTime = null): string
{
if (empty($dateTime)) {
return '';
}
return $dateTime->format("d.m.Y");
}
public function getJobsByProfile(ProfileInterface $profile): array
{
$jobsGQL = array();
$profileJobs = $profile->getJobs();
foreach ($profileJobs as $profileJob) {
$jobsGQL[] = $this->getJobGQL($profileJob);
}
return $jobsGQL;
}
public function getJobSimple(Job $jobSrc): JobSimpleGQL
{
$jobSimple = new JobSimpleGQL();
$jobSimple->setId($jobSrc->getId());
$jobSimple->setName($jobSrc->getName());
$jobSimple->setBicID($jobSrc->getBicID());
$this->addJobSimpleInterestFields($jobSrc, $jobSimple);
return $jobSimple;
}
public function getJobPreview(Job $jobSrc): JobPreviewGQL
{
$jobPreview = new JobPreviewGQL();
$jobPreview->setId($jobSrc->getId());
$jobPreview->setName($jobSrc->getName());
$image = $this->graphqlCommonHelper->generateThumbnails($jobSrc->getTeaserImage());
$jobPreview->setImage($image);
return $jobPreview;
}
private function addJobSimpleInterestFields(Job $jobSrc, JobSimpleGQL $job): void
{
$interestFields = $jobSrc->getInterestFields();
/* @var $interestField InterestField */
foreach ($interestFields as $interestField) {
$interestFieldGQL = $this->getinterestFieldGQL($interestField);
$job->addInterestField($interestFieldGQL);
}
}
public function getInterestFieldGQL(InterestField $interestField): InterestFieldGQL
{
$interestFieldGQL = new InterestFieldGQL();
$interestFieldGQL->setId($interestField->getId());
$interestFieldGQL->setInterestName($interestField->getInterestName());
$interestFieldGQL->setSubHeading($interestField->getSubHeading());
return $interestFieldGQL;
}
public function getJobGQL(Job $job, $setVideoUrl = false): JobGQL
{
$jobGQL = new JobGQL();
$jobGQL->setId($job->getId());
$jobGQL->setBicID($job->getBicID());
$jobGQL->setName($job->getName());
$jobGQL->setDescription($job->getDescription());
$jobGQL->setBicAnforderungen($job->getBicAnforderungen());
$jobGQL->setBicAlternativen($job->getBicAlternativen());
$jobGQL->setOperationsAndTasks($job->getOperationsAndTasks());
$jobGQL->setBicAusbildungBerufschule($job->getBicAusbildungBerufschule());
$jobGQL->setBicMoeglichkeiten($job->getBicMoeglichkeiten());
$this->setScholasticDuration($job, $jobGQL);
$this->addInterestFields($job, $jobGQL);
$this->addJobEducationalPaths($job, $jobGQL);
$this->addJobEducationCompanies($jobGQL);
$this->addJobExpertTerms($job, $jobGQL);
$this->addJobImage($job, $jobGQL);
$this->addJobInsights($job, $jobGQL);
$this->addJobLinkMappings($job, $jobGQL);
$this->addJobMarketDistricts($job, $jobGQL);
$this->addJobRedirects($job, $jobGQL);
$this->addJobSalary($job, $jobGQL);
$this->addJobSectors($job, $jobGQL);
$this->addJobSchools($job, $jobGQL);
$this->addJobSchoolSubjectMappings($job, $jobGQL);
$this->addJobWorkFields($job, $jobGQL);
$this->addJobVideoUrl($job, $jobGQL, $setVideoUrl);
$this->addJobPDFUrl($job, $jobGQL);
$this->addRequirementsByType($job, $jobGQL);
$this->addSearchTags($job, $jobGQL);
return $jobGQL;
}
private function setScholasticDuration(Job $jobSrc, JobGQL $job): void
{
$scholasticDuration = $jobSrc->getScholasticDuration();
if (empty($scholasticDuration)) {
return;
}
$scholasticDurationGQL = $this->prepareScholasticDuration($scholasticDuration);
$job->setScholasticDuration($scholasticDurationGQL);
}
public function prepareScholasticDuration(JobScholasticDuration $scholasticDuration): JobScholasticDurationGQL
{
$scholasticDurationGQL = new JobScholasticDurationGQL();
$scholasticDurationGQL->setId($scholasticDuration->getId());
$scholasticDurationGQL->setDurationName($scholasticDuration->getDurationName());
$scholasticDurationGQL->setPosition($scholasticDuration->getPosition());
return $scholasticDurationGQL;
}
private function getVideoUrl(Job $jobSrc): ?string
{
$jobDailyRoutines = $this->jobHelper->getJobDailyRoutinesByJobVisible($jobSrc);
if (count($jobDailyRoutines) == 0) {
return null;
}
/* @var $jobDailyRoutine JobDailyRoutine */
$jobDailyRoutine = $jobDailyRoutines[0];
return $jobDailyRoutine->getVideoUrl();
}
public function getJobReduced(Job $jobSrc): JobGQL
{
$job = new JobGQL();
$job->setId($jobSrc->getId());
$job->setBicID($jobSrc->getBicID());
$job->setName($jobSrc->getName());
return $job;
}
private function addInterestFields(Job $jobSrc, JobGQL $job): void
{
$interestFields = $jobSrc->getInterestFields();
/* @var $interestFielSrc InterestField */
foreach ($interestFields as $interestFieldSrc) {
$interestFieldGQL = $this->prepareInterestField($interestFieldSrc);
$job->addInterestField($interestFieldGQL);
}
}
public function prepareInterestField(InterestField $interestField): InterestFieldGQL
{
$interestFieldGQL = new InterestFieldGQL();
$interestFieldGQL->setId($interestField->getId());
$interestFieldGQL->setInterestName($interestField->getInterestName());
return $interestFieldGQL;
}
private function addJobEducationalPaths(Job $jobSrc, JobGQL $job): void
{
$educationalPaths = $jobSrc->getJobEducationalPaths();
foreach ($educationalPaths as $educationalPath) {
$jobEducationalPathGQL = $this->prepareJobEducationalPath($educationalPath);
$job->addJobEducationalPath($jobEducationalPathGQL);
}
}
public function prepareJobEducationalPath(JobEducationalPath $jobEducationalPath): JobEducationalPathGQL
{
$jobEducationalPathGQL = new JobEducationalPathGQL();
$jobEducationalPathGQL->setId($jobEducationalPath->getId());
$jobEducationalPathGQL->setName($jobEducationalPath->getName());
$jobEducationalPathGQL->setBicID($jobEducationalPath->getBicID());
$jobEducationalPathGQL->setDescription($jobEducationalPath->getDescription());
return $jobEducationalPathGQL;
}
private function addJobExpertTerms(Job $jobSrc, JobGQL $job): void
{
$expertTerms = $jobSrc->getJobExpertTerms();
foreach ($expertTerms as $expertTermSrc) {
$expertTerm = new JobExpertTermGQL();
$expertTerm->setExpertTermData($expertTermSrc);
$job->addExpertTerm($expertTerm);
}
}
private function addJobRedirects(Job $job, JobGQL $jobGQL): void
{
$jobRedirects = $job->getJobRedirects();
/* @var $jobRedirect JobRedirect */
foreach ($jobRedirects as $jobRedirect) {
$jobRedirectGQL = $this->prepareJobRedirectGQL($jobRedirect);
if (empty($jobRedirectGQL)) {
continue;
}
$jobGQL->addJobRedirect($jobRedirectGQL);
}
}
public function prepareJobRedirectGQL(JobRedirect $jobRedirect): ?JobRedirectGQL
{
/* @var $job Job */
$job = $jobRedirect->getDestJob();
if (empty($job)) {
return null;
}
$bicID = $job->getBicID();
if (empty($bicID)) {
return null;
}
$jobRedirectGQL = new JobRedirectGQL();
$jobRedirectGQL->setBicID($bicID);
$jobRedirectGQL->setJobName($job->getName());
$strType = $this->getJobRedirectTypeString($jobRedirect);
$jobRedirectGQL->setRedirectType($strType);
return $jobRedirectGQL;
}
private function getJobRedirectTypeString(JobRedirect $redirect): string
{
/* @var $type JobRedirectType */
$type = $redirect->getJobRedirectType();
return $type->getTypeName();
}
private function addJobSalary(Job $jobSrc, JobGQL $job): void
{
/* @var $jobSalary JobSalary */
$jobSalary = $jobSrc->getSalary();
if (empty($jobSalary)) {
return;
}
$jobSalaryGQL = $this->prepareJobSalary($jobSalary);
$job->setJobSalary($jobSalaryGQL);
}
public function prepareJobSalary(JobSalary $jobSalary): ?JobSalaryGQL
{
$jobSalaryGQL = new JobSalaryGQL();
$jobSalaryGQL->setId($jobSalary->getId());
$jobLehrlingseinkommen = $jobSalary->getJobLehrlingseinkommenMapping();
if (!empty($jobLehrlingseinkommen)) {
$jobSalaryGQL->setLehrlingseinkommenUrl($jobLehrlingseinkommen->getSiteJobUrl());
}
$jobAmsMapping = $jobSalary->getJobAmsMapping();
if (!empty($jobAmsMapping)) {
$jobSalaryGQL->setAmsUrl($jobAmsMapping->getAmsUrl());
}
$jobSalaryGQL->getCreatedAt($jobSalary->getCreatedAt()->format('d.m.Y'));
$this->addJobSalaryEntries($jobSalary, $jobSalaryGQL);
return $jobSalaryGQL;
}
private function addJobSalaryEntries(JobSalary $jobSalary, JobSalaryGQL $jobSalaryGQL): void
{
$entries = $jobSalary->getEntries();
/* @var $entry JobSalaryEntry */
foreach ($entries as $entry) {
$entryGQL = new JobSalaryEntryGQL();
$entryGQL->setId($entry->getId());
$strSalaryFrom = $this->getSalaryString($entry->getSalaryFrom());
$entryGQL->setSalaryFrom($strSalaryFrom);
$strSalaryTo = $this->getSalaryString($entry->getSalaryTo());
$entryGQL->setSalaryTo($strSalaryTo);
$entryGQL->setCreatedAt($entry->getCreatedAt()->format('d.m.Y'));
$salaryType = $entry->getSalaryType();
$salaryTypeGQL = $this->getJobSalaryTypeString($salaryType);
$entryGQL->setSalaryType($salaryTypeGQL);
$this->setJobSalaryEntryValue($jobSalaryGQL, $entry);
$jobSalaryGQL->addEntry($entryGQL);
}
}
private function getSalaryString($dbString)
{
if ($dbString == 'null') {
return null;
}
return $dbString;
}
private function getJobSalaryTypeString(JobSalaryType $salaryType): string
{
$typeID = $salaryType->getId();
switch ($typeID) {
case 1:
return "YROA1";
case 2:
return "YROA2";
case 3:
return "YROA3";
case 4:
return "YROA4";
case 5:
return "ENTRY";
}
return "";
}
private function setJobSalaryEntryValue(JobSalaryGQL $jobSalaryGQL, JobSalaryEntry $entry): void
{
/* @var $salaryType JobSalaryType */
$salaryType = $entry->getSalaryType();
if ($salaryType->getId() != 5) {
return;
}
$jobSalaryGQL->setEntryValue($entry->getSalaryFrom());
}
private function addJobSectors(Job $jobSrc, JobGQL $job): void
{
$sectors = $jobSrc->getJobSectors();
foreach ($sectors as $sector) {
$jobSector = new JobSectorGQL();
$jobSector->setJobSectorData($sector);
$job->addJobSector($jobSector);
}
}
private function addJobSchools(Job $jobSrc, JobGQL $job): void
{
$jobSchools = $jobSrc->getJobSchools();
/* @var $jobSchool JobSchool */
foreach ($jobSchools as $jobSchool) {
$jobSchoolGQL = new JobSchoolGQL();
$jobSchoolGQL->setId($jobSchool->getId());
$school = $jobSchool->getSchool();
$schoolGQL = $this->graphqlCommonHelper->prepareSchool($school);
$jobSchoolGQL->setSchool($schoolGQL);
$job->addJobSchool($jobSchoolGQL);
}
}
private function addJobSchoolSubjectMappings(Job $jobSrc, JobGQL $job): void
{
$jobSubjectMappings = $jobSrc->getSchoolSubjectMappings();
/* @var $jobSubjectMappingSrc JobSchoolSubjectMapping */
foreach ($jobSubjectMappings as $jobSubjectMappingSrc) {
$jobSubjectMapping = $this->prepareJobSchoolSubjectMapping($jobSubjectMappingSrc);
$job->addSchoolSubjectMapping($jobSubjectMapping);
}
}
public function prepareJobSchoolSubjectMapping(JobSchoolSubjectMapping $subjectMappingSrc): JobSchoolSubjectMappingGQL
{
$jobSubjectMapping = new JobSchoolSubjectMappingGQL();
$jobSubjectMapping->setId($subjectMappingSrc->getId());
$jobSchoolSubject = $this->getJobSchoolSubject($subjectMappingSrc->getJobSchoolSubject());
$jobSubjectMapping->setJobSchoolSubject($jobSchoolSubject);
return $jobSubjectMapping;
}
public function getJobSchoolSubject(JobSchoolSubject $subjectSrc): JobSchoolSubjectGQL
{
$jobSchoolSubject = new JobSchoolSubjectGQL();
$jobSchoolSubject->setId($subjectSrc->getId());
$jobSchoolSubject->setSubjectName($subjectSrc->getSubjectName());
$jobSchoolSubject->setAbbreviation($subjectSrc->getAbbreviation());
return $jobSchoolSubject;
}
private function addJobWorkFields(Job $jobSrc, JobGQL $job): void
{
$workFields = $jobSrc->getJobWorkFields();
foreach ($workFields as $workField) {
$jobWorkFieldGQL = $this->prepareJobWorkField($workField);
$job->addJobWorkField($jobWorkFieldGQL);
}
}
public function prepareJobWorkField(JobWorkField $jobWorkField): JobWorkFieldGQL
{
$jobWorkFieldGQL = new JobWorkFieldGQL();
$jobWorkFieldGQL->setId($jobWorkField->getId());
$jobWorkFieldGQL->setName($jobWorkField->getName());
$jobWorkFieldGQL->setBicID($jobWorkField->getBicID());
$jobWorkFieldGQL->setDescription($jobWorkField->getDescription());
return $jobWorkFieldGQL;
}
private function addRequirementsByType(Job $jobSrc, JobGQL $job): void
{
$requirementMappings = $jobSrc->getJobRequirementMappings();
if (empty($requirementMappings)) {
return;
}
$jobRequirementCollection = $this->prepareJobRequirementCollection($requirementMappings->toArray());
$job->setRequirementsByType($jobRequirementCollection);
}
public function prepareJobRequirementCollection(array $requirementMappings): JobRequirementCollectionGQL
{
$jobRequirementCollection = new JobRequirementCollectionGQL();
/* @var $requirementMapping JobRequirementMapping */
foreach ($requirementMappings as $requirementMapping) {
$jobRequirementSrc = $requirementMapping->getJobRequirement();
$requirementType = $this->getJobRequirementTypeByRequirement($jobRequirementSrc);
$requirementTypeID = $requirementType->getId();
$requirementTypeCollection = $jobRequirementCollection->getRequirementTypeCollectionByID($requirementTypeID);
if (empty($requirementTypeCollection)) {
$requirementTypeCollection = new JobRequirementTypeCollectionGQL();
$requirementTypeCollection->setRequirementType($requirementType);
$jobRequirementCollection->addRequirementType($requirementTypeID, $requirementTypeCollection);
}
$jobRequirement = $this->getJobRequirement($jobRequirementSrc);
$requirementTypeCollection->addRequirement($jobRequirement);
}
return $jobRequirementCollection;
}
private function addSearchTags(Job $jobSrc, JobGQL $job): void
{
$searchTags = $jobSrc->getSearchTags();
if (empty($searchTags)) {
return;
}
/* @var $searchTag SearchTag */
foreach ($searchTags as $searchTag) {
$tagName = $searchTag->getName();
$job->addSearchTag($tagName);
}
}
private function addJobImage(Job $jobSrc, JobGQL $job): void
{
$image = $this->graphqlCommonHelper->generateThumbnails($jobSrc->getTeaserImage());
$job->setImage($image);
}
private function addJobMarketDistricts(Job $jobSrc, JobGQL $job): void
{
$jobMarketDistricts = $this->getJobMarketDistricts($jobSrc);
$job->setJobMarketDistricts($jobMarketDistricts);
}
private function addJobVideoUrl(Job $jobSrc, JobGQL $job, $setVideoUrl): void
{
if (!$setVideoUrl) {
return;
}
$videoUrl = $this->getVideoUrl($jobSrc);
$job->setVideoUrl($videoUrl);
}
private function addJobPDFUrl(Job $jobSrc, JobGQL $job): void
{
/* @var $jobPDF JobPDF */
$jobPDF = $jobSrc->getJobPDF();
if (empty($jobPDF)) {
return;
}
$webPath = $jobPDF->getWebPath();
$pdfUrl = $this->backendDomain . "$webPath";
$job->setPdfUrl($pdfUrl);
}
private function addJobInsights(Job $jobSrc, JobGQL $job): void
{
$jobDailyRoutines = $this->jobHelper->getJobDailyRoutinesByJobVisible($jobSrc);
foreach ($jobDailyRoutines as $jobDailyRoutine) {
$story = $this->storyHelper->getStoryByDailyRoutine($jobDailyRoutine);
if (empty($story)) {
continue;
}
$job->addInsight($story);
}
}
private function addJobLinkMappings(Job $jobSrc, JobGQL $job): void
{
$linkMappings = $jobSrc->getJobLinkMappings();
/* @var $linkMapping JobLinkMapping */
foreach ($linkMappings as $linkMapping) {
$linkMappingGQL = $this->prepareJobLinkMapping($linkMapping);
$job->addJobLinkMapping($linkMappingGQL);
}
}
public function prepareJobLinkMapping(JobLinkMapping $linkMapping): JobLinkMappingGQL
{
$jobLinkMapping = new JobLinkMappingGQL();
$jobLinkMapping->setId($linkMapping->getId());
$jobLink = $this->getJobLink($linkMapping);
$jobLinkMapping->setJobLink($jobLink);
$jobLinkMappingCategory = $this->getJobLinkCategory($linkMapping);
$jobLinkMapping->setJobLinkMappingCategory($jobLinkMappingCategory);
$jobLinkMappingType = $this->getJobLinkMappingType($linkMapping);
$jobLinkMapping->setJobLinkMappingType($jobLinkMappingType);
return $jobLinkMapping;
}
private function getJobLink(JobLinkMapping $linkMapping): JobLinkGQL
{
/* @var $jobLinkSrc JobLink */
$jobLinkSrc = $linkMapping->getJobLink();
$jobLink = new JobLinkGQL();
$jobLink->setId($jobLinkSrc->getId());
$jobLink->setTitle($jobLinkSrc->getTitle());
$jobLink->setTitleFrontend($jobLinkSrc->getTitleFrontend());
$jobLink->setTitleBackend($jobLinkSrc->getTitleBackend());
$jobLink->setUrl($jobLinkSrc->getUrl());
return $jobLink;
}
private function getJobLinkCategory(JobLinkMapping $linkMapping)
{
/* @var $category JobLinkMappingCategory */
$category = $linkMapping->getJobLinkMappingCategory();
$categoryGQL = new JobLinkMappingCategoryGQL();
$categoryGQL->setId($category->getId());
$categoryGQL->setName($category->getName());
return $categoryGQL;
}
private function getJobLinkMappingType(JobLinkMapping $linkMapping)
{
/* @var $type JobLinkMappingType */
$type = $linkMapping->getJobLinkMappingType();
$linkType = new JobLinkMappingTypeGQL();
$linkType->setId($type->getId());
$linkType->setName($type->getName());
return $linkType;
}
private function getJobMarketDistricts(Job $jobSrc)
{
$jobMarketDistricts = new JobMarketDistrictsGQL();
$this->getJobMarketDistrictCompanies($jobMarketDistricts, $jobSrc);
$this->getJobMarketDistrictJobs($jobMarketDistricts, $jobSrc);
return $jobMarketDistricts;
}
private function getJobMarketDistrictCompanies(JobMarketDistrictsGQL $jobMarketDistricts, Job $jobSrc)
{
$companyProfiles = $this->jobHelper->getJobTrainingCompanies($jobSrc);
/* @var $companyProfile CompanyProfile */
foreach ($companyProfiles as $companyProfile) {
$this->getJobMarketDistrictCompany($jobMarketDistricts, $companyProfile);
}
}
private function getJobMarketDistrictCompany(JobMarketDistrictsGQL $jobMarketDistricts, CompanyProfile $companyProfile)
{
$companyProfileSimple = $this->getCompanyProfileSimple($companyProfile);
$locations = $companyProfile->getLocations();
/* @var $location CompanyLocation */
foreach ($locations as $location) {
$addressDistrict = $this->getCompanyLocationAddressDistrict($location);
if (empty($addressDistrict)) {
continue;
}
$this->checkJobMarketDistrict($jobMarketDistricts, $addressDistrict);
/* @var $jobMarketDistrict JobMarketDistrictGQL */
$jobMarketDistrict = $jobMarketDistricts->getDistrict($addressDistrict);
$jobMarketDistrict->addTrainingCompany($companyProfileSimple);
}
}
private function getJobMarketDistrictJobs(JobMarketDistrictsGQL $jobMarketDistricts, Job $jobSrc)
{
$jobMarkets = $this->jobMarketHelper->getActiveJobOffersByJob($jobSrc);
if (empty($jobMarkets)) {
return;
}
/* @var $jobMarket JobMarket */
foreach ($jobMarkets as $jobMarket) {
$addressDistricts = $this->getJobMarketAddressDistricts($jobMarket);
if (empty($addressDistricts)) {
continue;
}
foreach ($addressDistricts as $addressDistrict) {
$this->checkJobMarketDistrict($jobMarketDistricts, $addressDistrict);
/* @var $jobMarketDistrict JobMarketDistrictGQL */
$jobMarketDistrict = $jobMarketDistricts->getDistrict($addressDistrict);
$companyProfileSimple = $this->getCompanyProfileSimple($jobMarket->getCompanyProfile());
$jobMarketDistrict->addJobMarketEntry($companyProfileSimple);
}
}
}
private function checkJobMarketDistrict(JobMarketDistrictsGQL $jobMarketDistricts, AddressDistrict $addressDistrict)
{
if ($jobMarketDistricts->hasDistrict($addressDistrict)) {
return;
}
$jobMarketDistrict = new JobMarketDistrictGQL();
$jobMarketDistrict->setDistrictID($addressDistrict->getId());
$jobMarketDistrict->setDistrictName($addressDistrict->getName());
$jobMarketDistricts->addDistrict($addressDistrict, $jobMarketDistrict);
}
public function getCompanyProfileSimple(CompanyProfile $companyProfileSrc = null)
{
if (empty($companyProfileSrc)) {
return null;
}
$companyProfileSimple = new CompanyProfileSimple();
$companyProfileSimple->setId($companyProfileSrc->getId());
$companyProfileSimple->setUuid($companyProfileSrc->getUuid());
$companyProfileSimple->setName($companyProfileSrc->getName());
return $companyProfileSimple;
}
private function getCompanyLocationAddressDistrict(CompanyLocation $location)
{
$address = $location->getAddress();
if (empty($address)) {
return null;
}
return $this->addressHelper->getAddressDistrict($address);
}
private function getJobMarketAddressDistricts(JobMarket $jobMarket)
{
$addresses = $jobMarket->getAddresses();
if (empty($addresses)) {
return null;
}
$districts = array();
foreach ($addresses as $address) {
$district = $this->addressHelper->getAddressDistrict($address);
$districts[] = $district;
}
return $districts;
}
private function addJobEducationCompanies(JobGQL $job)
{
$companyProfiles = $this->jobHelper->getCompanyProfilesByJobID($job->getId());
foreach ($companyProfiles as $companyProfile) {
$companyProfileSimple = $this->getCompanyProfileSimple($companyProfile);
$job->addJobEducationCompany($companyProfileSimple);
}
}
public function getJobRequirement(JobRequirement $jobRequirementSrc)
{
$jobRequirement = new JobRequirementGQL();
$jobRequirement->setId($jobRequirementSrc->getId());
$jobRequirement->setBicID($jobRequirementSrc->getBicID());
$jobRequirement->setRequirementName($jobRequirementSrc->getRequirementName());
$jobRequirement->setDescription($jobRequirementSrc->getDescription());
return $jobRequirement;
}
public function getJobRequirementTypeByRequirement(JobRequirement $jobRequirementSrc)
{
/* @var $requirementTypeSrc JobRequirementType */
$requirementTypeSrc = $jobRequirementSrc->getJobRequirementType();
$requirementTypeGQL = new JobRequirementTypeGQL();
$requirementTypeGQL->setId($requirementTypeSrc->getId());
$requirementTypeGQL->setBicID($requirementTypeSrc->getBicID());
$requirementTypeGQL->setTypeName($requirementTypeSrc->getTypeName());
$requirementTypeGQL->setShortName($requirementTypeSrc->getShortName());
return $requirementTypeGQL;
}
public function getJobRequirementType(JobRequirementType $jobRequirementType)
{
$requirementTypeGQL = new JobRequirementTypeGQL();
$requirementTypeGQL->setId($jobRequirementType->getId());
$requirementTypeGQL->setBicID($jobRequirementType->getBicID());
$requirementTypeGQL->setTypeName($jobRequirementType->getTypeName());
$requirementTypeGQL->setShortName($jobRequirementType->getShortName());
return $requirementTypeGQL;
}
}