commit 9f4008a7754a178e6fe1cd69262cbccb4ee6b9b0 Author: Jonathan Bernard Date: Sun Jan 9 15:11:36 2011 -0600 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8c94d06 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +build/ +*.sw* diff --git a/lib/compile/groovylint-0.5.12.jar b/lib/compile/groovylint-0.5.12.jar new file mode 100644 index 0000000..d2c0ed2 Binary files /dev/null and b/lib/compile/groovylint-0.5.12.jar differ diff --git a/lib/compile/joda-time-1.6.2.jar b/lib/compile/joda-time-1.6.2.jar new file mode 100644 index 0000000..9b045c3 Binary files /dev/null and b/lib/compile/joda-time-1.6.2.jar differ diff --git a/lib/compile/slf4j-api-1.6.1.jar b/lib/compile/slf4j-api-1.6.1.jar new file mode 100644 index 0000000..42e0ad0 Binary files /dev/null and b/lib/compile/slf4j-api-1.6.1.jar differ diff --git a/lib/runtime/joda-time-1.6.2.jar b/lib/runtime/joda-time-1.6.2.jar new file mode 100644 index 0000000..9b045c3 Binary files /dev/null and b/lib/runtime/joda-time-1.6.2.jar differ diff --git a/lib/runtime/logback-classic-0.9.26.jar b/lib/runtime/logback-classic-0.9.26.jar new file mode 100644 index 0000000..b900b64 Binary files /dev/null and b/lib/runtime/logback-classic-0.9.26.jar differ diff --git a/lib/runtime/logback-core-0.9.26.jar b/lib/runtime/logback-core-0.9.26.jar new file mode 100644 index 0000000..d50f3cd Binary files /dev/null and b/lib/runtime/logback-core-0.9.26.jar differ diff --git a/lib/runtime/slf4j-api-1.6.1.jar b/lib/runtime/slf4j-api-1.6.1.jar new file mode 100644 index 0000000..42e0ad0 Binary files /dev/null and b/lib/runtime/slf4j-api-1.6.1.jar differ diff --git a/src/main/com/jdbernard/timeanalyzer/Category.groovy b/src/main/com/jdbernard/timeanalyzer/Category.groovy new file mode 100644 index 0000000..d6e49ac --- /dev/null +++ b/src/main/com/jdbernard/timeanalyzer/Category.groovy @@ -0,0 +1,15 @@ +package com.jdbernard.timeanalyzer + +public abstract class Category implements Comparable { + + List entries + + public abstract boolean matchesEvent(Event e) + public abstract Entry addEvent(Event e) + + public Category() { entries = [] } + + public int compareTo(C other) { + + } +} diff --git a/src/main/com/jdbernard/timeanalyzer/Entry.java b/src/main/com/jdbernard/timeanalyzer/Entry.java new file mode 100644 index 0000000..ce20f00 --- /dev/null +++ b/src/main/com/jdbernard/timeanalyzer/Entry.java @@ -0,0 +1,6 @@ +package com.jdbernard.timanalyzer; + +public class Entry extends Event { + + public Category category; +} diff --git a/src/main/com/jdbernard/timeanalyzer/Event.java b/src/main/com/jdbernard/timeanalyzer/Event.java new file mode 100644 index 0000000..3cbfff1 --- /dev/null +++ b/src/main/com/jdbernard/timeanalyzer/Event.java @@ -0,0 +1,13 @@ +package com.jdbernard.timeanalyzer; + +import org.joda.time.DateTime; +import org.joda.time.Duration; + +public class Event { + + public String description; + public String notes; + public DateTime start; + public Duration duration; + +} diff --git a/src/main/com/jdbernard/timeanalyzer/EventTransformation.java b/src/main/com/jdbernard/timeanalyzer/EventTransformation.java new file mode 100644 index 0000000..3320dce --- /dev/null +++ b/src/main/com/jdbernard/timeanalyzer/EventTransformation.java @@ -0,0 +1,25 @@ +package com.jdbernard.timeanalyzer; + +public abstract class EventTransformation { + + private Category category; + + public EventTransformation(Category cat) { + this.category = cat; + } + + /** + * Determine if this transformation is applicable for a given event. + * @param e An event to match. + * @return *true* if this transformation is applicable to the given event, + * *false* otherwise. + */ + public abstract boolean matches(Event e); + + /** + * Transform an entry. + * @param e The Event to transform. + * @return A new Entry. + */ + public abstract Entry transform(Event e); +} diff --git a/src/main/com/jdbernard/timeanalyzer/EventTransformer.groovy b/src/main/com/jdbernard/timeanalyzer/EventTransformer.groovy new file mode 100644 index 0000000..bb1d174 --- /dev/null +++ b/src/main/com/jdbernard/timeanalyzer/EventTransformer.groovy @@ -0,0 +1,21 @@ +package com.jdbernard.timeanalyzer + +public class EventTransformer { + + List transformations + + public EventTransformer(List transformations) { + this.transformations = transformations + } + + /** + * Transform an event. The first matching transformation is used. + * @param e The event to transform. + * @return The resulting Entry. + */ + public Entry transform(Event e) { + for (t : transformations) + if (t.matches(e)) + return t.transform(t) + } +} diff --git a/src/main/com/quantumdigital/ithelp/timeanalyzer/ITHelpCategory.groovy b/src/main/com/quantumdigital/ithelp/timeanalyzer/ITHelpCategory.groovy new file mode 100644 index 0000000..a04b414 --- /dev/null +++ b/src/main/com/quantumdigital/ithelp/timeanalyzer/ITHelpCategory.groovy @@ -0,0 +1,15 @@ +package com.quantumdigital.ithelp.timeanalyzer + +import com.jdbernard.timeanalyzer.Category + +public class ITHelpCategory extends Category { + + public boolean matchesEvent(Event e) { + return (e.description ==~ /^ITHelp:.*/) + } + + public ITHelpEntry addEvent(Event e) { + assert eventMatches(e) + + } +} diff --git a/src/main/com/quantumdigital/ithelp/timeanalyzer/ITHelpEntry.groovy b/src/main/com/quantumdigital/ithelp/timeanalyzer/ITHelpEntry.groovy new file mode 100644 index 0000000..df49d20 --- /dev/null +++ b/src/main/com/quantumdigital/ithelp/timeanalyzer/ITHelpEntry.groovy @@ -0,0 +1,5 @@ +package com.quantumdigital.ithelp.timeanalyzer + +import com.jdbernard.timeanalyzer.Event + +public class ITHelpEntry extends Entry diff --git a/src/main/com/quantumdigital/ithelp/timeanalyzer/ITHelpEventTransformation.groovy b/src/main/com/quantumdigital/ithelp/timeanalyzer/ITHelpEventTransformation.groovy new file mode 100644 index 0000000..884ac98 --- /dev/null +++ b/src/main/com/quantumdigital/ithelp/timeanalyzer/ITHelpEventTransformation.groovy @@ -0,0 +1,12 @@ +package com.quantumdigital.ithelp.timeanalyzer + +import com.jdbernard.timeanalyzer.EventTransformation + +public class ITHelpEventTransformation extends EventTransformation { + + public boolean matches(Event e) { + return e.description ==~ /^ITHelp: .*/ + } + + public Entry +} diff --git a/src/main/com/quantumdigital/ithelp/timeanalyzer/TicketCategory.groovy b/src/main/com/quantumdigital/ithelp/timeanalyzer/TicketCategory.groovy new file mode 100644 index 0000000..c172a72 --- /dev/null +++ b/src/main/com/quantumdigital/ithelp/timeanalyzer/TicketCategory.groovy @@ -0,0 +1,15 @@ +package com.quantumdigital.ithelp.timeanalyzer + +import com.jdbernard.timeanalyzer.Category + +public class TicketCategory extends Category { + + public boolean matchesEvent(Event e) { + return (e.description ==~ /ITHelp:.*#\d+.*/) + } + + public TicketEntry addEvent(Event e) { + assert eventMatches(e) + + TicketEntry entry = new TicketEntry(e) + entries << entry