FOSSology  4.6.0
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)
 Export license reference bulk data from the DB as CSV or JSON. More...
 

Protected Attributes

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

Private Member Functions

 groupResultsByText ($result)
 Group flat DB rows by bulk text, splitting licenses into add/remove buckets. More...
 
 createCsvContent ($result)
 Create CSV content from result array. More...
 
 normalizeNewlinesForCsv ($value)
 Convert CR/LF variants to literal
for line-safe CSV rows. More...
 
 createJson ($result)
 Create JSON content from result array. 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)
private

Create CSV content from result array.

Parameters
array$resultDatabase result array
Returns
string CSV content

Definition at line 179 of file BulkTextExport.php.

◆ createJson()

Fossology\Lib\Application\BulkTextExport::createJson (   $result)
private

Create JSON content from result array.

Parameters
array$resultDatabase result array
Returns
string JSON content

Definition at line 222 of file BulkTextExport.php.

◆ exportBulkText()

Fossology\Lib\Application\BulkTextExport::exportBulkText (   $user_pk = 0,
  $group_pk = 0,
  $generateJson = 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)
private

Group flat DB rows by bulk text, splitting licenses into add/remove buckets.

Parameters
array$resultDatabase result array
Returns
array Associative array keyed by rf_text with grouped export fields

Definition at line 119 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 209 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: