| 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 | |
|
| 23 | |
|
| 24 | |
|
| 25 | |
|
| 26 | |
public class AllDevelopersPageMaker { |
| 27 | 0 | private final ReportConfig config; |
| 28 | 0 | |
| 29 | 0 | public AllDevelopersPageMaker(final ReportConfig config) { |
| 30 | 0 | this.config = config; |
| 31 | 0 | } |
| 32 | 0 | |
| 33 | |
public NavigationNode toFile() { |
| 34 | 0 | final DevelopersTableReport developers = new DevelopersTableReport(this.config); |
| 35 | 0 | final DevelopersRollingTableReport rollingDevelopers = new DevelopersRollingTableReport(this.config); |
| 36 | 0 | |
| 37 | 0 | final Page page = this.config.createPage("developers", Messages.getString("DEVELOPERS"), this.config.getProjectName() + " " |
| 38 | 0 | + Messages.getString("DEVELOPERS")); |
| 39 | 0 | if (developers.getDeveloperCount() > 1) { |
| 40 | 0 | page.addAttribute(Messages.getString("NUMBER_DEVELOPERS"), developers.getDeveloperCount()); |
| 41 | 0 | page.add(developers); |
| 42 | 0 | page.addSection(Messages.getString("ROLLING_DEV_TITLE")); |
| 43 | 0 | page.add(rollingDevelopers); |
| 44 | 0 | page.addRawContent(getOtherLoginsLinks()); |
| 45 | 0 | page.addSection(Messages.getString("LOC_TITLE")); |
| 46 | 0 | final ChartImage allAuthorsLOCChart = new AllDevelopersLOCChartMaker(this.config, this.config.getLargeChartSize()).toFile(); |
| 47 | 0 | page.add(allAuthorsLOCChart); |
| 48 | 0 | } |
| 49 | 0 | |
| 50 | 0 | final ChartImage hoursChart = new HourBarChartMaker("activity_time", this.config, this.config.getRepository().getRevisions(), Messages |
| 51 | 0 | .getString("ACTIVITY_TIME_TITLE"), "activity_time.png").toFile(); |
| 52 | 0 | final ChartImage weekdaysChart = new WeekdayBarChartMaker("activity_day", this.config, this.config.getRepository().getRevisions(), Messages |
| 53 | 0 | .getString("ACTIVITY_DAY_TITLE"), "activity_day.png").toFile(); |
| 54 | 0 | final ChartImage scatterChart = new CommitScatterChartMaker(this.config, this.config.getLargeChartSize().width).toFile(); |
| 55 | 0 | final ChartImage modifyAddChart = new ModifyAddChartMaker(this.config, this.config.getSmallChartSize().width).toFile(); |
| 56 | 0 | |
| 57 | 0 | final DevelopersOfTheMonthTable developerOfTheMonth = new DevelopersOfTheMonthTable(this.config); |
| 58 | 0 | page.addSection(Messages.getString("DEVELOPER_OF_THE_MONTH")); |
| 59 | 0 | page.add(developerOfTheMonth); |
| 60 | 0 | |
| 61 | 0 | page.addSection(Messages.getString("DEVELOPER_ACTIVITY")); |
| 62 | 0 | page.add(scatterChart); |
| 63 | 0 | page.add(modifyAddChart); |
| 64 | 0 | |
| 65 | 0 | page.addSection(Messages.getString("ACTIVITY_TITLE")); |
| 66 | 0 | page.add(hoursChart); |
| 67 | 0 | page.add(weekdaysChart); |
| 68 | 0 | |
| 69 | 0 | if (this.config.getRepository().getAuthors().size() >= 1) { |
| 70 | 0 | final PageGroup developerPages = new PageGroup(Messages.getString("DEVELOPERS"), false); |
| 71 | 0 | final Iterator it = this.config.getRepository().getAuthors().iterator(); |
| 72 | 0 | while (it.hasNext()) { |
| 73 | 0 | final Author developer = (Author) it.next(); |
| 74 | 0 | Page devPage = new DeveloperPageMaker(this.config, developer).toFile(); |
| 75 | 0 | developerPages.add(devPage); |
| 76 | 0 | } |
| 77 | 0 | page.addChild(developerPages); |
| 78 | 0 | } |
| 79 | 0 | |
| 80 | 0 | return page; |
| 81 | 0 | } |
| 82 | 0 | |
| 83 | 0 | private String getOtherLoginsLinks() { |
| 84 | 0 | final List nonDeveloperLogins = new ArrayList(); |
| 85 | 0 | Iterator it = this.config.getRepository().getAuthors().iterator(); |
| 86 | 0 | while (it.hasNext()) { |
| 87 | 0 | final Author author = (Author) it.next(); |
| 88 | 0 | if (!this.config.isDeveloper(author)) { |
| 89 | 0 | nonDeveloperLogins.add(author); |
| 90 | 0 | } |
| 91 | 0 | } |
| 92 | 0 | if (nonDeveloperLogins.isEmpty()) { |
| 93 | 0 | return ""; |
| 94 | 0 | } |
| 95 | 0 | Collections.sort(nonDeveloperLogins); |
| 96 | 0 | final StringBuffer s = new StringBuffer("<p>\n Other Logins:\n "); |
| 97 | 0 | it = nonDeveloperLogins.iterator(); |
| 98 | 0 | while (it.hasNext()) { |
| 99 | 0 | final Author author = (Author) it.next(); |
| 100 | 0 | s.append(HTML.getLink(DeveloperPageMaker.getURL(author), author.getRealName())); |
| 101 | 0 | if (it.hasNext()) { |
| 102 | 0 | s.append(", \n "); |
| 103 | 0 | } |
| 104 | 0 | } |
| 105 | 0 | s.append("</p>\n"); |
| 106 | 0 | return s.toString(); |
| 107 | |
} |
| 108 | |
} |