| 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.charts.ChartImage; |
| 9 | |
import net.sf.statcvs.charts.CommitScatterChartMaker; |
| 10 | |
import net.sf.statcvs.charts.ModifyAddChartMaker; |
| 11 | |
import net.sf.statcvs.charts.LOCChartMaker.AllDevelopersLOCChartMaker; |
| 12 | |
import net.sf.statcvs.charts.TimeBarChartMaker.HourBarChartMaker; |
| 13 | |
import net.sf.statcvs.charts.TimeBarChartMaker.WeekdayBarChartMaker; |
| 14 | |
import net.sf.statcvs.model.Author; |
| 15 | |
import net.sf.statcvs.output.ReportConfig; |
| 16 | |
import net.sf.statcvs.reports.DevelopersOfTheMonthTable; |
| 17 | |
import net.sf.statcvs.reports.DevelopersTableReport; |
| 18 | |
|
| 19 | |
|
| 20 | |
|
| 21 | |
|
| 22 | |
|
| 23 | |
|
| 24 | |
public class AllDevelopersPageMaker { |
| 25 | |
private final ReportConfig config; |
| 26 | |
|
| 27 | 0 | public AllDevelopersPageMaker(final ReportConfig config) { |
| 28 | 0 | this.config = config; |
| 29 | 0 | } |
| 30 | |
|
| 31 | |
public NavigationNode toFile() { |
| 32 | 0 | final DevelopersTableReport developers = new DevelopersTableReport(this.config); |
| 33 | |
|
| 34 | 0 | final Page page = this.config.createPage("developers", "Developers", this.config.getProjectName() + " Developers"); |
| 35 | 0 | if (developers.getDeveloperCount() > 1) { |
| 36 | 0 | page.addAttribute("Number of Developers", developers.getDeveloperCount()); |
| 37 | 0 | page.add(developers); |
| 38 | 0 | page.addRawContent(getOtherLoginsLinks()); |
| 39 | 0 | page.addSection("Lines of Code"); |
| 40 | 0 | final ChartImage allAuthorsLOCChart = new AllDevelopersLOCChartMaker(this.config, this.config.getLargeChartSize()).toFile(); |
| 41 | 0 | page.add(allAuthorsLOCChart); |
| 42 | |
} |
| 43 | |
|
| 44 | 0 | final ChartImage hoursChart = new HourBarChartMaker(this.config, this.config.getRepository().getRevisions(), "Activity by Hour of Day", |
| 45 | |
"activity_time.png").toFile(); |
| 46 | 0 | final ChartImage weekdaysChart = new WeekdayBarChartMaker(this.config, this.config.getRepository().getRevisions(), "Activity by Day of Week", |
| 47 | |
"activity_day.png").toFile(); |
| 48 | 0 | final ChartImage scatterChart = new CommitScatterChartMaker(this.config, this.config.getLargeChartSize().width).toFile(); |
| 49 | 0 | final ChartImage modifyAddChart = new ModifyAddChartMaker(this.config, this.config.getSmallChartSize().width).toFile(); |
| 50 | |
|
| 51 | 0 | final DevelopersOfTheMonthTable developerOfTheMonth = new DevelopersOfTheMonthTable(this.config); |
| 52 | 0 | page.addSection("Developer of the Month"); |
| 53 | 0 | page.add(developerOfTheMonth); |
| 54 | |
|
| 55 | 0 | page.addSection("Developer Activity"); |
| 56 | 0 | page.add(scatterChart); |
| 57 | 0 | page.add(modifyAddChart); |
| 58 | |
|
| 59 | 0 | page.addSection("Activity by Clock Time"); |
| 60 | 0 | page.add(hoursChart); |
| 61 | 0 | page.add(weekdaysChart); |
| 62 | |
|
| 63 | 0 | if (this.config.getRepository().getAuthors().size() >= 1) { |
| 64 | 0 | final PageGroup developerPages = new PageGroup("Developers", false); |
| 65 | 0 | final Iterator it = this.config.getRepository().getAuthors().iterator(); |
| 66 | 0 | while (it.hasNext()) { |
| 67 | 0 | final Author developer = (Author) it.next(); |
| 68 | 0 | developerPages.add(new DeveloperPageMaker(this.config, developer).toFile()); |
| 69 | 0 | } |
| 70 | 0 | page.addChild(developerPages); |
| 71 | |
} |
| 72 | |
|
| 73 | 0 | return page; |
| 74 | |
} |
| 75 | |
|
| 76 | |
private String getOtherLoginsLinks() { |
| 77 | 0 | final List nonDeveloperLogins = new ArrayList(); |
| 78 | 0 | Iterator it = this.config.getRepository().getAuthors().iterator(); |
| 79 | 0 | while (it.hasNext()) { |
| 80 | 0 | final Author author = (Author) it.next(); |
| 81 | 0 | if (!this.config.isDeveloper(author)) { |
| 82 | 0 | nonDeveloperLogins.add(author); |
| 83 | |
} |
| 84 | 0 | } |
| 85 | 0 | if (nonDeveloperLogins.isEmpty()) { |
| 86 | 0 | return ""; |
| 87 | |
} |
| 88 | 0 | Collections.sort(nonDeveloperLogins); |
| 89 | 0 | final StringBuffer s = new StringBuffer("<p>\n Other Logins:\n "); |
| 90 | 0 | it = nonDeveloperLogins.iterator(); |
| 91 | 0 | while (it.hasNext()) { |
| 92 | 0 | final Author author = (Author) it.next(); |
| 93 | 0 | s.append(HTML.getLink(DeveloperPageMaker.getURL(author), author.getRealName())); |
| 94 | 0 | if (it.hasNext()) { |
| 95 | 0 | s.append(", \n "); |
| 96 | |
} |
| 97 | 0 | } |
| 98 | 0 | s.append("</p>\n"); |
| 99 | 0 | return s.toString(); |
| 100 | |
} |
| 101 | |
} |