agirstatool/src/org/april/agirstatool/core/pages/ProjectPage.java

91 lines
3.4 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.april.agirstatool.core.AgirStatoolException;
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;
/**
* The class AgirStatool.
*
* @author Christian Pierre MOMON
*/
public class ProjectPage
{
private static Logger logger = LoggerFactory.getLogger(ProjectPage.class);
/**
* Builds the.
*
* @param projects
* the projects
* @return the string
* @throws AgirStatoolException
* the agir statool exception
*/
public static String build(final Project project) throws AgirStatoolException
{
String result;
try
{
logger.info("Building project page " + project.getName() + "");
TagDataManager data = new TagDataManager();
data.setContent("projectName", project.getName());
data.setAttribute("agirLink", "href", "https://agir.april.org/projects/" + project.getIdentifier() + "/issues");
data.setContent("issueRawChart", IssueStatChartView.build("Issue Raw Count", project));
data.setContent("issueGroupedChart", IssueStatChartView.buildGrouped("Issue Grouped Count", project));
data.setContent("unassignedRawChart", UnassignedPolarChartView.build("Unassigned Raw Count", project));
data.setContent("unassignedGroupedChart", UnassignedPolarChartView.buildGrouped("Unassigned Grouped Count", project));
if (project.hasChild())
{
data.setContent("issueRawChartAlone", IssueStatChartView.build("Issue Raw Count", project.subProjects().get(0)));
data.setContent("issueGroupedChartAlone", IssueStatChartView.buildGrouped("Issue Grouped Count", project.subProjects().get(0)));
data.setContent("unassignedRawChartAlone", UnassignedPolarChartView.build("Unassigned Raw Count", project.subProjects().get(0)));
data.setContent("unassignedGroupedChartAlone", UnassignedPolarChartView.buildGrouped("Unassigned Grouped Count", project.subProjects().get(0)));
}
String projectsRawView = ProjectsRawView.build(project);
data.setContent("projectsRawView", projectsRawView);
String projectsGroupedView = ProjectsGroupedView.build(project);
data.setContent("projectsGroupedView", projectsGroupedView);
result = PresenterUtils.dynamize("/org/april/agirstatool/core/pages/project.xhtml", data).toString();
}
catch (XidynException exception)
{
throw new AgirStatoolException("Error building project page: " + exception.getMessage(), exception);
}
//
return result;
}
}