Search in sources :

Example 1 with PreparationResult

use of com.blackducksoftware.integration.hub.detect.workflow.extraction.PreparationResult 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)

Aggregations

DetectorType (com.blackducksoftware.integration.hub.detect.detector.DetectorType)1 DetectorToolResult (com.blackducksoftware.integration.hub.detect.tool.detector.DetectorToolResult)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 DetectorStatus (com.blackducksoftware.integration.hub.detect.workflow.status.DetectorStatus)1 StatusType (com.blackducksoftware.integration.hub.detect.workflow.status.StatusType)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1