当前位置: 首页>>代码示例>>PHP>>正文


PHP Reference::find_or_create_by_full_reference方法代码示例

本文整理汇总了PHP中Reference::find_or_create_by_full_reference方法的典型用法代码示例。如果您正苦于以下问题:PHP Reference::find_or_create_by_full_reference方法的具体用法?PHP Reference::find_or_create_by_full_reference怎么用?PHP Reference::find_or_create_by_full_reference使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Reference的用法示例。


在下文中一共展示了Reference::find_or_create_by_full_reference方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: add_hierarchy_entry


//.........这里部分代码省略.........
             return;
         }
         // NOTE: This is NOT adding a hierarchy entry, but a
         // harvest_event_hierarchy_entry:
         // TODO: I am not sure this adds entries for ancestors!
         $this->harvest_event->add_hierarchy_entry($hierarchy_entry, 'inserted');
         $this->taxon_ids_inserted[$taxon_id] = array('hierarchy_entry_id' => $hierarchy_entry->id, 'taxon_concept_id' => $hierarchy_entry->taxon_concept_id, 'source_url' => $source_url);
         self::compress_array($this->taxon_ids_inserted[$taxon_id]);
     } else {
         $params = array("identifier" => $taxon_id, "source_url" => $source_url, "name_id" => $name->id, "parent_id" => $parent_hierarchy_entry_id, "hierarchy_id" => $this->harvest_event->resource->hierarchy_id, "rank" => $rank, "ancestry" => $ancestry, "taxon_remarks" => $taxon_remarks);
         $hierarchy_entry = HierarchyEntry::find_or_create_by_array($params);
         if (@(!$hierarchy_entry->id)) {
             return;
         }
         $this->harvest_event->add_hierarchy_entry($hierarchy_entry, 'inserted');
         $this->taxon_ids_inserted[$taxon_id] = array('hierarchy_entry_id' => $hierarchy_entry->id, 'taxon_concept_id' => $hierarchy_entry->taxon_concept_id, 'source_url' => $source_url);
         self::compress_array($this->taxon_ids_inserted[$taxon_id]);
     }
     if (!isset($this->entry_references_deleted[$hierarchy_entry->id])) {
         $hierarchy_entry->delete_refs();
         $this->entry_references_deleted[$hierarchy_entry->id] = true;
     }
     if (!isset($this->entry_vernacular_names_deleted[$hierarchy_entry->id])) {
         $this->mysqli->delete("DELETE FROM synonyms WHERE hierarchy_entry_id={$hierarchy_entry->id} AND hierarchy_entry_id={$hierarchy_entry->id} AND hierarchy_id=" . $this->harvest_event->resource->hierarchy_id . " AND language_id!=0 AND language_id!=" . Language::find_or_create_for_parser('scientific name')->id);
         $this->entry_vernacular_names_deleted[$hierarchy_entry->id] = true;
     }
     if (!isset($this->entry_synonyms_deleted[$hierarchy_entry->id])) {
         $hierarchy_entry->delete_synonyms();
         $this->entry_synonyms_deleted[$hierarchy_entry->id] = true;
     }
     if ($name_published_in = @$row['http://rs.tdwg.org/dwc/terms/namePublishedIn']) {
         $individual_references = explode("||", $name_published_in);
         foreach ($individual_references as $reference_string) {
             $reference = Reference::find_or_create_by_full_reference(trim($reference_string));
             if (@$reference->id) {
                 $hierarchy_entry->add_reference($reference->id);
                 $this->mysqli->query("UPDATE refs SET published=1, visibility_id=" . Visibility::visible()->id . " WHERE id={$reference->id}");
             }
         }
     }
     // keep track of reference foreign keys
     self::append_foreign_keys_from_row($row, 'http://eol.org/schema/reference/referenceID', $this->taxon_reference_ids, $hierarchy_entry->id);
     if (isset($this->synonyms[$taxon_id])) {
         foreach ($this->synonyms[$taxon_id] as $synonym_row) {
             self::uncompress_array($synonym_row);
             $synonym_scientific_name = @self::field_decode($synonym_row['http://rs.tdwg.org/dwc/terms/scientificName']);
             $synonym_authorship = @self::field_decode($synonym_row['http://rs.tdwg.org/dwc/terms/scientificNameAuthorship']);
             if ($synonym_authorship && stripos($synonym_scientific_name, $synonym_authorship) === false) {
                 $synonym_scientific_name = trim($synonym_scientific_name . " " . $synonym_authorship);
             }
             if (!$synonym_scientific_name) {
                 continue;
             }
             $synonym_taxon_id = @self::field_decode($synonym_row['http://rs.tdwg.org/dwc/terms/taxonID']);
             if (!$synonym_taxon_id) {
                 $taxon_id = @self::field_decode($synonym_row['http://purl.org/dc/terms/identifier']);
             }
             if (!$synonym_taxon_id) {
                 continue;
             }
             $synonym_name = Name::find_or_create_by_string(ucfirst($synonym_scientific_name));
             if (@(!$synonym_name->id)) {
                 continue;
             }
             $taxonomic_status = @self::field_decode($synonym_row['http://rs.tdwg.org/dwc/terms/taxonomicStatus']) ?: 'synonym';
             if (isset($synonym_row['http://rs.tdwg.org/dwc/terms/taxonRemarks'])) {
开发者ID:eliagbayani,项目名称:maps_test,代码行数:67,代码来源:ArchiveDataIngester.php

示例2: read_taxon_xml

 public static function read_taxon_xml($t, $resource)
 {
     $t_dc = $t->children("http://purl.org/dc/elements/1.1/");
     $t_dcterms = $t->children("http://purl.org/dc/terms/");
     $t_dwc = $t->children("http://rs.tdwg.org/dwc/dwcore/");
     $taxon_parameters = array();
     $taxon_parameters["identifier"] = Functions::import_decode($t_dc->identifier);
     $taxon_parameters["source_url"] = Functions::import_decode($t_dc->source);
     $taxon_parameters["kingdom"] = Functions::import_decode($t_dwc->Kingdom);
     $taxon_parameters["phylum"] = Functions::import_decode($t_dwc->Phylum);
     $taxon_parameters["class"] = Functions::import_decode($t_dwc->Class);
     $taxon_parameters["order"] = Functions::import_decode($t_dwc->Order);
     $taxon_parameters["family"] = Functions::import_decode($t_dwc->Family);
     $taxon_parameters["genus"] = Functions::import_decode($t_dwc->Genus);
     $taxon_parameters["scientific_name"] = Functions::import_decode($t_dwc->ScientificName);
     $taxon_parameters["rank"] = Rank::find_or_create_by_translated_label(Functions::import_decode($t->rank));
     $taxon_parameters["taxon_created_at"] = trim($t_dcterms->created);
     $taxon_parameters["taxon_modified_at"] = trim($t_dcterms->modified);
     if ($taxon_parameters["scientific_name"]) {
         $taxon_parameters["name"] = Name::find_or_create_by_string($taxon_parameters["scientific_name"]);
     } else {
         if ($name = $taxon_parameters["genus"]) {
             $taxon_parameters["scientific_name"] = $name;
             $taxon_parameters["name"] = Name::find_or_create_by_string($name);
             $taxon_parameters["genus"] = "";
         } elseif ($name = $taxon_parameters["family"]) {
             $taxon_parameters["scientific_name"] = $name;
             $taxon_parameters["name"] = Name::find_or_create_by_string($name);
             $taxon_parameters["family"] = "";
         } elseif ($name = $taxon_parameters["order"]) {
             $taxon_parameters["scientific_name"] = $name;
             $taxon_parameters["name"] = Name::find_or_create_by_string($name);
             $taxon_parameters["order"] = "";
         } elseif ($name = $taxon_parameters["class"]) {
             $taxon_parameters["scientific_name"] = $name;
             $taxon_parameters["name"] = Name::find_or_create_by_string($name);
             $taxon_parameters["class"] = "";
         } elseif ($name = $taxon_parameters["phylum"]) {
             $taxon_parameters["scientific_name"] = $name;
             $taxon_parameters["name"] = Name::find_or_create_by_string($name);
             $taxon_parameters["phylum"] = "";
         } elseif ($name = $taxon_parameters["kingdom"]) {
             $taxon_parameters["scientific_name"] = $name;
             $taxon_parameters["name"] = Name::find_or_create_by_string($name);
             $taxon_parameters["kingdom"] = "";
         } else {
             return;
         }
     }
     $taxon_parameters["common_names"] = array();
     foreach ($t->commonName as $c) {
         $common_name = Functions::import_decode((string) $c);
         if (!$common_name) {
             continue;
         }
         $xml_attr = $c->attributes("http://www.w3.org/XML/1998/namespace");
         $params = array("name" => $common_name, "language" => Language::find_or_create_for_parser(@Functions::import_decode($xml_attr["lang"])));
         $taxon_parameters["common_names"][] = $params;
     }
     $taxon_parameters["synonyms"] = array();
     foreach ($t->synonym as $s) {
         $synonym = Functions::import_decode((string) $s);
         if (!$synonym) {
             continue;
         }
         $attr = $s->attributes();
         if (!@$attr["relationship"]) {
             $attr["relationship"] = 'synonym';
         }
         $params = array("name" => Name::find_or_create_by_string($synonym), "synonym_relation" => SynonymRelation::find_or_create_by_translated_label(trim($attr["relationship"])));
         $taxon_parameters["synonyms"][] = $params;
     }
     $taxon_parameters["agents"] = array();
     foreach ($t->agent as $a) {
         $agent_name = Functions::import_decode((string) $a);
         if (!$agent_name) {
             continue;
         }
         $attr = $a->attributes();
         $params = array("full_name" => Functions::import_decode((string) $a, 0, 0), "homepage" => @Functions::import_decode($attr["homepage"]), "logo_url" => @Functions::import_decode($attr["logoURL"]), "agent_role" => AgentRole::find_or_create_by_translated_label(@trim($attr["role"])));
         $taxon_parameters["agents"][] = $params;
         unset($params);
     }
     $taxon_parameters["refs"] = array();
     foreach ($t->reference as $r) {
         $reference = Functions::import_decode((string) $r, 0, 0);
         if (!$reference) {
             continue;
         }
         $ref = Reference::find_or_create_by_full_reference($reference);
         $taxon_parameters["refs"][] = $ref;
         $id_labels = array("bici", "coden", "doi", "eissn", "handle", "issn", "isbn", "lsid", "oclc", "sici", "url", "urn");
         $attr = $r->attributes();
         foreach ($id_labels as $label) {
             if ($id = @Functions::import_decode($attr[$label], 0, 0)) {
                 $type = RefIdentifierType::find_or_create_by_label($label);
                 $ref->add_ref_identifier(@$type->id ?: 0, $id);
             }
         }
     }
//.........这里部分代码省略.........
开发者ID:eliagbayani,项目名称:maps_test,代码行数:101,代码来源:SchemaParser.php


注:本文中的Reference::find_or_create_by_full_reference方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。