From 891bdc78f51ebc31280fa8a2b22f8312c5516bde Mon Sep 17 00:00:00 2001 From: "Christian P. MOMON" Date: Wed, 7 Oct 2020 04:33:30 +0200 Subject: [PATCH] Step in chart way. --- src/fr/devinsy/statoolinfos/core/Metric.java | 134 ++++ src/fr/devinsy/statoolinfos/core/Service.java | 76 ++ .../statoolinfos/core/StatoolInfosUtils.java | 111 +++ .../statoolinfos/htmlize/Htmlizer.java | 3 + .../statoolinfos/htmlize/ServicePage.java | 22 + .../htmlize/charts/BarMonthsChartView.java | 124 ++++ .../htmlize/charts/BarTimeChartView.java | 77 ++ .../htmlize/charts/ChabuUtils.java | 672 ++++++++++++++++++ .../htmlize/charts/ChartColors.java | 78 ++ .../htmlize/charts/DateCount.java | 72 ++ .../htmlize/charts/DateCountList.java | 112 +++ .../htmlize/charts/DateCountMap.java | 37 + .../htmlize/charts/FooChartView.java | 88 +++ .../htmlize/charts/LineMonthsChartView.java | 88 +++ .../htmlize/charts/barMonthsChartView.xhtml | 69 ++ .../htmlize/charts/barTimeChartView.xhtml | 69 ++ .../statoolinfos/htmlize/charts/foo.xhtml | 98 +++ .../htmlize/charts/lineMonthsChartView.xhtml | 99 +++ .../htmlize/charts/lineWeeksChartView.xhtml | 98 +++ .../statoolinfos/htmlize/webCharterView.xhtml | 2 +- .../statoolinfos/properties/PathProperty.java | 9 +- 21 files changed, 2136 insertions(+), 2 deletions(-) create mode 100644 src/fr/devinsy/statoolinfos/core/Metric.java create mode 100644 src/fr/devinsy/statoolinfos/htmlize/charts/BarMonthsChartView.java create mode 100644 src/fr/devinsy/statoolinfos/htmlize/charts/BarTimeChartView.java create mode 100644 src/fr/devinsy/statoolinfos/htmlize/charts/ChabuUtils.java create mode 100644 src/fr/devinsy/statoolinfos/htmlize/charts/ChartColors.java create mode 100644 src/fr/devinsy/statoolinfos/htmlize/charts/DateCount.java create mode 100644 src/fr/devinsy/statoolinfos/htmlize/charts/DateCountList.java create mode 100644 src/fr/devinsy/statoolinfos/htmlize/charts/DateCountMap.java create mode 100644 src/fr/devinsy/statoolinfos/htmlize/charts/FooChartView.java create mode 100644 src/fr/devinsy/statoolinfos/htmlize/charts/LineMonthsChartView.java create mode 100644 src/fr/devinsy/statoolinfos/htmlize/charts/barMonthsChartView.xhtml create mode 100644 src/fr/devinsy/statoolinfos/htmlize/charts/barTimeChartView.xhtml create mode 100644 src/fr/devinsy/statoolinfos/htmlize/charts/foo.xhtml create mode 100644 src/fr/devinsy/statoolinfos/htmlize/charts/lineMonthsChartView.xhtml create mode 100644 src/fr/devinsy/statoolinfos/htmlize/charts/lineWeeksChartView.xhtml diff --git a/src/fr/devinsy/statoolinfos/core/Metric.java b/src/fr/devinsy/statoolinfos/core/Metric.java new file mode 100644 index 0000000..5004c52 --- /dev/null +++ b/src/fr/devinsy/statoolinfos/core/Metric.java @@ -0,0 +1,134 @@ +/* + * Copyright (C) 2020 Christian Pierre MOMON + * + * This file is part of StatoolInfos, simple service statistics tool. + * + * StatoolInfos 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. + * + * StatoolInfos 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 StatoolInfos. If not, see . + */ +package fr.devinsy.statoolinfos.core; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import fr.devinsy.strings.StringList; + +/** + * The Class Metric. + */ +public class Metric +{ + private static Logger logger = LoggerFactory.getLogger(Metric.class); + + public enum Type + { + MONTHS, + WEEKS, + DAYS + } + + private String name; + private String description; + private String startYear; + private StringList yearValues; + private StringList monthValues; + private StringList weekValues; + private StringList dayValues; + + /** + * Instantiates a new metric. + */ + public Metric(final String name, final String description, final String startYear) + { + this.name = name; + this.description = description; + this.startYear = startYear; + this.yearValues = new StringList(); + this.monthValues = new StringList(); + this.weekValues = new StringList(); + this.dayValues = new StringList(); + } + + public StringList getDayValues() + { + return this.dayValues; + } + + public String getDescription() + { + return this.description; + } + + public StringList getMonthValues() + { + return this.monthValues; + } + + public String getName() + { + return this.name; + } + + public String getStartYear() + { + return this.startYear; + } + + public StringList getWeekValues() + { + return this.weekValues; + } + + public StringList getYearValues() + { + return this.yearValues; + } + + /** + * Checks if is empty. + * + * @return true, if is empty + */ + public boolean isEmpty() + { + boolean result; + + if ((this.monthValues.isEmpty()) && (this.weekValues.isEmpty()) && (this.dayValues.isEmpty())) + { + result = true; + } + else + { + result = false; + } + + // + return result; + } + + public void setDescription(final String description) + { + this.description = description; + } + + public void setName(final String name) + { + this.name = name; + } + + public void setStartYear(final String startYear) + { + this.startYear = startYear; + } + +} diff --git a/src/fr/devinsy/statoolinfos/core/Service.java b/src/fr/devinsy/statoolinfos/core/Service.java index 6d4aa54..7b0f34f 100644 --- a/src/fr/devinsy/statoolinfos/core/Service.java +++ b/src/fr/devinsy/statoolinfos/core/Service.java @@ -22,11 +22,16 @@ import java.io.File; import java.net.MalformedURLException; import java.net.URL; import java.time.LocalDateTime; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import org.apache.commons.lang3.RegExUtils; import org.apache.commons.lang3.StringUtils; import fr.devinsy.statoolinfos.properties.PathProperties; +import fr.devinsy.statoolinfos.properties.PathProperty; import fr.devinsy.statoolinfos.properties.PathPropertyList; +import fr.devinsy.strings.StringList; /** * The Class Service. @@ -204,6 +209,77 @@ public class Service extends PathPropertyList return result; } + /** + * Gets the metric. + * + * @param path + * the path + * @param year + * the year + * @return the metric + */ + public Metric getMetric(final String path) + { + Metric result; + + String metricName = StringUtils.defaultIfBlank(get(path + ".name"), RegExUtils.removeFirst(path, "^metrics\\.")); + String metricDescription = StringUtils.defaultIfBlank(get(path + ".description"), metricName); + + StringList years = getMetricYears(path).sort(); + + if (years.isEmpty()) + { + result = null; + } + else + { + result = new Metric(metricName, metricDescription, years.get(0)); + + for (String year : years) + { + result.getYearValues().add(get(path + "." + year)); + result.getMonthValues().addAll(StatoolInfosUtils.splitMonthValues(get(path + "." + year + ".months"))); + result.getWeekValues().addAll(StatoolInfosUtils.splitWeekValues(get(path + "." + year + ".weeks"))); + result.getDayValues().addAll(StatoolInfosUtils.splitDayValues(get(path + "." + year + ".weeks"))); + } + } + + // + return result; + } + + /** + * Gets the metric years. + * + * @param path + * the path + * @return the metric years + */ + public StringList getMetricYears(final String path) + { + StringList result; + + result = new StringList(); + + Pattern pattern = Pattern.compile("^" + path + "\\.(?\\d{4}).*=.*$"); + + for (PathProperty property : getByPrefix(path)) + { + String subPath = property.getPath(); + Matcher matcher = pattern.matcher(subPath); + if (matcher.matches()) + { + if (matcher.start("year") != -1) + { + result.add(matcher.group("year")); + } + } + } + + // + return result; + } + /** * Gets the name. * diff --git a/src/fr/devinsy/statoolinfos/core/StatoolInfosUtils.java b/src/fr/devinsy/statoolinfos/core/StatoolInfosUtils.java index 92557e5..c36ff9e 100644 --- a/src/fr/devinsy/statoolinfos/core/StatoolInfosUtils.java +++ b/src/fr/devinsy/statoolinfos/core/StatoolInfosUtils.java @@ -146,6 +146,117 @@ public class StatoolInfosUtils return new Date().getTime(); } + /** + * Split day values. + * + * @param values + * the values + * @return the string list + */ + public static StringList splitDayValues(final String values) + { + StringList result; + + result = new StringList(); + + if (StringUtils.isNotBlank(values)) + { + for (String value : values.split("[,]")) + { + if (StringUtils.isBlank(value)) + { + result.add(""); + } + else + { + result.add(value); + } + } + + for (int index = result.size(); index < 365; index++) + { + result.add(""); + } + } + + // + return result; + } + + /** + * Split month values. + * + * @param values + * the values + * @return the string list + */ + public static StringList splitMonthValues(final String values) + { + StringList result; + + result = new StringList(); + + if (StringUtils.isNotBlank(values)) + { + for (String value : values.split("[,]")) + { + if (StringUtils.isBlank(value)) + { + result.add(""); + } + else + { + result.add(value); + } + } + + for (int index = result.size(); index < 12; index++) + { + result.add(""); + } + } + + // + return result; + } + + /** + * Split week values. + * + * @param values + * the values + * @return the string list + */ + public static StringList splitWeekValues(final String values) + { + StringList result; + + result = new StringList(); + + if (StringUtils.isNotBlank(values)) + { + for (String value : values.split("[,]")) + { + if (StringUtils.isBlank(value)) + { + result.add(""); + } + else + { + result.add(value); + } + } + + for (int index = result.size(); index < 52; index++) + { + result.add(""); + } + } + + // + return result; + } + /** * To human long. * diff --git a/src/fr/devinsy/statoolinfos/htmlize/Htmlizer.java b/src/fr/devinsy/statoolinfos/htmlize/Htmlizer.java index 0b9bb98..47f62dd 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/Htmlizer.java +++ b/src/fr/devinsy/statoolinfos/htmlize/Htmlizer.java @@ -141,6 +141,9 @@ public class Htmlizer StatoolInfosUtils.copyRessource(source + "circle-icons/color/bookshelf.png", color); StatoolInfosUtils.copyRessource(source + "circle-icons/mono/bookshelf.png", mono); + StatoolInfosUtils.copyRessource(source + "circle-icons/color/clipboard.png", color); + StatoolInfosUtils.copyRessource(source + "circle-icons/mono/clipboard.png", mono); + StatoolInfosUtils.copyRessource(source + "circle-icons/color/contacts.png", color); StatoolInfosUtils.copyRessource(source + "circle-icons/mono/contacts.png", mono); diff --git a/src/fr/devinsy/statoolinfos/htmlize/ServicePage.java b/src/fr/devinsy/statoolinfos/htmlize/ServicePage.java index 6a310e7..32ed83d 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/ServicePage.java +++ b/src/fr/devinsy/statoolinfos/htmlize/ServicePage.java @@ -22,9 +22,12 @@ import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import fr.devinsy.statoolinfos.core.Metric; import fr.devinsy.statoolinfos.core.Organization; import fr.devinsy.statoolinfos.core.Service; import fr.devinsy.statoolinfos.core.StatoolInfosException; +import fr.devinsy.statoolinfos.htmlize.charts.BarMonthsChartView; +import fr.devinsy.statoolinfos.htmlize.charts.ChartColors; import fr.devinsy.xidyn.XidynException; import fr.devinsy.xidyn.data.DisplayMode; import fr.devinsy.xidyn.data.TagDataManager; @@ -149,6 +152,25 @@ public class ServicePage data.getIdData("softwareSourceLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE); } + // + int graphicIndex = 0; + // data.setContent("fooChart", graphicIndex++, + // LineMonthsChartView.build()); + + service.getPrefixes(); + + Metric metric = service.getMetric("metrics.http.hits"); + if ((metric != null) && (!metric.isEmpty())) + { + data.setContent("fooChart", graphicIndex++, BarMonthsChartView.build(metric)); + } + + metric = service.getMetric("metrics.http.errors"); + if ((metric != null) && (!metric.isEmpty())) + { + data.setContent("fooChart", graphicIndex++, BarMonthsChartView.build(metric, ChartColors.RED)); + } + // String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/service.xhtml", data).toString(); diff --git a/src/fr/devinsy/statoolinfos/htmlize/charts/BarMonthsChartView.java b/src/fr/devinsy/statoolinfos/htmlize/charts/BarMonthsChartView.java new file mode 100644 index 0000000..b8edc65 --- /dev/null +++ b/src/fr/devinsy/statoolinfos/htmlize/charts/BarMonthsChartView.java @@ -0,0 +1,124 @@ +/* + * Copyright (C) 2020 Christian Pierre MOMON + * + * This file is part of StatoolInfos, simple service statistics tool. + * + * StatoolInfos 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. + * + * StatoolInfos 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 StatoolInfos. If not, see . + */ +package fr.devinsy.statoolinfos.htmlize.charts; + +import java.io.IOException; +import java.time.LocalDate; + +import org.apache.commons.codec.digest.DigestUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import fr.devinsy.statoolinfos.core.Metric; +import fr.devinsy.statoolinfos.core.StatoolInfosException; +import fr.devinsy.strings.StringList; +import fr.devinsy.xidyn.utils.XidynUtils; + +/** + * The Class projectsRawPageBuilder. + */ +public class BarMonthsChartView +{ + private static Logger logger = LoggerFactory.getLogger(BarMonthsChartView.class); + + /** + * Builds the. + * + * @param metric + * the metric + * @return the string + * @throws StatoolInfosException + * the statool infos exception + */ + public static String build(final Metric metric) throws StatoolInfosException + { + String result; + + result = build(metric, ChartColors.BLUE); + + // + return result; + } + + /** + * Builds the. + * + * @param metric + * the metric + * @return the string + * @throws StatoolInfosException + */ + public static String build(final Metric metric, final ChartColors color) throws StatoolInfosException + { + String result; + + LocalDate start = LocalDate.parse(metric.getStartYear() + "-01-01"); + LocalDate end = start.plusMonths(metric.getMonthValues().size()); + StringList labels = ChabuUtils.buildYearMonthAlphaLabels(start, end); + + result = build(metric.getName(), metric.getDescription(), labels, metric.getMonthValues(), color); + + // + return result; + } + + /** + * Builds the. + * + * @param title + * the title + * @param description + * the description + * @param labels + * the labels + * @param values + * the values + * @param color + * the color + * @return the string + * @throws StatoolInfosException + * the statool infos exception + */ + public static String build(final String title, final String description, final StringList labels, final StringList values, final ChartColors color) throws StatoolInfosException + { + String result; + try + { + String source = XidynUtils.load(ChabuUtils.class.getResource("/fr/devinsy/statoolinfos/htmlize/charts/barMonthsChartView.xhtml")); + String code = XidynUtils.extractBodyContent(source); + + code = code.replace("rgb(54, 162, 235)", color.code()); + code = code.replace("rgb(54, 162, 235, 0.2)", color.light()); + code = code.replace("description", XidynUtils.escapeXmlBlank(description)); + code = code.replace("myChart", "myChart_" + DigestUtils.sha1Hex(title + "barMonthsChart")); + code = code.replace("# of Votes", title.replaceAll("'", "\\\\'")); + code = code.replaceFirst("labels: \\[.*\\]", "labels: " + ChabuUtils.toJSonStrings(labels)); + code = code.replaceFirst("data: \\[.*\\]", "data: " + ChabuUtils.toJSonNumbers(values)); + + result = code.toString(); + } + catch (IOException exception) + { + throw new StatoolInfosException("Error building bar months chart view: " + exception.getMessage(), exception); + } + + // + return result; + } +} diff --git a/src/fr/devinsy/statoolinfos/htmlize/charts/BarTimeChartView.java b/src/fr/devinsy/statoolinfos/htmlize/charts/BarTimeChartView.java new file mode 100644 index 0000000..1595101 --- /dev/null +++ b/src/fr/devinsy/statoolinfos/htmlize/charts/BarTimeChartView.java @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2020 Christian Pierre MOMON + * + * This file is part of StatoolInfos, simple service statistics tool. + * + * StatoolInfos 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. + * + * StatoolInfos 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 StatoolInfos. If not, see . + */ +package fr.devinsy.statoolinfos.htmlize.charts; + +import java.io.IOException; + +import org.apache.commons.codec.digest.DigestUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import fr.devinsy.statoolinfos.core.StatoolInfosException; +import fr.devinsy.strings.StringList; +import fr.devinsy.xidyn.utils.XidynUtils; + +/** + * The Class projectsRawPageBuilder. + */ +public class BarTimeChartView +{ + private static Logger logger = LoggerFactory.getLogger(BarTimeChartView.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 StatoolInfosException + { + String result; + + try + { + String source = XidynUtils.load(ChabuUtils.class.getResource("/fr/devinsy/statoolinfos/htmlize/charts/barTimeChartView.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: " + ChabuUtils.toJSonStrings(labels)); + code = code.replaceAll("data: \\[.*\\]", "data: " + ChabuUtils.toJSonNumbers(values)); + + result = code.toString(); + } + catch (IOException exception) + { + throw new StatoolInfosException("Error building ProjectsRaw view: " + exception.getMessage(), exception); + } + + // + return result; + } +} diff --git a/src/fr/devinsy/statoolinfos/htmlize/charts/ChabuUtils.java b/src/fr/devinsy/statoolinfos/htmlize/charts/ChabuUtils.java new file mode 100644 index 0000000..fde78fb --- /dev/null +++ b/src/fr/devinsy/statoolinfos/htmlize/charts/ChabuUtils.java @@ -0,0 +1,672 @@ +/* + * Copyright (C) 2020 Christian Pierre MOMON + * + * This file is part of StatoolInfos, simple service statistics tool. + * + * StatoolInfos 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. + * + * StatoolInfos 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 StatoolInfos. If not, see . + */ +package fr.devinsy.statoolinfos.htmlize.charts; + +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.Date; +import java.util.Iterator; +import java.util.Locale; + +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.math.NumberUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import fr.devinsy.strings.StringList; +import fr.devinsy.strings.StringsUtils; + +/** + * The Class ChabuUtils. + */ +public class ChabuUtils +{ + private static Logger logger = LoggerFactory.getLogger(ChabuUtils.class); + + public static final DateTimeFormatter PATTERN_SHORTDATE = DateTimeFormatter.ofPattern("dd/MM/yyyy", Locale.FRANCE); + public static final DateTimeFormatter PATTERN_LONGDATE = DateTimeFormatter.ofPattern("dd/MM/yyyy HH':'mm", Locale.FRANCE); + + /** + * Builds the month labels. + * + * @param start + * the start + * @param end + * the end + * @return the string list + */ + public static StringList buildMonthLabels(final LocalDate start, final LocalDate end) + { + StringList result; + + result = new StringList(); + + if (start != null) + { + LocalDate normalizedEnd = normaliseMonthDate(end); + LocalDate date = normaliseMonthDate(start); + while (date.isBefore(normalizedEnd) || date.isEqual(normalizedEnd)) + { + String label = date.format(DateTimeFormatter.ISO_DATE); + result.add(label); + date = date.plusMonths(1); + } + } + + // + return result; + } + + /** + * Builds the week labels. + * + * @param start + * the start + * @return the string list + */ + public static StringList buildWeekLabels(final LocalDate start) + { + StringList result; + + result = buildWeekLabels(start, LocalDate.now()); + + // + return result; + } + + /** + * Builds the week labels. + * + * @param start + * the start + * @param end + * the end + * @return the string list + */ + public static StringList buildWeekLabels(final LocalDate start, final LocalDate end) + { + StringList result; + + result = new StringList(); + + if (start != null) + { + LocalDate normalizedEnd = normaliseWeekDate(end); + LocalDate date = normaliseWeekDate(start); + while (date.isBefore(normalizedEnd) || date.isEqual(normalizedEnd)) + { + String label = date.format(DateTimeFormatter.ISO_DATE); + result.add(label); + date = date.plusWeeks(1); + } + } + + // + return result; + } + + /** + * Builds the year month alpha labels. + * + * @param start + * the start + * @param end + * the end + * @return the string list + */ + public static StringList buildYearMonthAlphaLabels(final LocalDate start, final LocalDate end) + { + StringList result; + + result = new StringList(); + + if (start != null) + { + LocalDate normalizedEnd = normaliseMonthDate(end); + LocalDate date = normaliseMonthDate(start); + while (date.isBefore(normalizedEnd) || date.isEqual(normalizedEnd)) + { + String label = date.format(DateTimeFormatter.ofPattern("YYYY-MMM", Locale.FRANCE)); + result.add(label); + date = date.plusMonths(1); + } + } + + // + return result; + } + + /** + * Builds the year month labels. + * + * @param start + * the start + * @param end + * the end + * @return the string list + */ + public static StringList buildYearMonthLabels(final LocalDate start, final LocalDate end) + { + StringList result; + + result = new StringList(); + + if (start != null) + { + LocalDate normalizedEnd = normaliseMonthDate(end); + LocalDate date = normaliseMonthDate(start); + while (date.isBefore(normalizedEnd) || date.isEqual(normalizedEnd)) + { + String label = date.format(DateTimeFormatter.ofPattern("YYYY-MM", Locale.FRANCE)); + result.add(label); + date = date.plusMonths(1); + } + } + + // + return result; + } + + /** + * Normalise month date. + * + * @param source + * the source + * @return the local date + */ + public static LocalDate normaliseMonthDate(final LocalDate source) + { + LocalDate result; + + if (source == null) + { + result = source; + } + else + { + result = source.minusDays(source.getDayOfMonth() - 1); + } + + // + return result; + } + + /** + * Normalise week date. + * + * @param source + * the source + * @return the local date + */ + public static LocalDate normaliseWeekDate(final LocalDate source) + { + LocalDate result; + + if (source == null) + { + result = source; + } + else + { + result = source.minusDays(source.getDayOfWeek().getValue() - 1); + } + + // + return result; + } + + /** + * Normalized month count list. + * + * @param source + * the source + * @param start + * the start + * @param end + * the end + * @return the date count list + */ + public static DateCountList normalizedMonthCountList(final DateCountList source, final LocalDate start, final LocalDate end) + { + DateCountList result; + + result = new DateCountList(); + + LocalDate normalizedEnd = normaliseMonthDate(end); + LocalDate date = normaliseMonthDate(start); + int index = source.indexOf(toYearMonth(start)); + if (index == -1) + { + index = 0; + } + while (date.isBefore(normalizedEnd) || date.isEqual(normalizedEnd)) + { + String dateToken = toYearMonth(date); + long count; + if (index < source.size()) + { + DateCount current = source.get(index); + // ChabuUtils.logger.info("===> " + dateToken + " " + + // current.getDate()); + if (StringUtils.equals(current.getDate(), dateToken)) + { + count = current.getCount(); + index += 1; + } + else + { + count = 0; + } + } + else + { + count = 0; + } + result.add(new DateCount(dateToken, count)); + date = date.plusMonths(1); + } + + // + return result; + } + + /** + * Normalized week count list. + * + * @param source + * the source + * @param start + * the start + * @param end + * the end + * @return the date count list + */ + public static DateCountList normalizedWeekCountList(final DateCountList source, final LocalDate start, final LocalDate end) + { + DateCountList result; + + result = new DateCountList(); + + LocalDate normalizedEnd = normaliseWeekDate(end); + LocalDate date = normaliseWeekDate(start); + int index = source.indexOf(toYearWeek(start)); + if (index == -1) + { + index = 0; + } + while (date.isBefore(normalizedEnd) || date.isEqual(normalizedEnd)) + { + String dateToken = toYearWeek(date); + long count; + if (index < source.size()) + { + DateCount current = source.get(index); + // AgirStatoolUtils.logger.info("===> " + dateToken + " " + + // current.getDate()); + if (StringUtils.equals(current.getDate(), dateToken)) + { + count = current.getCount(); + index += 1; + } + else + { + count = 0; + } + } + else + { + count = 0; + } + result.add(new DateCount(dateToken, count)); + date = date.plusWeeks(1); + } + + // + return result; + } + + /** + * Builds the week created count list. + * + * @param source + * the source + * @param start + * the start + * @return the date count list + */ + public static DateCountList normalizedWeekCountList(final DateCountMap source, final LocalDate start) + { + DateCountList result; + + result = new DateCountList(); + + LocalDate date = normaliseWeekDate(start); + LocalDate end = normaliseWeekDate(LocalDate.now()); + long count = 0; + while (date.isBefore(end) || date.isEqual(end)) + { + String dateToken = toYearWeek(date); + DateCount current = source.get(dateToken); + if (current != null) + { + count += current.getCount(); + } + result.add(new DateCount(dateToken, count)); + date = date.plusWeeks(1); + } + + // + return result; + } + + /** + * Gets the current time in long format. + * + * @return the long + */ + public static long now() + { + return new Date().getTime(); + } + + /** + * Select stat indicator. + * + * @param value + * the value + * @return the string + */ + public static String selectStatIndicator(final long value) + { + String result; + + if (value < 10) + { + result = null; + } + else if (value < 20) + { + result = "caution"; + } + else if (value < 50) + { + result = "warning"; + } + else + { + result = "alert"; + } + + // + return result; + } + + /** + * Select unassigned indicator. + * + * @param value + * the value + * @return the string + */ + public static String selectUnassignedIndicator(final long value) + { + String result; + + if (value == 0) + { + result = null; + } + else + { + result = "alert"; + } + + // + return result; + } + + /** + * To human long. + * + * @param value + * the value + * @return the string + */ + public static String toHumanLong(final LocalDateTime value) + { + String result; + + result = toHumanLong(value, null); + + // + return result; + } + + /** + * To human long. + * + * @param value + * the value + * @param defaultValue + * the default value + * @return the string + */ + public static String toHumanLong(final LocalDateTime value, final String defaultValue) + { + String result; + + if (value == null) + { + result = null; + } + else + { + result = value.format(PATTERN_LONGDATE); + } + + // + return result; + } + + /** + * To human short. + * + * @param value + * the value + * @return the string + */ + public static String toHumanShort(final LocalDateTime value) + { + String result; + + result = toHumanShort(value, null); + + // + return result; + } + + /** + * To human short. + * + * @param value + * the value + * @param defaultValue + * the default value + * @return the string + */ + public static String toHumanShort(final LocalDateTime value, final String defaultValue) + { + String result; + + if (value == null) + { + result = null; + } + else + { + result = value.format(PATTERN_SHORTDATE); + } + + // + return result; + } + + public static Integer toInteger(final String value) + { + Integer result; + + if ((value == null) || (!NumberUtils.isDigits(value))) + { + result = null; + } + else + { + result = Integer.parseInt(value); + } + + // + return result; + } + + /** + * To Json numbers. + * + * @param source + * the source + * @return the string + */ + public static String toJSonNumbers(final StringList source) + { + String result; + + result = StringsUtils.toString(source, "[", ",", "]"); + + // + return result; + } + + /** + * To J son numbers. + * + * @param labels + * the labels + * @param values + * the source + * @return the string + */ + public static String toJSonNumbers(final StringList labels, final StringList values) + { + String result; + + Iterator labelIterator = labels.iterator(); + Iterator valueIterator = values.iterator(); + + StringList buffer = new StringList(); + while (labelIterator.hasNext()) + { + String label = labelIterator.next(); + String value = valueIterator.next(); + + buffer.append(String.format("{t: '%s', y: %s}", label, value)); + } + result = StringsUtils.toString(buffer, "[", ",", "]"); + + // + return result; + } + + /** + * To Json strings. + * + * @param source + * the source + * @return the string + */ + public static String toJSonStrings(final StringList source) + { + String result; + + StringList target = new StringList(); + + target.append("["); + for (String string : source) + { + target.append("'"); + target.append(string); + target.append("'"); + target.append(","); + } + target.removeLast(); + target.append("]"); + + result = target.toString(); + + // + return result; + } + + /** + * To year month. + * + * @param source + * the source + * @return the string + */ + public static String toYearMonth(final LocalDate source) + { + String result; + + if (source == null) + { + result = null; + } + else + { + result = source.format(DateTimeFormatter.ofPattern("YYYYMM", Locale.FRANCE)); + } + + // + return result; + } + + /** + * To year week. + * + * @param source + * the source + * @return the string + */ + public static String toYearWeek(final LocalDate source) + { + String result; + + if (source == null) + { + result = null; + } + else + { + result = source.format(DateTimeFormatter.ofPattern("YYYYww", Locale.FRANCE)); + } + + // + return result; + } +} diff --git a/src/fr/devinsy/statoolinfos/htmlize/charts/ChartColors.java b/src/fr/devinsy/statoolinfos/htmlize/charts/ChartColors.java new file mode 100644 index 0000000..d4e7dd4 --- /dev/null +++ b/src/fr/devinsy/statoolinfos/htmlize/charts/ChartColors.java @@ -0,0 +1,78 @@ +/* + * Copyright (C) 2020 Christian Pierre MOMON + * + * This file is part of StatoolInfos, simple service statistics tool. + * + * StatoolInfos 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. + * + * StatoolInfos 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 StatoolInfos. If not, see . + */ +package fr.devinsy.statoolinfos.htmlize.charts; + +/** + * The Enum ChartColors. + */ +public enum ChartColors +{ + RED("rgb(255, 99, 132)"), + ORANGE("rgb(255, 159, 64)"), + YELLOW("rgb(255, 205, 86)"), + GREEN("rgb(75, 192, 192)"), + BLUE("rgb(54, 162, 235)"), + PURPLE("'rgb(153, 102, 255)"), + GREY("rgb(201, 203, 207)"); + + private String code; + private String light; + + /** + * Instantiates a new chart colors. + * + * @param code + * the code + */ + ChartColors(final String code) + { + this.code = code; + this.light = code.replace(")", ", 0.2)"); + } + + /** + * Code. + * + * @return the string + */ + public String code() + { + String result; + + result = this.code; + + // + return result; + } + + /** + * Gamma. + * + * @return the string + */ + public String light() + { + String result; + + result = this.light; + + // + return result; + } +} diff --git a/src/fr/devinsy/statoolinfos/htmlize/charts/DateCount.java b/src/fr/devinsy/statoolinfos/htmlize/charts/DateCount.java new file mode 100644 index 0000000..e2209ce --- /dev/null +++ b/src/fr/devinsy/statoolinfos/htmlize/charts/DateCount.java @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2020 Christian Pierre MOMON + * + * This file is part of StatoolInfos, simple service statistics tool. + * + * StatoolInfos 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. + * + * StatoolInfos 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 StatoolInfos. If not, see . + */ +package fr.devinsy.statoolinfos.htmlize.charts; + +import org.apache.commons.lang3.StringUtils; + +/** + * The Class Projects. + */ +public class DateCount +{ + private String date; + private long count; + + /** + * Instantiates a new date count. + * + * @param date + * the date + * @param count + * the count + */ + public DateCount(final String date, final long count) + { + setDate(date); + this.count = count; + } + + public long getCount() + { + return this.count; + } + + public String getDate() + { + return this.date; + } + + public void setCount(final long count) + { + this.count = count; + } + + public void setDate(final String date) + { + if (StringUtils.isBlank(date)) + { + throw new IllegalArgumentException("Null parameter."); + } + else + { + this.date = date; + } + } + +} diff --git a/src/fr/devinsy/statoolinfos/htmlize/charts/DateCountList.java b/src/fr/devinsy/statoolinfos/htmlize/charts/DateCountList.java new file mode 100644 index 0000000..0223d11 --- /dev/null +++ b/src/fr/devinsy/statoolinfos/htmlize/charts/DateCountList.java @@ -0,0 +1,112 @@ +/* + * Copyright (C) 2020 Christian Pierre MOMON + * + * This file is part of StatoolInfos, simple service statistics tool. + * + * StatoolInfos 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. + * + * StatoolInfos 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 StatoolInfos. If not, see . + */ +package fr.devinsy.statoolinfos.htmlize.charts; + +import java.util.ArrayList; + +import org.apache.commons.lang3.StringUtils; + +import fr.devinsy.strings.StringList; + +/** + * The Class Projects. + */ +public class DateCountList extends ArrayList +{ + private static final long serialVersionUID = -5526492552751712533L; + + /** + * Instantiates a new date count map. + */ + public DateCountList() + { + super(); + } + + /** + * Instantiates a new date count list. + * + * @param capacity + * the capacity + */ + public DateCountList(final int capacity) + { + super(capacity); + } + + /** + * Indexof. + * + * @param dateToken + * the date token + * @return the int + */ + public int indexOf(final String dateToken) + { + int result; + + boolean ended = false; + result = -1; + int index = 0; + while (!ended) + { + if (index < this.size()) + { + DateCount current = get(index); + if (StringUtils.equals(current.getDate(), dateToken)) + { + ended = true; + result = index; + } + else + { + index += 1; + } + } + else + { + ended = true; + result = -1; + } + } + + // + return result; + } + + /** + * To value list. + * + * @return the string list + */ + public StringList toValueList() + { + StringList result; + + result = new StringList(); + + for (DateCount item : this) + { + result.append(item.getCount()); + } + + // + return result; + } +} \ No newline at end of file diff --git a/src/fr/devinsy/statoolinfos/htmlize/charts/DateCountMap.java b/src/fr/devinsy/statoolinfos/htmlize/charts/DateCountMap.java new file mode 100644 index 0000000..41224f6 --- /dev/null +++ b/src/fr/devinsy/statoolinfos/htmlize/charts/DateCountMap.java @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2020 Christian Pierre MOMON + * + * This file is part of StatoolInfos, simple service statistics tool. + * + * StatoolInfos 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. + * + * StatoolInfos 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 StatoolInfos. If not, see . + */ +package fr.devinsy.statoolinfos.htmlize.charts; + +import java.util.HashMap; + +/** + * The Class Projects. + */ +public class DateCountMap extends HashMap +{ + private static final long serialVersionUID = -5526492552751712533L; + + /** + * Instantiates a new date count map. + */ + public DateCountMap() + { + super(); + } +} diff --git a/src/fr/devinsy/statoolinfos/htmlize/charts/FooChartView.java b/src/fr/devinsy/statoolinfos/htmlize/charts/FooChartView.java new file mode 100644 index 0000000..1fce1f9 --- /dev/null +++ b/src/fr/devinsy/statoolinfos/htmlize/charts/FooChartView.java @@ -0,0 +1,88 @@ +/* + * Copyright (C) 2020 Christian Pierre MOMON + * + * This file is part of StatoolInfos, simple service statistics tool. + * + * StatoolInfos 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. + * + * StatoolInfos 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 StatoolInfos. If not, see . + */ +package fr.devinsy.statoolinfos.htmlize.charts; + +import java.io.IOException; +import java.time.LocalDate; +import java.time.LocalDateTime; + +import org.apache.commons.codec.digest.DigestUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import fr.devinsy.statoolinfos.core.StatoolInfosException; +import fr.devinsy.strings.StringList; +import fr.devinsy.xidyn.utils.XidynUtils; + +/** + * The Class projectsRawPageBuilder. + */ +public class FooChartView +{ + private static Logger logger = LoggerFactory.getLogger(FooChartView.class); + + public static String build() throws StatoolInfosException + { + String result; + + try + { + String source = XidynUtils.load(FooChartView.class.getResource("/fr/devinsy/statoolinfos/htmlize/charts/foo.xhtml")); + String code = XidynUtils.extractBodyContent(source); + + code = code.replaceAll("myChart", "myChart_" + DigestUtils.md5Hex(LocalDateTime.now() + "lineChart")); + + // DO MonthsBarChart + + LocalDate start = LocalDate.parse("2020-01-01"); + LocalDate end = LocalDate.parse("2020-12-31"); + + DateCountList dates = new DateCountList(); + dates.add(new DateCount("202001", 7)); + dates.add(new DateCount("202002", 9)); + dates.add(new DateCount("202003", 4)); + dates.add(new DateCount("202004", 2)); + dates.add(new DateCount("202005", 1)); + dates.add(new DateCount("202006", 7)); + + StringList labels = ChabuUtils.buildYearMonthLabels(start, end); + StringList values = ChabuUtils.normalizedMonthCountList(dates, start, end).toValueList(); + code = code.replaceAll("data: \\[.*\\]", "data: " + ChabuUtils.toJSonNumbers(labels, values)); + + /* + StringList labels = ChabuUtils.buildWeekLabels(LocalDate.parse("2020-01-01"), LocalDate.parse("2020-12-31")); + DateCountList dates = project.issueStats().getWeekCreatedIssueCounts(); + StringList values = ChabuUtils.normalizedWeekCountList(dates, start, end).toValueList(); + code = code.replaceAll("data: \\[.*\\]", "data: " + ChabuUtils.toJSonNumbers(labels, values)); + + dates = project.issueStats().getWeekConcludedIssueCounts(); + values = ChabuUtils.normalizedWeekCountList(dates, start, end).toValueList(); + code = code.replaceAll("data: \\[.*\\] ", "data: " + ChabuUtils.toJSonNumbers(labels, values)); + */ + result = code.toString(); + } + catch (IOException exception) + { + throw new StatoolInfosException("Error building foo charts view: " + exception.getMessage(), exception); + } + + // + return result; + } +} diff --git a/src/fr/devinsy/statoolinfos/htmlize/charts/LineMonthsChartView.java b/src/fr/devinsy/statoolinfos/htmlize/charts/LineMonthsChartView.java new file mode 100644 index 0000000..4376522 --- /dev/null +++ b/src/fr/devinsy/statoolinfos/htmlize/charts/LineMonthsChartView.java @@ -0,0 +1,88 @@ +/* + * Copyright (C) 2020 Christian Pierre MOMON + * + * This file is part of StatoolInfos, simple service statistics tool. + * + * StatoolInfos 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. + * + * StatoolInfos 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 StatoolInfos. If not, see . + */ +package fr.devinsy.statoolinfos.htmlize.charts; + +import java.io.IOException; +import java.time.LocalDate; +import java.time.LocalDateTime; + +import org.apache.commons.codec.digest.DigestUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import fr.devinsy.statoolinfos.core.StatoolInfosException; +import fr.devinsy.strings.StringList; +import fr.devinsy.xidyn.utils.XidynUtils; + +/** + * The Class projectsRawPageBuilder. + */ +public class LineMonthsChartView +{ + private static Logger logger = LoggerFactory.getLogger(LineMonthsChartView.class); + + public static String build() throws StatoolInfosException + { + String result; + + try + { + String source = XidynUtils.load(LineMonthsChartView.class.getResource("/fr/devinsy/statoolinfos/htmlize/charts/lineMonthsChartView.xhtml")); + String code = XidynUtils.extractBodyContent(source); + + code = code.replaceAll("myChart", "myChart_" + DigestUtils.md5Hex(LocalDateTime.now() + "lineChart")); + + // DO MonthsBarChart + + LocalDate start = LocalDate.parse("2020-01-01"); + LocalDate end = LocalDate.parse("2020-12-31"); + + DateCountList dates = new DateCountList(); + dates.add(new DateCount("202001", 7)); + dates.add(new DateCount("202002", 9)); + dates.add(new DateCount("202003", 4)); + dates.add(new DateCount("202004", 2)); + dates.add(new DateCount("202005", 1)); + dates.add(new DateCount("202006", 7)); + + StringList labels = ChabuUtils.buildYearMonthLabels(start, end); + StringList values = ChabuUtils.normalizedMonthCountList(dates, start, end).toValueList(); + code = code.replaceFirst("data: \\[.*\\]", "data: " + ChabuUtils.toJSonNumbers(labels, values)); + + /* + StringList labels = ChabuUtils.buildWeekLabels(LocalDate.parse("2020-01-01"), LocalDate.parse("2020-12-31")); + DateCountList dates = project.issueStats().getWeekCreatedIssueCounts(); + StringList values = ChabuUtils.normalizedWeekCountList(dates, start, end).toValueList(); + code = code.replaceAll("data: \\[.*\\]", "data: " + ChabuUtils.toJSonNumbers(labels, values)); + + dates = project.issueStats().getWeekConcludedIssueCounts(); + values = ChabuUtils.normalizedWeekCountList(dates, start, end).toValueList(); + code = code.replaceAll("data: \\[.*\\] ", "data: " + ChabuUtils.toJSonNumbers(labels, values)); + */ + result = code.toString(); + } + catch (IOException exception) + { + throw new StatoolInfosException("Error building foo charts view: " + exception.getMessage(), exception); + } + + // + return result; + } +} diff --git a/src/fr/devinsy/statoolinfos/htmlize/charts/barMonthsChartView.xhtml b/src/fr/devinsy/statoolinfos/htmlize/charts/barMonthsChartView.xhtml new file mode 100644 index 0000000..d5baa8b --- /dev/null +++ b/src/fr/devinsy/statoolinfos/htmlize/charts/barMonthsChartView.xhtml @@ -0,0 +1,69 @@ + + + + + StatoolInfos + + + + + + + + + + +
+ + +
+ + diff --git a/src/fr/devinsy/statoolinfos/htmlize/charts/barTimeChartView.xhtml b/src/fr/devinsy/statoolinfos/htmlize/charts/barTimeChartView.xhtml new file mode 100644 index 0000000..c31d893 --- /dev/null +++ b/src/fr/devinsy/statoolinfos/htmlize/charts/barTimeChartView.xhtml @@ -0,0 +1,69 @@ + + + + + StatoolInfos + + + + + + + + + + +
+ + +
+ + diff --git a/src/fr/devinsy/statoolinfos/htmlize/charts/foo.xhtml b/src/fr/devinsy/statoolinfos/htmlize/charts/foo.xhtml new file mode 100644 index 0000000..0763576 --- /dev/null +++ b/src/fr/devinsy/statoolinfos/htmlize/charts/foo.xhtml @@ -0,0 +1,98 @@ + + + + + StatoolInfos + + + + + + + + + + +
+ + +
+ + diff --git a/src/fr/devinsy/statoolinfos/htmlize/charts/lineMonthsChartView.xhtml b/src/fr/devinsy/statoolinfos/htmlize/charts/lineMonthsChartView.xhtml new file mode 100644 index 0000000..b2ac604 --- /dev/null +++ b/src/fr/devinsy/statoolinfos/htmlize/charts/lineMonthsChartView.xhtml @@ -0,0 +1,99 @@ + + + + + StatoolInfos + + + + + + + + + + +
+ + +
+ + diff --git a/src/fr/devinsy/statoolinfos/htmlize/charts/lineWeeksChartView.xhtml b/src/fr/devinsy/statoolinfos/htmlize/charts/lineWeeksChartView.xhtml new file mode 100644 index 0000000..0763576 --- /dev/null +++ b/src/fr/devinsy/statoolinfos/htmlize/charts/lineWeeksChartView.xhtml @@ -0,0 +1,98 @@ + + + + + StatoolInfos + + + + + + + + + + +
+ + +
+ + diff --git a/src/fr/devinsy/statoolinfos/htmlize/webCharterView.xhtml b/src/fr/devinsy/statoolinfos/htmlize/webCharterView.xhtml index e5097ec..242d6c9 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/webCharterView.xhtml +++ b/src/fr/devinsy/statoolinfos/htmlize/webCharterView.xhtml @@ -7,7 +7,7 @@ - diff --git a/src/fr/devinsy/statoolinfos/properties/PathProperty.java b/src/fr/devinsy/statoolinfos/properties/PathProperty.java index 5a934a0..36f5130 100644 --- a/src/fr/devinsy/statoolinfos/properties/PathProperty.java +++ b/src/fr/devinsy/statoolinfos/properties/PathProperty.java @@ -88,7 +88,14 @@ public class PathProperty { String result; - result = this.path.substring(0, this.path.indexOf(".", this.path.indexOf(".") + 1)); + if (StringUtils.countMatches(this.path, '.') > 1) + { + result = this.path.substring(0, this.path.indexOf(".", this.path.indexOf(".") + 1)); + } + else + { + result = null; + } // return result;