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

108 lines
5.3 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 java.time.LocalDate;
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;
import utils.BuildInformation;
/**
* The class AgirStatool.
*
* @author Christian Pierre MOMON
*/
public class ProjectPage
{
private static Logger logger = LoggerFactory.getLogger(ProjectPage.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 project page {}…", project.getName());
TagDataManager data = new TagDataManager();
data.setContent("projectName", "Project " + project.getName());
data.setAttribute("projectName", "href", project.getPath());
data.setAttribute("agirLink", "href", "https://agir.april.org/projects/" + project.getIdentifier() + "/issues");
data.setContent("versionsup", BuildInformation.instance().version());
data.setContent("createClosePreviousYearButton", LocalDate.now().getYear() - 1);
data.setContent("createdClosed3MonthsChart", CreatedClosedCountChartView.buildLastMonths("Created/closed 3 months Count", project, 3));
data.setContent("created-Closed3MonthsChart", CreatedClosedDiffChartView.buildLastMonths("Created-closed 3 months Count", project, 3));
data.setContent("age3MonthsChart", IssueAgeChartView.buildLastMonths("Issue Age 3 months Chart", project, 3));
data.setContent("createdClosed6MonthsChart", CreatedClosedCountChartView.buildLastMonths("Created/closed 6 months Count", project, 6));
data.setContent("created-Closed6MonthsChart", CreatedClosedDiffChartView.buildLastMonths("Created-closed 6 months Count", project, 6));
data.setContent("age6MonthsChart", IssueAgeChartView.buildLastMonths("Issue Age 6 months", project, 6));
data.setContent("createdClosed12MonthsChart", CreatedClosedCountChartView.buildLastMonths("Created/closed 12 months Count", project, 12));
data.setContent("created-Closed12MonthsChart", CreatedClosedDiffChartView.buildLastMonths("Created-closed 12 months Count", project, 12));
data.setContent("age12MonthsChart", IssueAgeChartView.buildLastMonths("Issue Age 12 months", project, 12));
data.setContent("createdClosedPreviousYearChart", CreatedClosedCountChartView.buildPreviousYear("Created/closed last year Count", project));
data.setContent("created-ClosedPreviousYearChart", CreatedClosedDiffChartView.buildPreviousYear("Created-closed last year Count", project));
data.setContent("agePreviousYearChart", IssueAgeChartView.buildPreviousYear("Issue Age Previous Year Chart", project));
data.setContent("createdClosedFullChart", CreatedClosedCountChartView.buildFull("Created/closed Count", project));
data.setContent("created-ClosedFullChart", CreatedClosedDiffChartView.buildFull("Created-closed Count", project));
data.setContent("ageFullChart", IssueAgeChartView.buildFull("Issue Age Full Chart", project));
data.setContent("issueRawChart", IssueStatusChartView.build("Issue Raw Count", project));
data.setContent("issueGroupedChart", IssueStatusChartView.buildGrouped("Issue Grouped Count", project));
data.setContent("unassignedRawChart", UnassignedIssueChartView.build("Unassigned Raw Count", project));
data.setContent("unassignedGroupedChart", UnassignedIssueChartView.buildGrouped("Unassigned Grouped Count", project));
data.setContent("createdClosedChartMini", CreatedClosedCountChartView.buildLastMonths("Created/closed 6 months CountA", project, 6));
data.setContent("created-ClosedChartMini", CreatedClosedDiffChartView.buildLastMonths("Created-closed Count Mini", project, 6));
data.setContent("ageChartMini", IssueAgeChartView.buildLastMonths("Issue Age Chart Mini", project, 6));
String projectsRawView = ProjectsRawView.build(project);
data.setContent("tableRawView", projectsRawView);
String projectsGroupedView = ProjectsGroupedView.build(project);
data.setContent("tableGroupedView", 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;
}
}