Option for Creating New File Associations in Target Inventory
The import Web UI and REST interface provide options to set the file-matching criteria needed by the import to create new file associations in target project inventory when that inventory is identical to inventory in the data import file. (For a description of identical inventory items, see Handling of Identical Inventory During a Project Import.) The import process will create a new file association in the identical target inventory item only if the defined file-matching criteria is met. If a file association in the import data file already exists in the target inventory item, no new file association is added to the target inventory item.
By default, a file associated with an inventory item in the import data file can be added to an identical inventory item in the target project codebase only if the file’s complete path matches in both the import data file and in the target project codebase. For example, a file with a complete path of /ePortal-1.3/src/gettext.c, listed in the import data file as belonging to “Inventory Item 1”, will be considered for association with this same inventory item in the target project only if the target project codebase contains a file with the same complete path, /ePortal-1.3/src/gettext.c.
However, you can set different criteria for adding associated files to target inventory, such as requiring that only partial paths or MD5 values match or requiring that both MD5 values and paths match. For more details, see the following topics:
• | “Add Files to Inventory” Option in the Web UI |
• | “addFilesToInventory” Attribute in the REST Interface |
Note:The same file-matching criteria defined for creating new file associations in target inventory is also used in determining empty inventory. See Option to Create Empty Inventory.
“Add Files to Inventory” Option in the Web UI
The field Add Files to Inventory on the Import Project Data dialog is used to set the file-matching criteria for creating new file associations in target inventory. For a description of the criteria options available with this field, see Import Project Data Dialog. For complete instructions on using the Web UI to import project data, see Importing Project Data Using the Web UI.
“addFilesToInventory” Attribute in the REST Interface
The addFilesToInventory attribute is used in the Import Project Data REST API to set the file-matching criteria for creating new file associations in inventory. The following sections provide attribute details:
• | About the “addFilesToInventory” Attribute |
• | Example “addFilesToInventory” Syntax in Import cURL Command |
For instructions on executing Import Project Data API, see Importing Project Data Using the REST API.
About the “addFilesToInventory” Attribute
The addFilesToInventory attribute must be set to true to enable the import process to add files to inventory in the target project. Along with this attribute, a second attribute, inventoryFileMatchingCritieria, must be included to set the file-matching criteria used to determine whether a given file can be added to target inventory. A third attribute is required to set the directory depth if you specify partial-path criteria. For more information about setting file-matching criteria, see Specifying File-Matching Criteria in the Import REST Interface.
If the user explicitly sets the addFilesToInventory attribute to false (or omits this attribute entirely), the import does not associate any additional files to inventory in the target project.
Example “addFilesToInventory” Syntax in Import cURL Command
The following shows an example of the addFilesToInventory attribute in a cURL command that calls the REST import endpoint:
curl -H "Authorization:Bearer %jwt%" -F importFile=@"FileToImport.zip" -F projectImportModel={ "createEmptyInventory” : true, “overwriteInventoryNotes” : true, “addFilesToInventory” : true, “inventoryFileMatchingCriteria” : “MD5_AND_PARTIAL_FILEPATH”, “inventoryDirectoryDepth” : 2, “markFilesAsReviewed” : true, “reviewFileMatchingCriteria” : “PARTIAL_FILEPATH”, “reviewDirectoryDepth” : 2, "resetInventoryUsage": false" };type=application/json http://hostname:8888/codeinsight/api/projects/{projectId}/import
For complete instructions about using the cURL command to execute an import, see Importing Project Data Using the REST API.
For details about the implementation of the Import Project Data REST API, access the Code Insight Swagger documentation. To do so, click the icon in the upper right corner of the Code Insight Web UI, select Help, and click the REST API Guide link.