2222import org .stt .persistence .ItemReader ;
2323import org .stt .persistence .ItemReaderProvider ;
2424import org .stt .reporting .ItemCategorizer ;
25+ import org .stt .reporting .ItemCategorizer .ItemCategory ;
2526import org .stt .reporting .OvertimeReportGenerator ;
2627import org .stt .reporting .SummingReportGenerator ;
2728import org .stt .reporting .SummingReportGenerator .Report ;
2829import org .stt .reporting .WorkingtimeItemProvider ;
29- import org .stt .reporting .WorktimeCategorizer ;
3030import org .stt .stt .importer .CachingItemReader ;
3131
3232import com .google .common .base .Optional ;
@@ -39,13 +39,16 @@ public class ReportPrinter {
3939 private final ItemReaderProvider readFrom ;
4040 private final Configuration configuration ;
4141 private final WorkingtimeItemProvider workingtimeItemProvider ;
42+ private final ItemCategorizer categorizer ;
4243
4344 public ReportPrinter (ItemReaderProvider readFrom ,
4445 Configuration configuration ,
45- WorkingtimeItemProvider workingtimeItemProvider ) {
46+ WorkingtimeItemProvider workingtimeItemProvider ,
47+ ItemCategorizer categorizer ) {
4648 this .readFrom = readFrom ;
4749 this .configuration = configuration ;
4850 this .workingtimeItemProvider = workingtimeItemProvider ;
51+ this .categorizer = categorizer ;
4952 }
5053
5154 public void report (Collection <String > args , PrintStream printTo ) {
@@ -179,17 +182,28 @@ private void printSums(PrintStream printTo, String searchString,
179182 }
180183 List <ReportingItem > reportingItems = report .getReportingItems ();
181184
182- Duration overallDuration = new Duration (0 );
185+ Duration worktimeDuration = new Duration (0 );
186+ Duration breakTimeDuration = new Duration (0 );
183187 for (ReportingItem i : reportingItems ) {
184188 Duration duration = i .getDuration ();
185- overallDuration = overallDuration .plus (duration );
186189 String comment = i .getComment ();
187- printTruncatedString (DateTimeHelper .prettyPrintDuration (duration )
188- + " " + comment , printTo , truncateLongLines );
190+ String prefix = " " ;
191+ if (ItemCategory .BREAK .equals (categorizer .getCategory (comment ))) {
192+ prefix = "*" ;
193+ breakTimeDuration = breakTimeDuration .plus (duration );
194+ } else {
195+ worktimeDuration = worktimeDuration .plus (duration );
196+ }
197+ printTruncatedString (
198+ prefix + DateTimeHelper .prettyPrintDuration (duration )
199+ + " " + comment , printTo , truncateLongLines );
189200 }
190201
191- printTo .println ("====== overall sum: ======\n "
192- + DateTimeHelper .prettyPrintDuration (overallDuration ));
202+ printTo .println ("====== overall sum: ======" );
203+ printTo .println ("work: "
204+ + DateTimeHelper .prettyPrintDuration (worktimeDuration ));
205+ printTo .println ("break: "
206+ + DateTimeHelper .prettyPrintDuration (breakTimeDuration ));
193207
194208 IOUtils .closeQuietly (reportReader );
195209 }
@@ -235,7 +249,7 @@ private void printDetails(PrintStream printTo, String searchString,
235249 }
236250
237251 private OvertimeReportGenerator createOvertimeReportGenerator () {
238- ItemCategorizer categorizer = new WorktimeCategorizer ( configuration );
252+
239253 CachingItemReader cacher = new CachingItemReader (
240254 readFrom .provideReader ());
241255 return new OvertimeReportGenerator (cacher , categorizer ,
0 commit comments