Small changes to Category and Event toString()

* Updated Category and Event toString methods to report the duration alongside
  the description.
* Updated QD TicketCategorizationPlan to reflect previous changes to
  CategorizationPlan interface.
This commit is contained in:
Jonathan Bernard
2012-09-04 10:41:40 -05:00
parent 5dff4de089
commit 00a5252542
7 changed files with 57 additions and 47 deletions

View File

@ -13,26 +13,13 @@ import org.joda.time.DateTime
import org.joda.time.Interval
import org.joda.time.Period
import org.joda.time.format.PeriodFormat
pf = PeriodFormat.getDefault()
printDuration = { duration ->
pf.print(duration.toPeriod()) }
import static com.jdbernard.timeanalyzer.chart.Util.*
loadEvents = { file, processor ->
fileSource = new FileTimelineSource(file.toURI())
timeline = fileSource.read()
return processor.process(timeline) }
makePieDataset = { category ->
DefaultPieDataset dpds = new DefaultPieDataset()
category.categories.each { cat ->
dpds.setValue(cat.description, cat.duration.standardSeconds) }
category.events.each { entry ->
dpds.setValue(entry.description, entry.duration.standardSeconds) }
dpds.sortByValues(SortOrder.DESCENDING)
return dpds }
makePieFrame = { categoryName, category ->
def dataset = makePieDataset(category)
return new ChartFrame(categoryName,
@ -62,18 +49,24 @@ analyze = { file ->
return [topcat: topcat, rawEvents: events] }
listEvents = {topcat ->
String result = ""
topcat.events.eachWithIndex { event, index ->
println "${index}: ${event} (${printDuration(event.duration)})" }}
result += "${index}: ${event}\n" }
return result }
listCategories = { topcat ->
String result = ""
topcat.categories.eachWithIndex { cat, index ->
println "${index}: ${cat} (${printDuration(cat.duration)})" }}
result += "${index}: ${cat}\n" }
return result }
details = { topcat ->
println "Categories"
listCategories(topcat)
println "Events"
listEvents(topcat) }
def result = "Categories\n" + listCategories(topcat)
result += "Events\n" + listEvents(topcat)
return "\n" + result }
weeklySummary = { events ->
def todayMidnight = new DateTime()