<?php
namespace App\BackendBundle\Helper;
use DateTime;
use ErrorException;
use Doctrine\ORM\EntityManagerInterface;
use App\BackendBundle\Helper\AddressHelper;
use App\BackendBundle\Helper\GraphQlCommonHelper;
use App\BackendBundle\Helper\JobHelper;
use App\BackendBundle\Helper\JobMarketHelper;
use App\BackendBundle\Helper\MediaHelper;
use App\BackendBundle\Helper\StoryHelper;
use App\BackendBundle\Helper\VideoHelper;
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\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\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\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) {
if (empty($dateTime)) {
return '';
}
return $dateTime->format("d.m.Y");
}
public function getJobsByProfile(ProfileInterface $profile) {
$jobsGQL = array();
$profileJobs = $profile->getJobs();
foreach ($profileJobs as $profileJob) {
$jobsGQL[] = $this->getJobGQL($profileJob);
}
return $jobsGQL;
}
public function getJobSimple(Job $jobSrc) {
if (empty($jobSrc)) {
return null;
}
$jobSimple = new JobSimpleGQL();
$jobSimple->setId($jobSrc->getId());
$jobSimple->setName($jobSrc->getName());
$jobSimple->setBicID($jobSrc->getBicID());
$this->addJobSimpleInterestFields($jobSrc, $jobSimple);
return $jobSimple;
}
private function addJobSimpleInterestFields(Job $jobSrc, JobSimpleGQL $job) {
$interestFields = $jobSrc->getInterestFields();
/* @var $interestFielSrc InterestField */
foreach ($interestFields as $interestFieldSrc) {
$interestField = new InterestFieldGQL();
$interestField->setId($interestFieldSrc->getId());
$interestField->setInterestName($interestFieldSrc->getInterestName());
$job->addInterestField($interestField);
}
}
public function getJobGQL(Job $job, $setVideoUrl = false) {
$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) {
$scholasticDuration = $jobSrc->getScholasticDuration();
if (empty($scholasticDuration)) {
return null;
}
$scholasticDurationGQL = new JobScholasticDurationGQL();
$scholasticDurationGQL->setId($scholasticDuration->getId());
$scholasticDurationGQL->setDurationName($scholasticDuration->getDurationName());
$scholasticDurationGQL->setPosition($scholasticDuration->getPosition());
$job->setScholasticDuration($scholasticDurationGQL);
}
private function getVideoUrl(Job $jobSrc) {
$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) {
$job = new JobGQL();
$job->setId($jobSrc->getId());
$job->setBicID($jobSrc->getBicID());
$job->setName($jobSrc->getName());
return $job;
}
private function addInterestFields(Job $jobSrc, JobGQL $job) {
$interestFields = $jobSrc->getInterestFields();
/* @var $interestFielSrc InterestField */
foreach ($interestFields as $interestFieldSrc) {
$interestField = new InterestFieldGQL();
$interestField->setId($interestFieldSrc->getId());
$interestField->setInterestName($interestFieldSrc->getInterestName());
$job->addInterestField($interestField);
}
}
private function addJobEducationalPaths(Job $jobSrc, JobGQL $job) {
$educationalPaths = $jobSrc->getJobEducationalPaths();
foreach ($educationalPaths as $educationalPath) {
$jobEducationalPath = new JobEducationalPathGQL();
$jobEducationalPath->setJobEducationalPathData($educationalPath);
$job->addJobEducationalPath($jobEducationalPath);
}
}
private function addJobExpertTerms(Job $jobSrc, JobGQL $job) {
$expertTerms = $jobSrc->getJobExpertTerms();
foreach ($expertTerms as $expertTermSrc) {
$expertTerm = new JobExpertTermGQL();
$expertTerm->setExpertTermData($expertTermSrc);
$job->addExpertTerm($expertTerm);
}
}
private function addJobRedirects(Job $job, JobGQL $jobGQL) {
$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) {
/* @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) {
/* @var $type JobRedirectType */
$type = $redirect->getJobRedirectType();
return $type->getTypeName();
}
private function addJobSalary(Job $jobSrc, JobGQL $job) {
/* @var $jobSalary JobSalary */
$jobSalary = $jobSrc->getSalary();
if (empty($jobSalary)) {
return;
}
$jobSalaryGQL = new JobSalaryGQL();
$jobSalaryGQL->setId($jobSalary->getId());
$jobSalaryGQL->getCreatedAt($jobSalary->getCreatedAt()->format('d.m.Y'));
$this->addJobSalaryEntries($jobSalary, $jobSalaryGQL);
$job->setJobSalary($jobSalaryGQL);
}
private function addJobSalaryEntries(JobSalary $jobSalary, JobSalaryGQL $jobSalaryGQL) {
$entries = $jobSalary->getEntries();
/* @var $entry JobSalaryEntry */
foreach ($entries as $entry) {
$entryGQL = new JobSalaryEntryGQL();
$entryGQL->setId($entry->getId());
$entryGQL->setSalaryFrom($entry->getSalaryFrom());
$entryGQL->setSalaryTo($entry->getSalaryTo());
$entryGQL->setUrlExt($entry->getUrlExt());
$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 getJobSalaryTypeString(JobSalaryType $salaryType) {
$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) {
/* @var $salaryType JobSalaryType */
$salaryType = $entry->getSalaryType();
if ($salaryType->getId() != 5) {
return;
}
$jobSalaryGQL->setEntryValue($entry->getSalaryFrom());
}
private function addJobSectors(Job $jobSrc, JobGQL $job) {
$sectors = $jobSrc->getJobSectors();
foreach ($sectors as $sector) {
$jobSector = new JobSectorGQL();
$jobSector->setJobSectorData($sector);
$job->addJobSector($jobSector);
}
}
private function addJobSchools(Job $jobSrc, JobGQL $job) {
$jobSchools = $jobSrc->getJobSchools();
/* @var $jobSchool JobSchool */
foreach ($jobSchools as $jobSchool) {
$jobSchoolGQL = new JobSchoolGQL();
$jobSchoolGQL->setId($jobSchool->getId());
$school = $jobSchool->getSchool();
$schoolGQL = $this->getSchoolGQL($school);
$jobSchoolGQL->setSchool($schoolGQL);
$job->addJobSchool($jobSchoolGQL);
}
}
/* function getSchoolGQL implemented here, to prevent circular reference with
* GraphQLSchoolHelper */
public function getSchoolGQL(School $school) {
$schoolGQL = new SchoolGQL();
$schoolGQL->setId($school->getId());
$schoolGQL->setName($school->getName());
$schoolGQL->setUrl($school->getUrl());
$addressSrc = $school->getAddress();
$address = $this->graphqlCommonHelper->getAddress($addressSrc);
$schoolGQL->setAddress($address);
$commSrc = $school->getCommunication();
$comm = $this->graphqlCommonHelper->getCommunication($commSrc);
$schoolGQL->setCommunication($comm);
return $schoolGQL;
}
private function addJobSchoolSubjectMappings(Job $jobSrc, JobGQL $job) {
$jobSubjectMappings = $jobSrc->getSchoolSubjectMappings();
/* @var $jobSubjectMappingSrc JobSchoolSubjectMapping */
foreach ($jobSubjectMappings as $jobSubjectMappingSrc) {
$jobSubjectMapping = $this->getJobSchoolSubjectMapping($jobSubjectMappingSrc);
$job->addSchoolSubjectMapping($jobSubjectMapping);
}
}
public function getJobSchoolSubjectMapping(JobSchoolSubjectMapping $subjectMappingSrc) {
$jobSubjectMapping = new JobSchoolSubjectMappingGQL();
$jobSubjectMapping->setId($subjectMappingSrc->getId());
$jobSchoolSubject = $this->getJobSchoolSubject($subjectMappingSrc->getJobSchoolSubject());
$jobSubjectMapping->setJobSchoolSubject($jobSchoolSubject);
return $jobSubjectMapping;
}
public function getJobSchoolSubject(JobSchoolSubject $subjectSrc) {
$jobSchoolSubject = new JobSchoolSubjectGQL();
$jobSchoolSubject->setId($subjectSrc->getId());
$jobSchoolSubject->setSubjectName($subjectSrc->getSubjectName());
$jobSchoolSubject->setAbbreviation($subjectSrc->getAbbreviation());
return $jobSchoolSubject;
}
private function addJobWorkFields(Job $jobSrc, JobGQL $job) {
$workFields = $jobSrc->getJobWorkFields();
foreach ($workFields as $workField) {
$jobWorkField = new JobWorkFieldGQL();
$jobWorkField->setJobWorkFieldData($workField);
$job->addJobWorkField($jobWorkField);
}
}
private function addRequirementsByType(Job $jobSrc, JobGQL $job) {
$requirementMappings = $jobSrc->getJobRequirementMappings();
$jobRequirementCollection = new JobRequirementCollectionGQL();
/* @var $requirementMapping JobRequirementMapping */
foreach ($requirementMappings as $requirementMapping) {
$jobRequirementSrc = $requirementMapping->getJobRequirement();
$requirementType = $this->getJobRequirementType($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);
}
$job->setRequirementsByType($jobRequirementCollection);
}
private function addSearchTags(Job $jobSrc, JobGQL $job) {
$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) {
$image = $this->graphqlCommonHelper->generateThumbnails($jobSrc->getTeaserImage());
$job->setImage($image);
}
private function addJobMarketDistricts(Job $jobSrc, JobGQL $job) {
$jobMarketDistricts = $this->getJobMarketDistricts($jobSrc);
$job->setJobMarketDistricts($jobMarketDistricts);
}
private function addJobVideoUrl(Job $jobSrc, JobGQL $job, $setVideoUrl) {
if (!$setVideoUrl) {
return;
}
$videoUrl = $this->getVideoUrl($jobSrc);
$job->setVideoUrl($videoUrl);
}
private function addJobPDFUrl(Job $jobSrc, JobGQL $job) {
/* @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) {
$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) {
$linkMappings = $jobSrc->getJobLinkMappings();
/* @var $linkMapping JobLinkMapping */
foreach ($linkMappings as $linkMapping) {
$this->addJobLinkMapping($job, $linkMapping);
}
}
private function addJobLinkMapping(JobGQL $job, JobLinkMapping $linkMapping) {
$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);
$job->addJobLinkMapping($jobLinkMapping);
}
private function getJobLink(JobLinkMapping $linkMapping) {
/* @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 getJobRequirementType(JobRequirement $jobRequirementSrc) {
/* @var $requirementTypeSrc JobRequirementType */
$requirementTypeSrc = $jobRequirementSrc->getJobRequirementType();
$requirementType = new JobRequirementTypeGQL();
$requirementType->setId($requirementTypeSrc->getId());
$requirementType->setBicID($requirementTypeSrc->getBicID());
$typeName = $requirementTypeSrc->getTypeName();
if (empty($typeName)) {
throw new ErrorException("empty typename: ");
}
$requirementType->setTypeName($typeName);
return $requirementType;
}
}