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();
}
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());
}
}
Aggregations