137 lines
7.0 KiB
Java
137 lines
7.0 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.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
import fr.devinsy.xidyn.XidynException;
|
|
import fr.devinsy.xidyn.data.TagDataManager;
|
|
import fr.devinsy.xidyn.presenters.PresenterUtils;
|
|
import fr.devinsy.xidyn.utils.XidynUtils;
|
|
|
|
/**
|
|
* The Class projectsRawPageBuilder.
|
|
*/
|
|
public class ProjectsRawView
|
|
{
|
|
private static Logger logger = LoggerFactory.getLogger(ProjectsRawView.class);
|
|
|
|
/**
|
|
* Builds the.
|
|
*
|
|
* @param project
|
|
* the project
|
|
* @return the string
|
|
* @throws AgirStatoolException
|
|
* the agir statool exception
|
|
*/
|
|
public static String build(final Project project) throws AgirStatoolException
|
|
{
|
|
String result;
|
|
|
|
try
|
|
{
|
|
logger.debug("Building ProjectsRaw view…");
|
|
|
|
TagDataManager data = new TagDataManager();
|
|
|
|
fillLine(data, 0, project);
|
|
|
|
int index = 1;
|
|
for (Project subProject : project.subProjects())
|
|
{
|
|
fillLine(data, index, subProject);
|
|
index += 1;
|
|
|
|
for (Project subSubProject : subProject.subProjects())
|
|
{
|
|
fillLine(data, index, subSubProject);
|
|
index += 1;
|
|
}
|
|
}
|
|
|
|
CharSequence page = PresenterUtils.dynamize("/org/april/agirstatool/core/pages/projectsRawView.xhtml", data);
|
|
result = XidynUtils.extractBodyContent(page);
|
|
}
|
|
catch (XidynException exception)
|
|
{
|
|
throw new AgirStatoolException("Error building ProjectsRaw view: " + 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("projectRawLine", index, "prl_projectId", project.getId());
|
|
if (project.getParentId() != null)
|
|
{
|
|
data.setAttribute("projectRawLine", index, "prl_projectName", "style", "padding-left: 25px;");
|
|
}
|
|
data.setAttribute("projectRawLine", index, "prl_projectNameLink", "href", project.getPath());
|
|
data.setContent("projectRawLine", index, "prl_projectNameLink", StringEscapeUtils.escapeXml(project.getName()));
|
|
data.setContent("projectRawLine", index, "prl_childCount", project.getChildCount());
|
|
data.setContent("projectRawLine", index, "prl_issueCount", project.issueStats().getCount());
|
|
data.setContent("projectRawLine", index, "prl_maybeIssueCount", project.issueStats().getMaybeCount());
|
|
data.setContent("projectRawLine", index, "prl_newIssueCount", project.issueStats().getNewCount());
|
|
data.setAttribute("projectRawLine", index, "prl_newIssueCount", "class", AgirStatoolUtils.selectStatIndicator(project.issueStats().getNewCount()));
|
|
data.setContent("projectRawLine", index, "prl_confirmedIssueCount", project.issueStats().getConfirmedCount());
|
|
data.setAttribute("projectRawLine", index, "prl_confirmedIssueCount", "class", AgirStatoolUtils.selectStatIndicator(project.issueStats().getConfirmedCount()));
|
|
data.setContent("projectRawLine", index, "prl_ongoingIssueCount", project.issueStats().getOngoingCount());
|
|
data.setAttribute("projectRawLine", index, "prl_ongoingIssueCount", "class", AgirStatoolUtils.selectStatIndicator(project.issueStats().getOngoingCount()));
|
|
data.setContent("projectRawLine", index, "prl_waitingIssueCount", project.issueStats().getWaitingCount());
|
|
data.setContent("projectRawLine", index, "prl_resolvedIssueCount", project.issueStats().getResolvedCount());
|
|
data.setAttribute("projectRawLine", index, "prl_resolvedIssueCount", "class", AgirStatoolUtils.selectStatIndicator(project.issueStats().getResolvedCount()));
|
|
data.setContent("projectRawLine", index, "prl_rejectedIssueCount", project.issueStats().getRejectedCount());
|
|
data.setContent("projectRawLine", index, "prl_closedIssueCount", project.issueStats().getClosedCount());
|
|
data.setContent("projectRawLine", index, "prl_unassignedIssueCount", project.issueStats().getUnassignedCount());
|
|
data.setContent("projectRawLine", index, "prl_unassignedMaybeIssueCount", project.issueStats().getUnassignedMaybeCount());
|
|
data.setContent("projectRawLine", index, "prl_unassignedNewIssueCount", project.issueStats().getUnassignedNewCount());
|
|
data.setContent("projectRawLine", index, "prl_unassignedConfirmedIssueCount", project.issueStats().getUnassignedConfirmedCount());
|
|
data.setContent("projectRawLine", index, "prl_unassignedOngoingIssueCount", project.issueStats().getUnassignedOngoingCount());
|
|
data.setAttribute("projectRawLine", index, "prl_unassignedOngoingIssueCount", "class", AgirStatoolUtils.selectUnassignedIndicator(project.issueStats().getUnassignedOngoingCount()));
|
|
data.setContent("projectRawLine", index, "prl_unassignedWaitingIssueCount", project.issueStats().getUnassignedWaitingCount());
|
|
data.setAttribute("projectRawLine", index, "prl_unassignedWaitingIssueCount", "class", AgirStatoolUtils.selectUnassignedIndicator(project.issueStats().getUnassignedWaitingCount()));
|
|
data.setContent("projectRawLine", index, "prl_unassignedResolvedIssueCount", project.issueStats().getUnassignedResolvedCount());
|
|
data.setAttribute("projectRawLine", index, "prl_unassignedResolvedIssueCount", "class", AgirStatoolUtils.selectUnassignedIndicator(project.issueStats().getUnassignedResolvedCount()));
|
|
data.setContent("projectRawLine", index, "prl_unassignedRejectedIssueCount", project.issueStats().getUnassignedRejectedCount());
|
|
data.setAttribute("projectRawLine", index, "prl_unassignedRejectedIssueCount", "class", AgirStatoolUtils.selectUnassignedIndicator(project.issueStats().getUnassignedRejectedCount()));
|
|
data.setContent("projectRawLine", index, "prl_unassignedClosedIssueCount", project.issueStats().getUnassignedClosedCount());
|
|
data.setAttribute("projectRawLine", index, "prl_unassignedClosedIssueCount", "class", AgirStatoolUtils.selectUnassignedIndicator(project.issueStats().getUnassignedClosedCount()));
|
|
data.setContent("projectRawLine", index, "prl_lastUpdate", AgirStatoolUtils.toHumanShort(project.issueStats().getLastUpdate(), "n/a"));
|
|
data.setAttribute("projectRawLine", index, "prl_lastUpdate", "title", AgirStatoolUtils.toHumanLong(project.issueStats().getLastUpdate(), "n/a"));
|
|
}
|
|
}
|