FOSSology
3.2.0rc1
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) | |
Read the CSV line by line and import it. More... | |
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 33 of file ObligationCsvImport.php.
Fossology\Lib\Application\ObligationCsvImport::__construct | ( | DbManager | $dbManager | ) |
Constructor
DbManager | $dbManager | DB manager to use |
Definition at line 64 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 283 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 207 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 178 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 163 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 124 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 222 of file ObligationCsvImport.php.
Fossology\Lib\Application\ObligationCsvImport::handleFile | ( | $filename | ) |
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 94 of file ObligationCsvImport.php.
|
private |
Handle a row as head row.
array | $row | Head row to be handled. |
Definition at line 145 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 193 of file ObligationCsvImport.php.
Fossology\Lib\Application\ObligationCsvImport::setDelimiter | ( | $delimiter = ',' | ) |
Update the delimiter.
string | $delimiter | New delimiter to use. |
Definition at line 74 of file ObligationCsvImport.php.
Fossology\Lib\Application\ObligationCsvImport::setEnclosure | ( | $enclosure = '"' | ) |
Update the enclosure.
string | $enclosure | New enclosure to use. |
Definition at line 83 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 327 of file ObligationCsvImport.php.
|
protected |
Alias for headers
Definition at line 49 of file ObligationCsvImport.php.
|
protected |
DB manager to be used
Definition at line 37 of file ObligationCsvImport.php.
|
protected |
Delimiter used in the CSV
Definition at line 40 of file ObligationCsvImport.php.
|
protected |
Ecnlosure used in the CSV
Definition at line 43 of file ObligationCsvImport.php.
|
protected |
Header of CSV
Definition at line 46 of file ObligationCsvImport.php.