Browse Source

Cleaned code. Add hasToRefresh check.

master
Christian P. MOMON 2 years ago
parent
commit
094920c087
  1. 4
      log4j.properties
  2. 57
      src/org/april/agirstatool/core/AgirStatool.java
  3. 2
      src/org/april/agirstatool/core/pages/ChartBarView.java
  4. 2
      src/org/april/agirstatool/core/pages/ChartPolarView.java
  5. 10
      src/org/april/agirstatool/core/pages/CreatedConcludedCountChartView.java
  6. 4
      src/org/april/agirstatool/core/pages/IssueStatChartView.java
  7. 2
      src/org/april/agirstatool/core/pages/ProjectPage.java
  8. 2
      src/org/april/agirstatool/core/pages/ProjectsGroupedView.java
  9. 2
      src/org/april/agirstatool/core/pages/ProjectsRawView.java
  10. 4
      src/org/april/agirstatool/core/pages/UnassignedPolarChartView.java

4
log4j.properties

@ -3,8 +3,8 @@
# priority setting: DEBUG < INFO < WARN < ERROR
log4j.rootLogger = DEBUG, console
log4j.logger.fr.devinsy.xidyn = INFO
log4j.logger.org.april.agirstatool = INFO
log4j.logger.fr.devinsy.xidyn = WARN
#--
log4j.appender.console = org.apache.log4j.ConsoleAppender

57
src/org/april/agirstatool/core/AgirStatool.java

@ -25,6 +25,8 @@ import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import org.apache.commons.io.FileUtils;
import org.april.agirstatool.charts.DateCount;
@ -473,6 +475,54 @@ public class AgirStatool
return result;
}
/**
* Checks for to refresh.
*
* @param project
* the project
* @return true, if successful
*/
public boolean hasToRefresh(final Project project)
{
boolean result;
if (project == null)
{
result = false;
}
else
{
File target = new File(this.targetDirectory, project.getPath());
if (target.exists())
{
if (project.hasIssue())
{
LocalDateTime lastFileUpdate = LocalDateTime.ofEpochSecond(target.lastModified() / 1000, 0, ZoneOffset.UTC);
if (project.issueStats().getLastUpdate().isAfter(lastFileUpdate))
{
result = true;
}
else
{
result = false;
}
}
else
{
result = false;
}
}
else
{
result = true;
}
}
//
return result;
}
/**
* List projects.
*
@ -590,7 +640,7 @@ public class AgirStatool
}
for (Project project : projects)
{
logger.info("Fetching Created/Closed history for " + project.getName());
logger.debug("Fetching Created/Closed history for " + project.getName());
if (project.hasIssue())
{
{
@ -605,7 +655,7 @@ public class AgirStatool
}
}
}
logger.info("Fetching Created/Closed history done.");
logger.debug("Fetching Created/Closed history done.");
// Transform as tree.
for (Project project : projects)
@ -831,8 +881,9 @@ public class AgirStatool
{
try
{
if (project != null)
if (hasToRefresh(project))
{
logger.info("Refresh project page for {}", project.getName());
String page = ProjectPage.build(project);
FileUtils.write(new File(this.targetDirectory, project.getIdentifier() + ".xhtml"), page, StandardCharsets.UTF_8);
}

2
src/org/april/agirstatool/core/pages/ChartBarView.java

@ -52,8 +52,6 @@ public class ChartBarView
try
{
logger.info("Building chartBar view…");
String source = XidynUtils.load(AgirStatool.class.getResource("/org/april/agirstatool/core/pages/chartBarView.xhtml"));
String code = XidynUtils.extractBodyContent(source);

2
src/org/april/agirstatool/core/pages/ChartPolarView.java

@ -52,8 +52,6 @@ public class ChartPolarView
try
{
logger.info("Building polar chart view…");
String source = XidynUtils.load(AgirStatool.class.getResource("/org/april/agirstatool/core/pages/chartPolarView.xhtml"));
String code = XidynUtils.extractBodyContent(source);

10
src/org/april/agirstatool/core/pages/CreatedConcludedCountChartView.java

@ -62,8 +62,6 @@ public class CreatedConcludedCountChartView
try
{
logger.info("Building created/closed x months chart view…");
if (project.hasIssue())
{
String source = XidynUtils.load(AgirStatool.class.getResource("/org/april/agirstatool/core/pages/chartLineView.xhtml"));
@ -113,7 +111,7 @@ public class CreatedConcludedCountChartView
try
{
logger.info("Building created/concluded chart view…");
logger.debug("Building created/concluded chart view…");
if (project.hasIssue())
{
@ -162,8 +160,6 @@ public class CreatedConcludedCountChartView
{
String result;
logger.info("Building created/closed x months chart view…");
result = build(title, project, LocalDate.now().minusMonths(monthCount), LocalDate.now());
//
@ -180,8 +176,6 @@ public class CreatedConcludedCountChartView
{
String result;
logger.info("Building created/closed x months chart view…");
result = buildYear(title, project, LocalDate.now().getYear() - 1);
//
@ -253,8 +247,6 @@ public class CreatedConcludedCountChartView
{
String result;
logger.info("Building created/closed x months chart view…");
LocalDate start = LocalDate.of(year, 1, 1).minusDays(7);
LocalDate end = LocalDate.of(year + 1, 1, 1).minusDays(1);

4
src/org/april/agirstatool/core/pages/IssueStatChartView.java

@ -45,8 +45,6 @@ public class IssueStatChartView
{
String result;
logger.info("Building issue stat chart view…");
StringList labels = new StringList("Maybe", "New", "Confirmed", "Ongoing", "Waiting", "Resolved");
StringList values = new StringList();
values.append(project.issueStats().getMaybeCount());
@ -76,8 +74,6 @@ public class IssueStatChartView
{
String result;
logger.info("Building issue stat chart view…");
StringList labels = new StringList("Maybe", "Active", "Resolved");
StringList values = new StringList();
values.append(project.issueStats().getMaybeCount());

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

@ -51,7 +51,7 @@ public class ProjectPage
try
{
logger.info("Building project page " + project.getName() + "…");
logger.debug("Building project page {}…", project.getName());
TagDataManager data = new TagDataManager();

2
src/org/april/agirstatool/core/pages/ProjectsGroupedView.java

@ -54,7 +54,7 @@ public class ProjectsGroupedView
try
{
logger.info("Building ProjectsGrouped view…");
logger.debug("Building ProjectsGrouped view…");
TagDataManager data = new TagDataManager();

2
src/org/april/agirstatool/core/pages/ProjectsRawView.java

@ -52,7 +52,7 @@ public class ProjectsRawView
try
{
logger.info("Building ProjectsRaw view…");
logger.debug("Building ProjectsRaw view…");
TagDataManager data = new TagDataManager();

4
src/org/april/agirstatool/core/pages/UnassignedPolarChartView.java

@ -46,8 +46,6 @@ public class UnassignedPolarChartView
{
String result;
logger.info("Building issue stat chart view…");
StringList labels = new StringList("Confirmed", "Ongoing", "Waiting", "Resolved", "Rejected", "Closed");
StringList values = new StringList();
IssueStats stats = project.issueStats();
@ -78,8 +76,6 @@ public class UnassignedPolarChartView
{
String result;
logger.info("Building issue stat chart view…");
StringList labels = new StringList("Started", "Resolved", "Concluded");
StringList values = new StringList();
IssueStats stats = project.issueStats();

Loading…
Cancel
Save