Skip to content

Commit

Permalink
Partial update branch by pulling in master bug fixes (#523)
Browse files Browse the repository at this point in the history
* Occurrence Taxon Indexing adjustments

- Refactor OccurrenceMaintenance class to consolidate occurrence indexing tools into single set of functions
- Isolate general occurrence cleaning SQL statements from taxon indexing SQL
- Extend occurrence-taxon indexing to accommodate a matching hierarchy that involves taxon author, subgeneric formats, etc
- Refactor occurrence statistic function

* Taxonomic function adjustments

- Remove occurrence cleaning and occurrence-taxon indexing functions in preference to identical functions within OccurrenceMaintenance class (consolidate functions)

* Taxonomic Harvester bug

- Fix Catalog of Life API import issue where in certain situation species names are duplicated with one containing imbedded subgeneric name and the other not

* Resolve COL Taxonomy Harvesting discrepancies

- Include taxonRank within the ranking algorithm to get a correct match on subgenera search
- Condense translateColNode algorithm into a single function that can translate both api and webservice formats
- Various adjustments to subgeneric formatting

* Update code version

* Hotfix 2023-05-25 (#488)

* Taxon Profile display bug - Ensure the taxadescrblock field take precedence

* GeoLocate CoGe bug fix - path correction for temp staging area

* Hotfix: Occurrence upload, Key editor, Taxon Profile

- Resolve issue with occurrence-taxon indexing code
- Only build sciname from taxon units if all units are mapped
- Resolve issue with ID Key editor not displaying characters that are not grouped
-Taxon Profile insert issue

* Hotfix 2023 06 03 (#508)

* Occurrence Upload adjustment
    - Trim off delimiters that are left on the beginning or end of filter string to ensure that null values are not included
* Collection Listing bug fix
    - Collection categories failing to be persist
* Occurrence Image Submissions issue resolution
    - Set default image sort order to 40 for observations to ensure that preserved specimen images do not take precedence
* Image Processing bug
    - collection identifier (collid) failed to be passed to statistics update function
* Resolve Taxonomy Harvester issues
    - Improve TROPICOS method of matching on infraspecific taxa
    - Improve close match suggestions

* Update .gitignore

* Hotfix 2023 06 19 (#518)

* Taxonomy Harvesting minor adjustments

- Check resources before interpretation and again after interpretation
- If name is matched within one recourse, skip the unnecessary step to check other resources
- Synchronize display text

* Refactor ImageLocalProcessor and resolve various bugs

- Provide support for input file to include medium and thumbnail image derivatives
- Expand Image Map processing to allow mapping file to include any images table field name
- Expand images insert function to handle any valid field found within images table
- Merge duplicate actions into shared private functions
- MD5 hash large version of image input file, but don't overwrite hash if supplied by source, unless image is not modified by upload scripts
- Handle BOM characters at start of csv file.
- Trim header elements for testing column names.
- Enforce default action of accepting derivative urls supplied within a csv image map file
- Improve uriExists function
- Make sure to remove staging images

* Occurrence Public Display page

- Allow occurrence archive (deleted occurrences) to be searchable by GUID (occurrenceID, recordID), thus reporting when a record is deleted

* Checklist multi-polygon map Issue

- Multipolygons defined within a checklist fail to map within both simple and dynamic maps

* Suppress geo ref index during stats update

* Occurrence Reviewer bug

- Fix for field name and start and end date filter variables failing to be carried forward when advancing to pages beyond 1000 records
#335

* Collection metadata editor bug

- Reset contact array to ensure that JSON string is standardized as a non-associated array
Resolves issue: #487

---------

Co-authored-by: Greg Post <[email protected]>

---------

Co-authored-by: Greg Post <[email protected]>
  • Loading branch information
egbot and GregoryPost authored Jul 3, 2023
1 parent a870d74 commit ee0fa67
Show file tree
Hide file tree
Showing 30 changed files with 1,028 additions and 882 deletions.
45 changes: 23 additions & 22 deletions checklists/checklistmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,33 +67,34 @@ function initialize(){
}
}
}
//Check for and add checklist polygon
$clMeta = $clManager->getClMetaData();
if($clMeta['footprintwkt']){
?>
var polyPointArr = [];
<?php
$footPrintWkt = $clMeta['footprintwkt'];
if(substr($footPrintWkt, 0, 7) == 'POLYGON'){
$footPrintWkt = substr($footPrintWkt, 10, -2);
$pointArr = explode(',', $footPrintWkt);
foreach($pointArr as $pointStr){
$llArr = explode(' ', trim($pointStr));
if($llArr[0] > 90 || $llArr[0] < -90) break;
//Add checklist polygon
$wkt = $clMeta['footprintwkt'];
if(substr($wkt,0,7) == 'POLYGON') $wkt = substr($wkt,7);
else if(substr($wkt,0,12) == 'MULTIPOLYGON') $wkt = substr($wkt,12);
$coordArr = explode('),(', $wkt);
foreach($coordArr as $k => $polyFrag){
if($pointArr = explode(',', trim($polyFrag,' (),'))){
echo 'var polyPointArr'.$k.' = [];';
foreach($pointArr as $pointStr){
$llArr = explode(' ', trim($pointStr));
if($llArr[0] > 90 || $llArr[0] < -90) break;
?>
var polyPt = new google.maps.LatLng(<?php echo $llArr[0].','.$llArr[1]; ?>);
polyPointArr<?php echo $k; ?>.push(polyPt);
llBounds.extend(polyPt);
<?php
}
?>
var polyPt = new google.maps.LatLng(<?php echo $llArr[0].','.$llArr[1]; ?>);
polyPointArr.push(polyPt);
llBounds.extend(polyPt);
var footPoly<?php echo $k; ?> = new google.maps.Polygon({
paths: polyPointArr<?php echo $k; ?>,
strokeWeight: 2,
fillOpacity: 0.4,
map: map
});
<?php
}
?>
var footPoly = new google.maps.Polygon({
paths: polyPointArr,
strokeWeight: 2,
fillOpacity: 0.4,
map: map
});
<?php
}
}
?>
Expand Down
2 changes: 0 additions & 2 deletions classes/ChecklistVoucherReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,6 @@ private function getMissingTaxaBaseSql($sqlFrag){
public function getMissingProblemTaxa(){
$retArr = Array();
if($sqlFrag = $this->getSqlFrag()){
//Make sure tidinterpreted are valid
//$this->conn->query('UPDATE omoccurrences o INNER JOIN taxa t ON o.sciname = t.sciname SET o.tidinterpreted = t.tid WHERE o.tidinterpreted IS NULL');
//Grab records
$sql = 'SELECT DISTINCT o.occid, c.institutioncode, c.collectioncode, o.catalognumber, o.sciname, o.recordedby, o.recordnumber, o.eventdate, '.
'CONCAT_WS("; ",o.country, o.stateprovince, o.county, o.locality) as locality '.
Expand Down
693 changes: 376 additions & 317 deletions classes/ImageLocalProcessor.php

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions classes/ImageProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ public function loadFileData($postArr){
$occurMain = new OccurrenceMaintenance($this->conn);

$this->logOrEcho('Updating statistics...');
if(!$occurMain->updateCollectionStats($this->collid)){
if(!$occurMain->updateCollectionStatsBasic($this->collid)){
$errorArr = $occurMain->getErrorArr();
foreach($errorArr as $errorStr){
$this->logOrEcho($errorStr,1);
Expand Down Expand Up @@ -545,7 +545,8 @@ private function cleanHouse($collList){
/*
$this->logOrEcho('General cleaning...',2);
$collString = implode(',',$collList);
if(!$occurMain->generalOccurrenceCleaning($collString)){
$occurMain->setCollidStr($collString);
if(!$occurMain->generalOccurrenceCleaning()){
$errorArr = $occurMain->getErrorArr();
foreach($errorArr as $errorStr){
$this->logOrEcho($errorStr,1);
Expand All @@ -559,7 +560,7 @@ private function cleanHouse($collList){
if($collList){
$this->logOrEcho('Updating collection statistics...',2);
foreach($collList as $collid){
if(!$occurMain->updateCollectionStats($collid)){
if(!$occurMain->updateCollectionStatsBasic($collid)){
$errorArr = $occurMain->getErrorArr();
foreach($errorArr as $errorStr){
$this->logOrEcho($errorStr,1);
Expand Down
7 changes: 3 additions & 4 deletions classes/KeyEditorManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ public function __destruct(){
public function setTid($t){
if(is_numeric($t)){
$this->tid = $t;
$sql = "SELECT t.SciName, ts.ParentTID, t.RankId ".
"FROM taxa t INNER JOIN taxstatus ts ON t.tid = ts.tid WHERE ts.taxauthid = 1 AND (t.TID = ".$this->tid.')';
$sql = 'SELECT t.SciName, ts.ParentTID, t.RankId FROM taxa t INNER JOIN taxstatus ts ON t.tid = ts.tid WHERE ts.taxauthid = 1 AND (t.TID = '.$this->tid.')';
$result = $this->conn->query($sql);
if($row = $result->fetch_object()){
$this->taxonName = $row->SciName;
Expand Down Expand Up @@ -81,9 +80,9 @@ private function setCharList(){
$parentStr = implode(',',$this->getParentArr($this->tid));
$sql = 'SELECT c.CharName, c.CID, ch.headingname, dep.CIDDependance, dep.CSDependance '.
'FROM kmcharacters c INNER JOIN kmchartaxalink ctl ON c.CID = ctl.CID '.
'INNER JOIN kmcharheading ch ON c.hid = ch.hid '.
'LEFT JOIN kmcharheading ch ON c.hid = ch.hid '.
'LEFT JOIN kmchardependance dep ON c.CID = dep.CID '.
'WHERE (ch.language = "English") AND (c.CID Not In (SELECT DISTINCT chartl.CID FROM kmchartaxalink chartl WHERE (chartl.TID In ('.$parentStr.')) AND (chartl.Relation="exclude"))) '.
'WHERE (ch.language IS NULL OR ch.language = "English") AND (c.CID Not In (SELECT DISTINCT chartl.CID FROM kmchartaxalink chartl WHERE (chartl.TID In ('.$parentStr.')) AND (chartl.Relation="exclude"))) '.
'AND (c.chartype = "UM" Or c.chartype="OM") AND (ctl.TID In ('.$parentStr.')) AND (ctl.Relation="include") '.
'ORDER BY ch.SortSequence,c.SortSequence';
//echo $sql;
Expand Down
9 changes: 6 additions & 3 deletions classes/OccurrenceCollectionProfile.php
Original file line number Diff line number Diff line change
Expand Up @@ -507,20 +507,22 @@ public function getBasicStats(){

public function updateStatistics($verbose = false){
$occurMaintenance = new OccurrenceMaintenance();
$occurMaintenance->setCollidStr($this->collid);
if($verbose){
echo '<ul>';
$occurMaintenance->setVerbose(true);
echo '<li>General cleaning in preparation for collecting stats...</li>';
flush();
ob_flush();
}
$occurMaintenance->generalOccurrenceCleaning($this->collid);
$occurMaintenance->generalOccurrenceCleaning();
//$occurMaintenance->batchUpdateGeoreferenceIndex();
if($verbose){
echo '<li>Updating statistics...</li>';
flush();
ob_flush();
}
$occurMaintenance->updateCollectionStats($this->collid, true);
$occurMaintenance->updateCollectionStatsFull();
if($verbose){
echo '<li>Finished updating collection statistics</li>';
flush();
Expand Down Expand Up @@ -602,7 +604,8 @@ public function batchUpdateStatistics($collId){
echo '<li style="margin-left:15px;">Cleaning statistics for: '.$r->collectionname.'</li>';
flush();
ob_flush();
$occurMaintenance->updateCollectionStats($r->collid, true);
$occurMaintenance->setCollidStr($r->collid);
$occurMaintenance->updateCollectionStatsFull();
}
$rs->free();
echo '<li>Statistics update complete!</li>';
Expand Down
1 change: 1 addition & 0 deletions classes/OccurrenceEditorImages.php
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@ public function addImage($postArr){
if(array_key_exists('copyright',$postArr)) $imgManager->setCopyright($postArr['copyright']);
if(array_key_exists('notes',$postArr)) $imgManager->setNotes($postArr['notes']);
if(array_key_exists('sortoccurrence',$postArr)) $imgManager->setSortOccurrence($postArr['sortoccurrence']);
if(strpos($this->collMap['colltype'], 'Observations') !== false) $imgManager->setSortSeq(40);

$sourceImgUri = $postArr['imgurl'];
if($sourceImgUri){
Expand Down
34 changes: 24 additions & 10 deletions classes/OccurrenceIndividual.php
Original file line number Diff line number Diff line change
Expand Up @@ -968,21 +968,35 @@ public function getChecklists($clidExcludeArr){
return $returnArr;
}

public function checkArchive(){
public function checkArchive($guid){
$retArr = array();
$archiveObject = '';
$notes = '';
$sql = 'SELECT archiveobj, remarks FROM omoccurarchive ';
if($this->occid){
$sql = 'SELECT archiveobj, remarks FROM omoccurarchive WHERE occid = '.$this->occid;
if($rs = $this->conn->query($sql)){
if($r = $rs->fetch_object()){
$retArr['obj'] = json_decode($r->archiveobj, true);
$retArr['notes'] = $r->remarks;
}
$rs->free();
$sql .= 'WHERE occid = ?';
if($stmt = $this->conn->prepare($sql)){
$stmt->bind_param('i', $this->occid);
$stmt->execute();
$stmt->bind_result($archiveObject, $notes);
$stmt->fetch();
$stmt->close();
}
else{
trigger_error('ERROR checking archive: '.$this->conn->error,E_USER_WARNING);
}
if(!$retArr && $guid){
$sql .= 'WHERE (occurrenceid = ?) OR (recordID = ?) ';
if($stmt = $this->conn->prepare($sql)){
$stmt->bind_param('ss', $guid, $guid);
$stmt->execute();
$stmt->bind_result($archiveObject, $notes);
$stmt->fetch();
$stmt->close();
}
}
if($archiveObject){
$retArr['obj'] = json_decode($archiveObject, true);
$retArr['notes'] = $notes;
}
return $retArr;
}

Expand Down
Loading

0 comments on commit ee0fa67

Please sign in to comment.