FOSSology
4.4.0
Open Source License Compliance by Open Source Software
|
Helper class for Obligation CSV Import. More...
Public Member Functions | |
__construct (DbManager $dbManager) | |
setDelimiter ($delimiter=',') | |
Update the delimiter. More... | |
setEnclosure ($enclosure='"') | |
Update the enclosure. More... | |
handleFile ($filename, $fileExtension) | |
Read the CSV line by line and import it. More... | |
handleRowJson ($row) | |
AssociateWithLicenses ($licList, $obPk, $candidate=False) | |
Associate selected licenses to the obligation. More... | |
updateOtherFields ($exists, $row) | |
Update other fields of the obligation. More... | |
Protected Attributes | |
$dbManager | |
$delimiter = ',' | |
$enclosure = '"' | |
$headrow = null | |
$alias | |
Private Member Functions | |
handleCsv ($row) | |
handleHeadCsv ($row) | |
Handle a row as head row. More... | |
getKeyFromTopicAndText ($row) | |
Get the Obligation key from obligation topic and obligation text. More... | |
compareLicList ($exists, $listFromCsv, $candidate, $row) | |
Compare licenses from Database and CSV. More... | |
reArrangeString ($string) | |
clearListFromDb ($exists, $candidate) | |
Clear all license maps for given obligation. More... | |
handleCsvObligation ($row) | |
Handle a single row from CSV. More... | |
Helper class for Obligation CSV Import.
Definition at line 22 of file ObligationCsvImport.php.
Fossology\Lib\Application\ObligationCsvImport::__construct | ( | DbManager | $dbManager | ) |
Constructor
DbManager | $dbManager | DB manager to use |
Definition at line 53 of file ObligationCsvImport.php.
Fossology\Lib\Application\ObligationCsvImport::AssociateWithLicenses | ( | $licList, | |
$obPk, | |||
$candidate = False |
|||
) |
Associate selected licenses to the obligation.
array | $licList | List of licenses to be associated |
int | $obPk | The id of the newly created obligation |
boolean | $candidate | Do we handle candidate licenses? |
Definition at line 307 of file ObligationCsvImport.php.
|
private |
Clear all license maps for given obligation.
int | $exists | Existing obligation key |
bool | $candidate | Is a candidate obligation? |
Definition at line 231 of file ObligationCsvImport.php.
|
private |
Compare licenses from Database and CSV.
bool | $exists | Existing license id |
array | $listFromCsv | List of obligations from CSV |
bool | $candidate | Is a candidate obligation? |
array | $row | Unused |
Definition at line 204 of file ObligationCsvImport.php.
|
private |
Get the Obligation key from obligation topic and obligation text.
array | $row | CSV array with topic and text keys |
Definition at line 189 of file ObligationCsvImport.php.
|
private |
Handle a single row read from the CSV. If headrow is not set, then handle current row as head row.
array | $row | Single row from CSV |
Definition at line 150 of file ObligationCsvImport.php.
|
private |
Handle a single row from CSV.
The function checks if the obligation text hash is already in the DB, then update the license associations. Otherwise make a new entry in the DB.
array | $row | CSV row to be inserted. |
Definition at line 246 of file ObligationCsvImport.php.
Fossology\Lib\Application\ObligationCsvImport::handleFile | ( | $filename, | |
$fileExtension | |||
) |
Read the CSV line by line and import it.
string | $filename | Location of the CSV file. |
Read csv: <count> licenses
on success. Definition at line 83 of file ObligationCsvImport.php.
|
private |
Handle a row as head row.
array | $row | Head row to be handled. |
Definition at line 171 of file ObligationCsvImport.php.
Fossology\Lib\Application\ObligationCsvImport::handleRowJson | ( | $row | ) |
Handle a single row read from the JSON. If the key matches values from alias array then replace it with key
array | $row |
Definition at line 128 of file ObligationCsvImport.php.
|
private |
The function takes a string delimited by ;
, explodes it, sort the result and joins them back using ,
as new delimiter.
string | $string | String to be rearranged. |
Definition at line 218 of file ObligationCsvImport.php.
Fossology\Lib\Application\ObligationCsvImport::setDelimiter | ( | $delimiter = ',' | ) |
Update the delimiter.
string | $delimiter | New delimiter to use. |
Definition at line 63 of file ObligationCsvImport.php.
Fossology\Lib\Application\ObligationCsvImport::setEnclosure | ( | $enclosure = '"' | ) |
Update the enclosure.
string | $enclosure | New enclosure to use. |
Definition at line 72 of file ObligationCsvImport.php.
Fossology\Lib\Application\ObligationCsvImport::updateOtherFields | ( | $exists, | |
$row | |||
) |
Update other fields of the obligation.
Fields updated are:
int | $exists | Obligation key |
array | $row | Row from CSV. |
Definition at line 351 of file ObligationCsvImport.php.
|
protected |
Alias for headers
Definition at line 38 of file ObligationCsvImport.php.
|
protected |
DB manager to be used
Definition at line 26 of file ObligationCsvImport.php.
|
protected |
Delimiter used in the CSV
Definition at line 29 of file ObligationCsvImport.php.
|
protected |
Ecnlosure used in the CSV
Definition at line 32 of file ObligationCsvImport.php.
|
protected |
Header of CSV
Definition at line 35 of file ObligationCsvImport.php.