Skip to content

Commit

Permalink
Merge pull request #5 from BioKIC/master
Browse files Browse the repository at this point in the history
Various BioKIC/Symbiota developments and bug fixes
  • Loading branch information
egbot committed Mar 15, 2022
2 parents b9a21ee + 392f250 commit 5c83fe6
Show file tree
Hide file tree
Showing 35 changed files with 572 additions and 482 deletions.
60 changes: 43 additions & 17 deletions admin/portalindex.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
<style type="text/css">
fieldset{ margin:20px; padding:15px; }
legend{ font-weight: bold; }
label{ font-weight: bold; }
label{ }
button{ margin: 20px; }
hr{ margin-top: 15px; margin-bottom: 15px; }
</style>
</head>
Expand All @@ -44,15 +45,14 @@
?>
<div class="navpath">
<a href="../../index.php">Home</a> &gt;&gt;
<b>Portal Index Control Panel</b>
<b><a href="portalindex.php">Portal Index Control Panel</a></b>
</div>
<div id="innertext">
<?php
if($isEditor){
if($formSubmit == 'importProfile'){
if($collid = $portalManager->importProfile($portalID, $remoteID))
echo '<div><a href="../collections/misc/collprofiles.php?collid='.$collid.'" target="_blank">New snapshot collection created</a></div>';
else echo '<div>failed to insert new collections: '.$portalManager->getErrorMessage().'</div>';
if($collid = $portalManager->importProfile($portalID, $remoteID)) echo '<div><a href="../collections/misc/collprofiles.php?collid='.$collid.'" target="_blank">New snapshot collection created</a></div>';
else echo '<div>failed to insert new collections: '.$portalManager->getErrorMessage().'</div>';
}
$indexArr = $portalManager->getPortalIndexArr($portalID);
?>
Expand All @@ -72,34 +72,59 @@
echo '</div>';
}
}
echo '<hr/>';
if($remoteID){
$collectArr = $portalManager->getCollectionList($portalArr['urlRoot'], $remoteID);
$collTitle = $collectArr['collectionName'].' ('.$collectArr['institutionCode'].($collectArr['collectionCode']?':'.$collectArr['collectionCode']:'').')';
echo '<div style="font-weight:bold">#'.$remoteID.': '.$collTitle.'</div>';
$collectArr['remoteID'] = $collectArr['collID'];
echo '<fieldset>';
echo '<legend>Remote Collection #'.$remoteID.'</legend>';
$remoteCollid = $collectArr['collID'];
unset($collectArr['collID']);
echo '<div style="margin:15px 30px;">';
unset($collectArr['iid']);
$internalArr = $collectArr['internal'];
unset($collectArr['internal']);
foreach($collectArr as $fName => $fValue){
if($fValue){
if($fName == 'fullDescription') $fValue = htmlentities($fValue);
elseif($fName == 'internalCollid') $fValue = '<a href="'.$CLIENT_ROOT.'/collections/misc/collprofiles.php?collid='.$fValue.'" target="_blank">Mapped Internally</a>';
echo '<div><label>'.$fName.'</label>: '.$fValue.'</div>';
}
}
echo '</div>';
if(!$collectArr['internalCollid']){
$remoteUrl = $portalArr['urlRoot'].'/collections/misc/collprofiles.php?collid='.$remoteCollid;
echo '<div><label>Remote collection</label>: <a href="'.$remoteUrl.'" target="_blank">'.$remoteUrl.'</a></div>';
if($internalArr){
echo '<fieldset>';
echo '<legend>Internally Mapped Snapshot Collection</legend>';
foreach($internalArr as $collid => $intArr){
echo '<div><label>Management Type</label>: '.$intArr['managementType'].'</div>';
echo '<div><label>Specimen count</label>: '.number_format($intArr['recordCnt']).'</div>';
echo '<div><label>Refresh date</label>: '.$intArr['uploadDate'].'</div>';
$internalUrl = $CLIENT_ROOT.'/collections/misc/collprofiles.php?collid='.$collid;
echo '<div><label>Internal collection</label>: <a href="'.$internalUrl.'" target="_blank">'.$internalUrl.'</a></div>';
if($importProfile = $portalManager->getDataImportProfile($collid)){
foreach($importProfile as $uspid => $profileArr){
echo '<hr/>';
echo '<div style="margin:10px 5px">';
echo '<div><label>Title</label>: '.$profileArr['title'].'</div>';
echo '<div><label>Path</label>: '.$profileArr['path'].'</div>';
echo '<div><label>Query string</label>: '.$profileArr['queryStr'].'</div>';
echo '<div><label>Stored procedure (cleaning)</label>: '.$profileArr['cleanUpSp'].'</div>';
echo '<div>Go to <a href="../collections/admin/specuploadmap.php?uploadtype=9&uspid='.$uspid.'&collid='.$collid.'" target="_blank">Import Profile</a></div>';
echo '</div>';
}
}
}
echo '</fieldset>';
}
else{
?>
<div style="margin: 0px 30px">
<form name="collPubForm" method="post" action="portalindex.php">
<input name="portalid" type="hidden" value="<?php echo $portalID; ?>" />
<input name="remoteid" type="hidden" value="<?php echo $remoteID; ?>" />
<input name="collid" type="hidden" value="<?php echo $collectArr['internalCollid']; ?>" />
<button name="formsubmit" type="submit" value="importProfile">Import Profile</button>
<button name="formsubmit" type="submit" value="importProfile">Create Internal Snapshot Profile</button>
</form>
</div>
<?php
}
echo '</fieldset>';
}
elseif($formSubmit == 'listCollections'){
if($collList = $portalManager->getCollectionList($portalArr['urlRoot'])){
Expand All @@ -114,7 +139,8 @@
echo '<td>'.$collArr['collectionName'].'</td>';
echo '<td>'.$collArr['collType'].'</td>';
echo '<td>'.$collArr['managementType'].'</td>';
if($collArr['internalCollid']) $internal = '<a href="'.$CLIENT_ROOT.'/collections/misc/collprofiles.php?collid='.$collArr['internalCollid'].'" target="_blank">Yes</a>';
if(isset($collArr['internal']) && $collArr['internal'])
$internal = '<a href="'.$CLIENT_ROOT.'/collections/misc/collprofiles.php?collid='.key($collArr['internal']).'" target="_blank">Yes</a>';
else $internal = 'No';
echo '<td>'.$internal.'</td>';
echo '</tr>';
Expand All @@ -124,7 +150,7 @@
}
else{
?>
<div>
<div style="margin:15px;">
<form name="portalActionForm" method="post" action="portalindex.php">
<input name="portalid" type="hidden" value="<?php echo $portalID; ?>" />
<button name="formsubmit" type="submit" value="listCollections">List Collections</button>
Expand Down
2 changes: 1 addition & 1 deletion api/app/Http/Controllers/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ class Controller extends BaseController
*/

/**
* @OA\Server(url="portal")
* @OA\Server(url="../")
*/
}
82 changes: 50 additions & 32 deletions classes/DwcArchiverCore.php
Original file line number Diff line number Diff line change
Expand Up @@ -304,38 +304,16 @@ private function applyConditions(){
else $field = 'o.'.$field;
$sqlFrag2 = '';
foreach($condArr as $cond => $valueArr){
if($cond == 'NULL'){
$sqlFrag2 .= 'AND ('.$field.' IS NULL) ';
}
elseif($cond == 'NOTNULL'){
$sqlFrag2 .= 'AND ('.$field.' IS NOT NULL) ';
}
elseif($cond == 'EQUALS'){
$sqlFrag2 .= 'AND ('.$field.' IN("'.implode('","',$valueArr).'")) ';
}
elseif($cond == 'NOTEQUALS'){
$sqlFrag2 .= 'AND ('.$field.' NOT IN("'.implode('","',$valueArr).'")) ';
if($field == 'o.otherCatalogNumbers'){
$conj = 'OR';
if($cond == 'NOTEQUALS' || $cond == 'NOTLIKE' || $cond == 'NULL') $conj = 'AND';
$sqlFrag2 .= 'AND ('.substr($this->getSqlFragment($field, $cond, $valueArr),3).' ';
$sqlFrag2 .= $conj.' ('.substr($this->getSqlFragment('id.identifierValue', $cond, $valueArr),3);
if($cond == 'NOTEQUALS' || $cond == 'NOTLIKE') $sqlFrag2 .= ' OR id.identifierValue IS NULL';
$sqlFrag2 .= ')) ';
}
else{
$sqlFrag3 = '';
foreach($valueArr as $value){
if($cond == 'STARTS'){
$sqlFrag3 .= 'OR ('.$field.' LIKE "'.$value.'%") ';
}
elseif($cond == 'LIKE'){
$sqlFrag3 .= 'OR ('.$field.' LIKE "%'.$value.'%") ';
}
elseif($cond == 'NOTLIKE'){
$sqlFrag3 .= 'OR ('.$field.' NOT LIKE "%'.$value.'%") ';
}
elseif($cond == 'LESSTHAN'){
$sqlFrag3 .= 'OR ('.$field.' < "'.$value.'") ';
}
elseif($cond == 'GREATERTHAN'){
$sqlFrag3 .= 'OR ('.$field.' > "'.$value.'") ';
}
}
$sqlFrag2 .= 'AND ('.substr($sqlFrag3,3).') ';
$sqlFrag2 = $this->getSqlFragment($field, $cond, $valueArr);
}
}
if($sqlFrag2) $sqlFrag .= 'AND ('.substr($sqlFrag2,4).') ';
Expand All @@ -356,6 +334,44 @@ private function applyConditions(){
}
}

private function getSqlFragment($field, $cond, $valueArr){
$sql = '';
if($cond == 'NULL'){
$sql .= 'AND ('.$field.' IS NULL) ';
}
elseif($cond == 'NOTNULL'){
$sql .= 'AND ('.$field.' IS NOT NULL) ';
}
elseif($cond == 'EQUALS'){
$sql .= 'AND ('.$field.' IN("'.implode('","',$valueArr).'")) ';
}
elseif($cond == 'NOTEQUALS'){
$sql .= 'AND ('.$field.' NOT IN("'.implode('","',$valueArr).'") OR '.$field.' IS NULL) ';
}
else{
$sqlFrag = '';
foreach($valueArr as $value){
if($cond == 'STARTS'){
$sqlFrag .= 'OR ('.$field.' LIKE "'.$value.'%") ';
}
elseif($cond == 'LIKE'){
$sqlFrag .= 'OR ('.$field.' LIKE "%'.$value.'%") ';
}
elseif($cond == 'NOTLIKE'){
$sqlFrag .= 'OR ('.$field.' NOT LIKE "%'.$value.'%" OR '.$field.' IS NULL) ';
}
elseif($cond == 'LESSTHAN'){
$sqlFrag .= 'OR ('.$field.' < "'.$value.'") ';
}
elseif($cond == 'GREATERTHAN'){
$sqlFrag .= 'OR ('.$field.' > "'.$value.'") ';
}
}
$sql .= 'AND ('.substr($sqlFrag,3).') ';
}
return $sql;
}

private function getTableJoins(){
$sql = '';
if($this->conditionSql){
Expand Down Expand Up @@ -385,8 +401,10 @@ private function getTableJoins(){
}
elseif(stripos($this->conditionSql,'s.traitid')){
//Search is limited by occurrence trait
$sql .= 'INNER JOIN tmattributes a ON o.occid = a.occid '.
'INNER JOIN tmstates s ON a.stateid = s.stateid ';
$sql .= 'INNER JOIN tmattributes a ON o.occid = a.occid INNER JOIN tmstates s ON a.stateid = s.stateid ';
}
if(strpos($this->conditionSql,'id.identifierValue')){
$sql .= 'LEFT JOIN omoccuridentifiers id ON o.occid = id.occid ';
}
}
return $sql;
Expand Down
20 changes: 10 additions & 10 deletions classes/ImageLocalProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -615,13 +615,13 @@ private function processImageFile($fileName, $targetFileName, $targetPath, $sour
if($this->webImg == 1){
// 1 = evaluate source and import
if($fileSize < $this->webFileSizeLimit && $width < ($this->webPixWidth*2)){
if(copy($sourcePath.$fileName,$targetPath.$targetFileName)){
if(copy($sourcePath.$fileName, $targetPath.$targetFileName)){
$webUrl = $targetFileName;
$this->logOrEcho("Source image imported as web image (".date('Y-m-d h:i:s A').") ",1);
}
}
else{
if($this->createNewImage($sourcePath.$fileName,$targetPath.$targetFileName,$this->webPixWidth,round($this->webPixWidth*$height/$width),$width,$height)){
if($this->createNewImage($sourcePath.$fileName, $targetPath.$targetFileName,$this->webPixWidth,round($this->webPixWidth*$height/$width),$width,$height)){
$webUrl = $targetFileName;
$this->logOrEcho("Web image created from source image (".date('Y-m-d h:i:s A').") ",1);
}
Expand All @@ -630,7 +630,7 @@ private function processImageFile($fileName, $targetFileName, $targetPath, $sour
elseif($this->webImg == 2){
// 2 = import source and use as is
$webFileName = $fileNameBase.$this->webSourceSuffix.$fileNameExt;
if(copy($sourcePath.$webFileName,$targetPath.$targetFileName)){
if(copy($sourcePath.$webFileName, $targetPath.$targetFileName)){
$webUrl = $targetFileName;
$this->logOrEcho("Source image imported as web image (".date('Y-m-d h:i:s A').") ",1);
}
Expand All @@ -655,7 +655,7 @@ private function processImageFile($fileName, $targetFileName, $targetPath, $sour
//Source image is big enough to serve as large version
if($width > $this->lgPixWidth){
//Image is too wide, thus let's resize and import
if($this->createNewImage($sourcePath.$fileName,$targetPath.$lgTargetFileName,$this->lgPixWidth,round($this->lgPixWidth*$height/$width),$width,$height)){
if($this->createNewImage($sourcePath.$fileName, $targetPath.$lgTargetFileName,$this->lgPixWidth,round($this->lgPixWidth*$height/$width),$width,$height)){
$lgUrl = $lgTargetFileName;
$this->logOrEcho("Resized source as large derivative (".date('Y-m-d h:i:s A').") ",1);
}
Expand All @@ -672,9 +672,9 @@ private function processImageFile($fileName, $targetFileName, $targetPath, $sour
$newWidth = round($width * sqrt($ratio));

// Resize the image
if($this->createNewImage($sourcePath.$fileName,$targetPath.$lgTargetFileName,$newWidth,round($newWidth*$height/$width),$width,$height)){
$lgUrlFrag = $this->imgUrlBase.$targetFrag.$lgTargetFileName;
$this->logOrEcho("Resized source as large derivative (".date('Y-m-d h:i:s A').") ",1);
if($this->createNewImage($sourcePath.$fileName, $targetPath.$lgTargetFileName, $newWidth, round($newWidth*$height/$width), $width, $height)){
$lgUrl = $lgTargetFileName;
$this->logOrEcho("Resized source as large derivative (".date('Y-m-d h:i:s A').") ",1);
}
}
else{
Expand All @@ -684,7 +684,7 @@ private function processImageFile($fileName, $targetFileName, $targetPath, $sour
$this->logOrEcho("Imported source as large derivative (".date('Y-m-d h:i:s A').") ",1);
}
else{
$this->logOrEcho("WARNING: unable to import large derivative (".$sourcePath.$lgSourceFileName.") ",1);
$this->logOrEcho("WARNING: unable to import large derivative (".$sourcePath.$fileName.") ",1);
}
}
}
Expand Down Expand Up @@ -804,8 +804,8 @@ private function createNewImage($sourcePathBase, $targetPath, $newWidth, $newHei

private function createNewImageImagick($sourceImg,$targetPath,$newWidth,$newHeight){
$status = false;
$ct;
$retval;
$ct = null;
$retval = null;

if(!$newWidth || !$newHeight){
$this->logOrEcho("ERROR: Unable to create image because new width or height is not set (w:".$newWidth.' h:'.$newHeight.')');
Expand Down
Loading

0 comments on commit 5c83fe6

Please sign in to comment.