FOSSology  4.4.0
Open Source License Compliance by Open Source Software
Fossology\SpdxTwo\SpdxTwoAgent Class Reference

SPDX2 agent. More...

Inheritance diagram for Fossology\SpdxTwo\SpdxTwoAgent:
Inheritance graph
Collaboration diagram for Fossology\SpdxTwo\SpdxTwoAgent:
Collaboration graph

Public Member Functions

 processUploadId ($uploadId)
 Given an upload ID, process the items in it. More...
 
- Public Member Functions inherited from Fossology\Lib\Agent\Agent
 __construct ($agentName, $version, $revision)
 
 scheduler_connect ()
 Connect with scheduler and initialize options. More...
 
 heartbeat ($newProcessed)
 Send hear beat to the scheduler. More...
 
 bail ($exitvalue)
 Bail the agent, print the stack and disconnect from scheduler. More...
 
 scheduler_disconnect ($exitvalue)
 Closes connection from scheduler. More...
 
 scheduler_greet ()
 Greet the scheduler at the beginning of connection. More...
 
 initArsTable ()
 Initialize ARS table.
 
 run_scheduler_event_loop ()
 Runs a loop to read commands from scheduler and process them. More...
 

Public Attributes

const OUTPUT_FORMAT_KEY = "outputFormat"
 Argument key for output format.
 
const DEFAULT_OUTPUT_FORMAT = "spdx2"
 Default output format.
 
const AVAILABLE_OUTPUT_FORMATS = "spdx2,spdx2tv,dep5,spdx2csv"
 Output formats available.
 
const UPLOAD_ADDS = "uploadsAdd"
 Argument for additional uploads.
 
const DATA_LICENSE = "CC0-1.0"
 Data license for SPDX reports.
 

Protected Member Functions

 preWorkOnArgs ($args)
 Parse arguments. More...
 
 getTemplateFile ($partname)
 Get TWIG template file based on output format. More...
 
 getFileBasename ($packageName)
 Generate report basename based on upload name. More...
 
 getFileName ($packageName)
 Get absolute path for report. More...
 
 getUri ($packageName)
 Get the URI for the given package. More...
 
 renderPackage ($uploadId)
 Given an upload id, render the report string. More...
 
 getLicenseComment ($scannerIds)
 
 toLicensesWithFilesAdder (&$filesWithLicenses, $licenses, $copyrights, $file, $fullPath)
 Map licenses, copyrights, files and full path to filesWithLicenses array. More...
 
 toLicensesWithFiles (&$filesWithLicenses, $treeTableName)
 Map findings to the files. More...
 
 computeUri ($uploadId)
 For a given upload, compute the URI and filename for the report. More...
 
 writeReport (&$packageNodes, $packageIds, $uploadId)
 Write the report the file and update report table. More...
 
 updateReportTable ($uploadId, $jobId, $fileName)
 Update the reportgen table with new report path. More...
 
 renderString ($templateName, $vars)
 Render a twig template. More...
 
 generateFileNodes ($filesWithLicenses, $treeTableName, $uploadId)
 Generate report nodes for files. More...
 
 generateFileNodesByFiles ($filesWithLicenses, $treeTableName, $uploadId)
 For each file, generate the nodes by files. More...
 
 generateFileNodesByLicenses ($filesWithLicenses, $treeTableName)
 For each file, generate the nodes by licenses. More...
 
 getVerificationCode (Upload $upload)
 Get a unique identifier for a given upload. More...
 
 getSPDXReportConf ($uploadId, $key)
 Get spdx license comment state for a given upload. More...
 
 getSPDXDataLicense ()
 

Protected Attributes

 $dbManager
 
 $renderer
 
 $agentNames = AgentRef::AGENT_LIST
 
 $filebasename = null
 
 $uri
 
 $filename
 
 $outputFormat = self::DEFAULT_OUTPUT_FORMAT
 
- Protected Attributes inherited from Fossology\Lib\Agent\Agent
 $userId
 
 $groupId
 
 $jobId
 
 $agentSpecifOptions = ""
 
 $agentSpecifLongOptions = array()
 
 $args = array()
 
 $dbManager
 
 $agentDao
 
 $container
 
 $schedulerMode
 

Private Member Functions

 getObligations (int $uploadId, int $groupId)
 
 deduplicateLicenseList ()
 De-duplicate license list by comparing licenses with the same SPDX ID. More...
 

Private Attributes

 $uploadDao
 
 $clearingDao
 
 $licenseDao
 
 $licenseMap
 
 $licenseClearedGetter
 
 $licenseMainGetter
 
 $obligationsGetter
 
 $reportutils
 
 $licensesInDocument = []
 

Additional Inherited Members

- Static Public Member Functions inherited from Fossology\Lib\Agent\Agent
static heartbeat_handler ($signo)
 Function to handle hear beats from the agent and send them to the scheduler from STDOUT. More...
 

Detailed Description

SPDX2 agent.

Definition at line 75 of file spdx2.php.

Member Function Documentation

◆ computeUri()

Fossology\SpdxTwo\SpdxTwoAgent::computeUri (   $uploadId)
protected

For a given upload, compute the URI and filename for the report.

Parameters
int$uploadId

Definition at line 549 of file spdx2.php.

◆ deduplicateLicenseList()

Fossology\SpdxTwo\SpdxTwoAgent::deduplicateLicenseList ( )
private

De-duplicate license list by comparing licenses with the same SPDX ID.

First sort the license list by concatenating SPDX ID and shortname. Then compare each license with the next one. If they have the same SPDX ID, then the next one is a duplicate. Mark the duplicate by adding prefix of SPDX LicenseRef and suffix of MD5 hash of the license text to the shortname.

Returns
void

Definition at line 857 of file spdx2.php.

◆ generateFileNodes()

Fossology\SpdxTwo\SpdxTwoAgent::generateFileNodes (   $filesWithLicenses,
  $treeTableName,
  $uploadId 
)
protected

Generate report nodes for files.

Parameters
FileNode[]$filesWithLicenses
string$treeTableName
int$uploadId
Returns
string Node content

Definition at line 630 of file spdx2.php.

◆ generateFileNodesByFiles()

Fossology\SpdxTwo\SpdxTwoAgent::generateFileNodesByFiles (   $filesWithLicenses,
  $treeTableName,
  $uploadId 
)
protected

For each file, generate the nodes by files.

Parameters
FileNode[]$filesWithLicenses
string$treeTableName
int$uploadId
Returns
string Node string

Definition at line 647 of file spdx2.php.

◆ generateFileNodesByLicenses()

Fossology\SpdxTwo\SpdxTwoAgent::generateFileNodesByLicenses (   $filesWithLicenses,
  $treeTableName 
)
protected

For each file, generate the nodes by licenses.

Parameters
FileNode[]$filesWithLicenses
string$treeTableName
Returns
string Node string

Definition at line 731 of file spdx2.php.

◆ getFileBasename()

Fossology\SpdxTwo\SpdxTwoAgent::getFileBasename (   $packageName)
protected

Generate report basename based on upload name.

The base name is in format <OutputFormat>_<packagename>_<timestamp><.spdx.rdf|.spdx|.txt|.csv>

Parameters
string$packageNameName of the upload
Returns
string Report file's base name

Definition at line 270 of file spdx2.php.

◆ getFileName()

Fossology\SpdxTwo\SpdxTwoAgent::getFileName (   $packageName)
protected

Get absolute path for report.

Parameters
string$packageNameName of the upload
Returns
string Absolute file path for report

Definition at line 298 of file spdx2.php.

◆ getLicenseComment()

Fossology\SpdxTwo\SpdxTwoAgent::getLicenseComment (   $scannerIds)
protected
Parameters
string[]$scannerIds
Returns
string License Comment

Definition at line 454 of file spdx2.php.

◆ getObligations()

Fossology\SpdxTwo\SpdxTwoAgent::getObligations ( int  $uploadId,
int  $groupId 
)
private

Get obligations for the upload.

Parameters
int$uploadIdCurrent upload id
int$groupIdCurrent group id
Returns
array List of all obligations

Definition at line 818 of file spdx2.php.

◆ getSPDXDataLicense()

Fossology\SpdxTwo\SpdxTwoAgent::getSPDXDataLicense ( )
protected

Get SPDX Data License self::DATA_LICENSE

Returns
string Associated array with 'text', 'name', 'id', 'url'

Definition at line 840 of file spdx2.php.

◆ getSPDXReportConf()

Fossology\SpdxTwo\SpdxTwoAgent::getSPDXReportConf (   $uploadId,
  $key 
)
protected

Get spdx license comment state for a given upload.

Parameters
int$uploadId
Returns
bool License comment state (TRUE : show license comment, FALSE : don't show it)

Definition at line 799 of file spdx2.php.

◆ getTemplateFile()

Fossology\SpdxTwo\SpdxTwoAgent::getTemplateFile (   $partname)
protected

Get TWIG template file based on output format.

Parameters
string$partnamecopyright|document|file|package
Returns
string Template file path

Definition at line 245 of file spdx2.php.

◆ getUri()

Fossology\SpdxTwo\SpdxTwoAgent::getUri (   $packageName)
protected

Get the URI for the given package.

Parameters
string$packageNameName of the upload
Returns
string URI for the upload

Definition at line 310 of file spdx2.php.

◆ getVerificationCode()

Fossology\SpdxTwo\SpdxTwoAgent::getVerificationCode ( Upload  $upload)
protected

Get a unique identifier for a given upload.

This is done using concatenating SHA1 of every pfile in upload and calculating the SHA1 of the resulted string.

Parameters
Upload$upload
Returns
string The unique identifier

Definition at line 774 of file spdx2.php.

◆ preWorkOnArgs()

Fossology\SpdxTwo\SpdxTwoAgent::preWorkOnArgs (   $args)
protected

Parse arguments.

Parameters
string[]$argsArray of arguments to be parsed
Returns
array $args Parsed arguments

Definition at line 189 of file spdx2.php.

◆ processUploadId()

Fossology\SpdxTwo\SpdxTwoAgent::processUploadId (   $uploadId)

Given an upload ID, process the items in it.

This function is implemented by agent and should call heartbeat() at regular intervals.

Parameters
int$uploadIdUpload to be processed by the agent.
Returns
bool Process status
See also
Fossology::Lib::Agent::Agent::processUploadId()

Reimplemented from Fossology\Lib\Agent\Agent.

Definition at line 207 of file spdx2.php.

◆ renderPackage()

Fossology\SpdxTwo\SpdxTwoAgent::renderPackage (   $uploadId)
protected

Given an upload id, render the report string.

Parameters
int$uploadId
Returns
string Rendered report string

Definition at line 326 of file spdx2.php.

◆ renderString()

Fossology\SpdxTwo\SpdxTwoAgent::renderString (   $templateName,
  $vars 
)
protected

Render a twig template.

Parameters
string$templateNameName of the template to be rendered
array$varsVariables for the template
Returns
string The rendered output

Definition at line 618 of file spdx2.php.

◆ toLicensesWithFiles()

Fossology\SpdxTwo\SpdxTwoAgent::toLicensesWithFiles ( $filesWithLicenses,
  $treeTableName 
)
protected

Map findings to the files.

Parameters
FileNode[]&$filesWithLicenses
string$treeTableName
Returns
string[][][] Array of files with associated findings

Definition at line 496 of file spdx2.php.

◆ toLicensesWithFilesAdder()

Fossology\SpdxTwo\SpdxTwoAgent::toLicensesWithFilesAdder ( $filesWithLicenses,
  $licenses,
  $copyrights,
  $file,
  $fullPath 
)
protected

Map licenses, copyrights, files and full path to filesWithLicenses array.

Parameters
[in,out]string$filesWithLicenses
string$licenses
string[]$copyrights
string$file
string$fullPath

Definition at line 473 of file spdx2.php.

◆ updateReportTable()

Fossology\SpdxTwo\SpdxTwoAgent::updateReportTable (   $uploadId,
  $jobId,
  $fileName 
)
protected

Update the reportgen table with new report path.

Parameters
int$uploadIdUpload id
int$jobIdJob id
string$fileNameFile name of the report

Definition at line 605 of file spdx2.php.

◆ writeReport()

Fossology\SpdxTwo\SpdxTwoAgent::writeReport ( $packageNodes,
  $packageIds,
  $uploadId 
)
protected

Write the report the file and update report table.

Parameters
string$packageNodes
int[]$packageIds
int$uploadId

Definition at line 564 of file spdx2.php.

Member Data Documentation

◆ $agentNames

array Fossology\SpdxTwo\SpdxTwoAgent::$agentNames = AgentRef::AGENT_LIST
protected

Agent names mapping

Definition at line 131 of file spdx2.php.

◆ $clearingDao

ClearingDao Fossology\SpdxTwo\SpdxTwoAgent::$clearingDao
private

ClearingDao object

Definition at line 91 of file spdx2.php.

◆ $dbManager

DbManager Fossology\SpdxTwo\SpdxTwoAgent::$dbManager
protected

DbManager object

Definition at line 99 of file spdx2.php.

◆ $filebasename

string Fossology\SpdxTwo\SpdxTwoAgent::$filebasename = null
protected

Basename of SPDX2 report

Definition at line 135 of file spdx2.php.

◆ $filename

string Fossology\SpdxTwo\SpdxTwoAgent::$filename
protected

File name

Definition at line 143 of file spdx2.php.

◆ $licenseClearedGetter

LicenseClearedGetter Fossology\SpdxTwo\SpdxTwoAgent::$licenseClearedGetter
private

License cleared getter to fetch licenses.

Definition at line 112 of file spdx2.php.

◆ $licenseDao

LicenseDao Fossology\SpdxTwo\SpdxTwoAgent::$licenseDao
private

LicenseDao object

Definition at line 95 of file spdx2.php.

◆ $licenseMainGetter

LicenseMainGetter Fossology\SpdxTwo\SpdxTwoAgent::$licenseMainGetter
private

Getter for main licenses.

Definition at line 117 of file spdx2.php.

◆ $licenseMap

LicenseMap Fossology\SpdxTwo\SpdxTwoAgent::$licenseMap
private

LicenseMap object

Definition at line 107 of file spdx2.php.

◆ $licensesInDocument

SpdxLicenseInfo[] Fossology\SpdxTwo\SpdxTwoAgent::$licensesInDocument = []
private

List of licenses found in the document.

Definition at line 148 of file spdx2.php.

◆ $obligationsGetter

ObligationsGetter Fossology\SpdxTwo\SpdxTwoAgent::$obligationsGetter
private

Obligation getter.

Definition at line 122 of file spdx2.php.

◆ $outputFormat

string Fossology\SpdxTwo\SpdxTwoAgent::$outputFormat = self::DEFAULT_OUTPUT_FORMAT
protected

Output format of the report

Definition at line 152 of file spdx2.php.

◆ $renderer

Environment Fossology\SpdxTwo\SpdxTwoAgent::$renderer
protected

Twig_Environment object

Definition at line 103 of file spdx2.php.

◆ $reportutils

ReportUtils Fossology\SpdxTwo\SpdxTwoAgent::$reportutils
private

Report utils.

Definition at line 127 of file spdx2.php.

◆ $uploadDao

UploadDao Fossology\SpdxTwo\SpdxTwoAgent::$uploadDao
private

UploadDao object

Definition at line 87 of file spdx2.php.

◆ $uri

string Fossology\SpdxTwo\SpdxTwoAgent::$uri
protected

URI of the file

Definition at line 139 of file spdx2.php.


The documentation for this class was generated from the following file: