![]() |
FOSSology
4.7.0
Open Source License Compliance by Open Source Software
|
Import licenses from CSV. More...

Public Member Functions | |
| __construct (DbManager $dbManager, UserDao $userDao, $obligationMap=null) | |
| 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) | |
| importJsonData ($data, string $msg) | |
Protected Attributes | |
| $dbManager | |
| $userDao | |
| $delimiter = ',' | |
| $enclosure = '"' | |
| $headrow = null | |
| $nkMap = array() | |
| $mdkMap = array() | |
| $alias | |
| $obligationMap | |
Private Member Functions | |
| handleCsv ($row) | |
| handleJsonLicense ($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... | |
| handleLicenseDBLicenseImport ($row) | |
| Handle a single row from csv import form LicenseDB. 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 25 of file LicenseCsvImport.php.
| Fossology\Lib\Application\LicenseCsvImport::__construct | ( | DbManager | $dbManager, |
| UserDao | $userDao, | ||
$obligationMap = null |
|||
| ) |
Constructor
| DbManager | $dbManager | DB manager to use |
| UserDao | $userDao | User Dao to use |
Definition at line 76 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 564 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 534 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 183 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 383 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 106 of file LicenseCsvImport.php.
|
private |
Handle a row as head row.
| array | $row | Head row to be handled. |
Definition at line 235 of file LicenseCsvImport.php.
|
private |
Handle a single row read from JSON and normalize optional values before importing from LicenseDB.
| array | $row | Single row from JSON |
Definition at line 213 of file LicenseCsvImport.php.
|
private |
Handle a single row from csv import form LicenseDB.
The function checks for license with the row's licensedb id in the license_ref table. If found, updates it with the row's content and if not, creates a new one.
It also creates the license obligation maps with the obligations that are found in the obligation_ref table.
| array | $row | CSV row to be inserted. |
Definition at line 430 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 146 of file LicenseCsvImport.php.
| Fossology\Lib\Application\LicenseCsvImport::importJsonData | ( | $data, | |
| string | $msg | ||
| ) |
|
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 517 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 622 of file LicenseCsvImport.php.
| Fossology\Lib\Application\LicenseCsvImport::setDelimiter | ( | $delimiter = ',' | ) |
Update the delimiter.
| string | $delimiter | New delimiter to use. |
Definition at line 86 of file LicenseCsvImport.php.
| Fossology\Lib\Application\LicenseCsvImport::setEnclosure | ( | $enclosure = '"' | ) |
Update the enclosure.
| string | $enclosure | New enclosure to use. |
Definition at line 95 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 587 of file LicenseCsvImport.php.
|
private |
Update the license info in the DB.
| array | $row | Row with new values. |
| int | $rfPk | Matched license ID. |
Definition at line 259 of file LicenseCsvImport.php.
|
protected |
Alias for headers
Definition at line 50 of file LicenseCsvImport.php.
|
protected |
DB manager to use
Definition at line 29 of file LicenseCsvImport.php.
|
protected |
Delimiter used in CSV
Definition at line 35 of file LicenseCsvImport.php.
|
protected |
Enclosure used in CSV
Definition at line 38 of file LicenseCsvImport.php.
|
protected |
Header of CSV
Definition at line 41 of file LicenseCsvImport.php.
|
protected |
Map based on license text MD5
Definition at line 47 of file LicenseCsvImport.php.
|
protected |
Map based on license shortname
Definition at line 44 of file LicenseCsvImport.php.
|
protected |
obligation map to use
Definition at line 69 of file LicenseCsvImport.php.
|
protected |
User DAO to use
Definition at line 32 of file LicenseCsvImport.php.