private function createNewJob($status = null, $multimediaObject)
 {
     $job = new Job();
     if (null !== $status) {
         $job->setStatus($status);
     }
     $job->setMmId($multimediaObject->getId());
     $job->setTimeini(new \DateTime('now'));
     $job->setTimestart(new \DateTime('now'));
     $job->setDuration(60);
     $job->setNewDuration(65);
     $job->setProfile('master_copy');
     $job->setCpu('cpu_local');
     $job->setOutput('OK');
     $job->setEmail('*****@*****.**');
     $job->setPathIni('pathini/to/track.mp4');
     $job->setPathEnd('pathend/to/track.mp4');
     $this->dm->persist($job);
     $this->dm->flush();
     return $job;
 }
Ejemplo n.º 2
0
 /**
  * Add job
  */
 public function addJob($pathFile, $profile, $priority, MultimediaObject $multimediaObject, $language = null, $description = array(), $initVars = array())
 {
     $this->checkService();
     if (!is_file($pathFile)) {
         $this->logger->addError('[addJob] FileNotFoundException: Could not find file "' . $pathFile);
         throw new FileNotFoundException($pathFile);
     }
     if (null === $this->profileService->getProfile($profile)) {
         $this->logger->addError('[addJob] Can not find given profile with name "' . $profile);
         throw new \Exception("Can't find given profile with name " . $profile);
     }
     if (null === $multimediaObject) {
         $this->logger->addError('[addJob] Given null multimedia object');
         throw new \Exception("Given null multimedia object");
     }
     try {
         $duration = $this->inspectionService->getDuration($pathFile);
     } catch (\Exception $e) {
         $this->logger->addError('[addJob] InspectionService getDuration error message: ' . $e->getMessage());
         throw new \Exception($e->getMessage());
     }
     $job = new Job();
     $job->setMmId($multimediaObject->getId());
     $job->setProfile($profile);
     $job->setPathIni($pathFile);
     $job->setDuration($duration);
     $job->setPriority($priority);
     $job->setInitVars($initVars);
     if (null !== $language) {
         //TODO languageId is only language "es", "en", "gl"
         $job->setLanguageId($language);
     }
     if (!empty($description)) {
         $job->setI18nDescription($description);
     }
     if ($email = $this->getUserEmail()) {
         $job->setEmail($email);
     }
     $job->setTimeini(new \DateTime('now'));
     $this->dm->persist($job);
     $this->dm->flush();
     $this->setPathEndAndExtensions($job);
     $this->logger->addInfo('[addJob] Added job with id: ' . $job->getId());
     $this->executeNextJob();
     return $job;
 }
Ejemplo n.º 3
0
 private function newJob($mm_id, $name)
 {
     $job = new Job();
     $language_id = 'es';
     $profile = 1;
     $cpu = 'local';
     $url = 'video/' . $mm_id . '/' . $name . '.avi';
     $status = Job::STATUS_WAITING;
     $priority = 1;
     $timeini = new \DateTime('now');
     $timestart = new \DateTime('now');
     $timeend = new \DateTime('now');
     $pid = 3;
     $path_ini = 'path/ini';
     $path_end = 'path/end';
     $ext_ini = 'ext/ini';
     $ext_end = 'ext/end';
     $duration = 40;
     $size = '12000';
     $email = '*****@*****.**';
     $locale = 'en';
     $job->setLocale('en');
     $job->setMmId($mm_id);
     $job->setLanguageId($language_id);
     $job->setProfile($profile);
     $job->setCpu($cpu);
     $job->setUrl($url);
     $job->setStatus($status);
     $job->setPriority($priority);
     $job->setName($name);
     $job->setTimeini($timeini);
     $job->setTimestart($timestart);
     $job->setTimeend($timeend);
     $job->setPid($pid);
     $job->setPathIni($path_ini);
     $job->setPathEnd($path_end);
     $job->setExtIni($ext_ini);
     $job->setExtEnd($ext_end);
     $job->setDuration($duration);
     $job->setSize($size);
     $job->setEmail($email);
     $this->dm->persist($job);
     $this->dm->flush();
     return $job;
 }
Ejemplo n.º 4
0
 public function testGetterAndSetter()
 {
     $job = new Job();
     $mm_id = '54ad3f5e6e4cd68a278b4573';
     $language_id = 'es';
     $profile = 1;
     $cpu = 'local';
     $url = 'video/' . $mm_id . '/video1.avi';
     $status = Job::STATUS_WAITING;
     $priority = 1;
     $name = 'video1';
     $description = 'description1';
     $timeini = new \DateTime('now');
     $timestart = new \DateTime('now');
     $timeend = new \DateTime('now');
     $pid = 3;
     $path_ini = 'path/ini';
     $path_end = 'path/end';
     $ext_ini = 'ext/ini';
     $ext_end = 'ext/end';
     $duration = 40;
     $size = '12000';
     $email = '*****@*****.**';
     $initVars = array('ocurls' => array('presenter/master' => 'http://presentatermaster.com', 'presentation/master' => 'http://presentationmaster'));
     $locale = 'en';
     $job->setLocale('en');
     $job->setMmId($mm_id);
     $job->setLanguageId($language_id);
     $job->setProfile($profile);
     $job->setCpu($cpu);
     $job->setUrl($url);
     $job->setStatus($status);
     $job->setPriority($priority);
     $job->setName($name);
     $job->setDescription($description);
     $job->setTimeini($timeini);
     $job->setTimestart($timestart);
     $job->setTimeend($timeend);
     $job->setPid($pid);
     $job->setPathIni($path_ini);
     $job->setPathEnd($path_end);
     $job->setExtIni($ext_ini);
     $job->setExtEnd($ext_end);
     $job->setDuration($duration);
     $job->setSize($size);
     $job->setEmail($email);
     $job->setInitVars($initVars);
     $this->assertEquals($mm_id, $job->getMmId());
     $this->assertEquals($language_id, $job->getLanguageId());
     $this->assertEquals($profile, $job->getProfile());
     $this->assertEquals($cpu, $job->getCpu());
     $this->assertEquals($url, $job->getUrl());
     $this->assertEquals($status, $job->getStatus());
     $this->assertEquals($priority, $job->getPriority());
     $this->assertEquals($name, $job->getName());
     $this->assertEquals($description, $job->getDescription());
     $this->assertEquals($timeini, $job->getTimeini());
     $this->assertEquals($timestart, $job->getTimestart());
     $this->assertEquals($timeend, $job->getTimeend());
     $this->assertEquals($pid, $job->getPid());
     $this->assertEquals($path_ini, $job->getPathIni());
     $this->assertEquals($path_end, $job->getPathEnd());
     $this->assertEquals($ext_ini, $job->getExtIni());
     $this->assertEquals($ext_end, $job->getExtEnd());
     $this->assertEquals($duration, $job->getDuration());
     $this->assertEquals($size, $job->getSize());
     $this->assertEquals($email, $job->getEmail());
     $this->assertEquals($initVars, $job->getInitVars());
     $this->assertEquals($locale, $job->getLocale());
     $descriptionI18n = array('en' => 'description', 'es' => 'descripción');
     $nameI18n = array('en' => 'name', 'es' => 'nombre');
     $job->setI18nDescription($descriptionI18n);
     $job->setI18nName($nameI18n);
     $this->assertEquals($descriptionI18n, $job->getI18nDescription());
     $this->assertEquals($nameI18n, $job->getI18nName());
     $this->assertEquals("Waiting", $job->getStatusText());
 }