function it_normalizes_job_instance(JobInstance $jobinstance)
 {
     $jobinstance->getCode()->willReturn('product_export');
     $jobinstance->getLabel()->willReturn('Product export');
     $jobinstance->getConnector()->willReturn('myconnector');
     $jobinstance->getType()->willReturn('EXPORT');
     $jobinstance->getRawConfiguration()->willReturn(['delimiter' => ';']);
     $this->normalize($jobinstance)->shouldReturn(['code' => 'product_export', 'label' => 'Product export', 'connector' => 'myconnector', 'type' => 'EXPORT', 'configuration' => ['delimiter' => ';']]);
 }
Exemplo n.º 2
0
 /**
  * To string
  * @return string
  */
 public function __toString()
 {
     $startTime = self::formatDate($this->startTime);
     $endTime = self::formatDate($this->endTime);
     $updatedTime = self::formatDate($this->updatedTime);
     $jobInstanceCode = $this->jobInstance != null ? $this->jobInstance->getCode() : '';
     $message = "startTime=%s, endTime=%s, updatedTime=%s, status=%d, exitStatus=%s, exitDescription=[%s], job=[%s]";
     return sprintf($message, $startTime, $endTime, $updatedTime, $this->status, $this->exitStatus, $this->exitDescription, $jobInstanceCode);
 }
 /**
  * Launch a job
  * TODO: refactor all this
  *
  * @param JobInstance $job
  */
 protected function launchJob(JobInstance $job)
 {
     $app = new Application($this->container->get('kernel'));
     $cmd = new BatchCommand();
     $cmd->setContainer($this->container);
     $cmd->setApplication($app);
     $cmd->run(new ArrayInput(['command' => 'akeneo:batch:job', 'code' => $job->getCode(), '--no-debug' => true, '--no-log' => true, '-v' => true]), new ConsoleOutput());
     $execution = $this->getJobExecution($job);
     if (!$this->executionComplete($execution)) {
         throw new JobExecutionException($execution);
     }
 }
 /**
  * Launch a job
  * TODO: refactor all this
  *
  * @param JobInstance $job
  */
 protected function launchJob(JobInstance $job)
 {
     $app = new Application($this->container->get('kernel'));
     $cmd = new BatchCommand();
     $cmd->setContainer($this->container);
     $cmd->setApplication($app);
     $cmd->run(new ArrayInput(['command' => 'akeneo:batch:job', 'code' => $job->getCode(), '--no-debug' => true]), new ConsoleOutput());
     $execution = $this->getJobExecution($job);
     if (ExitStatus::COMPLETED !== $execution->getExitStatus()->getExitCode()) {
         throw new \Exception(sprintf('An error occured during execution of the job "%s", detailled trace can be found in %s', $job->getCode(), $execution->getLogFile()));
     }
 }
Exemplo n.º 5
0
 /**
  * Set data to JobResult
  * TODO: Find a way to work with multiple amount of job and step executions
  * TODO https://magecore.atlassian.net/browse/BAP-2600
  *
  * @param JobResult $jobResult
  * @param JobInstance $jobInstance
  */
 protected function setJobResultData(JobResult $jobResult, JobInstance $jobInstance)
 {
     $jobResult->setJobId($jobInstance->getId());
     $jobResult->setJobCode($jobInstance->getCode());
     /** @var JobExecution $jobExecution */
     $jobExecution = $jobInstance->getJobExecutions()->first();
     if ($jobExecution) {
         $stepExecutions = $jobExecution->getStepExecutions();
         /** @var StepExecution $firstStepExecution */
         $firstStepExecution = $stepExecutions->first();
         if ($firstStepExecution) {
             $context = $this->contextRegistry->getByStepExecution($firstStepExecution);
             if ($stepExecutions->count() > 1) {
                 /** @var StepExecution $stepExecution */
                 foreach ($stepExecutions->slice(1) as $stepExecution) {
                     ContextHelper::mergeContextCounters($context, $this->contextRegistry->getByStepExecution($stepExecution));
                 }
             }
             $jobResult->setContext($context);
         }
     }
 }
 /**
  * {@inheritDoc}
  */
 public function getCode()
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'getCode', array());
     return parent::getCode();
 }