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.
This commit is contained in:
parent
6de924927a
commit
ba04aae34e
BIN
lib/compile/jfreechart-1.0.13-experimental.jar
Normal file
BIN
lib/compile/jfreechart-1.0.13-experimental.jar
Normal file
Binary file not shown.
BIN
lib/compile/jfreechart-1.0.13-swt.jar
Normal file
BIN
lib/compile/jfreechart-1.0.13-swt.jar
Normal file
Binary file not shown.
BIN
lib/compile/jfreechart-1.0.13.jar
Normal file
BIN
lib/compile/jfreechart-1.0.13.jar
Normal file
Binary file not shown.
BIN
lib/runtime/gnujaxp.jar
Normal file
BIN
lib/runtime/gnujaxp.jar
Normal file
Binary file not shown.
BIN
lib/runtime/iText-2.1.5.jar
Normal file
BIN
lib/runtime/iText-2.1.5.jar
Normal file
Binary file not shown.
BIN
lib/runtime/jcommon-1.0.16.jar
Normal file
BIN
lib/runtime/jcommon-1.0.16.jar
Normal file
Binary file not shown.
BIN
lib/runtime/jfreechart-1.0.13-experimental.jar
Normal file
BIN
lib/runtime/jfreechart-1.0.13-experimental.jar
Normal file
Binary file not shown.
BIN
lib/runtime/jfreechart-1.0.13-swt.jar
Normal file
BIN
lib/runtime/jfreechart-1.0.13-swt.jar
Normal file
Binary file not shown.
BIN
lib/runtime/jfreechart-1.0.13.jar
Normal file
BIN
lib/runtime/jfreechart-1.0.13.jar
Normal file
Binary file not shown.
BIN
lib/runtime/servlet.jar
Normal file
BIN
lib/runtime/servlet.jar
Normal file
Binary file not shown.
BIN
lib/runtime/swtgraphics2d.jar
Normal file
BIN
lib/runtime/swtgraphics2d.jar
Normal file
Binary file not shown.
Binary file not shown.
5
src/main/com/jdbernard/timeanalyzer/CategoryFilter.java
Normal file
5
src/main/com/jdbernard/timeanalyzer/CategoryFilter.java
Normal file
@ -0,0 +1,5 @@
|
||||
package com.jdbernard.timeanalyzer;
|
||||
|
||||
public interface CategoryFilter {
|
||||
public boolean matchesEvent(Event event);
|
||||
}
|
16
src/main/com/jdbernard/timeanalyzer/FilteredCategory.groovy
Normal file
16
src/main/com/jdbernard/timeanalyzer/FilteredCategory.groovy
Normal file
@ -0,0 +1,16 @@
|
||||
package com.jdbernard.timeanalyzer
|
||||
|
||||
public class FilteredCategory extends Category{
|
||||
|
||||
List<CategoryFilter> filters = []
|
||||
|
||||
public FilteredCategory(String description) {
|
||||
super()
|
||||
this.description = description
|
||||
}
|
||||
|
||||
public boolean matchesEvent(Event e) {
|
||||
return filters.every { filter -> filter.matchesEvent(e) }
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package com.jdbernard.timeanalyzer
|
||||
|
||||
import org.joda.time.Interval
|
||||
import org.joda.time.ReadableInstant
|
||||
import org.joda.time.ReadableInterval
|
||||
|
||||
public class TimeIntervalCategoryFilter implements CategoryFilter {
|
||||
|
||||
ReadableInterval interval
|
||||
|
||||
public TimeIntervalCategoryFilter(ReadableInterval interval) {
|
||||
this.interval = interval
|
||||
}
|
||||
|
||||
public TimeIntervalCategoryFilter(ReadableInstant start, ReadableInstant end) {
|
||||
this.interval = new Interval(start, end)
|
||||
}
|
||||
|
||||
public boolean matchesEvent(Event event) {
|
||||
return interval.contains(event.start)
|
||||
}
|
||||
}
|
16
src/main/com/jdbernard/timeanalyzer/chart/Util.groovy
Normal file
16
src/main/com/jdbernard/timeanalyzer/chart/Util.groovy
Normal file
@ -0,0 +1,16 @@
|
||||
package com.jdbernard.timeanalyzer.chart
|
||||
|
||||
import com.jdbernard.timeanalyzer.Category
|
||||
import org.jfree.data.general.DefaultPieDataset
|
||||
import org.jfree.data.general.PieDataset
|
||||
import org.jfree.util.SortOrder
|
||||
|
||||
public class Util {
|
||||
|
||||
public static PieDataset makePieDataset(Category category) {
|
||||
DefaultPieDataset dpds = new DefaultPieDataset()
|
||||
|
||||
category.categories { subcat ->
|
||||
dpds.setValue(subcat.description, subcat.
|
||||
}
|
||||
}
|
@ -6,7 +6,7 @@ import com.jdbernard.timeanalyzer.Event
|
||||
|
||||
public class ITHelpCategory extends Category {
|
||||
|
||||
private def ithelpPattern = ~/^ITHelp:(.*)$/
|
||||
private def ithelpPattern = ~/^ITHelp:\s*(.*)$/
|
||||
private def ticketPattern = ~/^ITHelp:.*#(\d+).*/
|
||||
|
||||
public boolean matchesEvent(Event e) {
|
||||
|
@ -17,4 +17,9 @@ public class TicketCategory extends Category {
|
||||
return (e.description ==~ /ITHelp:.*#${ticketId}.*/)
|
||||
}
|
||||
|
||||
public TicketEntry addEvent(Event e) {
|
||||
TicketEntry te = new TicketEntry(this, e)
|
||||
entries << te
|
||||
return te
|
||||
}
|
||||
}
|
||||
|
@ -7,10 +7,10 @@ public class TicketEntry extends Entry {
|
||||
|
||||
public int id
|
||||
|
||||
public TicketEntry(ITHelpCategory category, Event e) {
|
||||
public TicketEntry(TicketCategory category, Event e) {
|
||||
super(category, e)
|
||||
|
||||
def m = e.description =~ /^ITHelp:(.*#(\d+).*)$/
|
||||
def m = e.description =~ /^ITHelp:\s*(.*#(\d+).*)$/
|
||||
this.description = m[0][1]
|
||||
this.id = m[0][2] as int
|
||||
}
|
||||
|
@ -1,16 +1,47 @@
|
||||
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/
|
||||
uri = new URI("file:///C:/Documents%20and%20Settings/jbernard/My%20Documents/projects/time-analyzer/timeline.jdbernard.txt")
|
||||
fileSource = new FileTimelineSource(uri)
|
||||
|
||||
pf = PeriodFormat.getDefault()
|
||||
|
||||
fileSource = new FileTimelineSource(new File("timeline.jdbernard.txt").toURI())
|
||||
timeline = fileSource.read()
|
||||
events = tep.process(timeline)
|
||||
topcat = new GeneralCategory()
|
||||
|
||||
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"
|
||||
thelpcat = new ITHelpCategory()
|
||||
iithelpcat.description = "ITHelp"
|
||||
|
||||
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))
|
||||
|
Loading…
x
Reference in New Issue
Block a user