From eafe2083b5c07ea5a471b3b15f32ddfe02bd2794 Mon Sep 17 00:00:00 2001 From: "Christian P. MOMON" Date: Thu, 30 Jan 2020 22:34:33 +0100 Subject: [PATCH] Renamed chart classes. --- .../agirstatool/core/pages/ChartBarView.java | 79 ------------ .../core/pages/ChartPolarView.java | 79 ------------ .../pages/CreatedClosedCountChartView.java | 4 +- .../pages/CreatedClosedDiffChartView.java | 2 +- ...artView.java => IssueStatusChartView.java} | 118 +++++++++++------ .../agirstatool/core/pages/ProjectPage.java | 8 +- ...iew.java => UnassignedIssueChartView.java} | 120 ++++++++++++------ ...html => createdClosedCountChartView.xhtml} | 0 ...xhtml => createdClosedDiffChartView.xhtml} | 0 ...rView.xhtml => issueStatusChartView.xhtml} | 0 ...rView.xhtml => unassignedIssueChart.xhtml} | 0 11 files changed, 172 insertions(+), 238 deletions(-) delete mode 100644 src/org/april/agirstatool/core/pages/ChartBarView.java delete mode 100644 src/org/april/agirstatool/core/pages/ChartPolarView.java rename src/org/april/agirstatool/core/pages/{IssueStatChartView.java => IssueStatusChartView.java} (63%) rename src/org/april/agirstatool/core/pages/{UnassignedPolarChartView.java => UnassignedIssueChartView.java} (63%) rename src/org/april/agirstatool/core/pages/{chartLineView.xhtml => createdClosedCountChartView.xhtml} (100%) rename src/org/april/agirstatool/core/pages/{chartLineView2.xhtml => createdClosedDiffChartView.xhtml} (100%) rename src/org/april/agirstatool/core/pages/{chartBarView.xhtml => issueStatusChartView.xhtml} (100%) rename src/org/april/agirstatool/core/pages/{chartPolarView.xhtml => unassignedIssueChart.xhtml} (100%) diff --git a/src/org/april/agirstatool/core/pages/ChartBarView.java b/src/org/april/agirstatool/core/pages/ChartBarView.java deleted file mode 100644 index 562bd33..0000000 --- a/src/org/april/agirstatool/core/pages/ChartBarView.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (C) 2020 Christian Pierre MOMON - * - * 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 . - */ -package org.april.agirstatool.core.pages; - -import java.io.IOException; - -import org.apache.commons.codec.digest.DigestUtils; -import org.april.agirstatool.core.AgirStatool; -import org.april.agirstatool.core.AgirStatoolException; -import org.april.agirstatool.core.AgirStatoolUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import fr.devinsy.strings.StringList; -import fr.devinsy.xidyn.utils.XidynUtils; - -/** - * The Class projectsRawPageBuilder. - */ -public class ChartBarView -{ - private static Logger logger = LoggerFactory.getLogger(ChartBarView.class); - - /** - * Builds the. - * - * @param title - * the title - * @param labelTitle - * the label title - * @param labels - * the labels - * @param values - * the values - * @return the string - * @throws AgirStatoolException - * the agir statool exception - */ - public static String build(final String title, final String labelTitle, final StringList labels, final StringList values) throws AgirStatoolException - { - String result; - - try - { - String source = XidynUtils.load(AgirStatool.class.getResource("/org/april/agirstatool/core/pages/chartBarView.xhtml")); - String code = XidynUtils.extractBodyContent(source); - - code = code.replaceAll("myChart", "myChart_" + DigestUtils.md5Hex(title + "chartBar")); - code = code.replace("# of Votes", labelTitle); - code = code.replaceAll("labels: \\[.*\\]", "labels: " + AgirStatoolUtils.toJSonStrings(labels)); - code = code.replaceAll("data: \\[.*\\]", "data: " + AgirStatoolUtils.toJSonNumbers(values)); - - result = code.toString(); - } - catch (IOException exception) - { - throw new AgirStatoolException("Error building ProjectsRaw view: " + exception.getMessage(), exception); - } - - // - return result; - } -} diff --git a/src/org/april/agirstatool/core/pages/ChartPolarView.java b/src/org/april/agirstatool/core/pages/ChartPolarView.java deleted file mode 100644 index cbead1a..0000000 --- a/src/org/april/agirstatool/core/pages/ChartPolarView.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (C) 2020 Christian Pierre MOMON - * - * 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 . - */ -package org.april.agirstatool.core.pages; - -import java.io.IOException; - -import org.apache.commons.codec.digest.DigestUtils; -import org.april.agirstatool.core.AgirStatool; -import org.april.agirstatool.core.AgirStatoolException; -import org.april.agirstatool.core.AgirStatoolUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import fr.devinsy.strings.StringList; -import fr.devinsy.xidyn.utils.XidynUtils; - -/** - * The Class projectsRawPageBuilder. - */ -public class ChartPolarView -{ - private static Logger logger = LoggerFactory.getLogger(ChartPolarView.class); - - /** - * Builds the. - * - * @param title - * the title - * @param labelTitle - * the label title - * @param labels - * the labels - * @param values - * the values - * @return the string - * @throws AgirStatoolException - * the agir statool exception - */ - public static String build(final String title, final String labelTitle, final StringList labels, final StringList values) throws AgirStatoolException - { - String result; - - try - { - String source = XidynUtils.load(AgirStatool.class.getResource("/org/april/agirstatool/core/pages/chartPolarView.xhtml")); - String code = XidynUtils.extractBodyContent(source); - - code = code.replaceAll("myChart", "myChart_" + DigestUtils.md5Hex(title + "chartPolar")); - code = code.replace("# of Votes", labelTitle); - code = code.replaceAll("labels: \\[.*\\]", "labels: " + AgirStatoolUtils.toJSonStrings(labels)); - code = code.replaceAll("data: \\[.*\\]", "data: " + AgirStatoolUtils.toJSonNumbers(values)); - - result = code.toString(); - } - catch (IOException exception) - { - throw new AgirStatoolException("Error building ProjectsRaw view: " + exception.getMessage(), exception); - } - - // - return result; - } -} diff --git a/src/org/april/agirstatool/core/pages/CreatedClosedCountChartView.java b/src/org/april/agirstatool/core/pages/CreatedClosedCountChartView.java index 032348b..8aab103 100644 --- a/src/org/april/agirstatool/core/pages/CreatedClosedCountChartView.java +++ b/src/org/april/agirstatool/core/pages/CreatedClosedCountChartView.java @@ -63,7 +63,7 @@ public class CreatedClosedCountChartView { if (project.hasIssue()) { - String source = XidynUtils.load(AgirStatool.class.getResource("/org/april/agirstatool/core/pages/chartLineView.xhtml")); + String source = XidynUtils.load(AgirStatool.class.getResource("/org/april/agirstatool/core/pages/createdClosedCountChartView.xhtml")); String code = XidynUtils.extractBodyContent(source); code = code.replaceAll("myChart", "myChart_" + DigestUtils.md5Hex(title + "lineChart")); @@ -116,7 +116,7 @@ public class CreatedClosedCountChartView if (project.hasIssue()) { - String source = XidynUtils.load(AgirStatool.class.getResource("/org/april/agirstatool/core/pages/chartLineView.xhtml")); + String source = XidynUtils.load(AgirStatool.class.getResource("/org/april/agirstatool/core/pages/createdClosedCountChartView.xhtml")); String code = XidynUtils.extractBodyContent(source); code = code.replaceAll("myChart", "myChart_" + DigestUtils.md5Hex(title + "lineBar")); diff --git a/src/org/april/agirstatool/core/pages/CreatedClosedDiffChartView.java b/src/org/april/agirstatool/core/pages/CreatedClosedDiffChartView.java index 92d90cd..fc77a78 100644 --- a/src/org/april/agirstatool/core/pages/CreatedClosedDiffChartView.java +++ b/src/org/april/agirstatool/core/pages/CreatedClosedDiffChartView.java @@ -64,7 +64,7 @@ public class CreatedClosedDiffChartView { if (project.hasIssue()) { - String source = XidynUtils.load(AgirStatool.class.getResource("/org/april/agirstatool/core/pages/chartLineView2.xhtml")); + String source = XidynUtils.load(AgirStatool.class.getResource("/org/april/agirstatool/core/pages/createdClosedDiffChartView.xhtml")); String code = XidynUtils.extractBodyContent(source); code = code.replaceAll("myChart", "myChart_" + DigestUtils.md5Hex(title + "line2Chart")); diff --git a/src/org/april/agirstatool/core/pages/IssueStatChartView.java b/src/org/april/agirstatool/core/pages/IssueStatusChartView.java similarity index 63% rename from src/org/april/agirstatool/core/pages/IssueStatChartView.java rename to src/org/april/agirstatool/core/pages/IssueStatusChartView.java index 540509e..5fd33a3 100644 --- a/src/org/april/agirstatool/core/pages/IssueStatChartView.java +++ b/src/org/april/agirstatool/core/pages/IssueStatusChartView.java @@ -18,50 +18,25 @@ */ package org.april.agirstatool.core.pages; +import java.io.IOException; + +import org.apache.commons.codec.digest.DigestUtils; +import org.april.agirstatool.core.AgirStatool; 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.strings.StringList; +import fr.devinsy.xidyn.utils.XidynUtils; /** * The Class projectsRawPageBuilder. */ -public class IssueStatChartView +public class IssueStatusChartView { - private static Logger logger = LoggerFactory.getLogger(IssueStatChartView.class); - - /** - * Builds the. - * - * @param title - * the title - * @param project - * the project - * @return the string - * @throws AgirStatoolException - * the agir statool exception - */ - public static String build(final String title, final Project project) throws AgirStatoolException - { - String result; - - StringList labels = new StringList("Maybe", "New", "Confirmed", "Ongoing", "Waiting", "Resolved"); - StringList values = new StringList(); - values.append(project.issueStats().getMaybeCount()); - values.append(project.issueStats().getNewCount()); - values.append(project.issueStats().getConfirmedCount()); - values.append(project.issueStats().getOngoingCount()); - values.append(project.issueStats().getWaitingCount()); - values.append(project.issueStats().getResolvedCount()); - - String targetTitle = title + " – " + project.getName(); - result = ChartBarView.build(targetTitle, targetTitle, labels, values); - - // - return result; - } + private static Logger logger = LoggerFactory.getLogger(IssueStatusChartView.class); /** * Builds the grouped. @@ -77,15 +52,86 @@ public class IssueStatChartView public static String buildGrouped(final String title, final Project project) throws AgirStatoolException { String result; - + StringList labels = new StringList("Maybe", "Active", "Resolved"); StringList values = new StringList(); values.append(project.issueStats().getMaybeCount()); values.append(project.issueStats().getActiveCount()); values.append(project.issueStats().getResolvedCount()); - + String targetTitle = title + " – " + project.getName(); - result = ChartBarView.build(targetTitle, targetTitle, labels, values); + result = build(targetTitle, targetTitle, labels, values); + + // + return result; + } + + /** + * Builds the. + * + * @param title + * the title + * @param project + * the project + * @return the string + * @throws AgirStatoolException + * the agir statool exception + */ + public static String build(final String title, final Project project) throws AgirStatoolException + { + String result; + + StringList labels = new StringList("Maybe", "New", "Confirmed", "Ongoing", "Waiting", "Resolved"); + StringList values = new StringList(); + values.append(project.issueStats().getMaybeCount()); + values.append(project.issueStats().getNewCount()); + values.append(project.issueStats().getConfirmedCount()); + values.append(project.issueStats().getOngoingCount()); + values.append(project.issueStats().getWaitingCount()); + values.append(project.issueStats().getResolvedCount()); + + String targetTitle = title + " – " + project.getName(); + result = build(targetTitle, targetTitle, labels, values); + + // + return result; + } + + /** + * Builds the. + * + * @param title + * the title + * @param labelTitle + * the label title + * @param labels + * the labels + * @param values + * the values + * @return the string + * @throws AgirStatoolException + * the agir statool exception + */ + public static String build(final String title, final String labelTitle, final StringList labels, final StringList values) throws AgirStatoolException + { + String result; + + try + { + String source = XidynUtils.load(AgirStatool.class.getResource("/org/april/agirstatool/core/pages/issueStatusChartView.xhtml")); + String code = XidynUtils.extractBodyContent(source); + + code = code.replaceAll("myChart", "myChart_" + DigestUtils.md5Hex(title + "chartBar")); + code = code.replace("# of Votes", labelTitle); + code = code.replaceAll("labels: \\[.*\\]", "labels: " + AgirStatoolUtils.toJSonStrings(labels)); + code = code.replaceAll("data: \\[.*\\]", "data: " + AgirStatoolUtils.toJSonNumbers(values)); + + result = code.toString(); + } + catch (IOException exception) + { + throw new AgirStatoolException("Error building ProjectsRaw view: " + exception.getMessage(), exception); + } // return result; diff --git a/src/org/april/agirstatool/core/pages/ProjectPage.java b/src/org/april/agirstatool/core/pages/ProjectPage.java index 7d95236..57d868f 100644 --- a/src/org/april/agirstatool/core/pages/ProjectPage.java +++ b/src/org/april/agirstatool/core/pages/ProjectPage.java @@ -79,10 +79,10 @@ public class ProjectPage data.setContent("created-ClosedFullChart", CreatedClosedDiffChartView.buildFull("Created-closed Count", project)); data.setContent("ageFullChart", IssueAgeChartView.buildFull("Issue Age Full Chart", project)); - 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)); + 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)); diff --git a/src/org/april/agirstatool/core/pages/UnassignedPolarChartView.java b/src/org/april/agirstatool/core/pages/UnassignedIssueChartView.java similarity index 63% rename from src/org/april/agirstatool/core/pages/UnassignedPolarChartView.java rename to src/org/april/agirstatool/core/pages/UnassignedIssueChartView.java index 7e44316..46e088f 100644 --- a/src/org/april/agirstatool/core/pages/UnassignedPolarChartView.java +++ b/src/org/april/agirstatool/core/pages/UnassignedIssueChartView.java @@ -18,52 +18,26 @@ */ package org.april.agirstatool.core.pages; +import java.io.IOException; + +import org.apache.commons.codec.digest.DigestUtils; +import org.april.agirstatool.core.AgirStatool; import org.april.agirstatool.core.AgirStatoolException; +import org.april.agirstatool.core.AgirStatoolUtils; import org.april.agirstatool.core.IssueStats; import org.april.agirstatool.core.Project; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import fr.devinsy.strings.StringList; +import fr.devinsy.xidyn.utils.XidynUtils; /** * The Class projectsRawPageBuilder. */ -public class UnassignedPolarChartView +public class UnassignedIssueChartView { - private static Logger logger = LoggerFactory.getLogger(UnassignedPolarChartView.class); - - /** - * Builds the. - * - * @param title - * the title - * @param project - * the project - * @return the string - * @throws AgirStatoolException - * the agir statool exception - */ - public static String build(final String title, final Project project) throws AgirStatoolException - { - String result; - - StringList labels = new StringList("Confirmed", "Ongoing", "Waiting", "Resolved", "Rejected", "Closed"); - StringList values = new StringList(); - IssueStats stats = project.issueStats(); - values.append(stats.getUnassignedConfirmedCount()); - values.append(stats.getUnassignedOngoingCount()); - values.append(stats.getUnassignedWaitingCount()); - values.append(stats.getUnassignedResolvedCount()); - values.append(stats.getUnassignedRejectedCount()); - values.append(stats.getUnassignedClosedCount()); - - String targetTitle = title + " – " + project.getName(); - result = ChartPolarView.build(targetTitle, targetTitle, labels, values); - - // - return result; - } + private static Logger logger = LoggerFactory.getLogger(UnassignedIssueChartView.class); /** * Builds the grouped. @@ -79,16 +53,88 @@ public class UnassignedPolarChartView public static String buildGrouped(final String title, final Project project) throws AgirStatoolException { String result; - + StringList labels = new StringList("Started", "Resolved", "Concluded"); StringList values = new StringList(); IssueStats stats = project.issueStats(); values.append(stats.getUnassignedStartedCount()); values.append(stats.getUnassignedResolvedCount()); values.append(stats.getUnassignedConcludedCount()); - + String targetTitle = title + " – " + project.getName(); - result = ChartPolarView.build(targetTitle, targetTitle, labels, values); + result = build(targetTitle, targetTitle, labels, values); + + // + return result; + } + + /** + * Builds the. + * + * @param title + * the title + * @param project + * the project + * @return the string + * @throws AgirStatoolException + * the agir statool exception + */ + public static String build(final String title, final Project project) throws AgirStatoolException + { + String result; + + StringList labels = new StringList("Confirmed", "Ongoing", "Waiting", "Resolved", "Rejected", "Closed"); + StringList values = new StringList(); + IssueStats stats = project.issueStats(); + values.append(stats.getUnassignedConfirmedCount()); + values.append(stats.getUnassignedOngoingCount()); + values.append(stats.getUnassignedWaitingCount()); + values.append(stats.getUnassignedResolvedCount()); + values.append(stats.getUnassignedRejectedCount()); + values.append(stats.getUnassignedClosedCount()); + + String targetTitle = title + " – " + project.getName(); + result = build(targetTitle, targetTitle, labels, values); + + // + return result; + } + + /** + * Builds the. + * + * @param title + * the title + * @param labelTitle + * the label title + * @param labels + * the labels + * @param values + * the values + * @return the string + * @throws AgirStatoolException + * the agir statool exception + */ + public static String build(final String title, final String labelTitle, final StringList labels, final StringList values) throws AgirStatoolException + { + String result; + + try + { + String source = XidynUtils.load(AgirStatool.class.getResource("/org/april/agirstatool/core/pages/unassignedIssueChart.xhtml")); + String code = XidynUtils.extractBodyContent(source); + + code = code.replaceAll("myChart", "myChart_" + DigestUtils.md5Hex(title + "chartPolar")); + code = code.replace("# of Votes", labelTitle); + code = code.replaceAll("labels: \\[.*\\]", "labels: " + AgirStatoolUtils.toJSonStrings(labels)); + code = code.replaceAll("data: \\[.*\\]", "data: " + AgirStatoolUtils.toJSonNumbers(values)); + + result = code.toString(); + } + catch (IOException exception) + { + throw new AgirStatoolException("Error building ProjectsRaw view: " + exception.getMessage(), exception); + } // return result; diff --git a/src/org/april/agirstatool/core/pages/chartLineView.xhtml b/src/org/april/agirstatool/core/pages/createdClosedCountChartView.xhtml similarity index 100% rename from src/org/april/agirstatool/core/pages/chartLineView.xhtml rename to src/org/april/agirstatool/core/pages/createdClosedCountChartView.xhtml diff --git a/src/org/april/agirstatool/core/pages/chartLineView2.xhtml b/src/org/april/agirstatool/core/pages/createdClosedDiffChartView.xhtml similarity index 100% rename from src/org/april/agirstatool/core/pages/chartLineView2.xhtml rename to src/org/april/agirstatool/core/pages/createdClosedDiffChartView.xhtml diff --git a/src/org/april/agirstatool/core/pages/chartBarView.xhtml b/src/org/april/agirstatool/core/pages/issueStatusChartView.xhtml similarity index 100% rename from src/org/april/agirstatool/core/pages/chartBarView.xhtml rename to src/org/april/agirstatool/core/pages/issueStatusChartView.xhtml diff --git a/src/org/april/agirstatool/core/pages/chartPolarView.xhtml b/src/org/april/agirstatool/core/pages/unassignedIssueChart.xhtml similarity index 100% rename from src/org/april/agirstatool/core/pages/chartPolarView.xhtml rename to src/org/april/agirstatool/core/pages/unassignedIssueChart.xhtml