FOSSology
4.4.0
Open Source License Compliance by Open Source Software
|
Import licenses from CSV. More...
Public Member Functions | |
__construct (DbManager $dbManager, UserDao $userDao) | |
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) | |
Protected Attributes | |
$dbManager | |
$userDao | |
$delimiter = ',' | |
$enclosure = '"' | |
$headrow = null | |
$nkMap = array() | |
$mdkMap = array() | |
$alias | |
Private Member Functions | |
handleCsv ($row) | |
handleHeadCsv ($row) | |
Handle a row as head row. More... | |
updateLicense ($row, $rfPk) | |
Update the license info in the DB. More... | |
handleCsvLicense ($row) | |
Handle a single row from CSV. More... | |
insertMapIfNontrivial ($fromName, $toName, $usage) | |
Insert in license_map table if the license conclusion is non-trivial. More... | |
getKeyFromShortname ($shortname, $groupFk=null) | |
Get the license id using license shortname from DB or nkMap. More... | |
getKeyFromMd5 ($licenseText) | |
setMap ($from, $to, $usage) | |
Update license mappings. More... | |
insertNewLicense ($row, $tableName="license_ref") | |
Insert a new license in DB. More... | |
Import licenses from CSV.
Definition at line 24 of file LicenseCsvImport.php.
Constructor
DbManager | $dbManager | DB manager to use |
UserDao | $userDao | User Dao to use |
Definition at line 70 of file LicenseCsvImport.php.
|
private |
Get the license id using license text's checksum from DB or mdkMap.
string | $licenseText | License text |
Definition at line 436 of file LicenseCsvImport.php.
|
private |
Get the license id using license shortname from DB or nkMap.
string | $shortname | Shortname of the license. |
Definition at line 407 of file LicenseCsvImport.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 182 of file LicenseCsvImport.php.
|
private |
Handle a single row from CSV.
The function checks if the license text hash is already in the DB, then updates it. Otherwise inserts new row in the DB.
array | $row | CSV row to be inserted. |
Definition at line 347 of file LicenseCsvImport.php.
Fossology\Lib\Application\LicenseCsvImport::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 100 of file LicenseCsvImport.php.
|
private |
Handle a row as head row.
array | $row | Head row to be handled. |
Definition at line 212 of file LicenseCsvImport.php.
Fossology\Lib\Application\LicenseCsvImport::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 145 of file LicenseCsvImport.php.
|
private |
Insert in license_map
table if the license conclusion is non-trivial.
If the from and to are not same and from exists in database, then the conclusion is non-trivial.
string | $fromName | Parent license name |
string | $toName | License name |
string | $usage | Usage of the license |
Definition at line 390 of file LicenseCsvImport.php.
|
private |
Insert a new license in DB.
Creates a new main license/candidate license based on table name sent and if the required group exists in DB.
array | $row | Rows comming from CSV |
string | $tableName | Table where this new license should go to |
Definition at line 494 of file LicenseCsvImport.php.
Fossology\Lib\Application\LicenseCsvImport::setDelimiter | ( | $delimiter = ',' | ) |
Update the delimiter.
string | $delimiter | New delimiter to use. |
Definition at line 80 of file LicenseCsvImport.php.
Fossology\Lib\Application\LicenseCsvImport::setEnclosure | ( | $enclosure = '"' | ) |
Update the enclosure.
string | $enclosure | New enclosure to use. |
Definition at line 89 of file LicenseCsvImport.php.
|
private |
Update license mappings.
First check if the mapping already exists for the license, then update it. If the mapping does not exists, then insert it.
integer | $from | The new mapping license |
integer | $to | The license to be updated |
integer | $usage | The usage |
Definition at line 459 of file LicenseCsvImport.php.
|
private |
Update the license info in the DB.
array | $row | Row with new values. |
array | $rfPk | Matched license ID. |
Definition at line 236 of file LicenseCsvImport.php.
|
protected |
Alias for headers
Definition at line 49 of file LicenseCsvImport.php.
|
protected |
DB manager to use
Definition at line 28 of file LicenseCsvImport.php.
|
protected |
Delimiter used in CSV
Definition at line 34 of file LicenseCsvImport.php.
|
protected |
Enclosure used in CSV
Definition at line 37 of file LicenseCsvImport.php.
|
protected |
Header of CSV
Definition at line 40 of file LicenseCsvImport.php.
|
protected |
Map based on license text MD5
Definition at line 46 of file LicenseCsvImport.php.
|
protected |
Map based on license shortname
Definition at line 43 of file LicenseCsvImport.php.
|
protected |
User DAO to use
Definition at line 31 of file LicenseCsvImport.php.