Search in sources :

Example 1 with DetectorStatus

use of com.blackducksoftware.integration.hub.detect.workflow.status.DetectorStatus in project hub-detect by blackducksoftware.

the class DetectorManager method runDetectors.

public DetectorToolResult runDetectors() throws DetectUserFriendlyException {
    List<DetectorEvaluation> detectorEvaluations = new ArrayList<>();
    // search
    SearchResult searchResult = searchManager.performSearch();
    eventSystem.publishEvent(Event.SearchCompleted, searchResult);
    detectorEvaluations.addAll(searchResult.getDetectorEvaluations());
    // prepare
    PreparationResult preparationResult = preparationManager.prepareExtractions(detectorEvaluations);
    eventSystem.publishEvent(Event.PreparationsCompleted, preparationResult);
    // extract
    ExtractionResult extractionResult = extractionManager.performExtractions(detectorEvaluations);
    eventSystem.publishEvent(Event.ExtractionsCompleted, extractionResult);
    // create results
    DetectorToolResult detectorToolResult = new DetectorToolResult();
    detectorToolResult.evaluatedDetectors = detectorEvaluations;
    detectorToolResult.bomToolCodeLocations = extractionResult.getDetectCodeLocations();
    detectorToolResult.applicableDetectorTypes = searchResult.getApplicableBomTools();
    detectorToolResult.failedDetectorTypes.addAll(preparationResult.getFailedBomToolTypes());
    detectorToolResult.failedDetectorTypes.addAll(extractionResult.getFailedBomToolTypes());
    detectorToolResult.succesfullDetectorTypes.addAll(preparationResult.getSuccessfulBomToolTypes());
    detectorToolResult.succesfullDetectorTypes.addAll(extractionResult.getSuccessfulBomToolTypes());
    detectorToolResult.succesfullDetectorTypes.removeIf(it -> detectorToolResult.failedDetectorTypes.contains(it));
    // post status
    Map<DetectorType, StatusType> detectorStatus = new HashMap<>();
    detectorToolResult.succesfullDetectorTypes.forEach(it -> detectorStatus.put(it, StatusType.SUCCESS));
    detectorToolResult.failedDetectorTypes.forEach(it -> detectorStatus.put(it, StatusType.FAILURE));
    detectorStatus.forEach((detector, status) -> eventSystem.publishEvent(Event.StatusSummary, new DetectorStatus(detector, status)));
    return detectorToolResult;
}
Also used : DetectorToolResult(com.blackducksoftware.integration.hub.detect.tool.detector.DetectorToolResult) DetectorType(com.blackducksoftware.integration.hub.detect.detector.DetectorType) DetectorStatus(com.blackducksoftware.integration.hub.detect.workflow.status.DetectorStatus) PreparationResult(com.blackducksoftware.integration.hub.detect.workflow.extraction.PreparationResult) HashMap(java.util.HashMap) StatusType(com.blackducksoftware.integration.hub.detect.workflow.status.StatusType) ArrayList(java.util.ArrayList) SearchResult(com.blackducksoftware.integration.hub.detect.workflow.search.SearchResult) ExtractionResult(com.blackducksoftware.integration.hub.detect.workflow.extraction.ExtractionResult) DetectorEvaluation(com.blackducksoftware.integration.hub.detect.workflow.search.result.DetectorEvaluation)

Example 2 with DetectorStatus

use of com.blackducksoftware.integration.hub.detect.workflow.status.DetectorStatus in project hub-detect by blackducksoftware.

the class BdioManager method createBdioFiles.

public BdioResult createBdioFiles(String aggregateName, NameVersion projectNameVersion, List<DetectCodeLocation> codeLocations) throws DetectUserFriendlyException {
    DetectBdioWriter detectBdioWriter = new DetectBdioWriter(simpleBdioFactory, detectInfo);
    if (StringUtils.isBlank(aggregateName)) {
        logger.info("Creating BDIO code locations.");
        final BdioCodeLocationResult codeLocationResult = bdioCodeLocationCreator.createFromDetectCodeLocations(codeLocations, projectNameVersion);
        codeLocationResult.getFailedBomToolGroupTypes().forEach(it -> eventSystem.publishEvent(Event.StatusSummary, new DetectorStatus(it, StatusType.FAILURE)));
        logger.info("Creating BDIO files from code locations.");
        CodeLocationBdioCreator codeLocationBdioCreator = new CodeLocationBdioCreator(detectBdioWriter, simpleBdioFactory);
        final List<UploadTarget> uploadTargets = codeLocationBdioCreator.createBdioFiles(directoryManager.getBdioOutputDirectory(), codeLocationResult.getBdioCodeLocations(), projectNameVersion);
        return new BdioResult(uploadTargets);
    } else {
        logger.info("Creating aggregate BDIO file.");
        AggregateBdioCreator aggregateBdioCreator = new AggregateBdioCreator(simpleBdioFactory, integrationEscapeUtil, codeLocationNameManager, detectConfiguration, detectBdioWriter);
        final Optional<UploadTarget> uploadTarget = aggregateBdioCreator.createAggregateBdioFile(directoryManager.getSourceDirectory(), directoryManager.getBdioOutputDirectory(), codeLocations, projectNameVersion);
        if (uploadTarget.isPresent()) {
            return new BdioResult(Arrays.asList(uploadTarget.get()));
        } else {
            return new BdioResult(Collections.emptyList());
        }
    }
}
Also used : DetectorStatus(com.blackducksoftware.integration.hub.detect.workflow.status.DetectorStatus) UploadTarget(com.synopsys.integration.blackduck.codelocation.bdioupload.UploadTarget) BdioCodeLocationResult(com.blackducksoftware.integration.hub.detect.workflow.codelocation.BdioCodeLocationResult)

Aggregations

DetectorStatus (com.blackducksoftware.integration.hub.detect.workflow.status.DetectorStatus)2 DetectorType (com.blackducksoftware.integration.hub.detect.detector.DetectorType)1 DetectorToolResult (com.blackducksoftware.integration.hub.detect.tool.detector.DetectorToolResult)1 BdioCodeLocationResult (com.blackducksoftware.integration.hub.detect.workflow.codelocation.BdioCodeLocationResult)1 ExtractionResult (com.blackducksoftware.integration.hub.detect.workflow.extraction.ExtractionResult)1 PreparationResult (com.blackducksoftware.integration.hub.detect.workflow.extraction.PreparationResult)1 SearchResult (com.blackducksoftware.integration.hub.detect.workflow.search.SearchResult)1 DetectorEvaluation (com.blackducksoftware.integration.hub.detect.workflow.search.result.DetectorEvaluation)1 StatusType (com.blackducksoftware.integration.hub.detect.workflow.status.StatusType)1 UploadTarget (com.synopsys.integration.blackduck.codelocation.bdioupload.UploadTarget)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1