diff --git a/src/main/com/jdbernard/timeanalyzer/Category.groovy b/src/main/com/jdbernard/timeanalyzer/Category.groovy index f84e38b..97fda2e 100644 --- a/src/main/com/jdbernard/timeanalyzer/Category.groovy +++ b/src/main/com/jdbernard/timeanalyzer/Category.groovy @@ -7,9 +7,9 @@ import org.joda.time.Duration */ public abstract class Category implements Comparable { - public List events - public List categories - public List categorizationPlans + public List events + public List categories + public List categorizationPlans public String description public Category() { @@ -28,7 +28,7 @@ public abstract class Category implements Comparable { public abstract boolean matchesEvent(Event e) - public void addEvent(Event event) { + public Event addEvent(Event event) { // see if we have or can create a subcategory that will hold this event Event addedEvent = addToSubcategory(event) @@ -42,12 +42,12 @@ public abstract class Category implements Comparable { return addedEvent } - public boolean addToSubcategory(Event e) { + public Event addToSubcategory(Event e) { // find all matching subcategories def matchingCategories = categories.findAll { it.matchesEvent(e) } - if (matchingCategories) + if (matchingCategories) return matchingCategories[0].addEvent(e) // no matching subcategories, can we create a new one based on one @@ -77,7 +77,7 @@ public abstract class Category implements Comparable { return null } - public Category filter(List filters) { + public Category filter(List filters) { // create new filtered category FilteredCategory fc = new FilteredCategory(description) diff --git a/src/main/com/jdbernard/timeanalyzer/DescriptionBasedCategory.groovy b/src/main/com/jdbernard/timeanalyzer/DescriptionBasedCategory.groovy index 64675f1..8512909 100644 --- a/src/main/com/jdbernard/timeanalyzer/DescriptionBasedCategory.groovy +++ b/src/main/com/jdbernard/timeanalyzer/DescriptionBasedCategory.groovy @@ -6,11 +6,11 @@ public class DescriptionBasedCategory extends Category { public DescriptionBasedCategory(String description) { super() - this.description = description + this.description = description.replaceAll(/\p{Punct}/, '') } public boolean matchesEvent(Event e) { - return e.description == description + return e.description.replaceAll(/\p{Punct}/, '') == description } } diff --git a/src/main/com/jdbernard/timeanalyzer/Event.groovy b/src/main/com/jdbernard/timeanalyzer/Event.groovy index 3cd0518..b6180d7 100644 --- a/src/main/com/jdbernard/timeanalyzer/Event.groovy +++ b/src/main/com/jdbernard/timeanalyzer/Event.groovy @@ -10,7 +10,8 @@ public class Event implements Cloneable { public final String description public final String notes public final DateTime start - public final Duration duration + public Duration duration // bit of a hack, allows modification for the + // TimelineEventProcessor public static PeriodFormatter periodFormatter = PeriodFormat.getDefault() diff --git a/src/main/com/jdbernard/timeanalyzer/TimelineEventProcessor.groovy b/src/main/com/jdbernard/timeanalyzer/TimelineEventProcessor.groovy index 84c81fa..f90159b 100644 --- a/src/main/com/jdbernard/timeanalyzer/TimelineEventProcessor.groovy +++ b/src/main/com/jdbernard/timeanalyzer/TimelineEventProcessor.groovy @@ -20,12 +20,11 @@ public class TimelineEventProcessor { List events = [] timeline.each { marker -> - Event e = new Event() - - e.description = marker.mark - e.notes = marker.notes - e.start = new DateTime(marker.timestamp) - e.duration = new Duration(0) + Event e = new Event( + description: marker.mark, + notes: marker.notes, + start: new DateTime(marker.timestamp), + duration: new Duration(0)) // if this is not the first event, then we need to update the // duration of the previous event diff --git a/src/main/com/jdbernard/timeanalyzer/TwoLevelCategory.groovy b/src/main/com/jdbernard/timeanalyzer/TwoLevelCategory.groovy index 6a261f3..5c22953 100644 --- a/src/main/com/jdbernard/timeanalyzer/TwoLevelCategory.groovy +++ b/src/main/com/jdbernard/timeanalyzer/TwoLevelCategory.groovy @@ -14,11 +14,11 @@ public class TwoLevelCategory extends Category { return e.description ==~ descriptionPattern } - public Entry addEvent(Event e) { + public Event addEvent(Event e) { def m = e.description =~ descriptionPattern e = new Event(e, description: m[0][1]) - return super.addEvent(e) + super.addEvent(e) } } diff --git a/src/main/com/quantumdigital/ithelp/timeanalyzer/TicketCategory.groovy b/src/main/com/quantumdigital/ithelp/timeanalyzer/TicketCategory.groovy index 2beddd7..6d75a40 100644 --- a/src/main/com/quantumdigital/ithelp/timeanalyzer/TicketCategory.groovy +++ b/src/main/com/quantumdigital/ithelp/timeanalyzer/TicketCategory.groovy @@ -17,9 +17,8 @@ public class TicketCategory extends Category { return (e.description ==~ /.*#${ticketId}.*/) } - public TicketEvent addEvent(Event e) { - TicketEvent te = new TicketEvent(this, e) + public Event addEvent(Event e) { + TicketEvent te = new TicketEvent(e) events << te - return te } } diff --git a/src/main/com/quantumdigital/ithelp/timeanalyzer/TicketEntry.groovy b/src/main/com/quantumdigital/ithelp/timeanalyzer/TicketEvent.groovy similarity index 76% rename from src/main/com/quantumdigital/ithelp/timeanalyzer/TicketEntry.groovy rename to src/main/com/quantumdigital/ithelp/timeanalyzer/TicketEvent.groovy index dbb05d4..43c6dfe 100644 --- a/src/main/com/quantumdigital/ithelp/timeanalyzer/TicketEntry.groovy +++ b/src/main/com/quantumdigital/ithelp/timeanalyzer/TicketEvent.groovy @@ -8,7 +8,7 @@ public class TicketEvent extends Event { public TicketEvent(String desc, String notes, String start, String duration) { - super(desc, note, start, duration) + super(desc, notes, start, duration) def m = desc =~ /.*#(\d+).*/ this.id = m[0][1] as int @@ -27,4 +27,11 @@ public class TicketEvent extends Event { def m = description =~ /.*#(\d+).*/ this.id = m[0][1] as int } + + public TicketEvent(Event e) { + super([:], e) + + def m = description =~ /.*#(\d+).*/ + this.id = m[0][1] as int + } }