Ejemplo n.º 1
0
 private function _parseCommonData($postArr)
 {
     $jobSpec = new JobSpec();
     if (isset($postArr['txtFieldName']) && !empty($postArr['txtFieldName'])) {
         $jobSpec->setName(trim($postArr['txtFieldName']));
     }
     if (isset($postArr['txtDesc']) && !empty($postArr['txtDesc'])) {
         $jobSpec->setDesc(trim($postArr['txtDesc']));
     }
     if (isset($postArr['txtDuties']) && !empty($postArr['txtDuties'])) {
         $jobSpec->setDuties(trim($postArr['txtDuties']));
     }
     return $jobSpec;
 }
Ejemplo n.º 2
0
 /**
  * Tests getJobSpecForJob method.
  */
 public function testGetJobSpecForJob()
 {
     $viewController = new ViewController();
     // invalid job title id
     $spec = $viewController->getJobSpecForJob('JOB010');
     $this->assertNull($spec);
     // job title with no job spec assigned
     $spec = $viewController->getJobSpecForJob('JOB001');
     $this->assertNull($spec);
     // job id with job spec assigned
     $spec = $viewController->getJobSpecForJob('JOB002');
     $this->assertNotNull($spec);
     $expected = new JobSpec();
     $expected->setId(1);
     $expected->setName('Spec 1');
     $expected->setDesc('Desc 1');
     $expected->setDuties('duties 1');
     $this->assertEquals($expected, $spec);
 }
 /**
  * Create a JobSpec object with the passed parameters
  */
 private function _getJobSpec($id, $name, $desc, $duties)
 {
     $spec = new JobSpec($id);
     $spec->setName($name);
     $spec->setDesc($desc);
     $spec->setDuties($duties);
     return $spec;
 }
 /**
  * Get the job spec for the given job title
  * @param String $jobTitleCode The job title code
  * @return JobSpec JobSpec object or null if no job spec assigned for given job title
  */
 public function getJobSpecForJob($jobTitleCode)
 {
     $jobSpec = null;
     if (CommonFunctions::isValidId($jobTitleCode, 'JOB')) {
         $jobTitle = new JobTitle();
         $jobTitles = $jobTitle->filterJobTitles($jobTitleCode);
         if (is_array($jobTitles) && count($jobTitles) == 1) {
             $jobSpecId = $jobTitles[0][5];
             try {
                 $jobSpec = JobSpec::getJobSpec($jobSpecId);
             } catch (JobSpecException $ex) {
                 // ignore, we will be returning null
             }
         }
     }
     return $jobSpec;
 }
Ejemplo n.º 5
0
 /**
  * Creates a JobSpec object from a resultset row
  *
  * @param array $row Resultset row from the database.
  * @return JobSpec JobSpec object.
  */
 private static function _createFromRow($row)
 {
     $spec = new JobSpec($row[self::DB_FIELD_ID]);
     $spec->setName($row[self::DB_FIELD_NAME]);
     $spec->setDesc($row[self::DB_FIELD_DESC]);
     $spec->setDuties($row[self::DB_FIELD_DUTIES]);
     return $spec;
 }