View Javadoc

1   package net.sf.statcvs.pages;
2   
3   import java.util.ArrayList;
4   import java.util.Collections;
5   import java.util.Iterator;
6   import java.util.List;
7   
8   import net.sf.statcvs.Messages;
9   import net.sf.statcvs.charts.ChartImage;
10  import net.sf.statcvs.charts.CommitScatterChartMaker;
11  import net.sf.statcvs.charts.ModifyAddChartMaker;
12  import net.sf.statcvs.charts.LOCChartMaker.AllDevelopersLOCChartMaker;
13  import net.sf.statcvs.charts.TimeBarChartMaker.HourBarChartMaker;
14  import net.sf.statcvs.charts.TimeBarChartMaker.WeekdayBarChartMaker;
15  import net.sf.statcvs.model.Author;
16  import net.sf.statcvs.output.ReportConfig;
17  import net.sf.statcvs.reports.DevelopersOfTheMonthTable;
18  import net.sf.statcvs.reports.DevelopersRollingTableReport;
19  import net.sf.statcvs.reports.DevelopersTableReport;
20  
21  /**
22   * @author anja
23   * @author Richard Cyganiak (richard@cyganiak.de)
24   * @version $Id: AllDevelopersPageMaker.java,v 1.14 2009/03/13 23:04:28 benoitx Exp $
25   */
26  public class AllDevelopersPageMaker {
27      private final ReportConfig config;
28  
29      public AllDevelopersPageMaker(final ReportConfig config) {
30          this.config = config;
31      }
32  
33      public NavigationNode toFile() {
34          final DevelopersTableReport developers = new DevelopersTableReport(this.config);
35          final DevelopersRollingTableReport rollingDevelopers = new DevelopersRollingTableReport(this.config);
36  
37          final Page page = this.config.createPage("developers", Messages.getString("DEVELOPERS"), this.config.getProjectName() + " "
38                  + Messages.getString("DEVELOPERS"));
39          if (developers.getDeveloperCount() > 1) {
40              page.addAttribute(Messages.getString("NUMBER_DEVELOPERS"), developers.getDeveloperCount());
41              page.add(developers);
42              page.addSection(Messages.getString("ROLLING_DEV_TITLE"));
43              page.add(rollingDevelopers);
44              page.addRawContent(getOtherLoginsLinks());
45              page.addSection(Messages.getString("LOC_TITLE"));
46              final ChartImage allAuthorsLOCChart = new AllDevelopersLOCChartMaker(this.config, this.config.getLargeChartSize()).toFile();
47              page.add(allAuthorsLOCChart);
48          }
49  
50          final ChartImage hoursChart = new HourBarChartMaker("activity_time", this.config, this.config.getRepository().getRevisions(), Messages
51                  .getString("ACTIVITY_TIME_TITLE"), "activity_time.png").toFile();
52          final ChartImage weekdaysChart = new WeekdayBarChartMaker("activity_day", this.config, this.config.getRepository().getRevisions(), Messages
53                  .getString("ACTIVITY_DAY_TITLE"), "activity_day.png").toFile();
54          final ChartImage scatterChart = new CommitScatterChartMaker(this.config, this.config.getLargeChartSize().width).toFile();
55          final ChartImage modifyAddChart = new ModifyAddChartMaker(this.config, this.config.getSmallChartSize().width).toFile();
56  
57          final DevelopersOfTheMonthTable developerOfTheMonth = new DevelopersOfTheMonthTable(this.config);
58          page.addSection(Messages.getString("DEVELOPER_OF_THE_MONTH"));
59          page.add(developerOfTheMonth);
60  
61          page.addSection(Messages.getString("DEVELOPER_ACTIVITY"));
62          page.add(scatterChart);
63          page.add(modifyAddChart);
64  
65          page.addSection(Messages.getString("ACTIVITY_TITLE"));
66          page.add(hoursChart);
67          page.add(weekdaysChart);
68  
69          if (this.config.getRepository().getAuthors().size() >= 1) {
70              final PageGroup developerPages = new PageGroup(Messages.getString("DEVELOPERS"), false);
71              final Iterator it = this.config.getRepository().getAuthors().iterator();
72              while (it.hasNext()) {
73                  final Author developer = (Author) it.next();
74                  developerPages.add(new DeveloperPageMaker(this.config, developer).toFile());
75              }
76              page.addChild(developerPages);
77          }
78  
79          return page;
80      }
81  
82      private String getOtherLoginsLinks() {
83          final List nonDeveloperLogins = new ArrayList();
84          Iterator it = this.config.getRepository().getAuthors().iterator();
85          while (it.hasNext()) {
86              final Author author = (Author) it.next();
87              if (!this.config.isDeveloper(author)) {
88                  nonDeveloperLogins.add(author);
89              }
90          }
91          if (nonDeveloperLogins.isEmpty()) {
92              return "";
93          }
94          Collections.sort(nonDeveloperLogins);
95          final StringBuffer s = new StringBuffer("<p>\n  Other Logins:\n  ");
96          it = nonDeveloperLogins.iterator();
97          while (it.hasNext()) {
98              final Author author = (Author) it.next();
99              s.append(HTML.getLink(DeveloperPageMaker.getURL(author), author.getRealName()));
100             if (it.hasNext()) {
101                 s.append(", \n  ");
102             }
103         }
104         s.append("</p>\n");
105         return s.toString();
106     }
107 }