コード例 #1
0
 public void add(SPDXPackageInfo pkgInfo) {
   Row row = addRow();
   Cell nameCell = row.createCell(NAME_COL);
   nameCell.setCellValue(pkgInfo.getDeclaredName());
   Cell copyrightCell = row.createCell(DECLARED_COPYRIGHT_COL);
   copyrightCell.setCellValue(pkgInfo.getDeclaredCopyright());
   Cell DeclaredLicenseCol = row.createCell(DECLARED_LICENSE_COL);
   DeclaredLicenseCol.setCellValue(pkgInfo.getDeclaredLicenses().toString());
   Cell concludedLicenseCol = row.createCell(CONCLUDED_LICENSE_COL);
   concludedLicenseCol.setCellValue(pkgInfo.getConcludedLicense().toString());
   Cell fileChecksumCell = row.createCell(FILE_VERIFICATION_VALUE_COL);
   fileChecksumCell.setCellValue(pkgInfo.getPackageVerification().getValue());
   Cell verificationExcludedFilesCell = row.createCell(VERIFICATION_EXCLUDED_FILES_COL);
   StringBuilder excFilesStr = new StringBuilder();
   String[] excludedFiles = pkgInfo.getPackageVerification().getExcludedFileNames();
   if (excludedFiles.length > 0) {
     excFilesStr.append(excludedFiles[0]);
     for (int i = 1; i < excludedFiles.length; i++) {
       excFilesStr.append(", ");
       excFilesStr.append(excludedFiles[i]);
     }
   }
   verificationExcludedFilesCell.setCellValue(excFilesStr.toString());
   if (pkgInfo.getDescription() != null) {
     Cell descCell = row.createCell(FULL_DESC_COL);
     descCell.setCellValue(pkgInfo.getDescription());
   }
   Cell fileNameCell = row.createCell(MACHINE_NAME_COL);
   fileNameCell.setCellValue(pkgInfo.getFileName());
   Cell pkgSha1 = row.createCell(PACKAGE_SHA_COL);
   if (pkgInfo.getSha1() != null) {
     pkgSha1.setCellValue(pkgInfo.getSha1());
   }
   // add the license infos in files in multiple rows
   SPDXLicenseInfo[] licenseInfosInFiles = pkgInfo.getLicensesFromFiles();
   if (licenseInfosInFiles != null && licenseInfosInFiles.length > 0) {
     StringBuilder sb = new StringBuilder(licenseInfosInFiles[0].toString());
     for (int i = 1; i < licenseInfosInFiles.length; i++) {
       sb.append(",");
       sb.append(licenseInfosInFiles[i].toString());
     }
     row.createCell(LICENSE_INFO_IN_FILES_COL).setCellValue(sb.toString());
   }
   if (pkgInfo.getLicenseComments() != null) {
     row.createCell(LICENSE_COMMENT_COL).setCellValue(pkgInfo.getLicenseComments());
   }
   if (pkgInfo.getShortDescription() != null) {
     Cell shortDescCell = row.createCell(SHORT_DESC_COL);
     shortDescCell.setCellValue(pkgInfo.getShortDescription());
   }
   if (pkgInfo.getSourceInfo() != null) {
     Cell sourceInfoCell = row.createCell(SOURCE_INFO_COL);
     sourceInfoCell.setCellValue(pkgInfo.getSourceInfo());
   }
   Cell urlCell = row.createCell(URL_COL);
   urlCell.setCellValue(pkgInfo.getUrl());
 }
コード例 #2
0
 private static void copyPackageInfo(PackageInfoSheet packageInfoSheet, SPDXPackage spdxPackage)
     throws SpreadsheetException, InvalidSPDXAnalysisException {
   SPDXPackageInfo info = packageInfoSheet.getPackageInfo(packageInfoSheet.getFirstDataRow());
   if (info == null) {
     throw (new InvalidSPDXAnalysisException("No package info in the spreadsheet"));
   }
   spdxPackage.setDeclaredCopyright(info.getDeclaredCopyright());
   spdxPackage.setDeclaredLicense(info.getDeclaredLicenses());
   spdxPackage.setDeclaredName(info.getDeclaredName());
   spdxPackage.setDescription(info.getDescription());
   spdxPackage.setConcludedLicenses(info.getConcludedLicense());
   spdxPackage.setLicenseInfoFromFiles(info.getLicensesFromFiles());
   spdxPackage.setLicenseComment(info.getLicenseComments());
   spdxPackage.setVerificationCode(info.getPackageVerification());
   spdxPackage.setFileName(info.getFileName());
   spdxPackage.setSha1(info.getSha1());
   spdxPackage.setShortDescription(info.getShortDescription());
   spdxPackage.setSourceInfo(info.getSourceInfo());
   spdxPackage.setDownloadUrl(info.getUrl());
   if (info.getVersionInfo() != null && !info.getVersionInfo().isEmpty()) {
     spdxPackage.setVersionInfo(info.getVersionInfo());
   }
   if (info.getOriginator() != null && !info.getOriginator().isEmpty()) {
     spdxPackage.setOriginator(info.getOriginator());
   }
   if (info.getSupplier() != null && !info.getSupplier().isEmpty()) {
     spdxPackage.setSupplier(info.getSupplier());
   }
 }