use of com.mulesoft.tools.migration.report.html.model.ReportEntryModel in project mule-migration-assistant by mulesoft.
the class MigrationJob method generateReport.
private void generateReport(MigrationReport<ReportEntryModel> report, ApplicationModel applicationModel) throws Exception {
List<ReportEntryModel> reportEntries = report.getReportEntries();
for (ReportEntryModel entry : reportEntries) {
try {
entry.setElementLocation();
} catch (Exception ex) {
throw new MigrationJobException("Failed to generate report.", ex);
}
}
HTMLReport htmlReport = new HTMLReport(report, reportPath.toFile(), this.getRunnerVersion());
htmlReport.printReport();
if (jsonReportEnabled) {
applicationModel.getPomModel().ifPresent(p -> report.addConnectors(p));
JSONReport jsonReport = new JSONReport(report, reportPath.toFile(), outputProject);
jsonReport.printReport();
}
}
use of com.mulesoft.tools.migration.report.html.model.ReportEntryModel in project mule-migration-assistant by mulesoft.
the class HTMLReport method generateResourceFiles.
private void generateResourceFiles(Map<String, Map<String, List<ReportEntryModel>>> entries, Level level) throws IOException {
StringWriter writer = null;
for (Map.Entry<String, Map<String, List<ReportEntryModel>>> entry : entries.entrySet()) {
Integer fileCounter = 0;
for (Map.Entry<String, List<ReportEntryModel>> fileEntry : entry.getValue().entrySet()) {
try {
if (fileEntry.getValue().size() > 0) {
Template resourceTemplate = getTemplate(RESOURCE_TEMPLATE_FILE_NAME);
Map<String, Object> data = new HashMap<>();
data.put("version", runnerVersion);
data.put("resource", Paths.get(entry.getKey()).getFileName().toString());
data.put("description", fileEntry.getKey());
data.put("docLinks", fileEntry.getValue().get(0).getDocumentationLinks());
data.put("entries", fileEntry.getValue());
String fileName = level.toString().toLowerCase() + "-" + Paths.get(entry.getKey()).getFileName().toString();
writer = new StringWriter();
resourceTemplate.process(data, writer);
reportFileWriter.writeToFile(new File(reportDirectory.toPath().resolve(RESOURCES_FOLDER).toFile(), reportFileWriter.getHtmlFileName(fileName, fileCounter)), writer.getBuffer().toString());
}
} catch (TemplateException e) {
e.printStackTrace();
} finally {
IOUtils.closeQuietly(writer);
}
fileCounter++;
}
}
}
use of com.mulesoft.tools.migration.report.html.model.ReportEntryModel in project mule-migration-assistant by mulesoft.
the class DefaultMigrationReport method report.
private void report(String entryKey, Level level, Element element, Element elementToComment, String message, String... documentationLinks) {
int i = 0;
ReportEntryModel reportEntry;
if (elementToComment != null) {
if (elementToComment.getDocument() != null || element.getDocument() == null) {
reportEntry = new ReportEntryModel(entryKey, level, elementToComment, message, documentationLinks);
} else {
reportEntry = new ReportEntryModel(entryKey, level, elementToComment, message, element.getDocument(), documentationLinks);
}
if (reportEntries.add(reportEntry)) {
elementToComment.addContent(i++, new Comment("Migration " + level.name() + ": " + sanitize(message)));
if (documentationLinks.length > 0) {
elementToComment.addContent(i++, new Comment(" For more information refer to:"));
for (String link : documentationLinks) {
elementToComment.addContent(i++, new Comment(" * " + link));
}
}
if (element != elementToComment) {
XmlDslUtils.removeNestedComments(element);
elementToComment.addContent(i, new Comment(outp.outputString(element)));
}
}
}
}
Aggregations