Search in sources :

Example 1 with DetectorResult

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

the class DetectorSearchEvaluator method searchable.

public DetectorResult searchable(final DetectorSearchRule searchRules, final List<Detector> appliedSoFar, DetectorEnvironment environment) {
    Detector detector = searchRules.getDetector();
    final DetectorType detectorType = detector.getDetectorType();
    if (!environment.getDetectorFilter().shouldInclude(detectorType.toString())) {
        return new ExcludedDetectorResult();
    }
    final int maxDepth = searchRules.getMaxDepth();
    if (environment.getDepth() > maxDepth) {
        return new MaxDepthExceededDetectorResult(environment.getDepth(), maxDepth);
    }
    final Set<Detector> yieldTo = appliedSoFar.stream().filter(it -> searchRules.getYieldsTo().contains(it)).collect(Collectors.toSet());
    if (yieldTo.size() > 0) {
        return new YieldedDetectorResult(yieldTo);
    }
    final boolean nestable = searchRules.isNestable();
    if (environment.getForceNestedSearch()) {
        return new ForcedNestedPassedDetectorResult();
    } else if (nestable) {
        if (environment.getAppliedToParent().stream().anyMatch(applied -> applied.isSame(detector))) {
            return new NotSelfNestableDetectorResult();
        }
    } else if (!nestable && environment.getAppliedToParent().size() > 0) {
        return new NotNestableDetectorResult();
    }
    return new PassedDetectorResult();
}
Also used : Detector(com.blackducksoftware.integration.hub.detect.detector.Detector) DetectorType(com.blackducksoftware.integration.hub.detect.detector.DetectorType) NotNestableDetectorResult(com.blackducksoftware.integration.hub.detect.workflow.search.result.NotNestableDetectorResult) DetectorEvaluation(com.blackducksoftware.integration.hub.detect.workflow.search.result.DetectorEvaluation) Set(java.util.Set) EventSystem(com.blackducksoftware.integration.hub.detect.workflow.event.EventSystem) NotSelfNestableDetectorResult(com.blackducksoftware.integration.hub.detect.workflow.search.result.NotSelfNestableDetectorResult) Collectors(java.util.stream.Collectors) ForcedNestedPassedDetectorResult(com.blackducksoftware.integration.hub.detect.workflow.search.result.ForcedNestedPassedDetectorResult) ArrayList(java.util.ArrayList) DetectorEnvironment(com.blackducksoftware.integration.hub.detect.detector.DetectorEnvironment) PassedDetectorResult(com.blackducksoftware.integration.hub.detect.workflow.search.result.PassedDetectorResult) List(java.util.List) Event(com.blackducksoftware.integration.hub.detect.workflow.event.Event) DetectorResult(com.blackducksoftware.integration.hub.detect.workflow.search.result.DetectorResult) MaxDepthExceededDetectorResult(com.blackducksoftware.integration.hub.detect.workflow.search.result.MaxDepthExceededDetectorResult) ExcludedDetectorResult(com.blackducksoftware.integration.hub.detect.workflow.search.result.ExcludedDetectorResult) YieldedDetectorResult(com.blackducksoftware.integration.hub.detect.workflow.search.result.YieldedDetectorResult) YieldedDetectorResult(com.blackducksoftware.integration.hub.detect.workflow.search.result.YieldedDetectorResult) ForcedNestedPassedDetectorResult(com.blackducksoftware.integration.hub.detect.workflow.search.result.ForcedNestedPassedDetectorResult) PassedDetectorResult(com.blackducksoftware.integration.hub.detect.workflow.search.result.PassedDetectorResult) DetectorType(com.blackducksoftware.integration.hub.detect.detector.DetectorType) MaxDepthExceededDetectorResult(com.blackducksoftware.integration.hub.detect.workflow.search.result.MaxDepthExceededDetectorResult) NotSelfNestableDetectorResult(com.blackducksoftware.integration.hub.detect.workflow.search.result.NotSelfNestableDetectorResult) Detector(com.blackducksoftware.integration.hub.detect.detector.Detector) ForcedNestedPassedDetectorResult(com.blackducksoftware.integration.hub.detect.workflow.search.result.ForcedNestedPassedDetectorResult) NotNestableDetectorResult(com.blackducksoftware.integration.hub.detect.workflow.search.result.NotNestableDetectorResult) ExcludedDetectorResult(com.blackducksoftware.integration.hub.detect.workflow.search.result.ExcludedDetectorResult)

Example 2 with DetectorResult

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

the class ToolRunner method run.

public void run(final RunResult runResult) throws DetectorException {
    logger.info(String.format("Checking if %s applies.", toolDetector.getToolEnum().toString()));
    DetectorResult applicableResult = toolDetector.applicable();
    if (applicableResult.getPassed()) {
        logger.info(String.format("Checking if %s is extractable.", toolDetector.getToolEnum().toString()));
        DetectorResult extractableResult = toolDetector.extractable();
        if (extractableResult.getPassed()) {
            logger.info(String.format("Performing the %s extraction.", toolDetector.getToolEnum().toString()));
            Extraction extractionResults = toolDetector.extract();
            if (extractionResults.result != Extraction.ExtractionResultType.SUCCESS) {
                logger.error(String.format("%s extraction failed: %s", toolDetector.getToolEnum().toString(), extractionResults.description));
            }
            publishExtractionResults(eventSystem, runResult, extractionResults);
        } else {
            publishNotExtractableResults(eventSystem, extractableResult, toolDetector.getToolEnum().toString());
        }
    } else {
        logger.info(String.format("%s was not applicable, will not actually run %s tool.", toolDetector.getToolEnum().toString(), toolDetector.getToolEnum().toString()));
        logger.info(applicableResult.toDescription());
    }
}
Also used : DetectorResult(com.blackducksoftware.integration.hub.detect.workflow.search.result.DetectorResult) Extraction(com.blackducksoftware.integration.hub.detect.workflow.extraction.Extraction)

Aggregations

DetectorResult (com.blackducksoftware.integration.hub.detect.workflow.search.result.DetectorResult)2 Detector (com.blackducksoftware.integration.hub.detect.detector.Detector)1 DetectorEnvironment (com.blackducksoftware.integration.hub.detect.detector.DetectorEnvironment)1 DetectorType (com.blackducksoftware.integration.hub.detect.detector.DetectorType)1 Event (com.blackducksoftware.integration.hub.detect.workflow.event.Event)1 EventSystem (com.blackducksoftware.integration.hub.detect.workflow.event.EventSystem)1 Extraction (com.blackducksoftware.integration.hub.detect.workflow.extraction.Extraction)1 DetectorEvaluation (com.blackducksoftware.integration.hub.detect.workflow.search.result.DetectorEvaluation)1 ExcludedDetectorResult (com.blackducksoftware.integration.hub.detect.workflow.search.result.ExcludedDetectorResult)1 ForcedNestedPassedDetectorResult (com.blackducksoftware.integration.hub.detect.workflow.search.result.ForcedNestedPassedDetectorResult)1 MaxDepthExceededDetectorResult (com.blackducksoftware.integration.hub.detect.workflow.search.result.MaxDepthExceededDetectorResult)1 NotNestableDetectorResult (com.blackducksoftware.integration.hub.detect.workflow.search.result.NotNestableDetectorResult)1 NotSelfNestableDetectorResult (com.blackducksoftware.integration.hub.detect.workflow.search.result.NotSelfNestableDetectorResult)1 PassedDetectorResult (com.blackducksoftware.integration.hub.detect.workflow.search.result.PassedDetectorResult)1 YieldedDetectorResult (com.blackducksoftware.integration.hub.detect.workflow.search.result.YieldedDetectorResult)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1