Abstracted the create of a SimpleBdioDocument
@@ -36,6 +36,7 @@ import com.blackducksoftware.integration.hub.bdio.simple.model.BdioBillOfMateria
import com.blackducksoftware.integration.hub.bdio.simple.model.BdioComponent
import com.blackducksoftware.integration.hub.bdio.simple.model.BdioExternalIdentifier
import com.blackducksoftware.integration.hub.bdio.simple.model.BdioProject
+import com.blackducksoftware.integration.hub.bdio.simple.model.DependencyNode
import com.blackducksoftware.integration.hub.bdio.simple.model.SimpleBdioDocument
import com.blackducksoftware.integration.hub.detect.bomtool.BomTool
import com.blackducksoftware.integration.hub.detect.bomtool.output.DetectCodeLocation
@@ -160,32 +161,25 @@ class DetectProjectManager {
}
private SimpleBdioDocument createAggregateSimpleBdioDocument(DetectProject detectProject) {
- String projectName = detectProject.projectName
- String projectVersionName = detectProject.projectVersionName
-
- final BdioBillOfMaterials bdioBillOfMaterials = bdioNodeFactory.createBillOfMaterials('', projectName, projectVersionName)
- final BdioExternalIdentifier projectExternalIdentifier = bdioPropertyHelper.createExternalIdentifier('', projectName)
- final BdioProject project = bdioNodeFactory.createProject(projectName, projectVersionName, projectName, projectExternalIdentifier)
+ createSimpleBdioDocument(detectProject, '', detectProject.projectName, bdioPropertyHelper.createExternalIdentifier('', detectProject.projectName), [] as Set)
+ }
- final SimpleBdioDocument simpleBdioDocument = new SimpleBdioDocument()
- simpleBdioDocument.billOfMaterials = bdioBillOfMaterials
- simpleBdioDocument.project = project
+ private SimpleBdioDocument createSimpleBdioDocument(DetectProject detectProject, DetectCodeLocation detectCodeLocation) {
+ final String codeLocationName = getCodeLocationName(detectCodeLocation.bomToolType, detectCodeLocation.sourcePath, detectProject.projectName, detectProject.projectVersionName)
+ final String projectId = detectCodeLocation.bomToolProjectExternalId.createDataId()
+ final BdioExternalIdentifier projectExternalIdentifier = bdioPropertyHelper.createExternalIdentifier(detectCodeLocation.bomToolProjectExternalId)
- simpleBdioDocument
+ createSimpleBdioDocument(detectProject, codeLocationName, projectId, projectExternalIdentifier, detectCodeLocation.dependencies)
}
- private SimpleBdioDocument createSimpleBdioDocument(DetectProject detectProject, DetectCodeLocation detectCodeLocation) {
- String projectName = detectProject.projectName
- String projectVersionName = detectProject.projectVersionName
- String codeLocationName = getCodeLocationName(detectCodeLocation.bomToolType, detectCodeLocation.sourcePath, projectName, projectVersionName)
+ private SimpleBdioDocument createSimpleBdioDocument(DetectProject detectProject, String codeLocationName, String projectId, BdioExternalIdentifier projectExternalIdentifier, Set<DependencyNode> dependencies) {
+ final String projectName = detectProject.projectName
+ final String projectVersionName = detectProject.projectVersionName
final BdioBillOfMaterials bdioBillOfMaterials = bdioNodeFactory.createBillOfMaterials(codeLocationName, projectName, projectVersionName)
-
- final String projectId = detectCodeLocation.bomToolProjectExternalId.createDataId()
- final BdioExternalIdentifier projectExternalIdentifier = bdioPropertyHelper.createExternalIdentifier(detectCodeLocation.bomToolProjectExternalId)
final BdioProject project = bdioNodeFactory.createProject(projectName, projectVersionName, projectId, projectExternalIdentifier)
- final List<BdioComponent> bdioComponents = dependencyNodeTransformer.addComponentsGraph(project, detectCodeLocation.dependencies)
+ final List<BdioComponent> bdioComponents = dependencyNodeTransformer.addComponentsGraph(project, dependencies)
final SimpleBdioDocument simpleBdioDocument = new SimpleBdioDocument()
simpleBdioDocument.billOfMaterials = bdioBillOfMaterials
