private String getPrimaryColumn(ExecutableRule rule, List<String> columnNames) { String primaryColumn = rule.getReport().getPrimaryColumn(); if (primaryColumn == null && columnNames != null && !columnNames.isEmpty()) { primaryColumn = columnNames.get(0); } return primaryColumn; }
/** * Select the report writers for the given rule. * * @param rule * The rule. * @throws ReportException * If no writer exists for a specified id. */ private Map<String, ReportPlugin> selectReportPlugins(ExecutableRule rule) throws ReportException { Set<String> selection = rule.getReport().getSelectedTypes(); Map<String, ReportPlugin> reportPlugins = new HashMap<>(); if (selection != null) { for (String type : selection) { ReportPlugin candidate = this.selectableReportPlugins.get(type); if (candidate == null) { throw new ReportException("Unknown report selection '" + type + "' selected for '" + rule + "'"); } reportPlugins.put(type, candidate); } } return reportPlugins; } }
/** * Creates an instance of the select {@link GraphMLDecorator}. * * @param result The rule result. * @return The {@link GraphMLDecorator}. */ private GraphMLDecorator getGraphMLDecorator(Result<?> result) { String graphMLDecorator = result.getRule().getReport().getProperties().getProperty(GRAPHML_DECORATOR); Class<? extends GraphMLDecorator> decoratorClass; if (graphMLDecorator != null) { decoratorClass = classHelper.getType(graphMLDecorator); } else { decoratorClass = defaultDecoratorClass; } return classHelper.createInstance(decoratorClass); }
@Override public void setResult(Result<? extends ExecutableRule> result) throws ReportException { Rule rule = result.getRule(); Set<String> selectedReports = result.getRule().getReport().getSelectedTypes(); if ((selectedReports != null && selectedReports.contains(GRAPHML)) || (rule instanceof Concept && rule.getId().matches(conceptPattern))) { SubGraph subGraph = subGraphFactory.createSubGraph(result); try { String fileName = ReportHelper.escapeRuleId(rule); if (!fileName.endsWith(FILEEXTENSION_GRAPHML)) { fileName = fileName + FILEEXTENSION_GRAPHML; } File file = new File(reportDirectory, fileName); xmlGraphMLWriter.write(result, subGraph, file); reportContext.addReport("GraphML", result.getRule(), ReportContext.ReportType.LINK, file.toURI().toURL()); } catch (IOException | XMLStreamException e) { throw new ReportException("Cannot write custom report.", e); } } } }