private function cleanHouse($collList) { $this->logOrEcho('Updating collection statistics...', 1); $occurMain = new OccurrenceMaintenance($this->conn); $this->logOrEcho('General cleaning...', 2); $collString = implode(',', $collList); if (!$occurMain->generalOccurrenceCleaning($collString)) { $errorArr = $occurMain->getErrorArr(); foreach ($errorArr as $errorStr) { $this->logOrEcho($errorStr, 1); } } $this->logOrEcho('Protecting sensitive species...', 2); if (!$occurMain->protectRareSpecies()) { $errorArr = $occurMain->getErrorArr(); foreach ($errorArr as $errorStr) { $this->logOrEcho($errorStr, 1); } } if ($collList) { $this->logOrEcho('Updating collection statistics...', 2); foreach ($collList as $collid) { if (!$occurMain->updateCollectionStats($collid)) { $errorArr = $occurMain->getErrorArr(); foreach ($errorArr as $errorStr) { $this->logOrEcho($errorStr, 1); } } } } $this->logOrEcho('Populating global unique identifiers (GUIDs) for all records...', 2); $uuidManager = new UuidFactory($this->conn); $uuidManager->setSilent(1); $uuidManager->populateGuids(); }
public function updateStatistics($verbose = false) { $occurMaintenance = new OccurrenceMaintenance(); if ($verbose) { echo '<ul>'; $occurMaintenance->setVerbose(true); echo '<li>General cleaning in preparation for collecting stats...</li>'; flush(); ob_flush(); } $occurMaintenance->generalOccurrenceCleaning($this->collid); if ($verbose) { echo '<li>Updating statistics...</li>'; flush(); ob_flush(); } $occurMaintenance->updateCollectionStats($this->collid, true); if ($verbose) { echo '<li>Finished updating collection statistics</li>'; flush(); ob_flush(); } }
private function updateCollectionStats() { if ($this->dbMetadata) { //Do some more cleaning of the data after it haas been indexed in the omoccurrences table $occurMain = new OccurrenceMaintenance($this->conn); $this->logOrEcho('Cleaning house...'); $collString = implode(',', $this->collProcessedArr); if (!$occurMain->generalOccurrenceCleaning($collString)) { $errorArr = $occurMain->getErrorArr(); foreach ($errorArr as $errorStr) { $this->logOrEcho($errorStr, 1); } } $this->logOrEcho('Protecting sensitive species...'); if (!$occurMain->protectRareSpecies()) { $errorArr = $occurMain->getErrorArr(); foreach ($errorArr as $errorStr) { $this->logOrEcho($errorStr, 1); } } $this->logOrEcho('Updating statistics...'); foreach ($this->collProcessedArr as $collid) { if (!$occurMain->updateCollectionStats($collid)) { $errorArr = $occurMain->getErrorArr(); foreach ($errorArr as $errorStr) { $this->logOrEcho($errorStr, 1); } } } $this->logOrEcho('Populating global unique identifiers (GUIDs) for all records...'); $uuidManager = new UuidFactory(); $uuidManager->setSilent(1); $uuidManager->populateGuids(); } $this->logOrEcho("Stats update completed"); }
protected function finalCleanup() { $this->outputMsg('<li>Transfer process complete</li>'); //Update uploaddate $sql = 'UPDATE omcollectionstats SET uploaddate = CURDATE() WHERE collid = ' . $this->collId; $this->conn->query($sql); //Remove records from occurrence temp table (uploadspectemp) $sql = 'DELETE FROM uploadspectemp WHERE (collid = ' . $this->collId . ') OR (initialtimestamp < DATE_SUB(CURDATE(),INTERVAL 3 DAY))'; $this->conn->query($sql); //Optimize table to reset indexes $this->conn->query('OPTIMIZE TABLE uploadspectemp'); //Remove records from determination temp table (uploaddetermtemp) $sql = 'DELETE FROM uploaddetermtemp WHERE (collid = ' . $this->collId . ') OR (initialtimestamp < DATE_SUB(CURDATE(),INTERVAL 3 DAY))'; $this->conn->query($sql); //Optimize table to reset indexes $this->conn->query('OPTIMIZE TABLE uploaddetermtemp'); //Remove records from image temp table (uploadimagetemp) $sql = 'DELETE FROM uploadimagetemp WHERE (collid = ' . $this->collId . ') OR (initialtimestamp < DATE_SUB(CURDATE(),INTERVAL 3 DAY))'; $this->conn->query($sql); //Optimize table to reset indexes $this->conn->query('OPTIMIZE TABLE uploadimagetemp'); //Do some more cleaning of the data after it haas been indexed in the omoccurrences table $occurMain = new OccurrenceMaintenance($this->conn); $this->outputMsg('<li>Cleaning house</li>'); ob_flush(); flush(); if (!$occurMain->generalOccurrenceCleaning($this->collId)) { $errorArr = $occurMain->getErrorArr(); foreach ($errorArr as $errorStr) { echo '<li style="margin-left:20px;">' . $errorStr . '</li>'; } } $this->outputMsg('<li style="margin-left:10px;">Protecting sensitive species...</li>'); ob_flush(); flush(); if (!$occurMain->protectRareSpecies($this->collId)) { $errorArr = $occurMain->getErrorArr(); foreach ($errorArr as $errorStr) { echo '<li style="margin-left:20px;">' . $errorStr . '</li>'; } } $this->outputMsg('<li style="margin-left:10px;">Updating statistics...</li>'); ob_flush(); flush(); if (!$occurMain->updateCollectionStats($this->collId)) { $errorArr = $occurMain->getErrorArr(); foreach ($errorArr as $errorStr) { echo '<li style="margin-left:20px;">' . $errorStr . '</li>'; } } /* $this->outputMsg('<li style="margin-left:10px;">Searching for duplicate Catalog Numbers... '); ob_flush(); flush(); $sql = 'SELECT catalognumber FROM omoccurrences GROUP BY catalognumber, collid '. 'HAVING Count(*)>1 AND collid = '.$this->collId.' AND catalognumber IS NOT NULL'; $rs = $this->conn->query($sql); if($rs->num_rows){ $this->outputMsg('<span style="color:red;">Duplicate Catalog Numbers exist</span></li>'); $this->outputMsg('<li style="margin-left:10px;">'); $this->outputMsg('Open <a href="../cleaning/occurrencecleaner.php?collid='.$this->collId.'&action=listdupscatalog" target="_blank">Occurrence Cleaner</a> to resolve this issue'); $this->outputMsg('</li>'); } else{ $this->outputMsg('All good!</li>'); } $rs->free(); */ $this->outputMsg('<li style="margin-left:10px;">Populating global unique identifiers (GUIDs) for all records... </li>'); ob_flush(); flush(); $uuidManager = new UuidFactory(); $uuidManager->setSilent(1); $uuidManager->populateGuids(); if ($this->imageTransferCount) { $this->outputMsg('<li style="margin-left:10px;color:orange">WARNING: Image thumbnails likely need to be created! Do this using the <a href="../../imagelib/admin/thumbnailbuilder.php?collid=' . $this->collId . '">Images Thumbnail Builder</a></li>'); ob_flush(); flush(); } }