Option to Create Empty Inventory

The import Web UI and REST interface provide an option to specify whether “empty” system-generated inventory items are still processed in the target project during the import. Empty inventory items either have no file associations in the data file to be imported or do have associated files in the import data file but no matching paths or MD5s for these files in the target project codebase (also see Complete vs Partial Paths in the Import Path-Matching Process).

When this option is enabled, all inventory items in the import data file—with or without matching associated files in the target codebase—are created in the target project during the import.

When the option is disabled, the import process does not create empty inventory items in the target project. It creates only inventory items whose associated files are found in the target codebase. To define what constitutes “matching files” between the import data file and the target project codebase, this option depends on the criteria set for the Option for Creating New File Associations in Target Inventory.

Note:If you are importing from a scanned project into an inventory-only project, which has no codebase, ensure this option is enabled so that inventory is generated in the new project.

For more details about this option, see the following topics:

Option in the Web UI
“createEmptyInventory” Attribute in the REST Interface

Option in the Web UI

The option to create empty inventory is available in the Web UI as the project setting, On the data import or rescan, delete inventory with no associated files, located on the Edit Project: General Tab. Ensure that this field is properly set for the import you are about to perform. (You can always reset this value for the project once the import is complete.) See Editing the Project Definition and General Settings for details.

The default for this setting is defined at a global-project level by the Code Insight System Administrator. (The initial global setting disables the creation of empty inventory, but obviously this can be changed at the administrator’s discretion to affect all projects.)

“createEmptyInventory” Attribute in the REST Interface

The option to create empty inventory is available as the createEmptyInventory attribute when invoking the Import Project Data REST API. The following sections provide attribute details:

About the “createEmptyInventory” Attribute
Example “createEmptyInventory” Syntax in Import cURL Command

About the “createEmptyInventory” Attribute

To enable the creation of empty inventory items in the target project, explicitly include the createEmptyInventory attribute and set it to true in the cURL command that calls the import REST endpoint. All inventory items in the import data file—with or without matching associated files in the target codebase—are created in the target project during the import.

To disable the creation of empty inventory items in the target project, explicitly include the createEmptyInventory attribute and set it to false in the cURL command. Only those inventory items with associated files in the import data file that match files in the target codebase are created in the target project.

If you omit the createEmpyInventory attribute entirely from cURL command, the import process uses the value of the deleteEmptyInventory attribute defined for the project (the same setting as the On the data import or rescan, delete inventory with no associated files value on the Edit Project: General Tab.) To override this project setting for the current import process only, explicitly include the createEmptyInventory attribute with the appropriate setting when invoking the import endpoint.

Example “createEmptyInventory” Syntax in Import cURL Command

The following example shows the attribute explicitly included in the cURL command that calls the import REST 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 more 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.