Improved code.
This commit is contained in:
parent
1b2969a1eb
commit
3f2a667040
2 changed files with 84 additions and 86 deletions
|
@ -54,15 +54,56 @@ public class ProjectsGroupedPageBuilder
|
|||
|
||||
try
|
||||
{
|
||||
System.out.println("Building welcome page (2)…");
|
||||
System.out.println("Building ProjectsGrouped page…");
|
||||
|
||||
TagDataManager data = new TagDataManager();
|
||||
int index = 0;
|
||||
for (Project project : projects)
|
||||
{
|
||||
if (project.getParentId() == null)
|
||||
{
|
||||
fillLine(data, index, project);
|
||||
index += 1;
|
||||
}
|
||||
|
||||
if (project.hasChild())
|
||||
{
|
||||
for (Project subProject : project.subProjects())
|
||||
{
|
||||
fillLine(data, index, subProject);
|
||||
index += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
result = PresenterUtils.dynamize("/org/april/agirstatool/core/pages/projectsGrouped.xhtml", data).toString();
|
||||
}
|
||||
catch (XidynException exception)
|
||||
{
|
||||
throw new AgirStatoolException("Error building ProjectsGrouped page: " + exception.getMessage(), exception);
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill line.
|
||||
*
|
||||
* @param data
|
||||
* the data
|
||||
* @param index
|
||||
* the index
|
||||
* @param project
|
||||
* the project
|
||||
*/
|
||||
private static void fillLine(final TagDataManager data, final int index, final Project project)
|
||||
{
|
||||
data.setContent("projectLine", index, "projectId", project.getId());
|
||||
if (project.getParentId() != null)
|
||||
{
|
||||
data.setAttribute("projectLine", index, "projectName", "style", "padding-left: 25px;");
|
||||
}
|
||||
data.setAttribute("projectLine", index, "projectNameLink", "href", project.getPath());
|
||||
data.setContent("projectLine", index, "projectNameLink", StringEscapeUtils.escapeXml(project.getName()));
|
||||
data.setContent("projectLine", index, "childCount", project.getChildCount());
|
||||
|
@ -78,43 +119,5 @@ public class ProjectsGroupedPageBuilder
|
|||
data.setContent("projectLine", index, "unassignedConcludedIssueCount", project.issueStats().getUnassignedConcludedCount());
|
||||
data.setContent("projectLine", index, "lastUpdate", AgirStatoolUtils.toHumanShort(project.getLastUpdate(), "n/a"));
|
||||
data.setAttribute("projectLine", index, "lastUpdate", "title", AgirStatoolUtils.toHumanLong(project.getLastUpdate(), "n/a"));
|
||||
index += 1;
|
||||
}
|
||||
|
||||
if (project.hasChild())
|
||||
{
|
||||
for (Project subProject : project.subProjects())
|
||||
{
|
||||
data.setContent("projectLine", index, "projectId", subProject.getId());
|
||||
data.setAttribute("projectLine", index, "projectName", "style", "padding-left: 25px;");
|
||||
data.setAttribute("projectLine", index, "projectNameLink", "href", subProject.getPath());
|
||||
data.setContent("projectLine", index, "projectNameLink", StringEscapeUtils.escapeXml(subProject.getName()));
|
||||
data.setContent("projectLine", index, "childCount", subProject.getChildCount());
|
||||
data.setContent("projectLine", index, "issueCount", subProject.issueStats().getCount());
|
||||
data.setContent("projectLine", index, "activeIssueCount", subProject.issueStats().getActiveCount());
|
||||
data.setContent("projectLine", index, "maybeIssueCount", subProject.issueStats().getMaybeCount());
|
||||
data.setContent("projectLine", index, "resolvedIssueCount", subProject.issueStats().getResolvedCount());
|
||||
data.setContent("projectLine", index, "concludedIssueCount", subProject.issueStats().getConcludedCount());
|
||||
data.setContent("projectLine", index, "unassignedIssueCount", subProject.issueStats().getUnassignedCount());
|
||||
data.setContent("projectLine", index, "unassignedNewIssueCount", subProject.issueStats().getUnassignedNewCount());
|
||||
data.setContent("projectLine", index, "unassignedStartedIssueCount", subProject.issueStats().getUnassignedStartedCount());
|
||||
data.setContent("projectLine", index, "unassignedResolvedIssueCount", subProject.issueStats().getUnassignedResolvedCount());
|
||||
data.setContent("projectLine", index, "unassignedConcludedIssueCount", subProject.issueStats().getUnassignedConcludedCount());
|
||||
data.setContent("projectLine", index, "lastUpdate", AgirStatoolUtils.toHumanShort(subProject.issueStats().getLastUpdate(), "n/a"));
|
||||
data.setAttribute("projectLine", index, "lastUpdate", "title", AgirStatoolUtils.toHumanLong(subProject.issueStats().getLastUpdate(), "n/a"));
|
||||
index += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
result = PresenterUtils.dynamize("/org/april/agirstatool/core/pages/projectsGrouped.xhtml", data).toString();
|
||||
}
|
||||
catch (XidynException exception)
|
||||
{
|
||||
throw new AgirStatoolException("Error building welcome page: " + exception.getMessage(), exception);
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,15 +52,56 @@ public class ProjectsRawPageBuilder
|
|||
|
||||
try
|
||||
{
|
||||
System.out.println("Building welcome page…");
|
||||
System.out.println("Building ProjectsRaw page…");
|
||||
|
||||
TagDataManager data = new TagDataManager();
|
||||
int index = 0;
|
||||
for (Project project : projects)
|
||||
{
|
||||
if (project.getParentId() == null)
|
||||
{
|
||||
fillLine(data, index, project);
|
||||
index += 1;
|
||||
}
|
||||
|
||||
if (project.hasChild())
|
||||
{
|
||||
for (Project subProject : project.subProjects())
|
||||
{
|
||||
fillLine(data, index, subProject);
|
||||
index += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
result = PresenterUtils.dynamize("/org/april/agirstatool/core/pages/projectsRaw.xhtml", data).toString();
|
||||
}
|
||||
catch (XidynException exception)
|
||||
{
|
||||
throw new AgirStatoolException("Error building ProjectsRaw page: " + exception.getMessage(), exception);
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill line.
|
||||
*
|
||||
* @param data
|
||||
* the data
|
||||
* @param index
|
||||
* the index
|
||||
* @param project
|
||||
* the project
|
||||
*/
|
||||
private static void fillLine(final TagDataManager data, final int index, final Project project)
|
||||
{
|
||||
data.setContent("projectLine", index, "projectId", project.getId());
|
||||
if (project.getParentId() != null)
|
||||
{
|
||||
data.setAttribute("projectLine", index, "projectName", "style", "padding-left: 25px;");
|
||||
}
|
||||
data.setAttribute("projectLine", index, "projectNameLink", "href", project.getPath());
|
||||
data.setContent("projectLine", index, "projectNameLink", StringEscapeUtils.escapeXml(project.getName()));
|
||||
data.setContent("projectLine", index, "childCount", project.getChildCount());
|
||||
|
@ -84,51 +125,5 @@ public class ProjectsRawPageBuilder
|
|||
data.setContent("projectLine", index, "unassignedClosedIssueCount", project.issueStats().getUnassignedClosedCount());
|
||||
data.setContent("projectLine", index, "lastUpdate", AgirStatoolUtils.toHumanShort(project.issueStats().getLastUpdate(), "n/a"));
|
||||
data.setAttribute("projectLine", index, "lastUpdate", "title", AgirStatoolUtils.toHumanLong(project.issueStats().getLastUpdate(), "n/a"));
|
||||
index += 1;
|
||||
}
|
||||
|
||||
if (project.hasChild())
|
||||
{
|
||||
for (Project subProject : project.subProjects())
|
||||
{
|
||||
data.setContent("projectLine", index, "projectId", subProject.getId());
|
||||
data.setAttribute("projectLine", index, "projectName", "style", "padding-left: 25px;");
|
||||
data.setAttribute("projectLine", index, "projectNameLink", "href", subProject.getPath());
|
||||
data.setContent("projectLine", index, "projectNameLink", StringEscapeUtils.escapeXml(subProject.getName()));
|
||||
data.setContent("projectLine", index, "childCount", subProject.getChildCount());
|
||||
data.setContent("projectLine", index, "issueCount", subProject.issueStats().getCount());
|
||||
data.setContent("projectLine", index, "newIssueCount", subProject.issueStats().getNewCount());
|
||||
data.setContent("projectLine", index, "confirmedIssueCount", subProject.issueStats().getConfirmedCount());
|
||||
data.setContent("projectLine", index, "ongoingIssueCount", subProject.issueStats().getOngoingCount());
|
||||
data.setContent("projectLine", index, "waitingIssueCount", subProject.issueStats().getWaitingCount());
|
||||
data.setContent("projectLine", index, "maybeIssueCount", subProject.issueStats().getMaybeCount());
|
||||
data.setContent("projectLine", index, "resolvedIssueCount", subProject.issueStats().getResolvedCount());
|
||||
data.setContent("projectLine", index, "rejectedIssueCount", subProject.issueStats().getRejectedCount());
|
||||
data.setContent("projectLine", index, "closedIssueCount", subProject.issueStats().getClosedCount());
|
||||
data.setContent("projectLine", index, "unassignedIssueCount", subProject.issueStats().getUnassignedCount());
|
||||
data.setContent("projectLine", index, "unassignedNewIssueCount", subProject.issueStats().getUnassignedNewCount());
|
||||
data.setContent("projectLine", index, "unassignedConfirmedIssueCount", subProject.issueStats().getUnassignedConfirmedCount());
|
||||
data.setContent("projectLine", index, "unassignedOngoingIssueCount", subProject.issueStats().getUnassignedOngoingCount());
|
||||
data.setContent("projectLine", index, "unassignedWaitingIssueCount", subProject.issueStats().getUnassignedWaitingCount());
|
||||
data.setContent("projectLine", index, "unassignedMaybeIssueCount", subProject.issueStats().getUnassignedMaybeCount());
|
||||
data.setContent("projectLine", index, "unassignedResolvedIssueCount", subProject.issueStats().getUnassignedResolvedCount());
|
||||
data.setContent("projectLine", index, "unassignedRejectedIssueCount", subProject.issueStats().getUnassignedRejectedCount());
|
||||
data.setContent("projectLine", index, "unassignedClosedIssueCount", subProject.issueStats().getUnassignedClosedCount());
|
||||
data.setContent("projectLine", index, "lastUpdate", AgirStatoolUtils.toHumanShort(subProject.issueStats().getLastUpdate(), "n/a"));
|
||||
data.setAttribute("projectLine", index, "lastUpdate", "title", AgirStatoolUtils.toHumanLong(subProject.issueStats().getLastUpdate(), "n/a"));
|
||||
index += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
result = PresenterUtils.dynamize("/org/april/agirstatool/core/pages/projectsRaw.xhtml", data).toString();
|
||||
}
|
||||
catch (XidynException exception)
|
||||
{
|
||||
throw new AgirStatoolException("Error building welcome page: " + exception.getMessage(), exception);
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue