function getByStationIdArray($id)
 {
     $sdlf = new StationDepartmentListFactory();
     $sdlf->getByStationId($id);
     foreach ($sdlf as $obj) {
         $list[$obj->getStation()] = NULL;
     }
     if (isset($list)) {
         return $list;
     }
     return array();
 }
 function setDepartment($ids)
 {
     Debug::text('Setting IDs...', __FILE__, __LINE__, __METHOD__, 10);
     if (is_array($ids)) {
         $tmp_ids = array();
         if (!$this->isNew()) {
             //If needed, delete mappings first.
             $lf_a = new StationDepartmentListFactory();
             $lf_a->getByStationId($this->getId());
             foreach ($lf_a as $obj) {
                 $id = $obj->getDepartment();
                 Debug::text('Department ID: ' . $obj->getDepartment() . ' ID: ' . $id, __FILE__, __LINE__, __METHOD__, 10);
                 //Delete users that are not selected.
                 if (!in_array($id, $ids)) {
                     Debug::text('Deleting: ' . $id, __FILE__, __LINE__, __METHOD__, 10);
                     $obj->Delete();
                 } else {
                     //Save ID's that need to be updated.
                     Debug::text('NOT Deleting : ' . $id, __FILE__, __LINE__, __METHOD__, 10);
                     $tmp_ids[] = $id;
                 }
             }
             unset($id, $obj);
         }
         //Insert new mappings.
         $lf_b = new DepartmentListFactory();
         foreach ($ids as $id) {
             if (isset($ids) and !in_array($id, $tmp_ids)) {
                 $f = new StationDepartmentFactory();
                 $f->setStation($this->getId());
                 $f->setDepartment($id);
                 $obj = $lf_b->getById($id)->getCurrent();
                 if ($this->Validator->isTrue('department', $f->Validator->isValid(), TTi18n::gettext('Selected Department is invalid') . ' (' . $obj->getName() . ')')) {
                     $f->save();
                 }
             }
         }
         return TRUE;
     }
     Debug::text('No IDs to set.', __FILE__, __LINE__, __METHOD__, 10);
     return FALSE;
 }