Coverage Report - net.sf.statcvs.pages.CommitLogPageGroupMaker
 
Classes in this File Line Coverage Branch Coverage Complexity
CommitLogPageGroupMaker
0%
0/29
0%
0/10
3.5
 
 1  
 package net.sf.statcvs.pages;
 2  
 
 3  
 import java.util.ArrayList;
 4  
 import java.util.Calendar;
 5  
 import java.util.Date;
 6  
 import java.util.GregorianCalendar;
 7  
 import java.util.Iterator;
 8  
 import java.util.List;
 9  
 
 10  
 import net.sf.statcvs.model.Repository;
 11  
 import net.sf.statcvs.output.ReportConfig;
 12  
 
 13  
 public class CommitLogPageGroupMaker {
 14  
     private final ReportConfig config;
 15  
     private final Repository repository;
 16  
 
 17  0
     public CommitLogPageGroupMaker(final ReportConfig config) {
 18  0
         this.config = config;
 19  0
         this.repository = config.getRepository();
 20  0
     }
 21  
 
 22  
     public PageGroup getPages() {
 23  0
         final PageGroup pages = new PageGroup("Commit Logs");
 24  0
         List commits = this.repository.getCommits();
 25  0
         if (commits == null || commits.isEmpty()) {
 26  0
             return null;
 27  
         }
 28  0
         final Date start = this.repository.getFirstDate();
 29  0
         final Date end = this.repository.getLastDate();
 30  0
         final Calendar calendar = new GregorianCalendar();
 31  0
         calendar.setTime(end);
 32  0
         final Calendar startCal = new GregorianCalendar();
 33  0
         startCal.setTime(start);
 34  0
         final List results = new ArrayList();
 35  0
         boolean firstPage = true;
 36  
         while (true) {
 37  0
             final int year = calendar.get(Calendar.YEAR);
 38  0
             final int month = calendar.get(Calendar.MONTH);
 39  
 
 40  0
             final NavigationNode page = new CommitLogPageMaker(this.config, year, month, commits, firstPage).toFile();
 41  0
             results.add(page);
 42  0
             if (calendar.get(Calendar.YEAR) == startCal.get(Calendar.YEAR) && calendar.get(Calendar.MONTH) == startCal.get(Calendar.MONTH)) {
 43  0
                 break;
 44  
             }
 45  0
             firstPage = false;
 46  0
             calendar.add(Calendar.MONTH, -1);
 47  
         }
 48  0
         final Iterator it = results.iterator();
 49  0
         while (it.hasNext()) {
 50  0
             pages.add((NavigationNode) it.next());
 51  
         }
 52  0
         pages.setShowLinkToPreviousSibling(true);
 53  0
         return pages;
 54  
     }
 55  
 }