/** * @param RokGallery_Model_Job $job * @return RokGallery_Job * */ protected function _create($type) { $tx = RokGallery_Doctrine::getConnection()->transaction; $tx->setIsolation('REPEATABLE READ'); try { // Uncomment to send debug output to the apache error_log. //$this->_fsm->setDebugFlag(true); $this->_fsm = new RokGallery_Job_StateMachine($this); $tx->beginTransaction(); $this->_job = new RokGallery_Model_Job(); $this->_job->sm = serialize($this->_fsm); $this->_job->id = RokCommon_UUID::generate(); $this->_job->type = $type; $this->_job->state = $this->getStateName(); $this->_job->percent = 0; $this->_job->save(); $this->_processor = RokGallery_Job_ProcessorFactory::factory($this); $this->_id = $this->_job->id; $tx->commit(); } catch (Exception $e) { $tx->rollback(); throw $e; } }
/** * create a new Job and return the Job Info * * @param $params * @return RokCommon_Ajax_Result */ public function createJob($params) { $result = new RokCommon_Ajax_Result(); $tx = RokGallery_Doctrine::getConnection()->transaction; $tx->setIsolation('REPEATABLE READ'); try { $tx->beginTransaction(); $job = new RokGallery_Model_Job(); $job->id = RokCommon_UUID::generate(); $job->type = RokGallery_Model_Job::TYPE_UPLOAD; $job->state = RokGallery_Model_Job::STATE_PENDING; $job->percent = 0; $job->save(); $result->setPayload(array('job' => $job->id)); $tx->commit(); } catch (Exception $e) { $tx->rollback(); throw $e; } return $result; }
/** * @static * @return string */ public static function createUUID() { return RokCommon_UUID::generate(); }
/** * */ public function __construct() { $this->id = RokCommon_UUID::generate(); }