示例#1
0
 /**
  * @param int $uploadId
  * @return string
  */
 protected function renderPackage($uploadId)
 {
     $uploadTreeTableName = $this->uploadDao->getUploadtreeTableName($uploadId);
     $itemTreeBounds = $this->uploadDao->getParentItemBounds($uploadId, $uploadTreeTableName);
     $this->heartbeat(0);
     $filesWithLicenses = $this->getFilesWithLicensesFromClearings($itemTreeBounds);
     $this->heartbeat(0);
     $this->addClearingStatus($filesWithLicenses, $itemTreeBounds);
     $this->heartbeat(0);
     $licenseComment = $this->addScannerResults($filesWithLicenses, $itemTreeBounds);
     $this->heartbeat(0);
     $this->addCopyrightResults($filesWithLicenses, $uploadId);
     $this->heartbeat(0);
     $upload = $this->uploadDao->getUpload($uploadId);
     $fileNodes = $this->generateFileNodes($filesWithLicenses, $upload->getTreeTableName());
     $mainLicenseIds = $this->clearingDao->getMainLicenseIds($uploadId, $this->groupId);
     $mainLicenses = array();
     foreach ($mainLicenseIds as $licId) {
         $reportedLicenseId = $this->licenseMap->getProjectedId($licId);
         $this->includedLicenseIds[$reportedLicenseId] = true;
         $mainLicenses[] = $this->licenseMap->getProjectedShortname($reportedLicenseId);
     }
     $hashes = $this->uploadDao->getUploadHashes($uploadId);
     return $this->renderString($this->getTemplateFile('package'), array('uploadId' => $uploadId, 'uri' => $this->uri, 'packageName' => $upload->getFilename(), 'uploadName' => $upload->getFilename(), 'sha1' => $hashes['sha1'], 'md5' => $hashes['md5'], 'verificationCode' => $this->getVerificationCode($upload), 'mainLicenses' => $mainLicenses, 'mainLicense' => SpdxTwoUtils::implodeLicenses($mainLicenses, "LicenseRef-"), 'licenseComments' => $licenseComment, 'fileNodes' => $fileNodes));
 }
示例#2
0
 public function testGetUploadHashes()
 {
     $this->testDb->createPlainTables(array('pfile'));
     $this->dbManager->queryOnce('TRUNCATE upload');
     $this->testDb->insertData(array('upload', 'pfile'));
     // (pfile_pk, pfile_md5, pfile_sha1, pfile_size) := (9, 'F703E0197FB6C5BD0C8DFDCC115A0231', '5DAFC9C82988A81413B995210B668CF5CF5975FF', 16845)
     $hashes = $this->uploadDao->getUploadHashes(2);
     assertThat($hashes, equalTo(array('md5' => 'F703E0197FB6C5BD0C8DFDCC115A0231', 'sha1' => '5DAFC9C82988A81413B995210B668CF5CF5975FF')));
 }