FOSSology  4.7.1
Open Source License Compliance by Open Source Software
Fossology\Lib\Application\BulkTextExport Class Reference

Helper class to export license reference bulk data as CSV or JSON from the DB. More...

Collaboration diagram for Fossology\Lib\Application\BulkTextExport:
Collaboration graph

Public Member Functions

 __construct (DbManager $dbManager)
 
 setDelimiter ($delimiter=',')
 Update the delimiter. More...
 
 setEnclosure ($enclosure='"')
 Update the enclosure. More...
 
 exportBulkText ($user_pk=0, $group_pk=0, $generateJson=false, $includeLicenseText=false)
 Export license reference bulk data from the DB as CSV or JSON. More...
 

Protected Attributes

 $dbManager
 
 $delimiter = ','
 
 $enclosure = '"'
 

Private Member Functions

 groupResultsByText ($result, $includeLicenseText=false)
 Group flat DB rows by rf_text into the nested licenses format. More...
 
 createCsvContent ($result, $includeLicenseText=false)
 Create CSV content, one row per text+license, compatible with CustomTextImport. More...
 
 normalizeNewlinesForCsv ($value)
 Convert CR/LF variants to literal
for line-safe CSV rows. More...
 
 createJson ($result, $includeLicenseText=false)
 Create JSON content, nested licenses format, compatible with CustomTextImport. More...
 

Detailed Description

Helper class to export license reference bulk data as CSV or JSON from the DB.

Definition at line 21 of file BulkTextExport.php.

Constructor & Destructor Documentation

◆ __construct()

Fossology\Lib\Application\BulkTextExport::__construct ( DbManager  $dbManager)

Constructor

Parameters
DbManager$dbManagerDB manager to use.

Definition at line 37 of file BulkTextExport.php.

Member Function Documentation

◆ createCsvContent()

Fossology\Lib\Application\BulkTextExport::createCsvContent (   $result,
  $includeLicenseText = false 
)
private

Create CSV content, one row per text+license, compatible with CustomTextImport.

Parameters
array$resultDatabase result array
bool$includeLicenseTextWhether to include rf_text from license_ref
Returns
string CSV content

Definition at line 178 of file BulkTextExport.php.

◆ createJson()

Fossology\Lib\Application\BulkTextExport::createJson (   $result,
  $includeLicenseText = false 
)
private

Create JSON content, nested licenses format, compatible with CustomTextImport.

Parameters
array$resultDatabase result array
bool$includeLicenseTextWhether to include rf_text from license_ref
Returns
string JSON content

Definition at line 245 of file BulkTextExport.php.

◆ exportBulkText()

Fossology\Lib\Application\BulkTextExport::exportBulkText (   $user_pk = 0,
  $group_pk = 0,
  $generateJson = false,
  $includeLicenseText = false 
)

Export license reference bulk data from the DB as CSV or JSON.

Parameters
int$user_pkFilter by user ID, set 0 to export all
int$group_pkFilter by group ID, set 0 to export all
bool$generateJsonWhether to generate JSON format instead of CSV
Returns
string CSV or JSON content

Definition at line 79 of file BulkTextExport.php.

◆ groupResultsByText()

Fossology\Lib\Application\BulkTextExport::groupResultsByText (   $result,
  $includeLicenseText = false 
)
private

Group flat DB rows by rf_text into the nested licenses format.

Parameters
array$resultDatabase result array
bool$includeLicenseTextWhether to include rf_text from license_ref
Returns
array keyed by rf_text

Definition at line 129 of file BulkTextExport.php.

◆ normalizeNewlinesForCsv()

Fossology\Lib\Application\BulkTextExport::normalizeNewlinesForCsv (   $value)
private

Convert CR/LF variants to literal
for line-safe CSV rows.

Parameters
string | null$valueValue to normalize.
Returns
string

Definition at line 234 of file BulkTextExport.php.

◆ setDelimiter()

Fossology\Lib\Application\BulkTextExport::setDelimiter (   $delimiter = ',')

Update the delimiter.

Parameters
string$delimiterNew delimiter to use.

Definition at line 46 of file BulkTextExport.php.

◆ setEnclosure()

Fossology\Lib\Application\BulkTextExport::setEnclosure (   $enclosure = '"')

Update the enclosure.

Parameters
string$enclosureNew enclosure to use.

Definition at line 61 of file BulkTextExport.php.

Member Data Documentation

◆ $dbManager

DbManager Fossology\Lib\Application\BulkTextExport::$dbManager
protected

DB manager in use

Definition at line 25 of file BulkTextExport.php.

◆ $delimiter

string Fossology\Lib\Application\BulkTextExport::$delimiter = ','
protected

Delimiter for CSV

Definition at line 28 of file BulkTextExport.php.

◆ $enclosure

string Fossology\Lib\Application\BulkTextExport::$enclosure = '"'
protected

Enclosure for CSV strings

Definition at line 31 of file BulkTextExport.php.


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