private function ScanAndInsertFolioItems(BoxEntity $oBoxEntity, FolioEntity $oMappedFolioEntity) { $sBoxPrefix = $this->sBoxPrefix; $sBoxNumber = $oBoxEntity->getBoxNumber(); $sFolioNumber = $oMappedFolioEntity->getFolioNumber(); $aScannedItemNumbers = $this->aScannedFileNames[$sBoxNumber][$sFolioNumber]; if ($aScannedItemNumbers < 1) { throw new ImporterException('ScanAndInsertFolioItems() could not find the meta data items: box number ' . $sBoxNumber . ' and folio number ' . $sFolioNumber . ' in the scanned files for box number ' . $sBoxPrefix . $sBoxNumber); } $oItemEntity = $this->oItemEntity; foreach ($aScannedItemNumbers as $sItemNumber) { $oItemEntity->SetAllPropertiesToNull(); $oItemEntity->setItemNumber($sItemNumber); $iFolioId = $oMappedFolioEntity->getId(); $oItemEntity->setFolioId($iFolioId); $oItemEntity = $this->oItemDb->Insert($oItemEntity); /* Already exists so updated and not inserted */ $sItemUpdated = $oItemEntity->getUpdated(); if ($sItemUpdated !== null) { $this->oLogger->Log('Item ' . $sItemNumber . ' already exists'); continue; } $this->oLogger->Log('Inserted Item ' . $sItemNumber); } /* Remove the item from the array so reduce the size */ unset($this->aScannedFileNames[$sBoxNumber][$sFolioNumber]); unset($this->aBoxFolioCollection[$sBoxNumber][$sFolioNumber]); // If we have reached this point then flag this folio as completed $this->oFolioDb->UpdateProcessStatus($iFolioId, 'import', 'completed'); $this->oFolioDb->ClearErrorLog($iFolioId); $this->oLogger->Log('-----------------------------------'); }
protected function ProcessItems(BoxEntity $oBoxEntity, FolioEntity $oFolioEntity) { $iFolioId = $oFolioEntity->getId(); $rItems = $this->GetItems($iFolioId); if ($rItems->count() < 0) { $this->oLogger->Log('ProcessItems(): No items could be found with ' . $this->sPreviousProcess . ' completed'); return; } /* @var $oItemEntity ItemEntity */ while ($oItemEntity = $rItems->getResource()->fetchObject('Classes\\Entities\\Item')) { $iItemId = $oItemEntity->getId(); $this->oItemDb->UpdateProcessStatus($iItemId, $this->sProcess, 'started'); $this->oItemDb->ClearErrorLog($iItemId); try { $sItemTitle = $this->ConstructPath($oBoxEntity, $oFolioEntity, $oItemEntity); // During development Comment this out to skip actual slicing $this->Process($sItemTitle); } catch (ImporterException $oException) { $this->HandleError($oException, $oItemEntity); } $this->oItemDb->UpdateProcessStatus($iItemId, $this->sProcess, 'completed'); } }