Пример #1
0
 protected function setUp()
 {
     $db_util = DbTestUtil::instance();
     $db_util->emptyTable('member');
     $this->_dao = DAOFactory::getDAOFactory(DAOFactory::DB);
     $this->_member_dao = $this->_dao->getMemberDAO();
 }
function generateJSONRegionsTaxaQuantity($region)
{
    $taxonDAO = DAOFactory::getDAOFactory()->getTaxonDAO();
    $result = array();
    $r = new stdClass();
    $r->regionName = utf8_encode($region);
    $r->taxaCount = $taxonDAO->getCountTaxaInRegion($r->regionName);
    array_push($result, $r);
    return json_encode($result);
}
<?php

require_once '../../config/config.php';
require '../../config/smarty.php';
require_once WORKSPACE_DIR . 'core/model/Country.php';
require_once WORKSPACE_DIR . 'core/dao/factories/DAOFactory.php';
if (isset($_GET['specie_id']) && $_GET['specie_id'] != '') {
    $taxonID = $_GET['specie_id'];
    $countryDAO = DAOFactory::getDAOFactory()->getCountryDAO();
    //TODO
}
Пример #4
0
            $cwrConcept->getTaxon()->setUtilizationReferences($utilizationReferences);
        }
        /*         * ** CROP BREEDING USES *** */
        $taxonBreedingDAO = DAOFactory::getDAOFactory()->getBreedingUseDAO();
        $taxonBreedingUses = $taxonBreedingDAO->getTaxonBreedingUses($taxonID);
        if (count($taxonBreedingUses) > 0) {
            $cwrConcept->setTaxonBreedingUses($taxonBreedingUses);
        }
        /*         * ** STORAGE BEHAVIOR *** */
        $storageBehaviorDAO = DAOFactory::getDAOFactory()->getStorageBehaviorDAO();
        $storageBehavior = $storageBehaviorDAO->getStorageBehavior($cwrConcept->getTaxon()->getGenus());
        if ($storageBehavior != null) {
            $cwrConcept->setStorageBehavior($storageBehavior);
        }
        /*         * ** HERBARIA *** */
        $herbariumDAO = DAOFactory::getDAOFactory()->getHerbariumDAO();
        $herbaria = $herbariumDAO->getHerbariaData($cwrConcept->getTaxon()->getID());
        if (count($herbaria) > 0) {
            $cwrConcept->getTaxon()->setHerbaria($herbaria);
        }
    }
    $firephp = new FirePHP(true);
    //TODO - Remove this variable when the development of this page finalize.
    $firephp->log($cwrConcept, 'CWR:');
    // Only for test
    $smarty->assign("taxon", $cwrConcept->getTaxon());
    $smarty->assign("mainTaxon", $mainTaxon);
    $smarty->assign("cwr", $cwrConcept);
}
// display TPL
$smarty->display("cwr-details.tpl");
<?php

/* Initializing WordPress features */
require_once '../../../wp-blog-header.php';
/* Initializing Smarty and Database Objects */
require_once '../../config/config.php';
require_once '../../config/smarty.php';
require_once '../../config/db.php';
require_once WORKSPACE_DIR . 'core/dao/factories/DAOFactory.php';
/* Show WordPress Header */
get_header();
// display sidebar
get_sidebar();
$taxonDAO = DAOFactory::getDAOFactory()->getTaxonDAO();
$taxonDAO->updateScientificNames();
// display footer
get_footer();
Пример #6
0
    header("Content-length: " . filesize($filename));
    readfile($filename);
    unlink($filename);
}
/* Ideado principalmente para la descarga desde el boton de gene pool */
if ($_GET["term"]) {
    $ids = $_GET['term'];
    if (!is_array($ids)) {
        $filename = $term . "-" . date("d-M-Y H-i-s") . ".csv";
    } else {
        $filename = "Results-" . date("d-M-Y H-i-s") . ".csv";
    }
    $file = fopen($filename, "w");
    $sep = ",";
    $header = "Id" . $sep . "Family" . $sep . "FamilyAuthor" . $sep . "Genus" . $sep . "Specie" . $sep . "SpecieAuthor" . $sep . "Subspecie" . $sep . "SubspecieAuthor" . $sep . "Variety" . $sep . "VarietyAuthor" . $sep . "commonName" . $sep . "ScientificName" . $sep . "ConceptType" . $sep . "ConceptLevel" . $sep . "Relative of" . $sep . "\n";
    $genePoolConceptDAO = DAOFactory::getDAOFactory()->getGenePoolConceptDAO();
    $data = $header;
    foreach ($ids as $id) {
        $concepts = $genePoolConceptDAO->getGenePoolConcept($id);
        $arrayConcepts = $concepts->getConcepts();
        $mainTaxon = $concepts->getMainCrop();
        foreach ($arrayConcepts as $concept) {
            $taxon = $concept->getTaxon();
            $data .= $taxon->getId() . $sep . str_replace(",", " ", $taxon->getFamily()) . $sep . str_replace(",", " ", $taxon->getFamilyAuthor()) . $sep . str_replace(",", " ", $taxon->getGenus()) . $sep . str_replace(",", " ", $taxon->getSpecie()) . $sep . str_replace(",", " ", $taxon->getSpecieAuthor()) . $sep . str_replace(",", " ", $taxon->getSubspecie()) . $sep . str_replace(",", " ", $taxon->getSubspecieAuthor()) . $sep . $taxon->getVariety() . $sep . str_replace(",", " ", $taxon->getVarietyAuthor()) . $sep . str_replace(",", " ", $taxon->getCommonName()) . $sep . str_replace(",", " ", $taxon->generateScientificName(false, false)) . $sep . str_replace(",", " ", $concept->getConceptType()) . $sep . str_replace(",", " ", $concept->getConceptLevel()) . $sep . $mainTaxon->getTaxon()->generateScientificName(false, false);
            $data .= "\n";
        }
    }
    fwrite($file, $data);
    fclose($file);
    header("Content-type: application/csv");
    header("Content-Disposition: attachment; filename=" . $filename . " ");
<?php

require_once '../../config/config.php';
require_once '../../config/smarty.php';
require_once WORKSPACE_DIR . 'core/dao/factories/DAOFactory.php';
if (isset($_GET['search-type']) && $_GET['search-type'] != '') {
    $term = $_GET['term'];
    switch ($_GET['search-type']) {
        case "concept-level":
            $conceptDAO = DAOFactory::getDAOFactory()->getConceptDAO();
            $concept_level = $conceptDAO->getAllLevelsByType($term);
            echo generateJSONConceptLevel($concept_level);
            break;
    }
}
function generateJSONConceptLevel($concept_level)
{
    $result = array();
    foreach ($concept_level as $level) {
        array_push($result, $level);
    }
    return json_encode($result);
}
 if (isset($_POST["priority-genera-only"])) {
     $priority_genera = $_POST["priority-genera"];
     // Array con los generos prioritarios a buscar
     $search_type = 1;
     // Busqueda por generos prioritarios
 } else {
     if (isset($_POST["priority-croptaxa-only"])) {
         $search_type = 2;
         // Busqueda realizada por priority taxa
     } else {
         if (empty($countries) && empty($regions)) {
             $search_type = 3;
         }
     }
 }
 $advancedSearchDAO = DAOFactory::getDAOFactory()->getAdvancedSearchDAO();
 $taxa = $advancedSearchDAO->getResultsAdvancedSearch($term, $search_type, $countries, $regions, $concept_type, $concept_levels, $priority_genera);
 // Devuelve un arreglo de objetos taxon
 $long = count($taxa);
 if ($long != 1) {
     $middle = ceil($long / 2);
     foreach ($taxa as $tx) {
         if ($i < $middle) {
             $taxa_left[] = $tx;
         } else {
             $taxa_right[] = $tx;
         }
         $i++;
     }
 } else {
     $taxa_left[] = $taxa[0];
Пример #9
0
 protected function setUp()
 {
     $this->_dao = DAOFactory::getDAOFactory(DAOFactory::DB);
 }
 public function __construct()
 {
     $mySqlDAOFactory = DAOFactory::getDAOFactory(DAOFactory::$MYSQL);
     $this->dao = $mySqlDAOFactory->getDataBaseOperations();
     $this->message = Localization::getInstance();
 }
function generateJSONConceptInformation($taxonName)
{
    $cwrConceptDAO = DAOFactory::getDAOFactory()->getCWRConceptDAO();
    $cwrConcept = $cwrConceptDAO->getCWRConceptbyTaxonName($taxonName);
    $mainTaxon = $cwrConceptDAO->getMainConcept($cwrConcept->getTaxon()->getId());
    if ($cwrConcept != null && $mainTaxon != null) {
        $r = new stdClass();
        $r->specieName = utf8_encode($cwrConcept->getTaxon()->generateScientificName(true, true));
        $validName = $cwrConcept->getTaxon()->getValidName();
        if (!empty($validName)) {
            $r->validName = utf8_encode($validName);
        }
        $commonName = $cwrConcept->getTaxon()->getCommonName();
        if (!empty($commonName)) {
            $r->commonName = utf8_encode($commonName);
        }
        $taxonID = $cwrConcept->getTaxon()->getId();
        if (!empty($taxonID)) {
            $r->taxonID = $taxonID;
        }
        $mainCropList = array();
        if ($mainTaxon != null) {
            foreach ($mainTaxon as $crop) {
                $mainCrop = new stdClass();
                $mainCrop->mainCropID = $crop->taxon->getId();
                $mainCrop->type = $crop->Concept_Type;
                $mainCrop->level = $crop->Concept_Level;
                $mainCrop->mainCropName = utf8_encode($crop->taxon->generateScientificName(true, false));
                array_push($mainCropList, $mainCrop);
            }
        }
        $r->mainCropList = $mainCropList;
    } else {
        // No tiene un concept asociado en la base de datos
        $taxonDAO = TaxonMySQL::getInstance();
        $taxon = $taxonDAO->getTaxonbyName($taxonName);
        $r = new stdClass();
        $r->taxonID = $taxon->getId();
        $r->specieName = utf8_encode($taxon->generateScientificName(true, false));
    }
    return json_encode($r);
}
<?php

require_once '../../config/config.php';
require_once '../../config/smarty.php';
require_once WORKSPACE_DIR . 'core/model/Occurrences.php';
require_once WORKSPACE_DIR . 'core/dao/factories/DAOFactory.php';
if (isset($_GET['search-type']) && $_GET['search-type'] != '') {
    $term = $_GET['term'];
    $limit = $_GET['limit'];
    $type = $_GET['search-type'];
    $occurrencesDAO = DAOFactory::getDAOFactory()->getOccurrencesDAO();
    echo json_encode($occurrencesDAO->suggestList($type, $limit, $term));
}
 /**
  *
  * @param type $db - ADONewConnection.
  * @param type $cropID - Crop ID to search from concepts table.
  * @return \GenePoolConcept - GenePoolConcept Object and its Concepts.
  */
 public function getGenePoolConcept($taxonID)
 {
     global $db;
     $query = "SELECT DISTINCT c.Crop_ID, c.Concept_ID, c.Concept_Type, c.Concept_Level, s2.*\n          FROM concepts c\n          INNER JOIN species s ON c.Taxon_ID = s.Taxon_ID\n          JOIN species s2 ON s.Valid_Taxon_ID = s2.Taxon_ID\n          WHERE c.Concept_ID = (\n            SELECT c.Concept_ID\n            FROM concepts c\n            WHERE c.Concept_Level in ('1A','Crop taxa') and c.Taxon_ID = {$taxonID}\n          )  AND s2.Taxon_ID = s2.Valid_Taxon_ID\n          ORDER BY c.Concept_Level, s2.Scientific_Name";
     $result = $db->getAll($query);
     $genePoolConcept = null;
     $cropID = null;
     // Validate if $result has not data.
     if (!empty($result)) {
         $genePoolConcept = new GenePoolConcept();
         $theConceptID = null;
         $theConceptType = null;
         $array_id = array();
         foreach ($result as $db_concept) {
             $concept = new Concept();
             $concept->setConceptType(trim($db_concept["Concept_Type"]));
             $concept->setConceptLevel(trim($db_concept["Concept_Level"]));
             $concept->setConceptID(trim($db_concept["Concept_ID"]));
             $concept->setCropID(trim($db_concept["Crop_ID"]));
             if ($cropID == null) {
                 $cropID = trim($db_concept["Crop_ID"]);
             }
             if ($theConceptID == null) {
                 $theConceptID = $concept->getConceptID();
             }
             if ($theConceptType == null) {
                 $theConceptType = $concept->getConceptType();
             }
             /*                 * ** TAXON - BASIC INFORMATION *** */
             $taxon = new Taxon(trim($db_concept["Valid_Taxon_ID"]));
             // Taxon_ID will be the identifier of the suggestion list.
             $taxon->setCommonName(trim($db_concept["Common_Name"]));
             $taxon->setFamily(trim($db_concept["Family"]));
             $taxon->setFamilyAuthor(trim($db_concept["Family_Author"]));
             $taxon->setGenus(trim($db_concept["Genus"]));
             $taxon->setSpecie(trim($db_concept["Species"]));
             $taxon->setSpecieAuthor(trim($db_concept["Species_Author"]));
             $taxon->setSubspecie(trim($db_concept["Subsp"]));
             $taxon->setSubspecieAuthor($db_concept["Subsp_Author"]);
             $taxon->setVariety(trim($db_concept["Var"]));
             $taxon->setVarietyAuthor(trim($db_concept["Var_Author"]));
             $taxon->setForm(trim($db_concept["Form"]));
             $taxon->setFormAuthor(trim($db_concept["Form_Author"]));
             $taxon->setMainCrop(trim($db_concept["Main_Crop"]));
             $taxon->setScientificName(trim($db_concept["Scientific_Name"]));
             $concept->setTaxon($taxon);
             if ($concept->getConceptLevel() == "Crop taxa") {
                 $genePoolConcept->addCropTaxa($taxon);
             } else {
                 // if concept level = 1A it should be also in the genepool concept list.
                 if ($concept->getConceptLevel() == "1A") {
                     $genePoolConcept->addCropTaxa($taxon);
                 }
                 $genePoolConcept->addConcept($concept);
             }
         }
         $taxonDAO = DAOFactory::getDAOFactory()->getTaxonDAO();
         $mainTaxon = $taxonDAO->getTaxon($cropID);
         $mainCrop = new Concept($mainTaxon->getId());
         $mainCrop->setConceptID($theConceptID);
         $mainCrop->setConceptType($theConceptType);
         $mainCrop->setCropID($cropID);
         $mainCrop->setTaxon($mainTaxon);
         $genePoolConcept->setMainCrop($mainCrop);
     }
     return $genePoolConcept;
 }