timestamper/startscript.groovy
Jonathan Bernard ba04aae34e Fixed, expanded category implementations. Started chart work.
Added FilteredCategory, filters by arbitrary CategoryFilters.
Started on Util class with code to create charts based on categories.
Fixed ITHelp ticket matching to swallow optional space after "ITHelp:"
Fixed TicketCategory to use it's own addEvent logic instead of inheriting the
  default Category implementation.
Updated startscript.groovy to reflect test data for recent changes.
2011-01-11 08:21:41 -06:00

48 lines
1.5 KiB
Groovy

import com.jdbernard.timeanalyzer.*
import com.jdbernard.timestamper.core.*
import com.quantumdigital.ithelp.timeanalyzer.*
import org.joda.time.*
import org.joda.time.format.*
import org.jfree.chart.*
import org.jfree.data.general.*
import org.jfree.util.SortOrder
tep = new TimelineEventProcessor()
tep.exclusions << ~/Going Home/
pf = PeriodFormat.getDefault()
fileSource = new FileTimelineSource(new File("timeline.jdbernard.txt").toURI())
timeline = fileSource.read()
events = tep.process(timeline)
topcat = new FilteredCategory()
topcat.filters << new TimeIntervalCategoryFilter(
new DateTime(2011, 1, 2, 0, 0, 0, 0), new DateTime(2011, 1, 9, 0, 0, 0, 0))
topcat.description = "Top Category"
ithelpcat = new ITHelpCategory()
ithelpcat.description = "ITHelp"
topcat.categories << ithelpcat
events.each { if (topcat.matchesEvent(it)) topcat.addEvent(it) }
makePieDataset = { category ->
DefaultPieDataset dpds = new DefaultPieDataset()
category.categories.each { cat ->
dpds.setValue(cat.description, cat.duration.standardSeconds) }
category.entries.each { entry ->
dpds.setValue(entry.description, entry.duration.standardSeconds) }
dpds.sortByValues(SortOrder.DESCENDING)
return dpds
}
topcatDataset = makePieDataset(topcat)
ithelpDataset = makePieDataset(ithelpcat)
topcatFrame = new ChartFrame("Top Category",
ChartFactory.createPieChart("Time Spent", topcatDataset, true, true, false))
ithelpFrame = new ChartFrame("ITHelp",
ChartFactory.createPieChart("Time Spent", ithelpDataset, true, true, false))