uuid = $uuid; } // fill object from DB public function fromDB () { $j = DB::QueryAllResultsAssoc( 'SELECT id, UNIX_TIMESTAMP(update_timestamp) AS uts, ' . ' UNIX_TIMESTAMP(submit_timestamp) AS sts, ' . ' walltime, jobname, cpus, ' . ' userid, softwareid, infrastructureid, `status`, status_details ' . 'FROM jobs WHERE `uuid` = ?(uujid)', $this->uuid); if(is_null($j)) return FALSE; // set variables in accordance to select $this->jid = $j['id']; $this->submitutime = $j['sts']; $this->updateutime = $j['uts']; $this->walltime = $j['walltime']; $this->jname = $j['jobname']; $this->cpus = $j['cpus']; $this->status = $j['status']; $this->status_details = $j['status_details']; // objects $this->cuser = new User($j['userid']); $this->csoft = new Software($j['softwareid']); $this->cinf = new Infrastructure($j['infrastructureid']); } // fill object from request public function fromREQ ($name, $wallt, $cpus, $soft, $infr, $user, $paramsf, $jobidf ) { // vars $this->walltime = $wallt; $this->jname = $name; $this->cpus = $cpus; // objects $this->cuser = $user; $this->csoft = new Software($soft); $this->cinf = new Infrastructure($infr); // files $this->params_file = $paramsf; $this->jobid_file = $jobidf; } public function saveNewDBJob () { // insert job record $this->jid = DB::InsertQuery('INSERT INTO jobs(' . '`uuid`, submit_timestamp, walltime, jobname, cpus, ' . 'userid, softwareid, infrastructureid) ' . 'VALUES( ?(uuid), NOW(), ?(wallt), ?(jname), ?(cpus), ' . '?(userid), ?(softid), ?(infid) )', $this->uuid, $this->walltime, $this->jname, $this->cpus, $this->cuser->getID(), $this->csoft->getID(), $this->cinf->getID() ); if ( is_null($this->jid) ) return FALSE; // parse params $this->cparams = new JobParams($this->params_file); $this->cparams->save2DB($this->jid); // save jobid file $this->cjobid = new DBFile($this->jobid_file, 'jobid'); $r = DB::UpdateQuery( 'INSERT INTO jobidfiles(jobid,fileid) ' . 'VALUES (?(jobid), ?(fileid))', $this->jid, $this->cjobid->getFileID() ); if ( is_null($r) ) return FALSE; return TRUE; } public function updateJobStatus ($status, $status_det = NULL) { if ( ! is_numeric($status) ) return FALSE; $this->status = $status; $this->status_details = $status_det; $r = DB::UpdateQuery( 'UPDATE jobs SET `status` = ?(status), status_details = ?(statdet) ' . 'WHERE `uuid` = ?(uuid)', $this->status, $this->status_details, $this->uuid ); if ( is_null($r) ) return FALSE; return TRUE; } } ?>