Example #1
0
    public function Insert(ItemEntity $oItemEntity)
    {
        $sSql = 'INSERT INTO
					' . $this->sTableName . '
							(
							    folio_id
							  , item_number

							  , process
							  , process_status

							  , process_start_time
							  , process_end_time
							  , updated
							)
				VALUES
							(
							    ?
							  , ?

							  , \'import\'
							  , \'completed\'

							  , NOW()
							  , NOW()
							  , NOW()
							)
							ON DUPLICATE KEY UPDATE
								id = LAST_INSERT_ID( id );';
        $aBindArray = array($oItemEntity->getFolioId(), $oItemEntity->getItemNumber());
        $this->Execute($sSql, $aBindArray);
        $iItemId = $this->oAdapter->getDriver()->getLastGeneratedValue();
        $oItemEntity->setId($iItemId);
        return $oItemEntity;
    }
 protected function ConstructPath(BoxEntity $oBoxEntity, FolioEntity $oFolioEntity, ItemEntity $oItemEntity)
 {
     $sBoxNumber = $oBoxEntity->getBoxNumber();
     $sFolioNumber = $oFolioEntity->getFolioNumber();
     $sItemNumber = $oItemEntity->getItemNumber();
     $sItemPath = $sBoxNumber . '/' . $sFolioNumber . '/' . $sItemNumber;
     return $sItemPath;
 }
 protected function ConstructPath(BoxEntity $oBoxEntity, FolioEntity $oFolioEntity, ItemEntity $oItemEntity)
 {
     $sBoxNumber = $oBoxEntity->getBoxNumber();
     $this->sBoxNumber = $sBoxNumber;
     $sFolioNumber = $oFolioEntity->getFolioNumber();
     $sItemNumber = $oItemEntity->getItemNumber();
     $sTokenSeperator = $this->sTokenSeperator;
     $sImagePath = $sBoxNumber . $sTokenSeperator . $sFolioNumber . $sTokenSeperator . $sItemNumber;
     return $sImagePath;
 }
 protected function ConstructPath(BoxEntity $oBoxEntity, FolioEntity $oFolioEntity, ItemEntity $oItemEntity)
 {
     $sBoxNumber = $oBoxEntity->getBoxNumber();
     $sFolioNumber = $oFolioEntity->getFolioNumber();
     $sItemNumber = $oItemEntity->getItemNumber();
     $sBoxPrefix = $this->sBoxPrefix;
     $sImageExportPath = $this->sImageExportPath;
     $sImageImportPath = $this->sImageImportPath;
     $sJobArchivePath = $this->sArchivePath;
     $sTokenSeperator = $this->sTokenSeperator;
     $iJobQueueId = $this->iJobQueueId;
     // Check whether slices already exixt
     $sImagePath = $sBoxNumber . DIRECTORY_SEPARATOR . $sBoxNumber . $sTokenSeperator . $sFolioNumber . $sTokenSeperator . $sItemNumber;
     // Check to see whether images have already been processes
     $sImageExportPath = $this->sImageExportPath;
     $sTargetPath = $sImageExportPath . DIRECTORY_SEPARATOR . $sImagePath;
     $bTargetPathExists = file_exists($sTargetPath);
     if ($bTargetPathExists) {
         $this->oLogger->Log($sTargetPath . ' already exists. Skipping...');
         return '';
     }
     // They have not been processed so carry on and determine the images full path
     $sImageImportPath = $this->sImageImportPath;
     $this->oFile->CheckDirExists($sImageImportPath);
     $sBoxPrefix = $this->sBoxPrefix;
     $sItemName = DIRECTORY_SEPARATOR . $sBoxPrefix . $sImagePath . '.jpg';
     $sFullImageImportPath = $sImageImportPath . $sItemName;
     // Fall back to Archive directory if needed
     if (file_exists($sFullImageImportPath) === false) {
         $sFullImageArchivePath = $sJobArchivePath . DIRECTORY_SEPARATOR . $iJobQueueId . $sItemName;
         $this->oLogger->Log($sFullImageImportPath . ' no longer exists. Now checking archive ' . $sFullImageArchivePath);
         if (file_exists($sFullImageArchivePath)) {
             //Before we move file, create the parent BOX directory otherwise it will complain
             $sTargetImageDirectory = $this->sImageImportPath . DIRECTORY_SEPARATOR . $sBoxPrefix . $sBoxNumber;
             if (!is_dir($sTargetImageDirectory)) {
                 if (!mkdir($sTargetImageDirectory, 0775, true)) {
                     throw new ImporterException('ConstructPath(): Failed to create ' . $sTargetImageDirectory);
                 }
                 $this->oLogger->Log('Created directory ' . $sTargetImageDirectory);
             }
             $this->oLogger->Log('Moving archived image back from ' . $sFullImageArchivePath . ' to ' . $sFullImageImportPath);
             if (!rename($sFullImageArchivePath, $sFullImageImportPath)) {
                 throw new ImporterException('ConstructPath(): unable to rename ' . $sFullImageArchivePath . ' to ' . $sFullImageImportPath);
             }
         }
         // Otherwise move it back from the archive
     }
     // Do one last check
     $bDirExists = file_exists($sFullImageImportPath);
     // If it doesn't exist in the Archive directory there then we have a genuine problem so throw an exception
     if ($bDirExists === false) {
         throw new ImporterException('FullImageImportPath ' . $sFullImageImportPath . ' does not exist');
     }
     return $sFullImageImportPath;
 }