![]() |
FOSSology
4.7.1
Open Source License Compliance by Open Source Software
|
Import custom text phrases from CSV/JSON. More...

Public Member Functions | |
| __construct (DbManager $dbManager, UserDao $userDao, LicenseDao $licenseDao=null) | |
| setDelimiter ($delimiter=',') | |
| Update the delimiter. More... | |
| setEnclosure ($enclosure='"') | |
| Update the enclosure. More... | |
| handleFile ($filename, $fileExtension) | |
| Read the CSV/JSON file and import it. More... | |
| importJsonData ($data, string &$msg) | |
| Import JSON data directly. More... | |
Protected Attributes | |
| $dbManager | |
| $userDao | |
| $licenseDao | |
| $delimiter = ',' | |
| $enclosure = '"' | |
| $headrow = null | |
| $unescapeNewlines = false | |
| $alias | |
Private Member Functions | |
| handleJsonFile ($filename) | |
| Handle JSON file import. More... | |
| handleCsvFile ($filename) | |
| Handle CSV file import. More... | |
| importPhrases ($data) | |
| Import phrases from data array. More... | |
| importSinglePhrase ($phraseData) | |
| Import a single phrase. More... | |
| mapHeaders ($data) | |
| Map CSV headers to standard field names. More... | |
| parseBoolean ($value) | |
| Parse boolean value from string. More... | |
| associateLicensesWithMetadata ($cpPk, $licenses, $groupId=null) | |
| Associate licenses with a phrase, writing per-mapping metadata. More... | |
| associateLicenseNames ($cpPk, $licenseNames, $removing, $groupId=null) | |
| Legacy flat-format helper: split a license-name string/array and delegate to associateLicensesWithMetadata() so the two formats share one lookup/insert path. More... | |
| splitLicenseNames ($licenseNames) | |
| Split a delimited license-name string on the first separator found. More... | |
Import custom text phrases from CSV/JSON.
Definition at line 26 of file CustomTextImport.php.
| Fossology\Lib\Application\CustomTextImport::__construct | ( | DbManager | $dbManager, |
| UserDao | $userDao, | ||
| LicenseDao | $licenseDao = null |
||
| ) |
| DbManager | $dbManager | |
| UserDao | $userDao | |
| LicenseDao | $licenseDao | Falls back to DI container when null. |
Definition at line 73 of file CustomTextImport.php.
|
private |
Legacy flat-format helper: split a license-name string/array and delegate to associateLicensesWithMetadata() so the two formats share one lookup/insert path.
| int | $cpPk | custom phrase PK |
| string | array | $licenseNames | Comma/semicolon/pipe separated names, or an array of names |
| bool | $removing | |
| int | null | $groupId |
Definition at line 497 of file CustomTextImport.php.
|
private |
Associate licenses with a phrase, writing per-mapping metadata.
Looks licenses up by shortname within the importing group, so group-scoped candidate licenses resolve too (see LicenseDao::getLicenseByCondition()). An already-mapped license is counted as 'skipped', never 'inserted', so a caller can tell a real import apart from a no-op re-import of the same file.
| int | $cpPk | custom phrase PK |
| array | $licenses | entries with shortname, removing, comment, reportinfo, acknowledgement |
| int | null | $groupId | Group to resolve candidate licenses against |
Definition at line 436 of file CustomTextImport.php.
|
private |
Handle CSV file import.
| string | $filename | Location of the CSV file. |
Definition at line 145 of file CustomTextImport.php.
| Fossology\Lib\Application\CustomTextImport::handleFile | ( | $filename, | |
| $fileExtension | |||
| ) |
Read the CSV/JSON file and import it.
| string | $filename | Location of the file. |
| string | $fileExtension | File extension (csv or json) |
Read file: <count> phrases on success. Definition at line 105 of file CustomTextImport.php.
|
private |
Handle JSON file import.
| string | $filename | Location of the JSON file. |
Definition at line 119 of file CustomTextImport.php.
| Fossology\Lib\Application\CustomTextImport::importJsonData | ( | $data, | |
| string & | $msg | ||
| ) |
Import JSON data directly.
| array | $data | Decoded JSON array |
| string | $msg | Populated with the result message |
Definition at line 541 of file CustomTextImport.php.
|
private |
Import phrases from data array.
| array | $data | Array of phrase data |
Definition at line 188 of file CustomTextImport.php.
|
private |
Import a single phrase.
| array | $phraseData | Phrase data |
Definition at line 237 of file CustomTextImport.php.
|
private |
Map CSV headers to standard field names.
| array | $data | Row data |
Definition at line 339 of file CustomTextImport.php.
|
private |
Parse boolean value from string.
| string | $value | String value |
Definition at line 409 of file CustomTextImport.php.
| Fossology\Lib\Application\CustomTextImport::setDelimiter | ( | $delimiter = ',' | ) |
Update the delimiter.
| string | $delimiter | New delimiter to use. |
Definition at line 84 of file CustomTextImport.php.
| Fossology\Lib\Application\CustomTextImport::setEnclosure | ( | $enclosure = '"' | ) |
Update the enclosure.
| string | $enclosure | New enclosure to use. |
Definition at line 93 of file CustomTextImport.php.
|
private |
Split a delimited license-name string on the first separator found.
| string | $licenseNames |
Definition at line 525 of file CustomTextImport.php.
|
protected |
Alias for CSV headers
Definition at line 53 of file CustomTextImport.php.
|
protected |
DB manager to use
Definition at line 30 of file CustomTextImport.php.
|
protected |
Delimiter used in CSV
Definition at line 38 of file CustomTextImport.php.
|
protected |
Enclosure used in CSV
Definition at line 41 of file CustomTextImport.php.
|
protected |
Header of CSV
Definition at line 44 of file CustomTextImport.php.
|
protected |
True for a CSV row, where real newlines were flattened to a literal '
' on export. JSON is never unescaped: it carries real newlines as-is.
Definition at line 50 of file CustomTextImport.php.
|
protected |
User DAO to use
Definition at line 33 of file CustomTextImport.php.