Search in sources :

Example 1 with ReportEntryModel

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();
    }
}
Also used : ReportEntryModel(com.mulesoft.tools.migration.report.html.model.ReportEntryModel) JSONReport(com.mulesoft.tools.migration.report.json.JSONReport) MigrationJobException(com.mulesoft.tools.migration.engine.exception.MigrationJobException) MigrationJobException(com.mulesoft.tools.migration.engine.exception.MigrationJobException) MigrationTaskException(com.mulesoft.tools.migration.exception.MigrationTaskException) HTMLReport(com.mulesoft.tools.migration.report.html.HTMLReport)

Example 2 with ReportEntryModel

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++;
        }
    }
}
Also used : ReportEntryModel(com.mulesoft.tools.migration.report.html.model.ReportEntryModel) TemplateException(freemarker.template.TemplateException) Template(freemarker.template.Template) StringWriter(java.io.StringWriter) File(java.io.File)

Example 3 with ReportEntryModel

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)));
            }
        }
    }
}
Also used : ReportEntryModel(com.mulesoft.tools.migration.report.html.model.ReportEntryModel) Comment(org.jdom2.Comment)

Aggregations

ReportEntryModel (com.mulesoft.tools.migration.report.html.model.ReportEntryModel)3 MigrationJobException (com.mulesoft.tools.migration.engine.exception.MigrationJobException)1 MigrationTaskException (com.mulesoft.tools.migration.exception.MigrationTaskException)1 HTMLReport (com.mulesoft.tools.migration.report.html.HTMLReport)1 JSONReport (com.mulesoft.tools.migration.report.json.JSONReport)1 Template (freemarker.template.Template)1 TemplateException (freemarker.template.TemplateException)1 File (java.io.File)1 StringWriter (java.io.StringWriter)1 Comment (org.jdom2.Comment)1