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