Example #1
0
 public function __construct()
 {
     $this->mysqli =& $GLOBALS['mysqli_connection'];
     if ($GLOBALS['ENV_NAME'] == 'production' && environment_defined('slave')) {
         $this->mysqli_slave = load_mysql_environment('slave');
     } else {
         $this->mysqli_slave =& $this->mysqli;
     }
     $this->sparql_client = SparqlClient::connection();
     $this->published_id = TranslatedResourceStatus::find_or_create_by_label('Published')->id;
     $this->trusted_id = Vetted::trusted()->id;
     $this->unknown_id = Vetted::unknown()->id;
     $this->untrusted_id = Vetted::untrusted()->id;
     $this->visible_id = Visibility::visible()->id;
     $this->invisible_id = Visibility::invisible()->id;
     $this->master_curator_id = CuratorLevel::master_curator()->id;
     $this->full_curator_id = CuratorLevel::full_curator()->id;
     $this->assistant_curator_id = CuratorLevel::assistant_curator()->id;
     $this->curator_ids = CuratorLevel::curator_ids();
     $this->data_object_scope = ChangeableObjectType::data_object_scope();
     $this->worms_content_partner_id = ContentPartner::find_or_create_by_full_name('World Register of Marine Species')->id;
     $this->col_hierarchy_id = Hierarchy::find_or_create_by_label('Species 2000 & ITIS Catalogue of Life: Annual Checklist 2011')->id;
     $this->latest_harvest_event_ids();
     $this->worms_latest_harvest_event_id();
 }
 public function __construct($year, $month)
 {
     $this->mysqli =& $GLOBALS['mysqli_connection'];
     $this->year = $year;
     $this->month = $month;
     $this->year_month = $year . "_" . $month;
     $this->bhl_user_id = ContentPartner::find_or_create_by_full_name('Biodiversity Heritage Library')->user_id;
     $this->col_user_id = ContentPartner::find_or_create_by_full_name('Catalogue of Life')->user_id;
     // we switched Google Analytics accounts on September 2011 when we launched V2
     if ($this->year < 2011 || $this->year == 2011 && $this->month < 9) {
         $this->profile_name = "EOLv1";
     } else {
         $this->profile_name = "EOLv2";
     }
 }
 function get_biomedical_terms_availability()
 {
     $time_start = time_elapsed();
     $arr_taxa = array();
     print "\n BOA_biomedical_terms [8 of 14]\n";
     $BOA_content_partner_id = ContentPartner::find_or_create_by_full_name('Biology of Aging')->id;
     //$BOA_content_partner_id = 39;
     if (!$BOA_content_partner_id) {
         self::save_totals_to_cumulative_txt(array(), "tpm_biomedical_terms");
         return;
     }
     $result = $this->mysqli_slave->query("SELECT Max(he.id) latest_harvent_event_id FROM harvest_events he JOIN resources r ON r.id = he.resource_id WHERE r.content_partner_id = {$BOA_content_partner_id} AND he.published_at Is Not Null");
     if ($result && ($row = $result->fetch_assoc())) {
         $latest_harvent_event_id = $row['latest_harvent_event_id'];
     }
     $sql = "SELECT he.taxon_concept_id tc_id FROM harvest_events_hierarchy_entries hehe JOIN hierarchy_entries he ON hehe.hierarchy_entry_id = he.id WHERE hehe.harvest_event_id = {$latest_harvent_event_id} ";
     if (isset($GLOBALS['test_taxon_concept_ids'])) {
         $sql .= " and he.taxon_concept_id IN (" . implode(",", $GLOBALS['test_taxon_concept_ids']) . ")";
     }
     $outfile = $this->mysqli_slave->select_into_outfile($sql);
     $FILE = fopen($outfile, "r");
     if (!$FILE) {
         print "!! ERROR: Could not read {$outfile}";
         debug("!! ERROR: Could not read {$outfile}");
         return;
     }
     $num_rows = 0;
     while (!feof($FILE)) {
         if ($line = fgets($FILE)) {
             $num_rows++;
             $line = trim($line);
             $fields = explode("\t", $line);
             $tc_id = trim($fields[0]);
             $arr_taxa[$tc_id] = "\t" . "1";
         }
     }
     fclose($FILE);
     unlink($outfile);
     print "\n num_rows: {$num_rows}";
     print "\n get_biomedical_terms_availability():" . (time_elapsed() - $time_start) / 60 . " minutes";
     self::save_totals_to_cumulative_txt($arr_taxa, "tpm_biomedical_terms");
     unset($arr_taxa);
 }