Search in sources :

Example 1 with DetectorEvaluation

use of com.blackducksoftware.integration.hub.detect.workflow.search.result.DetectorEvaluation in project hub-detect by blackducksoftware.

the class ExtractionManager method performExtractions.

public ExtractionResult performExtractions(final List<DetectorEvaluation> results) {
    final List<DetectorEvaluation> extractable = results.stream().filter(result -> result.isExtractable()).collect(Collectors.toList());
    for (int i = 0; i < extractable.size(); i++) {
        final DetectorEvaluation detectorEvaluation = extractable.get(i);
        final String progress = Integer.toString((int) Math.floor((i * 100.0f) / extractable.size()));
        logger.info(String.format("Extracting %d of %d (%s%%)", i + 1, extractable.size(), progress));
        logger.info(ReportConstants.SEPERATOR);
        final ExtractionId extractionId = new ExtractionId(detectorEvaluation.getDetector().getDetectorType(), Integer.toString(i));
        detectorEvaluation.setExtractionId(extractionId);
        extract(extractable.get(i));
    }
    final Set<DetectorType> succesfulBomToolGroups = extractable.stream().filter(it -> it.wasExtractionSuccessful()).map(it -> it.getDetector().getDetectorType()).collect(Collectors.toSet());
    final Set<DetectorType> failedBomToolGroups = extractable.stream().filter(it -> !it.wasExtractionSuccessful()).map(it -> it.getDetector().getDetectorType()).collect(Collectors.toSet());
    final List<DetectCodeLocation> codeLocations = extractable.stream().filter(it -> it.wasExtractionSuccessful()).flatMap(it -> it.getExtraction().codeLocations.stream()).collect(Collectors.toList());
    return new ExtractionResult(codeLocations, succesfulBomToolGroups, failedBomToolGroups);
}
Also used : DetectorType(com.blackducksoftware.integration.hub.detect.detector.DetectorType) ExtractionResultType(com.blackducksoftware.integration.hub.detect.workflow.extraction.Extraction.ExtractionResultType) Logger(org.slf4j.Logger) DetectorEvaluation(com.blackducksoftware.integration.hub.detect.workflow.search.result.DetectorEvaluation) LoggerFactory(org.slf4j.LoggerFactory) Set(java.util.Set) Collectors(java.util.stream.Collectors) List(java.util.List) ExtractionId(com.blackducksoftware.integration.hub.detect.detector.ExtractionId) InfoLogReportWriter(com.blackducksoftware.integration.hub.detect.workflow.report.writer.InfoLogReportWriter) DetectCodeLocation(com.blackducksoftware.integration.hub.detect.workflow.codelocation.DetectCodeLocation) ReportConstants(com.blackducksoftware.integration.hub.detect.workflow.report.util.ReportConstants) ObjectPrinter(com.blackducksoftware.integration.hub.detect.workflow.report.util.ObjectPrinter) DetectorType(com.blackducksoftware.integration.hub.detect.detector.DetectorType) DetectCodeLocation(com.blackducksoftware.integration.hub.detect.workflow.codelocation.DetectCodeLocation) DetectorEvaluation(com.blackducksoftware.integration.hub.detect.workflow.search.result.DetectorEvaluation) ExtractionId(com.blackducksoftware.integration.hub.detect.detector.ExtractionId)

Example 2 with DetectorEvaluation

use of com.blackducksoftware.integration.hub.detect.workflow.search.result.DetectorEvaluation in project hub-detect by blackducksoftware.

the class DetailedSearchSummarizer method createData.

private DetailedSearchSummaryData createData(final String directory, final List<DetectorEvaluation> evaluations) {
    final List<DetailedSearchSummaryBomToolData> applicable = new ArrayList<>();
    final List<DetailedSearchSummaryBomToolData> notApplicable = new ArrayList<>();
    final List<DetailedSearchSummaryBomToolData> notSearchable = new ArrayList<>();
    for (final DetectorEvaluation evaluation : evaluations) {
        if (evaluation.isApplicable()) {
            final String reason = "Search: " + evaluation.getSearchabilityMessage() + " Applicable: " + evaluation.getApplicabilityMessage();
            applicable.add(new DetailedSearchSummaryBomToolData(evaluation.getDetector(), reason));
        } else if (evaluation.isSearchable()) {
            final String reason = evaluation.getApplicabilityMessage();
            notApplicable.add(new DetailedSearchSummaryBomToolData(evaluation.getDetector(), reason));
        } else {
            final String reason = evaluation.getSearchabilityMessage();
            notSearchable.add(new DetailedSearchSummaryBomToolData(evaluation.getDetector(), reason));
        }
    }
    return new DetailedSearchSummaryData(directory, applicable, notApplicable, notSearchable);
}
Also used : ArrayList(java.util.ArrayList) DetectorEvaluation(com.blackducksoftware.integration.hub.detect.workflow.search.result.DetectorEvaluation)

Example 3 with DetectorEvaluation

use of com.blackducksoftware.integration.hub.detect.workflow.search.result.DetectorEvaluation in project hub-detect by blackducksoftware.

the class DetectorSearchEvaluator method evaluate.

public List<DetectorEvaluation> evaluate(DetectorSearchRuleSet rules, EventSystem eventSystem) {
    final List<DetectorEvaluation> evaluations = new ArrayList<>();
    final List<Detector> appliedSoFar = new ArrayList<>();
    for (final DetectorSearchRule searchRule : rules.getOrderedBomToolRules()) {
        final Detector detector = searchRule.getDetector();
        final DetectorEvaluation evaluation = new DetectorEvaluation(detector, rules.getEnvironment());
        evaluations.add(evaluation);
        evaluation.setSearchable(searchable(searchRule, appliedSoFar, rules.getEnvironment()));
        if (evaluation.isSearchable()) {
            eventSystem.publishEvent(Event.ApplicableStarted, detector);
            evaluation.setApplicable(detector.applicable());
            eventSystem.publishEvent(Event.ApplicableEnded, detector);
            if (evaluation.isApplicable()) {
                appliedSoFar.add(detector);
            }
        }
    }
    return evaluations;
}
Also used : Detector(com.blackducksoftware.integration.hub.detect.detector.Detector) ArrayList(java.util.ArrayList) DetectorEvaluation(com.blackducksoftware.integration.hub.detect.workflow.search.result.DetectorEvaluation)

Example 4 with DetectorEvaluation

use of com.blackducksoftware.integration.hub.detect.workflow.search.result.DetectorEvaluation in project hub-detect by blackducksoftware.

the class DetectorFinder method processDirectory.

private List<DetectorEvaluation> processDirectory(final File directory, final Set<Detector> appliedBefore, final int depth, final DetectorFinderOptions options) {
    final DetectorEnvironment environment = new DetectorEnvironment(directory, appliedBefore, depth, options.getDetectorFilter(), options.getForceNestedSearch());
    final DetectorSearchRuleSet bomToolSet = options.getDetectorSearchProvider().createBomToolSearchRuleSet(environment);
    final List<DetectorEvaluation> evaluations = options.getDetectorSearchEvaluator().evaluate(bomToolSet, options.getEventSystem());
    return evaluations;
}
Also used : DetectorEnvironment(com.blackducksoftware.integration.hub.detect.detector.DetectorEnvironment) DetectorSearchRuleSet(com.blackducksoftware.integration.hub.detect.workflow.search.rules.DetectorSearchRuleSet) DetectorEvaluation(com.blackducksoftware.integration.hub.detect.workflow.search.result.DetectorEvaluation)

Example 5 with DetectorEvaluation

use of com.blackducksoftware.integration.hub.detect.workflow.search.result.DetectorEvaluation in project hub-detect by blackducksoftware.

the class PreparationManager method prepareExtractions.

public PreparationResult prepareExtractions(final List<DetectorEvaluation> results) {
    for (final DetectorEvaluation result : results) {
        prepare(result);
    }
    final Set<DetectorType> succesfulBomToolGroups = results.stream().filter(it -> it.isApplicable()).filter(it -> it.isExtractable()).map(it -> it.getDetector().getDetectorType()).collect(Collectors.toSet());
    final Set<DetectorType> failedBomToolGroups = results.stream().filter(it -> it.isApplicable()).filter(it -> !it.isExtractable()).map(it -> it.getDetector().getDetectorType()).collect(Collectors.toSet());
    return new PreparationResult(succesfulBomToolGroups, failedBomToolGroups, results);
}
Also used : List(java.util.List) DetectorType(com.blackducksoftware.integration.hub.detect.detector.DetectorType) Event(com.blackducksoftware.integration.hub.detect.workflow.event.Event) Logger(org.slf4j.Logger) DetectorEvaluation(com.blackducksoftware.integration.hub.detect.workflow.search.result.DetectorEvaluation) LoggerFactory(org.slf4j.LoggerFactory) Set(java.util.Set) EventSystem(com.blackducksoftware.integration.hub.detect.workflow.event.EventSystem) ExceptionDetectorResult(com.blackducksoftware.integration.hub.detect.workflow.search.result.ExceptionDetectorResult) Collectors(java.util.stream.Collectors) DetectorType(com.blackducksoftware.integration.hub.detect.detector.DetectorType) DetectorEvaluation(com.blackducksoftware.integration.hub.detect.workflow.search.result.DetectorEvaluation)

Aggregations

DetectorEvaluation (com.blackducksoftware.integration.hub.detect.workflow.search.result.DetectorEvaluation)8 ArrayList (java.util.ArrayList)5 DetectorType (com.blackducksoftware.integration.hub.detect.detector.DetectorType)4 List (java.util.List)3 Set (java.util.Set)3 Collectors (java.util.stream.Collectors)3 Logger (org.slf4j.Logger)3 LoggerFactory (org.slf4j.LoggerFactory)3 Detector (com.blackducksoftware.integration.hub.detect.detector.Detector)2 DetectorEnvironment (com.blackducksoftware.integration.hub.detect.detector.DetectorEnvironment)2 DetectorSearchRuleSet (com.blackducksoftware.integration.hub.detect.workflow.search.rules.DetectorSearchRuleSet)2 HashMap (java.util.HashMap)2 DetectorException (com.blackducksoftware.integration.hub.detect.detector.DetectorException)1 ExtractionId (com.blackducksoftware.integration.hub.detect.detector.ExtractionId)1 DetectUserFriendlyException (com.blackducksoftware.integration.hub.detect.exception.DetectUserFriendlyException)1 ExitCodeType (com.blackducksoftware.integration.hub.detect.exitcode.ExitCodeType)1 DetectorToolResult (com.blackducksoftware.integration.hub.detect.tool.detector.DetectorToolResult)1 DetectCodeLocation (com.blackducksoftware.integration.hub.detect.workflow.codelocation.DetectCodeLocation)1 Event (com.blackducksoftware.integration.hub.detect.workflow.event.Event)1 EventSystem (com.blackducksoftware.integration.hub.detect.workflow.event.EventSystem)1