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.             $entryGQL->setSalaryFrom($entry->getSalaryFrom());
  259.             $entryGQL->setSalaryTo($entry->getSalaryTo());
  260.             $entryGQL->setUrlExt($entry->getUrlExt());
  261.             $entryGQL->setCreatedAt($entry->getCreatedAt()->format('d.m.Y'));
  262.             $salaryType $entry->getSalaryType();
  263.             $salaryTypeGQL $this->getJobSalaryTypeString($salaryType);
  264.             $entryGQL->setSalaryType($salaryTypeGQL);
  265.             $this->setJobSalaryEntryValue($jobSalaryGQL$entry);
  266.             $jobSalaryGQL->addEntry($entryGQL);
  267.         }
  268.     }
  269.     private function getJobSalaryTypeString(JobSalaryType $salaryType) {
  270.         $typeID $salaryType->getId();
  271.         switch ($typeID) {
  272.             case 1:
  273.                 return "YROA1";
  274.             case 2:
  275.                 return "YROA2";
  276.             case 3:
  277.                 return "YROA3";
  278.             case 4:
  279.                 return "YROA4";
  280.             case 5:
  281.                 return "ENTRY";
  282.         }
  283.         return "";
  284.     }
  285.     private function setJobSalaryEntryValue(JobSalaryGQL $jobSalaryGQLJobSalaryEntry $entry) {
  286.         /* @var $salaryType JobSalaryType */
  287.         $salaryType $entry->getSalaryType();
  288.         if ($salaryType->getId() != 5) {
  289.             return;
  290.         }
  291.         $jobSalaryGQL->setEntryValue($entry->getSalaryFrom());
  292.     }
  293.     private function addJobSectors(Job $jobSrcJobGQL $job) {
  294.         $sectors $jobSrc->getJobSectors();
  295.         foreach ($sectors as $sector) {
  296.             $jobSector = new JobSectorGQL();
  297.             $jobSector->setJobSectorData($sector);
  298.             $job->addJobSector($jobSector);
  299.         }
  300.     }
  301.     private function addJobSchools(Job $jobSrcJobGQL $job) {
  302.         $jobSchools $jobSrc->getJobSchools();
  303.         /* @var $jobSchool JobSchool */
  304.         foreach ($jobSchools as $jobSchool) {
  305.             $jobSchoolGQL = new JobSchoolGQL();
  306.             $jobSchoolGQL->setId($jobSchool->getId());
  307.             $school $jobSchool->getSchool();
  308.             $schoolGQL $this->getSchoolGQL($school);
  309.             $jobSchoolGQL->setSchool($schoolGQL);
  310.             $job->addJobSchool($jobSchoolGQL);
  311.         }
  312.     }
  313.     /* function getSchoolGQL implemented here, to prevent circular reference with 
  314.      * GraphQLSchoolHelper */
  315.     public function getSchoolGQL(School $school) {
  316.         $schoolGQL = new SchoolGQL();
  317.         $schoolGQL->setId($school->getId());
  318.         $schoolGQL->setName($school->getName());
  319.         $schoolGQL->setUrl($school->getUrl());
  320.         $addressSrc $school->getAddress();
  321.         $address $this->graphqlCommonHelper->getAddress($addressSrc);
  322.         $schoolGQL->setAddress($address);
  323.         $commSrc $school->getCommunication();
  324.         $comm $this->graphqlCommonHelper->getCommunication($commSrc);
  325.         $schoolGQL->setCommunication($comm);
  326.         return $schoolGQL;
  327.     }
  328.     
  329.     private function addJobSchoolSubjectMappings(Job $jobSrcJobGQL $job) {
  330.         $jobSubjectMappings $jobSrc->getSchoolSubjectMappings();
  331.         /* @var $jobSubjectMappingSrc JobSchoolSubjectMapping */
  332.         foreach ($jobSubjectMappings as $jobSubjectMappingSrc) {
  333.             $jobSubjectMapping $this->getJobSchoolSubjectMapping($jobSubjectMappingSrc);
  334.             $job->addSchoolSubjectMapping($jobSubjectMapping);
  335.         }
  336.     }
  337.     public function getJobSchoolSubjectMapping(JobSchoolSubjectMapping $subjectMappingSrc) {
  338.         $jobSubjectMapping = new JobSchoolSubjectMappingGQL();
  339.         $jobSubjectMapping->setId($subjectMappingSrc->getId());
  340.         $jobSchoolSubject $this->getJobSchoolSubject($subjectMappingSrc->getJobSchoolSubject());
  341.         $jobSubjectMapping->setJobSchoolSubject($jobSchoolSubject);
  342.         return $jobSubjectMapping;
  343.     }
  344.     public function getJobSchoolSubject(JobSchoolSubject $subjectSrc) {
  345.         $jobSchoolSubject = new JobSchoolSubjectGQL();
  346.         $jobSchoolSubject->setId($subjectSrc->getId());
  347.         $jobSchoolSubject->setSubjectName($subjectSrc->getSubjectName());
  348.         $jobSchoolSubject->setAbbreviation($subjectSrc->getAbbreviation());
  349.         return $jobSchoolSubject;
  350.     }
  351.     private function addJobWorkFields(Job $jobSrcJobGQL $job) {
  352.         $workFields $jobSrc->getJobWorkFields();
  353.         foreach ($workFields as $workField) {
  354.             $jobWorkField = new JobWorkFieldGQL();
  355.             $jobWorkField->setJobWorkFieldData($workField);
  356.             $job->addJobWorkField($jobWorkField);
  357.         }
  358.     }
  359.     private function addRequirementsByType(Job $jobSrcJobGQL $job) {
  360.         $requirementMappings $jobSrc->getJobRequirementMappings();
  361.         $jobRequirementCollection = new JobRequirementCollectionGQL();
  362.         /* @var $requirementMapping JobRequirementMapping */
  363.         foreach ($requirementMappings as $requirementMapping) {
  364.             $jobRequirementSrc $requirementMapping->getJobRequirement();
  365.             $requirementType $this->getJobRequirementType($jobRequirementSrc);
  366.             $requirementTypeID $requirementType->getId();
  367.             $requirementTypeCollection $jobRequirementCollection->getRequirementTypeCollectionByID($requirementTypeID);
  368.             if (empty($requirementTypeCollection)) {
  369.                 $requirementTypeCollection = new JobRequirementTypeCollectionGQL();
  370.                 $requirementTypeCollection->setRequirementType($requirementType);
  371.                 $jobRequirementCollection->addRequirementType($requirementTypeID$requirementTypeCollection);
  372.             }
  373.             $jobRequirement $this->getJobRequirement($jobRequirementSrc);
  374.             $requirementTypeCollection->addRequirement($jobRequirement);
  375.         }
  376.         $job->setRequirementsByType($jobRequirementCollection);
  377.     }
  378.     private function addSearchTags(Job $jobSrcJobGQL $job) {
  379.         $searchTags $jobSrc->getSearchTags();
  380.         if (empty($searchTags)) {
  381.             return;
  382.         }
  383.         /* @var $searchTag SearchTag */
  384.         foreach ($searchTags as $searchTag) {
  385.             $tagName $searchTag->getName();
  386.             $job->addSearchTag($tagName);
  387.         }
  388.     }
  389.     private function addJobImage(Job $jobSrcJobGQL $job) {
  390.         $image $this->graphqlCommonHelper->generateThumbnails($jobSrc->getTeaserImage());
  391.         $job->setImage($image);
  392.     }
  393.     private function addJobMarketDistricts(Job $jobSrcJobGQL $job) {
  394.         $jobMarketDistricts $this->getJobMarketDistricts($jobSrc);
  395.         $job->setJobMarketDistricts($jobMarketDistricts);
  396.     }
  397.     private function addJobVideoUrl(Job $jobSrcJobGQL $job$setVideoUrl) {
  398.         if (!$setVideoUrl) {
  399.             return;
  400.         }
  401.         $videoUrl $this->getVideoUrl($jobSrc);
  402.         $job->setVideoUrl($videoUrl);
  403.     }
  404.     private function addJobPDFUrl(Job $jobSrcJobGQL $job) {
  405.         /* @var $jobPDF JobPDF */
  406.         $jobPDF $jobSrc->getJobPDF();
  407.         if (empty($jobPDF)) {
  408.             return;
  409.         }
  410.         $webPath $jobPDF->getWebPath();
  411.         $pdfUrl $this->backendDomain "$webPath";
  412.         $job->setPdfUrl($pdfUrl);
  413.     }
  414.     private function addJobInsights(Job $jobSrcJobGQL $job) {
  415.         $jobDailyRoutines $this->jobHelper->getJobDailyRoutinesByJobVisible($jobSrc);
  416.         foreach ($jobDailyRoutines as $jobDailyRoutine) {
  417.             $story $this->storyHelper->getStoryByDailyRoutine($jobDailyRoutine);
  418.             if (empty($story)) {
  419.                 continue;
  420.             }
  421.             $job->addInsight($story);
  422.         }
  423.     }
  424.     private function addJobLinkMappings(Job $jobSrcJobGQL $job) {
  425.         $linkMappings $jobSrc->getJobLinkMappings();
  426.         /* @var $linkMapping JobLinkMapping */
  427.         foreach ($linkMappings as $linkMapping) {
  428.             $this->addJobLinkMapping($job$linkMapping);
  429.         }
  430.     }
  431.     private function addJobLinkMapping(JobGQL $jobJobLinkMapping $linkMapping) {
  432.         $jobLinkMapping = new JobLinkMappingGQL();
  433.         $jobLinkMapping->setId($linkMapping->getId());
  434.         $jobLink $this->getJobLink($linkMapping);
  435.         $jobLinkMapping->setJobLink($jobLink);
  436.         $jobLinkMappingCategory $this->getJobLinkCategory($linkMapping);
  437.         $jobLinkMapping->setJobLinkMappingCategory($jobLinkMappingCategory);
  438.         $jobLinkMappingType $this->getJobLinkMappingType($linkMapping);
  439.         $jobLinkMapping->setJobLinkMappingType($jobLinkMappingType);
  440.         $job->addJobLinkMapping($jobLinkMapping);
  441.     }
  442.     private function getJobLink(JobLinkMapping $linkMapping) {
  443.         /* @var $jobLinkSrc JobLink */
  444.         $jobLinkSrc $linkMapping->getJobLink();
  445.         $jobLink = new JobLinkGQL();
  446.         $jobLink->setId($jobLinkSrc->getId());
  447.         $jobLink->setTitle($jobLinkSrc->getTitle());
  448.         $jobLink->setTitleFrontend($jobLinkSrc->getTitleFrontend());
  449.         $jobLink->setTitleBackend($jobLinkSrc->getTitleBackend());
  450.         $jobLink->setUrl($jobLinkSrc->getUrl());
  451.         return $jobLink;
  452.     }
  453.     private function getJobLinkCategory(JobLinkMapping $linkMapping) {
  454.         /* @var $category JobLinkMappingCategory */
  455.         $category $linkMapping->getJobLinkMappingCategory();
  456.         $categoryGQL = new JobLinkMappingCategoryGQL();
  457.         $categoryGQL->setId($category->getId());
  458.         $categoryGQL->setName($category->getName());
  459.         return $categoryGQL;
  460.     }
  461.     private function getJobLinkMappingType(JobLinkMapping $linkMapping) {
  462.         /* @var $type JobLinkMappingType */
  463.         $type $linkMapping->getJobLinkMappingType();
  464.         $linkType = new JobLinkMappingTypeGQL();
  465.         $linkType->setId($type->getId());
  466.         $linkType->setName($type->getName());
  467.         return $linkType;
  468.     }
  469.     private function getJobMarketDistricts(Job $jobSrc) {
  470.         $jobMarketDistricts = new JobMarketDistrictsGQL();
  471.         $this->getJobMarketDistrictCompanies($jobMarketDistricts$jobSrc);
  472.         $this->getJobMarketDistrictJobs($jobMarketDistricts$jobSrc);
  473.         return $jobMarketDistricts;
  474.     }
  475.     private function getJobMarketDistrictCompanies(JobMarketDistrictsGQL $jobMarketDistrictsJob $jobSrc) {
  476.         $companyProfiles $this->jobHelper->getJobTrainingCompanies($jobSrc);
  477.         /* @var $companyProfile CompanyProfile */
  478.         foreach ($companyProfiles as $companyProfile) {
  479.             $this->getJobMarketDistrictCompany($jobMarketDistricts$companyProfile);
  480.         }
  481.     }
  482.     private function getJobMarketDistrictCompany(JobMarketDistrictsGQL $jobMarketDistrictsCompanyProfile $companyProfile) {
  483.         $companyProfileSimple $this->getCompanyProfileSimple($companyProfile);
  484.         $locations $companyProfile->getLocations();
  485.         /* @var $location CompanyLocation */
  486.         foreach ($locations as $location) {
  487.             $addressDistrict $this->getCompanyLocationAddressDistrict($location);
  488.             if (empty($addressDistrict)) {
  489.                 continue;
  490.             }
  491.             $this->checkJobMarketDistrict($jobMarketDistricts$addressDistrict);
  492.             /* @var $jobMarketDistrict JobMarketDistrictGQL */
  493.             $jobMarketDistrict $jobMarketDistricts->getDistrict($addressDistrict);
  494.             $jobMarketDistrict->addTrainingCompany($companyProfileSimple);
  495.         }
  496.     }
  497.     private function getJobMarketDistrictJobs(JobMarketDistrictsGQL $jobMarketDistrictsJob $jobSrc) {
  498.         $jobMarkets $this->jobMarketHelper->getActiveJobOffersByJob($jobSrc);
  499.         if (empty($jobMarkets)) {
  500.             return;
  501.         }
  502.         /* @var $jobMarket JobMarket */
  503.         foreach ($jobMarkets as $jobMarket) {
  504.             $addressDistricts $this->getJobMarketAddressDistricts($jobMarket);
  505.             if (empty($addressDistricts)) {
  506.                 continue;
  507.             }
  508.             foreach ($addressDistricts as $addressDistrict) {
  509.                 $this->checkJobMarketDistrict($jobMarketDistricts$addressDistrict);
  510.                 /* @var $jobMarketDistrict JobMarketDistrictGQL */
  511.                 $jobMarketDistrict $jobMarketDistricts->getDistrict($addressDistrict);
  512.                 $companyProfileSimple $this->getCompanyProfileSimple($jobMarket->getCompanyProfile());
  513.                 $jobMarketDistrict->addJobMarketEntry($companyProfileSimple);
  514.             }
  515.         }
  516.     }
  517.     private function checkJobMarketDistrict(JobMarketDistrictsGQL $jobMarketDistrictsAddressDistrict $addressDistrict) {
  518.         if ($jobMarketDistricts->hasDistrict($addressDistrict)) {
  519.             return;
  520.         }
  521.         $jobMarketDistrict = new JobMarketDistrictGQL();
  522.         $jobMarketDistrict->setDistrictID($addressDistrict->getId());
  523.         $jobMarketDistrict->setDistrictName($addressDistrict->getName());
  524.         $jobMarketDistricts->addDistrict($addressDistrict$jobMarketDistrict);
  525.     }
  526.     public function getCompanyProfileSimple(CompanyProfile $companyProfileSrc null) {
  527.         if (empty($companyProfileSrc)) {
  528.             return null;
  529.         }
  530.         $companyProfileSimple = new CompanyProfileSimple();
  531.         $companyProfileSimple->setId($companyProfileSrc->getId());
  532.         $companyProfileSimple->setUuid($companyProfileSrc->getUuid());
  533.         $companyProfileSimple->setName($companyProfileSrc->getName());
  534.         return $companyProfileSimple;
  535.     }
  536.     private function getCompanyLocationAddressDistrict(CompanyLocation $location) {
  537.         $address $location->getAddress();
  538.         if (empty($address)) {
  539.             return null;
  540.         }
  541.         return $this->addressHelper->getAddressDistrict($address);
  542.     }
  543.     private function getJobMarketAddressDistricts(JobMarket $jobMarket) {
  544.         $addresses $jobMarket->getAddresses();
  545.         if (empty($addresses)) {
  546.             return null;
  547.         }
  548.         $districts = array();
  549.         foreach ($addresses as $address) {
  550.             $district $this->addressHelper->getAddressDistrict($address);
  551.             $districts[] = $district;
  552.         }
  553.         return $districts;
  554.     }
  555.     private function addJobEducationCompanies(JobGQL $job) {
  556.         $companyProfiles $this->jobHelper->getCompanyProfilesByJobID($job->getId());
  557.         foreach ($companyProfiles as $companyProfile) {
  558.             $companyProfileSimple $this->getCompanyProfileSimple($companyProfile);
  559.             $job->addJobEducationCompany($companyProfileSimple);
  560.         }
  561.     }
  562.     public function getJobRequirement(JobRequirement $jobRequirementSrc) {
  563.         $jobRequirement = new JobRequirementGQL();
  564.         $jobRequirement->setId($jobRequirementSrc->getId());
  565.         $jobRequirement->setBicID($jobRequirementSrc->getBicID());
  566.         $jobRequirement->setRequirementName($jobRequirementSrc->getRequirementName());
  567.         $jobRequirement->setDescription($jobRequirementSrc->getDescription());
  568.         return $jobRequirement;
  569.     }
  570.     public function getJobRequirementType(JobRequirement $jobRequirementSrc) {
  571.         /* @var $requirementTypeSrc JobRequirementType */
  572.         $requirementTypeSrc $jobRequirementSrc->getJobRequirementType();
  573.         $requirementType = new JobRequirementTypeGQL();
  574.         $requirementType->setId($requirementTypeSrc->getId());
  575.         $requirementType->setBicID($requirementTypeSrc->getBicID());
  576.         $typeName $requirementTypeSrc->getTypeName();
  577.         if (empty($typeName)) {
  578.             throw new ErrorException("empty typename: ");
  579.         }
  580.         $requirementType->setTypeName($typeName);
  581.         return $requirementType;
  582.     }
  583. }