Search in sources :

Example 1 with NotNestableDetectorResult

use of com.blackducksoftware.integration.hub.detect.workflow.search.result.NotNestableDetectorResult 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)

Aggregations

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 DetectorEvaluation (com.blackducksoftware.integration.hub.detect.workflow.search.result.DetectorEvaluation)1 DetectorResult (com.blackducksoftware.integration.hub.detect.workflow.search.result.DetectorResult)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