function testCmp()
 {
     $s1 = Specimen::getOneFromDb(['specimen_id' => 8001], $this->DB);
     $s2 = Specimen::getOneFromDb(['specimen_id' => 8002], $this->DB);
     $this->assertEqual(Specimen::cmp($s1, $s2), -1);
     $this->assertEqual(Specimen::cmp($s1, $s1), 0);
     $this->assertEqual(Specimen::cmp($s2, $s1), 1);
     $sall = Specimen::getAllFromDb([], $this->DB);
     usort($sall, 'Specimen::cmp');
     $this->assertEqual(4, count($sall));
     $this->assertEqual(8001, $sall[0]->specimen_id);
     $this->assertEqual(8003, $sall[1]->specimen_id);
     $this->assertEqual(8002, $sall[2]->specimen_id);
     $this->assertEqual(8004, $sall[3]->specimen_id);
 }
 public function loadSpecimens()
 {
     $this->specimens = Specimen::getAllFromDb(['link_to_type' => 'authoritative_plant', 'link_to_id' => $this->authoritative_plant_id, 'flag_delete' => FALSE], $this->dbConnection);
     usort($this->specimens, 'Specimen::cmp');
 }
 public function loadSpecimens()
 {
     $this->specimens = Specimen::getAllFromDb(['link_to_type' => 'notebook_page', 'link_to_id' => $this->notebook_page_id, 'flag_delete' => FALSE], $this->dbConnection);
     usort($this->specimens, 'Specimen::cmp');
 }
 public function getTargets()
 {
     switch ($this->target_type) {
         case 'global_notebook':
             return Notebook::getAllFromDb([], $this->dbConnection);
             break;
         case 'global_metadata':
             return Metadata_Structure::getAllFromDb([], $this->dbConnection);
             break;
         case 'global_plant':
             return Authoritative_Plant::getAllFromDb([], $this->dbConnection);
             break;
         case 'global_specimen':
             return Specimen::getAllFromDb([], $this->dbConnection);
             break;
         case 'notebook':
             return array(Notebook::getOneFromDb(['notebook_id' => $this->target_id], $this->dbConnection));
             break;
         case 'metadata_structure':
             return array(Metadata_Structure::getOneFromDb(['metadata_structure_id' => $this->target_id], $this->dbConnection));
             break;
         case 'plant':
             return array(Authoritative_Plant::getOneFromDb(['authoritative_id' => $this->target_id], $this->dbConnection));
             break;
         case 'specimen':
             return array(Specimen::getOneFromDb(['specimen_id' => $this->target_id], $this->dbConnection));
             break;
         default:
             return array();
     }
 }