/**
  * Parse data from interface and return JobVacancy Object
  * @param Array $postArr Array containing POST values
  * @return JobVacancy Job Vacancy object
  */
 public function parseData($postArr)
 {
     $vacancy = new JobVacancy();
     if (isset($postArr['txtId']) && !empty($postArr['txtId'])) {
         $vacancy->setId(trim($postArr['txtId']));
     }
     if (isset($postArr['cmbJobTitle']) && !empty($postArr['cmbJobTitle'])) {
         $vacancy->setJobTitleCode(trim($postArr['cmbJobTitle']));
     }
     if (isset($postArr['cmbHiringManager']) && !empty($postArr['cmbHiringManager'])) {
         $vacancy->setManagerId(trim($postArr['cmbHiringManager']));
     }
     if (isset($postArr['txtDesc']) && !empty($postArr['txtDesc'])) {
         $vacancy->setDescription(trim($postArr['txtDesc']));
     }
     if (isset($postArr['active']) && !empty($postArr['active'])) {
         $vacancy->setActive(true);
     }
     return $vacancy;
 }
Exemple #2
0
 /**
  * Creates a JobVacancy object from a resultset row
  *
  * @param array $row Resultset row from the database.
  * @return JobVacancy JobVacancy object.
  */
 private static function _createFromRow($row)
 {
     $vacancy = new JobVacancy($row[self::DB_FIELD_VACANCY_ID]);
     $vacancy->setJobTitleCode($row[self::DB_FIELD_JOBTITLE_CODE]);
     $vacancy->setManagerId($row[self::DB_FIELD_MANAGER_ID]);
     $vacancy->setActive((bool) $row[self::DB_FIELD_ACTIVE]);
     $vacancy->setDescription($row[self::DB_FIELD_DESCRIPTION]);
     if (isset($row[self::FIELD_JOB_TITLE_NAME])) {
         $vacancy->setJobTitleName($row[self::FIELD_JOB_TITLE_NAME]);
     }
     if (isset($row[self::FIELD_MANAGER_NAME])) {
         $vacancy->setManagerName($row[self::FIELD_MANAGER_NAME]);
     }
     return $vacancy;
 }
 /**
  * test the parseData function
  */
 public function testParseData()
 {
     $extractor = new EXTRACTOR_JobVacancy();
     // No parameters - default settings
     $post = array();
     $vacancy = $extractor->parseData($post);
     $expected = new JobVacancy();
     $this->assertEquals($expected, $vacancy);
     // All parameters
     $post = array('txtId' => '2', 'cmbJobTitle' => '3', 'cmbHiringManager' => '2', 'txtDesc' => 'XYZ', 'active' => '1');
     $vacancy = $extractor->parseData($post);
     $expected = new JobVacancy();
     $expected->setId(2);
     $expected->setJobTitleCode(3);
     $expected->setManagerId(2);
     $expected->setDescription('XYZ');
     $expected->setActive(true);
     $this->assertEquals($expected, $vacancy);
     // Without ID
     $post = array('cmbJobTitle' => '3', 'cmbHiringManager' => '2', 'txtDesc' => 'XYZ', 'active' => '1');
     $vacancy = $extractor->parseData($post);
     $expected = new JobVacancy();
     $expected->setJobTitleCode(3);
     $expected->setManagerId(2);
     $expected->setDescription('XYZ');
     $expected->setActive(true);
     $this->assertEquals($expected, $vacancy);
 }
 /**
  * Create a JobVacancy object with the passed parameters
  */
 private function _getJobVacancy($id, $jobTitleCode, $managerId, $active, $description)
 {
     $vacancy = new JobVacancy($id);
     $vacancy->setJobTitleCode($jobTitleCode);
     $vacancy->setManagerId($managerId);
     $vacancy->setActive($active);
     $vacancy->setDescription($description);
     return $vacancy;
 }