Search in sources :

Example 6 with DetectCodeLocation

use of com.synopsys.integration.detect.workflow.codelocation.DetectCodeLocation in project synopsys-detect by blackducksoftware.

the class CodeLocationReporter method writeBomToolEvaluationDetails.

private void writeBomToolEvaluationDetails(ReportWriter writer, DetectorEvaluation evaluation, Map<DetectCodeLocation, Integer> dependencyCounts, Map<CodeLocation, DetectCodeLocation> detectCodeLocationMap, Map<DetectCodeLocation, String> codeLocationNameMap) {
    for (CodeLocation codeLocation : evaluation.getExtraction().getCodeLocations()) {
        DetectExtractionEnvironment detectExtractionEnvironment = (DetectExtractionEnvironment) evaluation.getExtractionEnvironment();
        DetectCodeLocation detectCodeLocation = detectCodeLocationMap.get(codeLocation);
        writeCodeLocationDetails(writer, detectCodeLocation, dependencyCounts.get(detectCodeLocation), codeLocationNameMap.get(detectCodeLocation), detectExtractionEnvironment.getExtractionId().toUniqueString());
    }
}
Also used : DetectExtractionEnvironment(com.synopsys.integration.detect.tool.detector.DetectExtractionEnvironment) CodeLocation(com.synopsys.integration.detectable.detectable.codelocation.CodeLocation) DetectCodeLocation(com.synopsys.integration.detect.workflow.codelocation.DetectCodeLocation) DetectCodeLocation(com.synopsys.integration.detect.workflow.codelocation.DetectCodeLocation)

Example 7 with DetectCodeLocation

use of com.synopsys.integration.detect.workflow.codelocation.DetectCodeLocation in project synopsys-detect by blackducksoftware.

the class CodeLocationConverter method toDetectCodeLocation.

public Map<CodeLocation, DetectCodeLocation> toDetectCodeLocation(File detectSourcePath, DetectorEvaluation evaluation) {
    Map<CodeLocation, DetectCodeLocation> detectCodeLocations = new HashMap<>();
    if (evaluation.wasExtractionSuccessful()) {
        Extraction extraction = evaluation.getExtraction();
        String name = evaluation.getDetectorType().toString();
        return toDetectCodeLocation(detectSourcePath, extraction, evaluation.getDetectableEnvironment().getDirectory(), name);
    }
    return detectCodeLocations;
}
Also used : CodeLocation(com.synopsys.integration.detectable.detectable.codelocation.CodeLocation) DetectCodeLocation(com.synopsys.integration.detect.workflow.codelocation.DetectCodeLocation) HashMap(java.util.HashMap) DetectCodeLocation(com.synopsys.integration.detect.workflow.codelocation.DetectCodeLocation) Extraction(com.synopsys.integration.detectable.extraction.Extraction)

Example 8 with DetectCodeLocation

use of com.synopsys.integration.detect.workflow.codelocation.DetectCodeLocation in project synopsys-detect by blackducksoftware.

the class UniversalStepRunner method generateBdio.

public BdioResult generateBdio(UniversalToolsResult universalToolsResult, NameVersion projectNameVersion) throws OperationException {
    ProjectDependencyGraph aggregateDependencyGraph = operationFactory.aggregateSubProject(projectNameVersion, universalToolsResult.getDetectCodeLocations());
    AggregateCodeLocation aggregateCodeLocation = operationFactory.createAggregateCodeLocation(aggregateDependencyGraph, projectNameVersion);
    operationFactory.createAggregateBdio2File(aggregateCodeLocation);
    List<UploadTarget> uploadTargets = new ArrayList<>();
    Map<DetectCodeLocation, String> codeLocationNamesResult = new HashMap<>();
    universalToolsResult.getDetectCodeLocations().forEach(cl -> codeLocationNamesResult.put(cl, aggregateCodeLocation.getCodeLocationName()));
    // TODO: This doesn't seem right, it should just be the aggregate CL name right?
    uploadTargets.add(UploadTarget.createDefault(projectNameVersion, aggregateCodeLocation.getCodeLocationName(), aggregateCodeLocation.getAggregateFile()));
    return new BdioResult(uploadTargets, new DetectCodeLocationNamesResult(codeLocationNamesResult));
}
Also used : AggregateCodeLocation(com.synopsys.integration.detect.workflow.bdio.AggregateCodeLocation) UploadTarget(com.synopsys.integration.blackduck.codelocation.upload.UploadTarget) HashMap(java.util.HashMap) DetectCodeLocation(com.synopsys.integration.detect.workflow.codelocation.DetectCodeLocation) ArrayList(java.util.ArrayList) BdioResult(com.synopsys.integration.detect.workflow.bdio.BdioResult) ProjectDependencyGraph(com.synopsys.integration.bdio.graph.ProjectDependencyGraph) DetectCodeLocationNamesResult(com.synopsys.integration.detect.workflow.codelocation.DetectCodeLocationNamesResult)

Example 9 with DetectCodeLocation

use of com.synopsys.integration.detect.workflow.codelocation.DetectCodeLocation in project synopsys-detect by blackducksoftware.

the class FullAggregateGraphCreator method aggregateCodeLocations.

public ProjectDependencyGraph aggregateCodeLocations(File sourcePath, NameVersion projectNameVersion, List<DetectCodeLocation> codeLocations) {
    ExternalId projectExternalId = ExternalId.FACTORY.createNameVersionExternalId(DETECT_FORGE, projectNameVersion.getName(), projectNameVersion.getVersion());
    ProjectDependency projectDependency = new ProjectDependency(projectExternalId);
    ProjectDependencyGraph aggregateDependencyGraph = new ProjectDependencyGraph(projectDependency);
    for (DetectCodeLocation detectCodeLocation : codeLocations) {
        Dependency codeLocationDependency = createAggregateNode(sourcePath, detectCodeLocation);
        aggregateDependencyGraph.addDirectDependency(codeLocationDependency);
        DependencyGraphUtil.copyDirectDependenciesToParent(aggregateDependencyGraph, codeLocationDependency, detectCodeLocation.getDependencyGraph());
    }
    return aggregateDependencyGraph;
}
Also used : DetectCodeLocation(com.synopsys.integration.detect.workflow.codelocation.DetectCodeLocation) ExternalId(com.synopsys.integration.bdio.model.externalid.ExternalId) ProjectDependencyGraph(com.synopsys.integration.bdio.graph.ProjectDependencyGraph) ProjectDependency(com.synopsys.integration.bdio.model.dependency.ProjectDependency) Dependency(com.synopsys.integration.bdio.model.dependency.Dependency) ProjectDependency(com.synopsys.integration.bdio.model.dependency.ProjectDependency)

Example 10 with DetectCodeLocation

use of com.synopsys.integration.detect.workflow.codelocation.DetectCodeLocation in project synopsys-detect by blackducksoftware.

the class BdioAggregationTest method readInputCodeLocations.

@NotNull
private static List<DetectCodeLocation> readInputCodeLocations(List<String> inputBdioFilenames, File sourceDir) throws IOException {
    File inputBdioDir = new File("src/test/resources/workflow/bdio/aggregation/input");
    List<DetectCodeLocation> inputCodelocations = new LinkedList<>();
    for (String inputBdioFilename : inputBdioFilenames) {
        File bdioFile = new File(inputBdioDir, inputBdioFilename);
        SimpleBdioDocument simpleBdioDocument;
        try (InputStream bdioInputStream = new FileInputStream(bdioFile);
            BdioReader bdioReader = new BdioReader(gson, bdioInputStream)) {
            simpleBdioDocument = bdioReader.readSimpleBdioDocument();
        }
        ExternalId externalId = simpleBdioDocument.getProject().bdioExternalIdentifier.externalIdMetaData;
        ProjectDependency projectDependency = new ProjectDependency(externalId);
        DependencyGraph dependencyGraph = bdioTransformer.transformToDependencyGraph(projectDependency, simpleBdioDocument.getProject(), simpleBdioDocument.getComponents());
        DetectCodeLocation detectCodeLocation = DetectCodeLocation.forCreator(dependencyGraph, sourceDir, externalId, "testcreator");
        inputCodelocations.add(detectCodeLocation);
    }
    return inputCodelocations;
}
Also used : DetectCodeLocation(com.synopsys.integration.detect.workflow.codelocation.DetectCodeLocation) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) ExternalId(com.synopsys.integration.bdio.model.externalid.ExternalId) BdioReader(com.synopsys.integration.bdio.BdioReader) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) ProjectDependency(com.synopsys.integration.bdio.model.dependency.ProjectDependency) File(java.io.File) LinkedList(java.util.LinkedList) FileInputStream(java.io.FileInputStream) SimpleBdioDocument(com.synopsys.integration.bdio.model.SimpleBdioDocument) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

DetectCodeLocation (com.synopsys.integration.detect.workflow.codelocation.DetectCodeLocation)10 CodeLocation (com.synopsys.integration.detectable.detectable.codelocation.CodeLocation)5 HashMap (java.util.HashMap)4 ExternalId (com.synopsys.integration.bdio.model.externalid.ExternalId)3 Extraction (com.synopsys.integration.detectable.extraction.Extraction)3 ArrayList (java.util.ArrayList)3 DependencyGraph (com.synopsys.integration.bdio.graph.DependencyGraph)2 ProjectDependencyGraph (com.synopsys.integration.bdio.graph.ProjectDependencyGraph)2 Dependency (com.synopsys.integration.bdio.model.dependency.Dependency)2 ProjectDependency (com.synopsys.integration.bdio.model.dependency.ProjectDependency)2 UploadTarget (com.synopsys.integration.blackduck.codelocation.upload.UploadTarget)2 AggregateCodeLocation (com.synopsys.integration.detect.workflow.bdio.AggregateCodeLocation)2 BdioResult (com.synopsys.integration.detect.workflow.bdio.BdioResult)2 DetectCodeLocationNamesResult (com.synopsys.integration.detect.workflow.codelocation.DetectCodeLocationNamesResult)2 DetectorEvaluation (com.synopsys.integration.detector.base.DetectorEvaluation)2 NameVersion (com.synopsys.integration.util.NameVersion)2 JsonSyntaxException (com.google.gson.JsonSyntaxException)1 BdioReader (com.synopsys.integration.bdio.BdioReader)1 MutableDependencyGraph (com.synopsys.integration.bdio.graph.MutableDependencyGraph)1 MissingExternalIdException (com.synopsys.integration.bdio.graph.builder.MissingExternalIdException)1