1 package net.sf.statcvs.reports;
2
3 import java.util.Iterator;
4
5 import net.sf.statcvs.Messages;
6 import net.sf.statcvs.model.Author;
7 import net.sf.statcvs.output.ReportConfig;
8 import net.sf.statcvs.reportmodel.AuthorColumn;
9 import net.sf.statcvs.reportmodel.IntegerColumn;
10 import net.sf.statcvs.reportmodel.Table;
11
12 /**
13 * Table report which creates a table containing the names of the
14 * top 10 developers and their LOC contributions.
15 *
16 * @author Richard Cyganiak <rcyg@gmx.de>
17 * @version $Id: TopDevelopersTableReport.java,v 1.2 2008/04/02 11:22:15 benoitx Exp $
18 */
19 public class TopDevelopersTableReport extends AbstractLocTableReport implements TableReport {
20 private Table table = null;
21
22 /**
23 * Creates a table report containing the top 10 authors and their
24 * LOC contributions
25 * @param content the version control source data
26 */
27 public TopDevelopersTableReport(final ReportConfig config) {
28 super(config);
29 }
30
31 /**
32 * @see net.sf.statcvs.reports.TableReport#calculate()
33 */
34 public void calculate() {
35 if (this.table != null) {
36 return;
37 }
38 String summary;
39 if (getDeveloperCount() > 10) {
40 summary = Messages.getString("TOP_AUTHORS_TABLE_SUMMARY1");
41 } else {
42 summary = Messages.getString("TOP_AUTHORS_TABLE_SUMMARY2");
43 }
44 table = new Table(summary);
45 final AuthorColumn authors = new AuthorColumn();
46 final IntegerColumn linesOfCode = new IntegerColumn(Messages.getString("COLUMN_LOC"));
47 linesOfCode.setShowPercentages(true);
48 table.addColumn(authors);
49 table.addColumn(linesOfCode);
50 table.setKeysInFirstColumn(true);
51
52 calculateChangesAndLinesPerDeveloper(getContent().getRevisions());
53 int lines = 0;
54 final Iterator it = getLinesMap().iteratorSortedByValueReverse();
55 while (it.hasNext()) {
56 final Author author = (Author) it.next();
57 authors.addValue(author);
58 linesOfCode.addValue(getLinesMap().get(author));
59 lines++;
60 if (lines == 10) {
61 break;
62 }
63 }
64 linesOfCode.setSum(getLinesMap().sum());
65 }
66
67 /**
68 * @see net.sf.statcvs.reports.TableReport#getTable()
69 */
70 public Table getTable() {
71 return table;
72 }
73 }