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.15 2009/06/02 13:28:53 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 Page devPage = new DeveloperPageMaker(this.config, developer).toFile(); 75 developerPages.add(devPage); 76 } 77 page.addChild(developerPages); 78 } 79 80 return page; 81 } 82 83 private String getOtherLoginsLinks() { 84 final List nonDeveloperLogins = new ArrayList(); 85 Iterator it = this.config.getRepository().getAuthors().iterator(); 86 while (it.hasNext()) { 87 final Author author = (Author) it.next(); 88 if (!this.config.isDeveloper(author)) { 89 nonDeveloperLogins.add(author); 90 } 91 } 92 if (nonDeveloperLogins.isEmpty()) { 93 return ""; 94 } 95 Collections.sort(nonDeveloperLogins); 96 final StringBuffer s = new StringBuffer("<p>\n Other Logins:\n "); 97 it = nonDeveloperLogins.iterator(); 98 while (it.hasNext()) { 99 final Author author = (Author) it.next(); 100 s.append(HTML.getLink(DeveloperPageMaker.getURL(author), author.getRealName())); 101 if (it.hasNext()) { 102 s.append(", \n "); 103 } 104 } 105 s.append("</p>\n"); 106 return s.toString(); 107 } 108 }