137 lines
7.9 KiB
Java
137 lines
7.9 KiB
Java
/*
|
|
* Copyright (C) 2020 Christian Pierre MOMON <christian.momon@devinsy.fr>
|
|
*
|
|
* This file is part of AgirStatool, simple key value database.
|
|
*
|
|
* AgirStatool is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU Affero General Public License as
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
* License, or (at your option) any later version.
|
|
*
|
|
* AgirStatool is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU Affero General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
* along with AgirStatool. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
package org.april.agirstatool.core.pages;
|
|
|
|
import org.apache.commons.lang3.StringEscapeUtils;
|
|
import org.april.agirstatool.core.AgirStatoolException;
|
|
import org.april.agirstatool.core.AgirStatoolUtils;
|
|
import org.april.agirstatool.core.Project;
|
|
import org.april.agirstatool.core.Projects;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
import fr.devinsy.xidyn.XidynException;
|
|
import fr.devinsy.xidyn.data.TagDataManager;
|
|
import fr.devinsy.xidyn.presenters.PresenterUtils;
|
|
|
|
/**
|
|
* The Class projectsRawPageBuilder.
|
|
*/
|
|
public class ProjectsRawPageBuilder
|
|
{
|
|
private static Logger logger = LoggerFactory.getLogger(ProjectsRawPageBuilder.class);
|
|
|
|
/**
|
|
* Builds the.
|
|
*
|
|
* @param projects
|
|
* the projects
|
|
* @return the string
|
|
* @throws AgirStatoolException
|
|
* the agir statool exception
|
|
*/
|
|
public static String build(final Projects projects) throws AgirStatoolException
|
|
{
|
|
String result;
|
|
|
|
try
|
|
{
|
|
System.out.println("Building welcome page…");
|
|
|
|
projects.sortByName();
|
|
|
|
TagDataManager data = new TagDataManager();
|
|
int index = 0;
|
|
for (Project project : projects)
|
|
{
|
|
if (project.getParentId() == null)
|
|
{
|
|
data.setContent("projectLine", index, "projectId", project.getId());
|
|
data.setAttribute("projectLine", index, "projectNameLink", "href", project.getPath());
|
|
data.setContent("projectLine", index, "projectNameLink", StringEscapeUtils.escapeXml(project.getName()));
|
|
data.setContent("projectLine", index, "childCount", project.getChildCount());
|
|
data.setContent("projectLine", index, "issueCount", project.getIssueStats().getCount());
|
|
data.setContent("projectLine", index, "newIssueCount", project.getIssueStats().getNewCount());
|
|
data.setContent("projectLine", index, "confirmedIssueCount", project.getIssueStats().getConfirmedCount());
|
|
data.setContent("projectLine", index, "ongoingIssueCount", project.getIssueStats().getOngoingCount());
|
|
data.setContent("projectLine", index, "waitingIssueCount", project.getIssueStats().getWaitingCount());
|
|
data.setContent("projectLine", index, "maybeIssueCount", project.getIssueStats().getMaybeCount());
|
|
data.setContent("projectLine", index, "resolvedIssueCount", project.getIssueStats().getResolvedCount());
|
|
data.setContent("projectLine", index, "rejectedIssueCount", project.getIssueStats().getRejectedCount());
|
|
data.setContent("projectLine", index, "closedIssueCount", project.getIssueStats().getClosedCount());
|
|
data.setContent("projectLine", index, "unassignedIssueCount", project.getIssueStats().getUnassignedCount());
|
|
data.setContent("projectLine", index, "unassignedNewIssueCount", project.getIssueStats().getUnassignedNewCount());
|
|
data.setContent("projectLine", index, "unassignedConfirmedIssueCount", project.getIssueStats().getUnassignedConfirmedCount());
|
|
data.setContent("projectLine", index, "unassignedOngoingIssueCount", project.getIssueStats().getUnassignedOngoingCount());
|
|
data.setContent("projectLine", index, "unassignedWaitingIssueCount", project.getIssueStats().getUnassignedWaitingCount());
|
|
data.setContent("projectLine", index, "unassignedMaybeIssueCount", project.getIssueStats().getUnassignedMaybeCount());
|
|
data.setContent("projectLine", index, "unassignedResolvedIssueCount", project.getIssueStats().getUnassignedResolvedCount());
|
|
data.setContent("projectLine", index, "unassignedRejectedIssueCount", project.getIssueStats().getUnassignedRejectedCount());
|
|
data.setContent("projectLine", index, "unassignedClosedIssueCount", project.getIssueStats().getUnassignedClosedCount());
|
|
data.setContent("projectLine", index, "lastUpdate", AgirStatoolUtils.toHumanShort(project.getIssueStats().getLastUpdate(), "n/a"));
|
|
data.setAttribute("projectLine", index, "lastUpdate", "title", AgirStatoolUtils.toHumanLong(project.getIssueStats().getLastUpdate(), "n/a"));
|
|
index += 1;
|
|
}
|
|
|
|
if (project.hasChild())
|
|
{
|
|
for (Project subProject : projects.getByParent(project.getId()).sortByName())
|
|
{
|
|
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.getIssueStats().getCount());
|
|
data.setContent("projectLine", index, "newIssueCount", subProject.getIssueStats().getNewCount());
|
|
data.setContent("projectLine", index, "confirmedIssueCount", subProject.getIssueStats().getConfirmedCount());
|
|
data.setContent("projectLine", index, "ongoingIssueCount", subProject.getIssueStats().getOngoingCount());
|
|
data.setContent("projectLine", index, "waitingIssueCount", subProject.getIssueStats().getWaitingCount());
|
|
data.setContent("projectLine", index, "maybeIssueCount", subProject.getIssueStats().getMaybeCount());
|
|
data.setContent("projectLine", index, "resolvedIssueCount", subProject.getIssueStats().getResolvedCount());
|
|
data.setContent("projectLine", index, "rejectedIssueCount", subProject.getIssueStats().getRejectedCount());
|
|
data.setContent("projectLine", index, "closedIssueCount", subProject.getIssueStats().getClosedCount());
|
|
data.setContent("projectLine", index, "unassignedIssueCount", subProject.getIssueStats().getUnassignedCount());
|
|
data.setContent("projectLine", index, "unassignedNewIssueCount", subProject.getIssueStats().getUnassignedNewCount());
|
|
data.setContent("projectLine", index, "unassignedConfirmedIssueCount", subProject.getIssueStats().getUnassignedConfirmedCount());
|
|
data.setContent("projectLine", index, "unassignedOngoingIssueCount", subProject.getIssueStats().getUnassignedOngoingCount());
|
|
data.setContent("projectLine", index, "unassignedWaitingIssueCount", subProject.getIssueStats().getUnassignedWaitingCount());
|
|
data.setContent("projectLine", index, "unassignedMaybeIssueCount", subProject.getIssueStats().getUnassignedMaybeCount());
|
|
data.setContent("projectLine", index, "unassignedResolvedIssueCount", subProject.getIssueStats().getUnassignedResolvedCount());
|
|
data.setContent("projectLine", index, "unassignedRejectedIssueCount", subProject.getIssueStats().getUnassignedRejectedCount());
|
|
data.setContent("projectLine", index, "unassignedClosedIssueCount", subProject.getIssueStats().getUnassignedClosedCount());
|
|
data.setContent("projectLine", index, "lastUpdate", AgirStatoolUtils.toHumanShort(subProject.getIssueStats().getLastUpdate(), "n/a"));
|
|
data.setAttribute("projectLine", index, "lastUpdate", "title", AgirStatoolUtils.toHumanLong(subProject.getIssueStats().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;
|
|
}
|
|
}
|