/**
     * Duplicates a job with similar properties to the original.
     *
     * @return NineThousand\Jobqueue\Vendor\Doctrine\Adapter\Job\DoctrineJobAdapter
     */
    public function spawn()
    {
        $entity = new JobEntity;
        $entity->setRetry($this->_jobEntity->getRetry());
        $entity->setCooldown($this->_jobEntity->getCooldown());
        $entity->setMaxRetries($this->_jobEntity->getMaxRetries());
        $entity->setAttempts(0);
        $entity->setExecutable($this->_jobEntity->getExecutable());
        $entity->setType($this->_jobEntity->getType());
        $entity->setStatus(null);
        $entity->setCreateDate(new \DateTime("now"));
        $entity->setLastRunDate(null);
        $entity->setActive(1);
        $entity->setSchedule(null);
        $entity->setParent($this->_jobEntity->getId());
        $this->_em->persist($entity);
        $this->_em->flush();

        //instantiate duplicated job adapter and set params, args, tags
        $jobAdapter = new self($this->_options, $entity, $this->_em, $this->_logger);
        if (count($params = $this->getParams())) $jobAdapter->setParams($params);
        if (count($args = $this->getArgs())) $jobAdapter->setArgs($args);
        if (count($tags = $this->getTags())) $jobAdapter->setTags($tags);
        
        return $jobAdapter;
    }
 public function load($manager)
 {
     $result = array();
     
     foreach ($this->data as $record) {
         $testHistory = new History;
         $testHistory->setTimestamp(new \DateTime);
         foreach ($record as $key => $val) {
             if ($key == 'job') {
                 $job = new Job;
                 $job->setCreateDate(new \DateTime);
                 foreach ($val as $k => $v) {
                     $job->{'set'.ucwords($k)}($v);
                 }
                 $val = $job;
                 $manager->persist($val);
                 unset($job);
             }
             $testHistory->{'set'.ucwords($key)}($val);
         }
         $manager->persist($testHistory);
         array_push($result, $testHistory);
         $manager->flush();
         unset($testHistory);
     }
     return $result;
 }
    /**
     * Displays a form to create a new Job entity.
     *
     */
    public function newAction()
    {
        $entity = new Job();
        $entity->setParams(array(new Param()));
        $entity->setArgs(array(new Arg()));
        $entity->setTags(array(new Tag()));
        $form   = $this->createForm(new ScheduledJobType(), $entity, $this->container->getParameter('jobqueue.adapter.options'));

        return $this->render('NineThousandJobqueueBundle:ScheduledJob:new.html.twig', array(
            'entity' => $entity,
            'form'   => $form->createView(),
            'action' => $this->generateUrl('jobqueue_scheduledjob_create'),
        ));
    }
 public function load($manager)
 {
     $result = array();
     foreach ($this->data as $record) {
         $testJob = new Job;
         $testJob->setCreateDate(new \DateTime);
         foreach ($record as $key => $val) {
             $testJob->{'set'.ucwords($key)}($val);
         }
         $manager->persist($testJob);
         array_push($result, $testJob);
         $manager->flush();
         unset($testJob);
     }
     return $result;
 }