https://wiki.bgbm.org/gps/index.php?title=Special:NewPages&feed=atom&hidebots=1&hideredirs=1&limit=50&offset=&namespace=0&username=&tagfilter=
GGBN Portal Software - New pages [en]
2024-03-29T08:59:57Z
From GGBN Portal Software
MediaWiki 1.28.2
https://wiki.bgbm.org/gps/index.php/Search_Feature
Search Feature
2016-08-30T07:30:12Z
<p>GabiDroege: /* Retrieved from Common folder */</p>
<hr />
<div>=Search Form=<br />
* 2 main controllers: Search & WebsiteSearch<br />
** Local WebsitesearchController extends CommonWebsitesearchController<br />
** Local SearchController <br />
<br />
==views/search/search.php==<br />
Contains some of the display specifications<br />
* website search tabs (e.g. GGBN) can be switched on/off in config/params.php <br />
* full code identical for WFO and GGBN; can be customized, but for updates this script should be kept generic<br />
<br />
==models/SearchForm.php==<br />
* extends CommonSearchForm, but contains a lot of customized styling (e.g. labels of all form fields)<br />
<br />
==Retrieved from Common folder==<br />
* views/search/mapSearch.php<br />
* views/search/searchFieldSelection.php</div>
GabiDroege
https://wiki.bgbm.org/gps/index.php/GGBN_specific-_configuration
GGBN specific- configuration
2016-02-09T16:06:34Z
<p>PatriciaKelbert: /* Add new statistics charts */</p>
<hr />
<div>=Database=<br />
==Specific views==<br />
* Several views are required for the counts-box on start page.<br />
<pre><br />
CREATE <br />
ALGORITHM = UNDEFINED <br />
DEFINER = `root`@`localhost` <br />
SQL SECURITY DEFINER<br />
VIEW `counts` AS<br />
select <br />
count(`ro`.`occurrenceid`) AS `counts`, 'DNA' AS `kind`<br />
from<br />
(`ggbn_index`.`rawoccurrence` `ro`<br />
join `ggbn_index`.`unitkind` `uk` ON ((`ro`.`fk_kindofunitid` = `uk`.`unitkindid`)))<br />
where<br />
(`uk`.`kindofunit_clean` = 'DNA') <br />
union select <br />
count(`ro`.`occurrenceid`) AS `counts`, 'Tissues' AS `kind`<br />
from<br />
(`ggbn_index`.`rawoccurrence` `ro`<br />
join `ggbn_index`.`unitkind` `uk` ON ((`ro`.`fk_kindofunitid` = `uk`.`unitkindid`)))<br />
where<br />
(`uk`.`kindofunit_clean` = 'tissue') <br />
union select <br />
count(`ro`.`occurrenceid`) AS `counts`, 'Cultures' AS `kind`<br />
from<br />
(`ggbn_index`.`rawoccurrence` `ro`<br />
join `ggbn_index`.`unitkind` `uk` ON ((`ro`.`fk_kindofunitid` = `uk`.`unitkindid`)))<br />
where<br />
(`uk`.`kindofunit_clean` = 'Culture') <br />
union select <br />
count(`ro`.`occurrenceid`) AS `counts`,<br />
'eVouchers' AS `kind`<br />
from<br />
(`ggbn_index`.`rawoccurrence` `ro`<br />
join `ggbn_index`.`unitkind` `uk` ON ((`ro`.`fk_kindofunitid` = `uk`.`unitkindid`)))<br />
where<br />
(`uk`.`kindofunit_clean` = 'eVoucher') <br />
union select <br />
count(`ro`.`occurrenceid`) AS `counts`,<br />
'Specimens' AS `kind`<br />
from<br />
(`ggbn_index`.`rawoccurrence` `ro`<br />
join `ggbn_index`.`unitkind` `uk` ON ((`ro`.`fk_kindofunitid` = `uk`.`unitkindid`)))<br />
where<br />
(`uk`.`kindofunit_clean` = 'specimen') <br />
union select <br />
count(`ro`.`occurrenceid`) AS `counts`, 'Unknown' AS `kind`<br />
from<br />
(`ggbn_index`.`rawoccurrence` `ro`<br />
join `ggbn_index`.`unitkind` `uk` ON ((`ro`.`fk_kindofunitid` = `uk`.`unitkindid`)))<br />
where<br />
(`uk`.`kindofunit_clean` = 'unknown') <br />
union select <br />
count(`ro`.`occurrenceid`) AS `counts`, 'Enviros' AS `kind`<br />
from<br />
(`ggbn_index`.`rawoccurrence` `ro`<br />
join `ggbn_index`.`unitkind` `uk` ON ((`ro`.`fk_kindofunitid` = `uk`.`unitkindid`)))<br />
where<br />
(`uk`.`kindofunit_clean` = 'environmental sample') <br />
union select <br />
count(`grouped_fullscientificname`.`fullscientificname`) AS `counts`,<br />
'Taxa' AS `kind`<br />
from<br />
`ggbn_index`.`grouped_fullscientificname` <br />
union select <br />
count(distinct `families_view`.`family`) AS `counts`,<br />
'Families' AS `kind`<br />
from<br />
`ggbn_index`.`families_view` <br />
union select <br />
count(distinct `genera_view`.`genus`) AS `counts`,<br />
'Genera' AS `kind`<br />
from<br />
`ggbn_index`.`genera_view` <br />
union select <br />
count(distinct `species_view`.`species`) AS `counts`,<br />
'Species' AS `kind`<br />
from<br />
`ggbn_index`.`species_view`<br />
</pre><br />
<pre><br />
CREATE <br />
ALGORITHM = UNDEFINED <br />
DEFINER = `root`@`localhost` <br />
SQL SECURITY DEFINER<br />
VIEW `families_view` AS<br />
select distinct<br />
`f`.`family` AS `family`<br />
from<br />
((`backbone`.`family` `f`<br />
join `backbone`.`name` `n` ON ((`f`.`familykey` = `n`.`familyKey`)))<br />
join `ggbn_index`.`identification` `i` ON ((`i`.`gbifKey` = `n`.`acceptedKey`))) <br />
union select distinct<br />
`f`.`family` AS `family`<br />
from<br />
((`backbone_col`.`family` `f`<br />
join `backbone_col`.`name` `n` ON ((`f`.`familykey` = `n`.`familyKey`)))<br />
join `ggbn_index`.`identification` `i` ON ((`i`.`colKey` = `n`.`acceptedKey`))) <br />
union select distinct<br />
`f`.`family` AS `family`<br />
from<br />
((`backbone_ncbi`.`family` `f`<br />
join `backbone_ncbi`.`name` `n` ON ((`f`.`familykey` = `n`.`familyKey`)))<br />
join `ggbn_index`.`identification` `i` ON ((`i`.`ncbiKey` = `n`.`acceptedKey`)))<br />
</pre><br />
<pre><br />
CREATE <br />
ALGORITHM = UNDEFINED <br />
DEFINER = `root`@`localhost` <br />
SQL SECURITY DEFINER<br />
VIEW `genera_view` AS<br />
select distinct<br />
`f`.`genus` AS `genus`<br />
from<br />
((`backbone`.`genus` `f`<br />
join `backbone`.`name` `n` ON ((`f`.`genuskey` = `n`.`genusKey`)))<br />
join `ggbn_index`.`identification` `i` ON ((`i`.`gbifKey` = `n`.`acceptedKey`))) <br />
union select distinct<br />
`f`.`genus` AS `genus`<br />
from<br />
((`backbone_col`.`genus` `f`<br />
join `backbone_col`.`name` `n` ON ((`f`.`genuskey` = `n`.`genusKey`)))<br />
join `ggbn_index`.`identification` `i` ON ((`i`.`colKey` = `n`.`acceptedKey`))) <br />
union select distinct<br />
`f`.`genus` AS `genus`<br />
from<br />
((`backbone_ncbi`.`genus` `f`<br />
join `backbone_ncbi`.`name` `n` ON ((`f`.`genuskey` = `n`.`genusKey`)))<br />
join `ggbn_index`.`identification` `i` ON ((`i`.`ncbiKey` = `n`.`acceptedKey`)))<br />
</pre><br />
<pre><br />
CREATE <br />
ALGORITHM = UNDEFINED <br />
DEFINER = `root`@`localhost` <br />
SQL SECURITY DEFINER<br />
VIEW `grouped_fullscientificname` AS<br />
select <br />
`identification`.`fullScientificName` AS `fullscientificname`<br />
from<br />
`identification`<br />
group by `identification`.`fullScientificName`<br />
</pre><br />
<pre><br />
CREATE <br />
ALGORITHM = UNDEFINED <br />
DEFINER = `root`@`localhost` <br />
SQL SECURITY DEFINER<br />
VIEW `species_view` AS<br />
select distinct<br />
`n2`.`canonicalName` AS `species`<br />
from<br />
((`backbone`.`name` `n`<br />
join `backbone`.`name` `n2` ON ((`n`.`acceptedKey` = `n2`.`namekey`)))<br />
join `ggbn_index`.`identification` `i` ON ((`i`.`gbifKey` = `n`.`acceptedKey`)))<br />
where<br />
((`n`.`rank` = 'SPECIES')<br />
and (`n2`.`rank` = 'SPECIES')) <br />
union select distinct<br />
`n2`.`canonicalName` AS `species`<br />
from<br />
((`backbone_col`.`name` `n`<br />
join `backbone_col`.`name` `n2` ON ((`n`.`acceptedKey` = `n2`.`namekey`)))<br />
join `ggbn_index`.`identification` `i` ON ((`i`.`colKey` = `n`.`acceptedKey`)))<br />
where<br />
((`n`.`rank` = 'SPECIES')<br />
and (`n2`.`rank` = 'SPECIES')) <br />
union select distinct<br />
`n2`.`canonicalName` AS `species`<br />
from<br />
((`backbone_ncbi`.`name` `n`<br />
join `backbone_ncbi`.`name` `n2` ON ((`n`.`acceptedKey` = `n2`.`namekey`)))<br />
join `ggbn_index`.`identification` `i` ON ((`i`.`ncbiKey` = `n`.`acceptedKey`)))<br />
where<br />
((`n`.`rank` = 'SPECIES')<br />
and (`n2`.`rank` = 'SPECIES'))<br />
</pre><br />
<br />
==Specific columns and tables==<br />
* The institution has to be filled in bio_datasource (city and institution, for the harvester_factoy like '%Harvester%') - but first the datasource has to be added (metadata update). It will be used for the repository/registry field in the GGBN portal.<br />
* The parentInstitution table is used for the contacts and must be filled manually.<br />
* The GGBN registry is based on the NCD software and requires an additional database connection in the config file. Contact us for more information.<br />
* For user management (login/shopping), a few extra tables are required. Follow the instructions from the file common/controllers/CommonPermissionController.php to create and populate them if you do not already have them from the SQL-Dump. You will also need an extra view for the statistics:<br />
<pre><br />
CREATE <br />
ALGORITHM = UNDEFINED <br />
DEFINER = `root`@`localhost` <br />
SQL SECURITY DEFINER<br />
VIEW `shopping_view` AS<br />
select distinct<br />
`oc`.`fk_tripleidstoreid` AS `tripleidstoreid`,<br />
`bs`.`id` AS `data_source_id`,<br />
`pit`.`parentInstitutionID` AS `parentInstitutionID`,<br />
`pit`.`institutionShort` AS `institutionShort`,<br />
`pit`.`logoURL` AS `logoURL`<br />
from<br />
((`bio_datasource` `bs`<br />
join `occurrence` `oc` ON ((`bs`.`id` = `oc`.`fk_datasourceid`)))<br />
join `parentInstitution` `pit` ON ((`bs`.`fk_parentInstitutionid` = `pit`.`parentInstitutionID`)))<br />
</pre><br />
<br />
=SOLR core for search within a website=<br />
Install apache-nutch (tested with apache-nutch-1.10, https://wiki.apache.org/nutch/NutchTutorial). You need a local SOLR instance (easier that way).<br />
Configure in the folder "urls" the urls to seed (here http://data.ggbn.org/)<br />
You need another Core on the SOLR server (called nutch).<br />
<br />
Go in the installed folder and run: <br />
bin/crawl -i -D solr.server.url=http://localhost:8080/solr/nutch urls/ TestCrawl1002/ 2<br />
<br />
Stop the SOLR instance for a short moment on the SOLR server, copy the local nutch/data files on the server (also in nutch data, you can choose to delete the old files first, then copy, then check the writing/reading rights in this data folder).<br />
<br />
Restart the SOLR instance.<br />
<br />
Note: if you have old links in the search results, delete the content of the data folder of SOLR, and run 2 times the crawl function (exact same line).<br />
<br />
=Add new statistics charts=<br />
Example: show overview for the repositories (with filters). The repository will '''not''' be an active filter in the global statistics tab.<br />
Edit the file <code>StatsController.php</code>.<br />
<br />
In the function actionIndex, add following variables:<br />
<pre><br />
$repositoriessamples = [ ];<br />
$repositoriesvouchers = [ ];<br />
</pre><br />
and the calls to<br />
<pre><br />
try {<br />
$repositoriesvouchers = $this->getRepositories( $f, 'vouchers' );<br />
} catch ( \Solarium\Exception\HttpException $e ) {<br />
Yii::$app->mailer->compose ()->setFrom ( Yii::$app->params ['noreplyMail'] )->setTo ( Yii::$app->params ['feedbackMail'] )->setSubject ( 'Error occured' )->setTextBody ( $e )->send ();<br />
return $this->render ( '/site/error', [<br />
"name" => "Oooops",<br />
"message" => "The SOLR instance seems to be gone.",<br />
"error" => $e<br />
] );<br />
}<br />
<br />
try {<br />
$repositoriessamples = $this->getRepositories ( $f, 'samples' );<br />
} catch ( \Solarium\Exception\HttpException $e ) {<br />
Yii::$app->mailer->compose ()->setFrom ( Yii::$app->params ['noreplyMail'] )->setTo ( Yii::$app->params ['feedbackMail'] )->setSubject ( 'Error occured' )->setTextBody ( $e )->send ();<br />
return $this->render ( '/site/error', [<br />
"name" => "Oooops",<br />
"message" => "The SOLR instance seems to be gone.",<br />
"error" => $e<br />
] );<br />
}<br />
</pre><br />
and also<br />
<pre><br />
'repositoriessamples' => $repositoriessamples,<br />
'repositoriesvouchers' => $repositoriesvouchers,<br />
</pre> to the render list<br />
<br />
Create the function <code>getRepositories</code> (copy the getKindofunit method and edit the name of the SOLR facet).<br />
<pre><br />
public function getRepositories($filter, $type) {<br />
// Yii::info ( "getKindofunit " . $filter );<br />
$config = SOLRQueryManager::getConfigStats ();<br />
// create a client instance<br />
$client = new Solarium\Client ( $config );<br />
// set the adapter to http<br />
$client->setAdapter ( 'Solarium\Core\Client\Adapter\Http' );<br />
<br />
// get a select query instance<br />
$query = $client->createSelect ();<br />
// set fields to fetch (this overrides the default setting 'all fields')<br />
$query->setFields ( [<br />
"[]"<br />
] );<br />
<br />
$q = "sampletype:*";<br />
if ($type === "vouchers")<br />
$q = "sampletype:(culture OR specimen OR unknown OR eVoucher)";<br />
if ($type === "samples")<br />
$q = "-sampletype:(culture OR specimen OR unknown OR eVoucher)";<br />
if (! empty ( $filter ))<br />
$q .= " AND " . $filter;<br />
$q = str_replace ( "registry", "institution", $q );<br />
$query->setQuery ( $q );<br />
<br />
<br />
// get the facetset component<br />
$facetSet = $query->getFacetSet ();<br />
$facetSet->setLimit ( - 1 );<br />
$facetSet->setMinCount ( 1 );<br />
$facetSet->setSort ( "false" );<br />
<br />
// create a facet field instance and set options<br />
$facetSet->createFacetField ( "institution" )->setField ( "institution" );<br />
// this executes the query and returns the result<br />
$raw_response = $client->select ( $query );<br />
<br />
$result = $raw_response->getFacetSet ()->getFacet ( "institution" );<br />
$data = [ ];<br />
foreach ( $result as $doc => $count ) {<br />
$data [] = '["' . $doc . ' (' . $count . ')",' . $count . ']';<br />
// Yii::info("SUBLIST: ".$doc);<br />
}<br />
<br />
return "[" . implode ( ",", $data ) . "]";<br />
}<br />
</pre><br />
<br />
Now, the view has to be edited, to display the new graphs.<br />
Edit the file <code>views/stats/index.php</code>.<br />
Add in the "Global" tab two new divs (with new ids)<br />
<pre><br />
<div class="col-lg-6" id="chartrepo1" style="width: 500px; height: 400px;"></div><br />
<div class="col-lg-6" id="chartrepo2" style="width: 500px; height: 400px;"></div><br />
</pre><br />
Edit the Javascript part: copy the code for the $kindofunitdatasamples and edit it <br />
<pre><br />
<?php if(!empty($repositoriessamples) && $repositoriessamples!="[]"):?><br />
var data =<?php echo $repositoriessamples;?>;<br />
var plot1 = jQuery.jqplot ('chartrepo1', [data],<br />
{<br />
title: 'Repositories - samples',<br />
grid: {borderColor: 'white', shadow: false, drawBorder: false},<br />
seriesDefaults: {<br />
// Make this a pie chart.<br />
renderer: jQuery.jqplot.PieRenderer,<br />
rendererOptions: {<br />
// Put data labels on the pie slices.<br />
// By default, labels show the percentage of the slice.<br />
showDataLabels: true,<br />
fill: false,<br />
sliceMargin: 4,<br />
lineWidth: 5,<br />
}<br />
},<br />
highlighter: {<br />
show: true,<br />
sizeAdjust: 7.5<br />
},<br />
legend: { show:true, location: 'e' }<br />
}<br />
);<br />
<?php endif;?><br />
<br />
<?php if(!empty($repositoriesvouchers) && $repositoriesvouchers!="[]"):?><br />
var data =<?php echo $repositoriesvouchers;?>;<br />
var plot1 = jQuery.jqplot ('chartrepo2', [data],<br />
{<br />
title: 'Repositories - vouchers',<br />
grid: {borderColor: 'white', shadow: false, drawBorder: false},<br />
seriesDefaults: {<br />
// Make this a pie chart.<br />
renderer: jQuery.jqplot.PieRenderer,<br />
rendererOptions: {<br />
// Put data labels on the pie slices.<br />
// By default, labels show the percentage of the slice.<br />
showDataLabels: true,<br />
fill: false,<br />
sliceMargin: 4,<br />
lineWidth: 5,<br />
}<br />
},<br />
highlighter: {<br />
show: true,<br />
sizeAdjust: 7.5<br />
},<br />
legend: { show:true, location: 'e' }<br />
}<br />
);<br />
<?php endif;?><br />
</pre><br />
<br />
Here you go !<br />
<br />
[[File:repoStats.png]]</div>
GabiDroege