src/BackendBundle/Helper/GraphQlJobHelper.php line 79

Open in your IDE?
  1. <?php
  2. namespace App\BackendBundle\Helper;
  3. use DateTime;
  4. use ErrorException;
  5. use Doctrine\ORM\EntityManagerInterface;
  6. use App\BackendBundle\Helper\AddressHelper;
  7. use App\BackendBundle\Helper\GraphQlCommonHelper;
  8. use App\BackendBundle\Helper\JobHelper;
  9. use App\BackendBundle\Helper\JobMarketHelper;
  10. use App\BackendBundle\Helper\MediaHelper;
  11. use App\BackendBundle\Helper\StoryHelper;
  12. use App\BackendBundle\Helper\VideoHelper;
  13. use App\BackendBundle\Interfaces\ProfileInterface;
  14. use App\BackendBundle\Model\GraphQL\CompanyProfileSimple;
  15. use App\BackendBundle\Model\GraphQL\InterestField as InterestFieldGQL;
  16. use App\BackendBundle\Model\GraphQL\Job as JobGQL;
  17. use App\BackendBundle\Model\GraphQL\JobEducationalPath as JobEducationalPathGQL;
  18. use App\BackendBundle\Model\GraphQL\JobExpertTerm as JobExpertTermGQL;
  19. use App\BackendBundle\Model\GraphQL\JobLinkMapping as JobLinkMappingGQL;
  20. use App\BackendBundle\Model\GraphQL\JobLinkMappingCategory as JobLinkMappingCategoryGQL;
  21. use App\BackendBundle\Model\GraphQL\JobLinkMappingType as JobLinkMappingTypeGQL;
  22. use App\BackendBundle\Model\GraphQL\JobLink as JobLinkGQL;
  23. use App\BackendBundle\Model\GraphQL\JobMarketDistricts as JobMarketDistrictsGQL;
  24. use App\BackendBundle\Model\GraphQL\JobMarketDistrict as JobMarketDistrictGQL;
  25. use App\BackendBundle\Model\GraphQL\JobSimple as JobSimpleGQL;
  26. use App\BackendBundle\Model\GraphQL\JobRedirect as JobRedirectGQL;
  27. use App\BackendBundle\Model\GraphQL\JobRequirement as JobRequirementGQL;
  28. use App\BackendBundle\Model\GraphQL\JobRequirementCollection as JobRequirementCollectionGQL;
  29. use App\BackendBundle\Model\GraphQL\JobRequirementType as JobRequirementTypeGQL;
  30. use App\BackendBundle\Model\GraphQL\JobRequirementTypeCollection as JobRequirementTypeCollectionGQL;
  31. use App\BackendBundle\Model\GraphQL\JobSalary as JobSalaryGQL;
  32. use App\BackendBundle\Model\GraphQL\JobSalaryEntry as JobSalaryEntryGQL;
  33. use App\BackendBundle\Model\GraphQL\JobSchool as JobSchoolGQL;
  34. use App\BackendBundle\Model\GraphQL\JobScholasticDuration as JobScholasticDurationGQL;
  35. use App\BackendBundle\Model\GraphQL\JobSchoolSubjectMapping as JobSchoolSubjectMappingGQL;
  36. use App\BackendBundle\Model\GraphQL\JobSchoolSubject as JobSchoolSubjectGQL;
  37. use App\BackendBundle\Model\GraphQL\JobSector as JobSectorGQL;
  38. use App\BackendBundle\Model\GraphQL\JobWorkField as JobWorkFieldGQL;
  39. use App\BackendBundle\Model\GraphQL\School as SchoolGQL;
  40. use App\Entity\AddressDistrict;
  41. use App\Entity\CompanyProfile;
  42. use App\Entity\CompanyLocation;
  43. use App\Entity\InterestField;
  44. use App\Entity\Job;
  45. use App\Entity\JobDailyRoutine;
  46. use App\Entity\JobLink;
  47. use App\Entity\JobLinkMapping;
  48. use App\Entity\JobLinkMappingCategory;
  49. use App\Entity\JobLinkMappingType;
  50. use App\Entity\JobMarket;
  51. use App\Entity\JobPDF;
  52. use App\Entity\JobRedirect;
  53. use App\Entity\JobRedirectType;
  54. use App\Entity\JobRequirement;
  55. use App\Entity\JobRequirementMapping;
  56. use App\Entity\JobRequirementType;
  57. use App\Entity\JobSalary;
  58. use App\Entity\JobSalaryEntry;
  59. use App\Entity\JobSalaryType;
  60. use App\Entity\JobSchool;
  61. use App\Entity\JobSchoolSubjectMapping;
  62. use App\Entity\JobSchoolSubject;
  63. use App\Entity\School;
  64. use App\Entity\SearchTag;
  65. class GraphQlJobHelper {
  66.     private EntityManagerInterface $em;
  67.     private GraphQlCommonHelper $graphqlCommonHelper;
  68.     private JobHelper $jobHelper;
  69.     private JobMarketHelper $jobMarketHelper;
  70.     private MediaHelper $mediaHelper;
  71.     private StoryHelper $storyHelper;
  72.     private VideoHelper $videoHelper;
  73.     private $backendDomain;
  74.     public function __construct(EntityManagerInterface $emAddressHelper $addressHelperGraphQlCommonHelper $graphqlCommonHelper,
  75.             JobMarketHelper $jobMarketHelperJobHelper $jobHelperMediaHelper $mediaHelperStoryHelper $storyHelper,
  76.             VideoHelper $videoHelper$backendDomain) {
  77.         $this->em $em;
  78.         $this->addressHelper $addressHelper;
  79.         $this->graphqlCommonHelper $graphqlCommonHelper;
  80.         $this->jobHelper $jobHelper;
  81.         $this->jobMarketHelper $jobMarketHelper;
  82.         $this->mediaHelper $mediaHelper;
  83.         $this->storyHelper $storyHelper;
  84.         $this->videoHelper $videoHelper;
  85.         $this->backendDomain $backendDomain;
  86.     }
  87.     public function getDateString(DateTime $dateTime null) {
  88.         if (empty($dateTime)) {
  89.             return '';
  90.         }
  91.         return $dateTime->format("d.m.Y");
  92.     }
  93.     public function getJobsByProfile(ProfileInterface $profile) {
  94.         $jobsGQL = array();
  95.         $profileJobs $profile->getJobs();
  96.         foreach ($profileJobs as $profileJob) {
  97.             $jobsGQL[] = $this->getJobGQL($profileJob);
  98.         }
  99.         return $jobsGQL;
  100.     }
  101.     public function getJobSimple(Job $jobSrc) {
  102.         if (empty($jobSrc)) {
  103.             return null;
  104.         }
  105.         $jobSimple = new JobSimpleGQL();
  106.         $jobSimple->setId($jobSrc->getId());
  107.         $jobSimple->setName($jobSrc->getName());
  108.         $jobSimple->setBicID($jobSrc->getBicID());
  109.         $this->addJobSimpleInterestFields($jobSrc$jobSimple);
  110.         return $jobSimple;
  111.     }
  112.     private function addJobSimpleInterestFields(Job $jobSrcJobSimpleGQL $job) {
  113.         $interestFields $jobSrc->getInterestFields();
  114.         /* @var $interestFielSrc InterestField */
  115.         foreach ($interestFields as $interestFieldSrc) {
  116.             $interestField = new InterestFieldGQL();
  117.             $interestField->setId($interestFieldSrc->getId());
  118.             $interestField->setInterestName($interestFieldSrc->getInterestName());
  119.             $job->addInterestField($interestField);
  120.         }
  121.     }
  122.     public function getJobGQL(Job $job$setVideoUrl false) {
  123.         $jobGQL = new JobGQL();
  124.         $jobGQL->setId($job->getId());
  125.         $jobGQL->setBicID($job->getBicID());
  126.         $jobGQL->setName($job->getName());
  127.         $jobGQL->setDescription($job->getDescription());
  128.         $jobGQL->setBicAnforderungen($job->getBicAnforderungen());
  129.         $jobGQL->setBicAlternativen($job->getBicAlternativen());
  130.         $jobGQL->setOperationsAndTasks($job->getOperationsAndTasks());
  131.         $jobGQL->setBicAusbildungBerufschule($job->getBicAusbildungBerufschule());
  132.         $jobGQL->setBicMoeglichkeiten($job->getBicMoeglichkeiten());
  133.         $this->setScholasticDuration($job$jobGQL);
  134.         $this->addInterestFields($job$jobGQL);
  135.         $this->addJobEducationalPaths($job$jobGQL);
  136.         $this->addJobEducationCompanies($jobGQL);
  137.         $this->addJobExpertTerms($job$jobGQL);
  138.         $this->addJobImage($job$jobGQL);
  139.         $this->addJobInsights($job$jobGQL);
  140.         $this->addJobLinkMappings($job$jobGQL);
  141.         $this->addJobMarketDistricts($job$jobGQL);
  142.         $this->addJobRedirects($job$jobGQL);
  143.         $this->addJobSalary($job$jobGQL);
  144.         $this->addJobSectors($job$jobGQL);
  145.         $this->addJobSchools($job$jobGQL);
  146.         $this->addJobSchoolSubjectMappings($job$jobGQL);
  147.         $this->addJobWorkFields($job$jobGQL);
  148.         $this->addJobVideoUrl($job$jobGQL$setVideoUrl);
  149.         $this->addJobPDFUrl($job$jobGQL);
  150.         $this->addRequirementsByType($job$jobGQL);
  151.         $this->addSearchTags($job$jobGQL);
  152.         return $jobGQL;
  153.     }
  154.     private function setScholasticDuration(Job $jobSrcJobGQL $job) {
  155.         $scholasticDuration $jobSrc->getScholasticDuration();
  156.         if (empty($scholasticDuration)) {
  157.             return null;
  158.         }
  159.         $scholasticDurationGQL = new JobScholasticDurationGQL();
  160.         $scholasticDurationGQL->setId($scholasticDuration->getId());
  161.         $scholasticDurationGQL->setDurationName($scholasticDuration->getDurationName());
  162.         $scholasticDurationGQL->setPosition($scholasticDuration->getPosition());
  163.         $job->setScholasticDuration($scholasticDurationGQL);
  164.     }
  165.     private function getVideoUrl(Job $jobSrc) {
  166.         $jobDailyRoutines $this->jobHelper->getJobDailyRoutinesByJobVisible($jobSrc);
  167.         if (count($jobDailyRoutines) == 0) {
  168.             return null;
  169.         }
  170.         /* @var $jobDailyRoutine JobDailyRoutine */
  171.         $jobDailyRoutine $jobDailyRoutines[0];
  172.         return $jobDailyRoutine->getVideoUrl();
  173.     }
  174.     public function getJobReduced(Job $jobSrc) {
  175.         $job = new JobGQL();
  176.         $job->setId($jobSrc->getId());
  177.         $job->setBicID($jobSrc->getBicID());
  178.         $job->setName($jobSrc->getName());
  179.         return $job;
  180.     }
  181.     private function addInterestFields(Job $jobSrcJobGQL $job) {
  182.         $interestFields $jobSrc->getInterestFields();
  183.         /* @var $interestFielSrc InterestField */
  184.         foreach ($interestFields as $interestFieldSrc) {
  185.             $interestField = new InterestFieldGQL();
  186.             $interestField->setId($interestFieldSrc->getId());
  187.             $interestField->setInterestName($interestFieldSrc->getInterestName());
  188.             $job->addInterestField($interestField);
  189.         }
  190.     }
  191.     private function addJobEducationalPaths(Job $jobSrcJobGQL $job) {
  192.         $educationalPaths $jobSrc->getJobEducationalPaths();
  193.         foreach ($educationalPaths as $educationalPath) {
  194.             $jobEducationalPath = new JobEducationalPathGQL();
  195.             $jobEducationalPath->setJobEducationalPathData($educationalPath);
  196.             $job->addJobEducationalPath($jobEducationalPath);
  197.         }
  198.     }
  199.     private function addJobExpertTerms(Job $jobSrcJobGQL $job) {
  200.         $expertTerms $jobSrc->getJobExpertTerms();
  201.         foreach ($expertTerms as $expertTermSrc) {
  202.             $expertTerm = new JobExpertTermGQL();
  203.             $expertTerm->setExpertTermData($expertTermSrc);
  204.             $job->addExpertTerm($expertTerm);
  205.         }
  206.     }
  207.     private function addJobRedirects(Job $jobJobGQL $jobGQL) {
  208.         $jobRedirects $job->getJobRedirects();
  209.         /* @var $jobRedirect JobRedirect */
  210.         foreach ($jobRedirects as $jobRedirect) {
  211.             $jobRedirectGQL $this->prepareJobRedirectGQL($jobRedirect);
  212.             if (empty($jobRedirectGQL)) {
  213.                 continue;
  214.             }
  215.             $jobGQL->addJobRedirect($jobRedirectGQL);
  216.         }
  217.     }
  218.     public function prepareJobRedirectGQL(JobRedirect $jobRedirect) {
  219.         /* @var $job Job */
  220.         $job $jobRedirect->getDestJob();
  221.         if (empty($job)) {
  222.             return null;
  223.         }
  224.         $bicID $job->getBicID();
  225.         if (empty($bicID)) {
  226.             return null;
  227.         }
  228.         $jobRedirectGQL = new JobRedirectGQL();
  229.         $jobRedirectGQL->setBicID($bicID);
  230.         $jobRedirectGQL->setJobName($job->getName());
  231.         $strType $this->getJobRedirectTypeString($jobRedirect);
  232.         $jobRedirectGQL->setRedirectType($strType);
  233.         return $jobRedirectGQL;
  234.     }
  235.     private function getJobRedirectTypeString(JobRedirect $redirect) {
  236.         /* @var $type JobRedirectType */
  237.         $type $redirect->getJobRedirectType();
  238.         return $type->getTypeName();
  239.     }
  240.     private function addJobSalary(Job $jobSrcJobGQL $job) {
  241.         /* @var $jobSalary JobSalary */
  242.         $jobSalary $jobSrc->getSalary();
  243.         if (empty($jobSalary)) {
  244.             return;
  245.         }
  246.         $jobSalaryGQL = new JobSalaryGQL();
  247.         $jobSalaryGQL->setId($jobSalary->getId());
  248.         $jobSalaryGQL->getCreatedAt($jobSalary->getCreatedAt()->format('d.m.Y'));
  249.         $this->addJobSalaryEntries($jobSalary$jobSalaryGQL);
  250.         $job->setJobSalary($jobSalaryGQL);
  251.     }
  252.     private function addJobSalaryEntries(JobSalary $jobSalaryJobSalaryGQL $jobSalaryGQL) {
  253.         $entries $jobSalary->getEntries();
  254.         /* @var $entry JobSalaryEntry */
  255.         foreach ($entries as $entry) {
  256.             $entryGQL = new JobSalaryEntryGQL();
  257.             $entryGQL->setId($entry->getId());
  258.             $strSalaryFrom $this->getSalaryString($entry->getSalaryFrom());
  259.             $entryGQL->setSalaryFrom($strSalaryFrom);
  260.             $strSalaryTo $this->getSalaryString($entry->getSalaryTo());
  261.             $entryGQL->setSalaryTo($strSalaryTo);
  262.             $entryGQL->setUrlExt($entry->getUrlExt());
  263.             $entryGQL->setCreatedAt($entry->getCreatedAt()->format('d.m.Y'));
  264.             $salaryType $entry->getSalaryType();
  265.             $salaryTypeGQL $this->getJobSalaryTypeString($salaryType);
  266.             $entryGQL->setSalaryType($salaryTypeGQL);
  267.             $this->setJobSalaryEntryValue($jobSalaryGQL$entry);
  268.             $jobSalaryGQL->addEntry($entryGQL);
  269.         }
  270.     }
  271.     private function getSalaryString($dbString) {
  272.         if ($dbString == 'null') {
  273.             return null;
  274.         }
  275.         return $dbString;
  276.     }
  277.     private function getJobSalaryTypeString(JobSalaryType $salaryType) {
  278.         $typeID $salaryType->getId();
  279.         switch ($typeID) {
  280.             case 1:
  281.                 return "YROA1";
  282.             case 2:
  283.                 return "YROA2";
  284.             case 3:
  285.                 return "YROA3";
  286.             case 4:
  287.                 return "YROA4";
  288.             case 5:
  289.                 return "ENTRY";
  290.         }
  291.         return "";
  292.     }
  293.     private function setJobSalaryEntryValue(JobSalaryGQL $jobSalaryGQLJobSalaryEntry $entry) {
  294.         /* @var $salaryType JobSalaryType */
  295.         $salaryType $entry->getSalaryType();
  296.         if ($salaryType->getId() != 5) {
  297.             return;
  298.         }
  299.         $jobSalaryGQL->setEntryValue($entry->getSalaryFrom());
  300.     }
  301.     private function addJobSectors(Job $jobSrcJobGQL $job) {
  302.         $sectors $jobSrc->getJobSectors();
  303.         foreach ($sectors as $sector) {
  304.             $jobSector = new JobSectorGQL();
  305.             $jobSector->setJobSectorData($sector);
  306.             $job->addJobSector($jobSector);
  307.         }
  308.     }
  309.     private function addJobSchools(Job $jobSrcJobGQL $job) {
  310.         $jobSchools $jobSrc->getJobSchools();
  311.         /* @var $jobSchool JobSchool */
  312.         foreach ($jobSchools as $jobSchool) {
  313.             $jobSchoolGQL = new JobSchoolGQL();
  314.             $jobSchoolGQL->setId($jobSchool->getId());
  315.             $school $jobSchool->getSchool();
  316.             $schoolGQL $this->getSchoolGQL($school);
  317.             $jobSchoolGQL->setSchool($schoolGQL);
  318.             $job->addJobSchool($jobSchoolGQL);
  319.         }
  320.     }
  321.     /* function getSchoolGQL implemented here, to prevent circular reference with 
  322.      * GraphQLSchoolHelper */
  323.     public function getSchoolGQL(School $school) {
  324.         $schoolGQL = new SchoolGQL();
  325.         $schoolGQL->setId($school->getId());
  326.         $schoolGQL->setName($school->getName());
  327.         $schoolGQL->setUrl($school->getUrl());
  328.         $addressSrc $school->getAddress();
  329.         $address $this->graphqlCommonHelper->getAddress($addressSrc);
  330.         $schoolGQL->setAddress($address);
  331.         $commSrc $school->getCommunication();
  332.         $comm $this->graphqlCommonHelper->getCommunication($commSrc);
  333.         $schoolGQL->setCommunication($comm);
  334.         return $schoolGQL;
  335.     }
  336.     private function addJobSchoolSubjectMappings(Job $jobSrcJobGQL $job) {
  337.         $jobSubjectMappings $jobSrc->getSchoolSubjectMappings();
  338.         /* @var $jobSubjectMappingSrc JobSchoolSubjectMapping */
  339.         foreach ($jobSubjectMappings as $jobSubjectMappingSrc) {
  340.             $jobSubjectMapping $this->getJobSchoolSubjectMapping($jobSubjectMappingSrc);
  341.             $job->addSchoolSubjectMapping($jobSubjectMapping);
  342.         }
  343.     }
  344.     public function getJobSchoolSubjectMapping(JobSchoolSubjectMapping $subjectMappingSrc) {
  345.         $jobSubjectMapping = new JobSchoolSubjectMappingGQL();
  346.         $jobSubjectMapping->setId($subjectMappingSrc->getId());
  347.         $jobSchoolSubject $this->getJobSchoolSubject($subjectMappingSrc->getJobSchoolSubject());
  348.         $jobSubjectMapping->setJobSchoolSubject($jobSchoolSubject);
  349.         return $jobSubjectMapping;
  350.     }
  351.     public function getJobSchoolSubject(JobSchoolSubject $subjectSrc) {
  352.         $jobSchoolSubject = new JobSchoolSubjectGQL();
  353.         $jobSchoolSubject->setId($subjectSrc->getId());
  354.         $jobSchoolSubject->setSubjectName($subjectSrc->getSubjectName());
  355.         $jobSchoolSubject->setAbbreviation($subjectSrc->getAbbreviation());
  356.         return $jobSchoolSubject;
  357.     }
  358.     private function addJobWorkFields(Job $jobSrcJobGQL $job) {
  359.         $workFields $jobSrc->getJobWorkFields();
  360.         foreach ($workFields as $workField) {
  361.             $jobWorkField = new JobWorkFieldGQL();
  362.             $jobWorkField->setJobWorkFieldData($workField);
  363.             $job->addJobWorkField($jobWorkField);
  364.         }
  365.     }
  366.     private function addRequirementsByType(Job $jobSrcJobGQL $job) {
  367.         $requirementMappings $jobSrc->getJobRequirementMappings();
  368.         $jobRequirementCollection = new JobRequirementCollectionGQL();
  369.         /* @var $requirementMapping JobRequirementMapping */
  370.         foreach ($requirementMappings as $requirementMapping) {
  371.             $jobRequirementSrc $requirementMapping->getJobRequirement();
  372.             $requirementType $this->getJobRequirementType($jobRequirementSrc);
  373.             $requirementTypeID $requirementType->getId();
  374.             $requirementTypeCollection $jobRequirementCollection->getRequirementTypeCollectionByID($requirementTypeID);
  375.             if (empty($requirementTypeCollection)) {
  376.                 $requirementTypeCollection = new JobRequirementTypeCollectionGQL();
  377.                 $requirementTypeCollection->setRequirementType($requirementType);
  378.                 $jobRequirementCollection->addRequirementType($requirementTypeID$requirementTypeCollection);
  379.             }
  380.             $jobRequirement $this->getJobRequirement($jobRequirementSrc);
  381.             $requirementTypeCollection->addRequirement($jobRequirement);
  382.         }
  383.         $job->setRequirementsByType($jobRequirementCollection);
  384.     }
  385.     private function addSearchTags(Job $jobSrcJobGQL $job) {
  386.         $searchTags $jobSrc->getSearchTags();
  387.         if (empty($searchTags)) {
  388.             return;
  389.         }
  390.         /* @var $searchTag SearchTag */
  391.         foreach ($searchTags as $searchTag) {
  392.             $tagName $searchTag->getName();
  393.             $job->addSearchTag($tagName);
  394.         }
  395.     }
  396.     private function addJobImage(Job $jobSrcJobGQL $job) {
  397.         $image $this->graphqlCommonHelper->generateThumbnails($jobSrc->getTeaserImage());
  398.         $job->setImage($image);
  399.     }
  400.     private function addJobMarketDistricts(Job $jobSrcJobGQL $job) {
  401.         $jobMarketDistricts $this->getJobMarketDistricts($jobSrc);
  402.         $job->setJobMarketDistricts($jobMarketDistricts);
  403.     }
  404.     private function addJobVideoUrl(Job $jobSrcJobGQL $job$setVideoUrl) {
  405.         if (!$setVideoUrl) {
  406.             return;
  407.         }
  408.         $videoUrl $this->getVideoUrl($jobSrc);
  409.         $job->setVideoUrl($videoUrl);
  410.     }
  411.     private function addJobPDFUrl(Job $jobSrcJobGQL $job) {
  412.         /* @var $jobPDF JobPDF */
  413.         $jobPDF $jobSrc->getJobPDF();
  414.         if (empty($jobPDF)) {
  415.             return;
  416.         }
  417.         $webPath $jobPDF->getWebPath();
  418.         $pdfUrl $this->backendDomain "$webPath";
  419.         $job->setPdfUrl($pdfUrl);
  420.     }
  421.     private function addJobInsights(Job $jobSrcJobGQL $job) {
  422.         $jobDailyRoutines $this->jobHelper->getJobDailyRoutinesByJobVisible($jobSrc);
  423.         foreach ($jobDailyRoutines as $jobDailyRoutine) {
  424.             $story $this->storyHelper->getStoryByDailyRoutine($jobDailyRoutine);
  425.             if (empty($story)) {
  426.                 continue;
  427.             }
  428.             $job->addInsight($story);
  429.         }
  430.     }
  431.     private function addJobLinkMappings(Job $jobSrcJobGQL $job) {
  432.         $linkMappings $jobSrc->getJobLinkMappings();
  433.         /* @var $linkMapping JobLinkMapping */
  434.         foreach ($linkMappings as $linkMapping) {
  435.             $this->addJobLinkMapping($job$linkMapping);
  436.         }
  437.     }
  438.     private function addJobLinkMapping(JobGQL $jobJobLinkMapping $linkMapping) {
  439.         $jobLinkMapping = new JobLinkMappingGQL();
  440.         $jobLinkMapping->setId($linkMapping->getId());
  441.         $jobLink $this->getJobLink($linkMapping);
  442.         $jobLinkMapping->setJobLink($jobLink);
  443.         $jobLinkMappingCategory $this->getJobLinkCategory($linkMapping);
  444.         $jobLinkMapping->setJobLinkMappingCategory($jobLinkMappingCategory);
  445.         $jobLinkMappingType $this->getJobLinkMappingType($linkMapping);
  446.         $jobLinkMapping->setJobLinkMappingType($jobLinkMappingType);
  447.         $job->addJobLinkMapping($jobLinkMapping);
  448.     }
  449.     private function getJobLink(JobLinkMapping $linkMapping) {
  450.         /* @var $jobLinkSrc JobLink */
  451.         $jobLinkSrc $linkMapping->getJobLink();
  452.         $jobLink = new JobLinkGQL();
  453.         $jobLink->setId($jobLinkSrc->getId());
  454.         $jobLink->setTitle($jobLinkSrc->getTitle());
  455.         $jobLink->setTitleFrontend($jobLinkSrc->getTitleFrontend());
  456.         $jobLink->setTitleBackend($jobLinkSrc->getTitleBackend());
  457.         $jobLink->setUrl($jobLinkSrc->getUrl());
  458.         return $jobLink;
  459.     }
  460.     private function getJobLinkCategory(JobLinkMapping $linkMapping) {
  461.         /* @var $category JobLinkMappingCategory */
  462.         $category $linkMapping->getJobLinkMappingCategory();
  463.         $categoryGQL = new JobLinkMappingCategoryGQL();
  464.         $categoryGQL->setId($category->getId());
  465.         $categoryGQL->setName($category->getName());
  466.         return $categoryGQL;
  467.     }
  468.     private function getJobLinkMappingType(JobLinkMapping $linkMapping) {
  469.         /* @var $type JobLinkMappingType */
  470.         $type $linkMapping->getJobLinkMappingType();
  471.         $linkType = new JobLinkMappingTypeGQL();
  472.         $linkType->setId($type->getId());
  473.         $linkType->setName($type->getName());
  474.         return $linkType;
  475.     }
  476.     private function getJobMarketDistricts(Job $jobSrc) {
  477.         $jobMarketDistricts = new JobMarketDistrictsGQL();
  478.         $this->getJobMarketDistrictCompanies($jobMarketDistricts$jobSrc);
  479.         $this->getJobMarketDistrictJobs($jobMarketDistricts$jobSrc);
  480.         return $jobMarketDistricts;
  481.     }
  482.     private function getJobMarketDistrictCompanies(JobMarketDistrictsGQL $jobMarketDistrictsJob $jobSrc) {
  483.         $companyProfiles $this->jobHelper->getJobTrainingCompanies($jobSrc);
  484.         /* @var $companyProfile CompanyProfile */
  485.         foreach ($companyProfiles as $companyProfile) {
  486.             $this->getJobMarketDistrictCompany($jobMarketDistricts$companyProfile);
  487.         }
  488.     }
  489.     private function getJobMarketDistrictCompany(JobMarketDistrictsGQL $jobMarketDistrictsCompanyProfile $companyProfile) {
  490.         $companyProfileSimple $this->getCompanyProfileSimple($companyProfile);
  491.         $locations $companyProfile->getLocations();
  492.         /* @var $location CompanyLocation */
  493.         foreach ($locations as $location) {
  494.             $addressDistrict $this->getCompanyLocationAddressDistrict($location);
  495.             if (empty($addressDistrict)) {
  496.                 continue;
  497.             }
  498.             $this->checkJobMarketDistrict($jobMarketDistricts$addressDistrict);
  499.             /* @var $jobMarketDistrict JobMarketDistrictGQL */
  500.             $jobMarketDistrict $jobMarketDistricts->getDistrict($addressDistrict);
  501.             $jobMarketDistrict->addTrainingCompany($companyProfileSimple);
  502.         }
  503.     }
  504.     private function getJobMarketDistrictJobs(JobMarketDistrictsGQL $jobMarketDistrictsJob $jobSrc) {
  505.         $jobMarkets $this->jobMarketHelper->getActiveJobOffersByJob($jobSrc);
  506.         if (empty($jobMarkets)) {
  507.             return;
  508.         }
  509.         /* @var $jobMarket JobMarket */
  510.         foreach ($jobMarkets as $jobMarket) {
  511.             $addressDistricts $this->getJobMarketAddressDistricts($jobMarket);
  512.             if (empty($addressDistricts)) {
  513.                 continue;
  514.             }
  515.             foreach ($addressDistricts as $addressDistrict) {
  516.                 $this->checkJobMarketDistrict($jobMarketDistricts$addressDistrict);
  517.                 /* @var $jobMarketDistrict JobMarketDistrictGQL */
  518.                 $jobMarketDistrict $jobMarketDistricts->getDistrict($addressDistrict);
  519.                 $companyProfileSimple $this->getCompanyProfileSimple($jobMarket->getCompanyProfile());
  520.                 $jobMarketDistrict->addJobMarketEntry($companyProfileSimple);
  521.             }
  522.         }
  523.     }
  524.     private function checkJobMarketDistrict(JobMarketDistrictsGQL $jobMarketDistrictsAddressDistrict $addressDistrict) {
  525.         if ($jobMarketDistricts->hasDistrict($addressDistrict)) {
  526.             return;
  527.         }
  528.         $jobMarketDistrict = new JobMarketDistrictGQL();
  529.         $jobMarketDistrict->setDistrictID($addressDistrict->getId());
  530.         $jobMarketDistrict->setDistrictName($addressDistrict->getName());
  531.         $jobMarketDistricts->addDistrict($addressDistrict$jobMarketDistrict);
  532.     }
  533.     public function getCompanyProfileSimple(CompanyProfile $companyProfileSrc null) {
  534.         if (empty($companyProfileSrc)) {
  535.             return null;
  536.         }
  537.         $companyProfileSimple = new CompanyProfileSimple();
  538.         $companyProfileSimple->setId($companyProfileSrc->getId());
  539.         $companyProfileSimple->setUuid($companyProfileSrc->getUuid());
  540.         $companyProfileSimple->setName($companyProfileSrc->getName());
  541.         return $companyProfileSimple;
  542.     }
  543.     private function getCompanyLocationAddressDistrict(CompanyLocation $location) {
  544.         $address $location->getAddress();
  545.         if (empty($address)) {
  546.             return null;
  547.         }
  548.         return $this->addressHelper->getAddressDistrict($address);
  549.     }
  550.     private function getJobMarketAddressDistricts(JobMarket $jobMarket) {
  551.         $addresses $jobMarket->getAddresses();
  552.         if (empty($addresses)) {
  553.             return null;
  554.         }
  555.         $districts = array();
  556.         foreach ($addresses as $address) {
  557.             $district $this->addressHelper->getAddressDistrict($address);
  558.             $districts[] = $district;
  559.         }
  560.         return $districts;
  561.     }
  562.     private function addJobEducationCompanies(JobGQL $job) {
  563.         $companyProfiles $this->jobHelper->getCompanyProfilesByJobID($job->getId());
  564.         foreach ($companyProfiles as $companyProfile) {
  565.             $companyProfileSimple $this->getCompanyProfileSimple($companyProfile);
  566.             $job->addJobEducationCompany($companyProfileSimple);
  567.         }
  568.     }
  569.     public function getJobRequirement(JobRequirement $jobRequirementSrc) {
  570.         $jobRequirement = new JobRequirementGQL();
  571.         $jobRequirement->setId($jobRequirementSrc->getId());
  572.         $jobRequirement->setBicID($jobRequirementSrc->getBicID());
  573.         $jobRequirement->setRequirementName($jobRequirementSrc->getRequirementName());
  574.         $jobRequirement->setDescription($jobRequirementSrc->getDescription());
  575.         return $jobRequirement;
  576.     }
  577.     public function getJobRequirementType(JobRequirement $jobRequirementSrc) {
  578.         /* @var $requirementTypeSrc JobRequirementType */
  579.         $requirementTypeSrc $jobRequirementSrc->getJobRequirementType();
  580.         $requirementType = new JobRequirementTypeGQL();
  581.         $requirementType->setId($requirementTypeSrc->getId());
  582.         $requirementType->setBicID($requirementTypeSrc->getBicID());
  583.         $typeName $requirementTypeSrc->getTypeName();
  584.         if (empty($typeName)) {
  585.             throw new ErrorException("empty typename: ");
  586.         }
  587.         $requirementType->setTypeName($typeName);
  588.         return $requirementType;
  589.     }
  590. }