private function InsertFolio(BoxEntity $oBoxEntity, $aBoxFolio) { $oCsvRowToFolioMapper = $this->oCsvRowToFolioEntityMapper; $oMappedFolioEntity = $oCsvRowToFolioMapper->Map($aBoxFolio); if ($oMappedFolioEntity instanceof FolioEntity === false) { throw new ImporterException('$oMappedFolioEntity returned from mapper is not an instance of FolioEntity'); } $iBoxId = $oBoxEntity->getId(); $oMappedFolioEntity->setBoxId($iBoxId); /* @var $oMappedFolioEntity FolioEntity */ $oMappedFolioEntity = $this->oFolioDb->Insert($oMappedFolioEntity); /* Already exists so updated and not inserted */ $sFolioUpdated = $oMappedFolioEntity->getUpdated(); $sFolioNumber = $oMappedFolioEntity->getFolioNumber(); if ($sFolioUpdated === null) { $this->oLogger->Log('Inserting Folio ' . $oMappedFolioEntity->getFolioNumber()); } else { $this->oLogger->Log('Folio ' . $sFolioNumber . ' already exists'); } return $oMappedFolioEntity; }
protected function ProcessFolios(BoxEntity $oBoxEntity) { $iBoxId = $oBoxEntity->getId(); $rFolios = $this->GetFolios($iBoxId); if ($rFolios->count() < 1) { $this->oLogger->Log('ProcessFolios(): No folios could be found with ' . $this->sPreviousProcess . ' completed'); return; } /* @var $oFolioEntity FolioEntity */ while ($oFolioEntity = $rFolios->getResource()->fetchObject('Classes\\Entities\\Folio')) { $iFolioId = $oFolioEntity->getId(); $this->oFolioDb->UpdateProcessStatus($iFolioId, $this->sProcess, 'started'); $this->oFolioDb->ClearErrorLog($iFolioId); try { $this->ProcessItems($oBoxEntity, $oFolioEntity); } catch (ImporterException $oException) { $this->HandleError($oException, $oFolioEntity); } $this->oFolioDb->UpdateProcessStatus($iFolioId, $this->sProcess, 'completed'); } }