/** * Gets lists of {@link ProblemSummary} objects organized by {@link IssueCategoryModel}. */ public static Map<IssueCategoryModel, List<ProblemSummary>> getProblemSummaries( GraphContext graphContext, Set<ProjectModel> projectModels, Set<String> includeTags, Set<String> excludeTags) { return getProblemSummaries(graphContext, projectModels, includeTags, excludeTags, false, false); }
/** * Adds a file with the provided description. */ public void addFile(String description, FileModel fileModel) { Map<FileModel, ProblemFileSummary> files = addDescription(description); if (files.containsKey(fileModel)) { files.get(fileModel).addOccurrence(); } else { files.put(fileModel, new ProblemFileSummary(fileModel, 1)); } } }
private static void addToResults(Map<IssueCategoryModel, List<ProblemSummary>> results, ProblemSummary summary) { List<ProblemSummary> list = results.get(summary.getIssueCategoryModel()); if (list == null) { list = new ArrayList<>(); results.put(summary.getIssueCategoryModel(), list); } list.add(summary); } }
RuleSummaryKey key = new RuleSummaryKey(hint.getEffort(), hint.getRuleID(), hint.getTitle()); summary = new ProblemSummary(UUID.randomUUID().toString(), hint.getIssueCategory(), hint.getRuleID(), hint.getTitle(), 1, hint.getEffort()); for (LinkModel link : hint.getLinks()) summary.addLink(link.getDescription(), link.getLink()); addToResults(results, summary); summary.setNumberFound(summary.getNumberFound() + 1); summary.addFile(hint.getHint(), hint.getFile()); RuleSummaryKey key = new RuleSummaryKey(classification.getEffort(), classification.getRuleID(), classification.getClassification()); ProblemSummary summary = ruleToSummary.get(key); if (summary == null) summary = new ProblemSummary(UUID.randomUUID().toString(), classification.getIssueCategory(), classification.getRuleID(), classification.getClassification(), 0, classification.getEffort()); for (LinkModel link : classification.getLinks()) summary.addLink(link.getDescription(), link.getLink()); addToResults(results, summary); summary.addFile(classification.getDescription(), file); summary.setNumberFound(summary.getNumberFound() + newFileModels.size());
throw new TemplateModelException("Method " + getMethodName() + " requires the following parameters (GraphRewrite event, ProjectModel project, Set<String> includeTags, Set<String> excludeTags)"); Set<String> excludeTags = FreeMarkerUtil.simpleSequenceToSet((SimpleSequence) arguments.get(3)); Set<ProjectModel> projectModels = getProjects(projectModel); Map<IssueCategoryModel, List<ProblemSummary>> problemSummariesOriginal = ProblemSummaryService.getProblemSummaries(event.getGraphContext(), projectModels, includeTags, excludeTags);
private List<ProblemFileSummaryWrapper> getFileSummaries(Long executionId, ProblemSummary summary) { return StreamSupport.stream(summary.getDescriptions().spliterator(), false) .flatMap(description -> StreamSupport.stream(summary.getFilesForDescription(description).spliterator(), false)) .map(fileSummary -> new ProblemFileSummaryWrapper( this.convertToMap(executionId, fileSummary.getFile().getElement(), 0, false), fileSummary.getOccurrences())) .collect(Collectors.toList()); }
/** * Get details from problems categorized by EffortLevel and # of incidents * * @param problems all found problems * @return */ private EffortByCategoryDTO getIncidentsByEffort(Map<IssueCategoryModel, List<ProblemSummary>> problems) { EffortByCategoryDTO result = new EffortByCategoryDTO(); Map<String, Integer> categoryIDToPriority = new HashMap<>(); problems.forEach((issueCategory, problemSummaries) -> { categoryIDToPriority.put(issueCategory.getCategoryID(), issueCategory.getPriority()); EffortCategoryDTO categoryDTO = new EffortCategoryDTO(); categoryDTO.setCategoryID(issueCategory.getCategoryID()); for (ProblemSummary problemSummary : problemSummaries) { EffortLevel effort = EffortLevel.forPoints(problemSummary.getEffortPerIncident()); categoryDTO.addValue(effort.getShortDescription(), problemSummary.getNumberFound()); } result.addCategory(categoryDTO); }); result.categories.sort((category1, category2) -> { int priority1 = categoryIDToPriority.get(category1.getCategoryID()); int priority2 = categoryIDToPriority.get(category2.getCategoryID()); return priority1 - priority2; }); return result; }
private ProblemSummary getProblemSummary(Long executionId, String issueId, Map<String, Object> filterAsMap) { Map<String, List<ProblemSummary>> categorizedProblems = this.getAggregatedIssues(executionId, filterAsMap); List<ProblemSummary> problemSummaries = categorizedProblems.entrySet() .stream() .map(Map.Entry::getValue) .flatMap(Collection::stream) .filter(item -> item.getRuleID().concat(item.getIssueName()).equals(issueId)) .collect(Collectors.toList()); if (problemSummaries.size() == 0) { throw new NotFoundException(); } return problemSummaries.get(0); }
RuleSummaryKey key = new RuleSummaryKey(hint.getEffort(), hint.getRuleID(), hint.getTitle()); summary = new ProblemSummary(UUID.randomUUID().toString(), hint.getIssueCategory(), hint.getRuleID(), hint.getTitle(), 1, hint.getEffort()); for (LinkModel link : hint.getLinks()) summary.addLink(link.getDescription(), link.getLink()); addToResults(results, summary); summary.setNumberFound(summary.getNumberFound() + 1); summary.addFile(hint.getHint(), hint.getFile()); RuleSummaryKey key = new RuleSummaryKey(classification.getEffort(), classification.getRuleID(), classification.getClassification()); ProblemSummary summary = ruleToSummary.get(key); if (summary == null) summary = new ProblemSummary(UUID.randomUUID().toString(), classification.getIssueCategory(), classification.getRuleID(), classification.getClassification(), 0, classification.getEffort()); for (LinkModel link : classification.getLinks()) summary.addLink(link.getDescription(), link.getLink()); addToResults(results, summary); summary.addFile(classification.getDescription(), file); summary.setNumberFound(summary.getNumberFound() + newFileModels.size());
/** * Gets lists of {@link ProblemSummary} objects organized by {@link IssueCategoryModel}. */ public static Map<IssueCategoryModel, List<ProblemSummary>> getProblemSummaries( GraphContext graphContext, Set<ProjectModel> projectModels, Set<String> includeTags, Set<String> excludeTags) { return getProblemSummaries(graphContext, projectModels, includeTags, excludeTags, false, false); }
throw new TemplateModelException("Method " + getMethodName() + " requires the following parameters (GraphRewrite event, ProjectModel project, Set<String> includeTags, Set<String> excludeTags)"); Set<String> excludeTags = FreeMarkerUtil.simpleSequenceToSet((SimpleSequence) arguments.get(3)); Set<ProjectModel> projectModels = getProjects(projectModel); Map<IssueCategoryModel, List<ProblemSummary>> problemSummariesOriginal = ProblemSummaryService.getProblemSummaries(event.getGraphContext(), projectModels, includeTags, excludeTags);
/** * Adds a file with the provided description. */ public void addFile(String description, FileModel fileModel) { Map<FileModel, ProblemFileSummary> files = addDescription(description); if (files.containsKey(fileModel)) { files.get(fileModel).addOccurrence(); } else { files.put(fileModel, new ProblemFileSummary(fileModel, 1)); } } }
private static void addToResults(Map<IssueCategoryModel, List<ProblemSummary>> results, ProblemSummary summary) { List<ProblemSummary> list = results.get(summary.getIssueCategoryModel()); if (list == null) { list = new ArrayList<>(); results.put(summary.getIssueCategoryModel(), list); } list.add(summary); } }
/** * This counts incidents for every category issue type */ @Override public EffortByCategoryDTO getAggregatedCategories(Long executionId, Map<String, Object> filterAsMap) { GraphContext graphContext = this.getGraph(executionId); Set<String> includeTags = new HashSet<>(); Set<String> excludeTags = new HashSet<>(); Set<ProjectModel> projectModels = null; //ReportFilterDTO filter = this.reportFilterService.getReportFilter(executionId); ReportFilterDTO filter = this.reportFilterService.getReportFilterFromMap(filterAsMap); if (filter.isEnabled()) { includeTags.addAll(filter.getIncludeTags()); excludeTags.addAll(filter.getExcludeTags()); projectModels = this.getProjectModels(graphContext, filter); } Map<IssueCategoryModel, List<ProblemSummary>> issues = ProblemSummaryService.getProblemSummaries( graphContext, projectModels, includeTags, excludeTags, true, false); return getIncidentsByEffort(issues); }
Map<IssueCategoryModel, List<ProblemSummary>> issues = ProblemSummaryService.getProblemSummaries( graphContext, projectModels,
ProblemSummaryService.getProblemSummaries( event.getGraphContext(), projectModelTraversal.getAllProjects(true), Collections.emptySet(), Collections.emptySet()) .entrySet().stream().collect(Collectors.toMap((e) -> e.getKey().getCategoryID(), Map.Entry::getValue));
ProblemSummaryService.getProblemSummaries( event.getGraphContext(), projectModelTraversal.getAllProjects(true), Collections.emptySet(), Collections.emptySet()) .entrySet().stream().collect(Collectors.toMap((e) -> e.getKey().getCategoryID(), Map.Entry::getValue));