Skip to content

Commit

Permalink
WINDUP-912 Fixes and colors in the Migration Summary Page
Browse files Browse the repository at this point in the history
  • Loading branch information
OndraZizka committed Feb 16, 2016
1 parent b43d065 commit cb665a9
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 27 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.jboss.windup.reporting.freemarker;

import java.util.List;
import java.util.Map;

import org.jboss.windup.config.GraphRewrite;
import org.jboss.windup.reporting.service.EffortReportService;
Expand All @@ -10,6 +9,8 @@
import freemarker.template.SimpleNumber;
import freemarker.template.TemplateBooleanModel;
import freemarker.template.TemplateModelException;
import freemarker.template.TemplateScalarModel;
import org.jboss.windup.reporting.service.EffortReportService.Verbosity;

/**
* Given a number of points, return a short textual description (eg, Trivial or Complex).
Expand Down Expand Up @@ -43,13 +44,24 @@ public Object exec(List arguments) throws TemplateModelException
SimpleNumber simpleNumber = (SimpleNumber) arguments.get(0);
int effort = simpleNumber.getAsNumber().intValue();

boolean verbose = false;
Verbosity verbosity = Verbosity.SHORT;
if (arguments.size() > 1)
verbose = ((TemplateBooleanModel) arguments.get(1)).getAsBoolean();
{
final Object arg2 = arguments.get(1);
// Support for getEffortDescriptionForPoints( 10, true )
if( arg2 instanceof TemplateBooleanModel && ((TemplateBooleanModel) arg2).getAsBoolean())
verbosity = Verbosity.VERBOSE;
// Support for getEffortDescriptionForPoints( 10, 'verbose' ) or 'id'
if( arg2 instanceof TemplateScalarModel ){
String asString = ((TemplateScalarModel)arg2).getAsString();
if(asString.equals("verbose"))
verbosity = Verbosity.VERBOSE;
if(asString.equals("id"))
verbosity = Verbosity.ID;
}
}

Map<Integer, String> effortToDescription = verbose ? EffortReportService.getVerboseEffortLevelDescriptionMappings()
: EffortReportService.getEffortLevelDescriptionMappings();
String result = effortToDescription.containsKey(effort) ? effortToDescription.get(effort) : EffortReportService.UNKNOWN;
String result = EffortReportService.getEffortLevelDescription(verbosity, effort);

ExecutionStatistics.get().end(NAME);
return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@
* Contains methods for manipulating {@link EffortReportModel} instances.
*
* @author <a href="mailto:jesse.sightler@gmail.com">Jesse Sightler</a>
* @author <a href="mailto:zizka@seznam.cz">Ondrej Zizka</a>
*/
public class EffortReportService extends GraphService
{
private static Map<Integer, String> effortLevelDescriptionMap = Collections.synchronizedMap(new LinkedHashMap<Integer, String>());
private static Map<Integer, String> effortLevelDescriptionVerboseMap = Collections.synchronizedMap(new LinkedHashMap<Integer, String>());
private static final Map<Integer, String> effortLevelDescriptionMap = Collections.synchronizedMap(new LinkedHashMap<Integer, String>());
private static final Map<Integer, String> effortLevelDescriptionVerboseMap = Collections.synchronizedMap(new LinkedHashMap<Integer, String>());

public static final String UNKNOWN = "Unknown";
public static final String REQUIRES_ARCHITECTURAL_CHANGE = "Requires Architectural Change";
Expand All @@ -37,16 +38,54 @@ public class EffortReportService extends GraphService
effortLevelDescriptionVerboseMap.put(0, "Info");
effortLevelDescriptionVerboseMap.put(1, "Trivial change or 1-1 library swap");
effortLevelDescriptionVerboseMap.put(3, "Complex change with documented solution");
effortLevelDescriptionVerboseMap.put(5, "Complex change with documented solution");
effortLevelDescriptionVerboseMap.put(5, "Requires re-design or library change");
effortLevelDescriptionVerboseMap.put(7, "Requires architectural decision or change");
effortLevelDescriptionVerboseMap.put(13, "Unknown effort");
}

public static enum Verbosity { ID, SHORT, VERBOSE };

public EffortReportService(GraphContext context)
{
super(context, EffortReportModel.class);
}

/**
* Returns the right string representation of the effort level based on given number of points.
*/
public static String getEffortLevelDescription(Verbosity verbosity, int points)
{
Map<Integer, String> theMapToUse = null;
switch (verbosity)
{
case ID:
switch (points)
{
case 0: return "INFO";
case 1: case 2: return "TRIVIAL";
case 3: case 4: return "COMPLEX";
case 5: case 6: return "REDESIGN";
case 7: case 8: case 9: case 10: case 11: case 12: return "ARCHITECTURAL";
case 13: default: return "UNKNOWN";
}
case SHORT:
theMapToUse = effortLevelDescriptionMap;
break;
case VERBOSE:
theMapToUse = effortLevelDescriptionVerboseMap;
break;
}

String last = "";
for (Map.Entry<Integer, String> entry : theMapToUse.entrySet())
{
if (points <= entry.getKey())
return entry.getValue();
last = entry.getValue();
}
return last;
}

/**
* Gets a mapping from effort level to a description.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,33 +1,29 @@
<!DOCTYPE html>

<#macro migrationIssuesRenderer problemSummary>
<tr rospan="2">
<tr class="problemSummary effort${getEffortDescriptionForPoints(problemSummary.effortPerIncident, 'id')}">
<td>
<a href="#" class="toggle">
${problemSummary.issueName}
</a>
<a href="#" class="toggle">${problemSummary.issueName?html}</a>
</td>
<td class="text-right">${problemSummary.numberFound}</td>
<td class="text-right">${problemSummary.effortPerIncident}</td>
<td>${getEffortDescriptionForPoints(problemSummary.effortPerIncident, true)}</td>
<td class="text-right">${problemSummary.numberFound * problemSummary.effortPerIncident}</td>
<td class="text-right">${problemSummary.numberFound}&times;</td>
<td class="text-right">${problemSummary.effortPerIncident} sp</td>
<td class="level">${getEffortDescriptionForPoints(problemSummary.effortPerIncident, true)}</td>
<td class="text-right">${problemSummary.numberFound * problemSummary.effortPerIncident} sp</td>
</tr>
<tr class="tablesorter-childRow bg-info">
<td><div class="indent"><strong>File</strong></td>
<td><div class="indent"><strong>File</strong></div></td>
<td><strong>Incidents Found</strong></td>
<td colspan="3"><strong>Hint</strong></td>
</tr>
<#list problemSummary.descriptions as description>
<#assign filesCount=problemSummary.getFilesForDescription(description)?size>
<#list problemSummary.getFilesForDescription(description) as fileSummary>
<tr class="tablesorter-childRow">
<tr class="fileSummary tablesorter-childRow">
<td>
<div class="indent">
<@render_link model=fileSummary.file class="migration-issues-detailed-item"/><#t>
</div>
<div class="indent"> <@render_link model=fileSummary.file class="migration-issues-detailed-item"/> </div>
</td>
<td class="text-right">
<@render_link model=fileSummary.file text="#{fileSummary.occurences}" class="migration-issues-detailed-item"/><#t>
<@render_link model=fileSummary.file text="#{fileSummary.occurences}&times;" class="migration-issues-detailed-item"/><#t>
</td>
<#if fileSummary?is_first>
<td colspan="3" rowspan="${filesCount}">
Expand Down Expand Up @@ -96,7 +92,24 @@
<link href="resources/css/windup.java.css" rel="stylesheet" media="screen">
<link href="resources/css/jquery-ui.css" rel="stylesheet" media="screen">
<link href="resources/img/favicon.png" rel="shortcut icon" type="image/x-icon"/>
<style>.hint-detail-panel .panel-body { padding-bottom: 0; }</style>
<style>
.migration-issues-table.table-bordered > thead > tr > td { border-left-style: none; border-right-style: none; }
.hint-detail-panel > .panel-heading {
border-color: #c2c2c2;
background-color: #fbf4b1;
}
.hint-detail-panel {
border-color: #a8d0e3;
background-color: #fffcdc;
}
.hint-detail-panel > .panel-body { padding-bottom: 0; }
tr.problemSummary.effortINFO td.level { color: #1B540E; }
tr.problemSummary.effortTRIVIAL td.level { color: #50A40E; }
tr.problemSummary.effortCOMPLEX td.level { color: #0065AC; }
tr.problemSummary.effortREDESIGN td.level { color: #C67D00; }
tr.problemSummary.effortARCHITECTURAL td.level { color: #C42F0E; }
tr.problemSummary.effortUNKNOWN td.level { color: #C42F0E; }
</style>
</head>
<body role="document">
<!-- Navbar -->
Expand Down Expand Up @@ -152,7 +165,7 @@

<div class="panel-body">
<#list problemsBySeverity?keys as severity>
<table class="table table-hover table-bordered table-condensed tablesorter migration-issues-table">
<table class="table table-bordered table-condensed tablesorter migration-issues-table">
<thead>
<tr>
<th class="sortable">Issue by Category</th>
Expand All @@ -161,11 +174,11 @@
<th>Level of Effort</th>
<th class="sortable">Total Story Points</th>
</tr>
<tr style="background: silver;">
<tr style="background: rgb(212, 230, 233);">
<td>
<b>${severity}</b>
</td>
<td class="text-right">${getIncidentsFound(problemsBySeverity[severity])}</td>
<td class="text-right">${getIncidentsFound(problemsBySeverity[severity])}&times;</td>
<td></td>
<td></td>
<td class="text-right">${getTotalPoints(problemsBySeverity[severity])}</td>
Expand Down

0 comments on commit cb665a9

Please sign in to comment.