Many changes, bad commit message.
This commit is contained in:
parent
e4a3b967de
commit
f3a049777a
@ -7,9 +7,9 @@ import org.joda.time.Duration
|
|||||||
*/
|
*/
|
||||||
public abstract class Category implements Comparable<Category> {
|
public abstract class Category implements Comparable<Category> {
|
||||||
|
|
||||||
public List<Event> events
|
public List events
|
||||||
public List<Category> categories
|
public List categories
|
||||||
public List<CategorizationPlan> categorizationPlans
|
public List categorizationPlans
|
||||||
public String description
|
public String description
|
||||||
|
|
||||||
public Category() {
|
public Category() {
|
||||||
@ -28,7 +28,7 @@ public abstract class Category implements Comparable<Category> {
|
|||||||
|
|
||||||
public abstract boolean matchesEvent(Event e)
|
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
|
// see if we have or can create a subcategory that will hold this event
|
||||||
Event addedEvent = addToSubcategory(event)
|
Event addedEvent = addToSubcategory(event)
|
||||||
@ -42,7 +42,7 @@ public abstract class Category implements Comparable<Category> {
|
|||||||
return addedEvent
|
return addedEvent
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean addToSubcategory(Event e) {
|
public Event addToSubcategory(Event e) {
|
||||||
|
|
||||||
// find all matching subcategories
|
// find all matching subcategories
|
||||||
def matchingCategories = categories.findAll { it.matchesEvent(e) }
|
def matchingCategories = categories.findAll { it.matchesEvent(e) }
|
||||||
@ -77,7 +77,7 @@ public abstract class Category implements Comparable<Category> {
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
public Category filter(List<CategoryFilters> filters) {
|
public Category filter(List<CategoryFilter> filters) {
|
||||||
|
|
||||||
// create new filtered category
|
// create new filtered category
|
||||||
FilteredCategory fc = new FilteredCategory(description)
|
FilteredCategory fc = new FilteredCategory(description)
|
||||||
|
@ -6,11 +6,11 @@ public class DescriptionBasedCategory extends Category {
|
|||||||
|
|
||||||
public DescriptionBasedCategory(String description) {
|
public DescriptionBasedCategory(String description) {
|
||||||
super()
|
super()
|
||||||
this.description = description
|
this.description = description.replaceAll(/\p{Punct}/, '')
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean matchesEvent(Event e) {
|
public boolean matchesEvent(Event e) {
|
||||||
return e.description == description
|
return e.description.replaceAll(/\p{Punct}/, '') == description
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,8 @@ public class Event implements Cloneable {
|
|||||||
public final String description
|
public final String description
|
||||||
public final String notes
|
public final String notes
|
||||||
public final DateTime start
|
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()
|
public static PeriodFormatter periodFormatter = PeriodFormat.getDefault()
|
||||||
|
|
||||||
|
@ -20,12 +20,11 @@ public class TimelineEventProcessor {
|
|||||||
List<Event> events = []
|
List<Event> events = []
|
||||||
|
|
||||||
timeline.each { marker ->
|
timeline.each { marker ->
|
||||||
Event e = new Event()
|
Event e = new Event(
|
||||||
|
description: marker.mark,
|
||||||
e.description = marker.mark
|
notes: marker.notes,
|
||||||
e.notes = marker.notes
|
start: new DateTime(marker.timestamp),
|
||||||
e.start = new DateTime(marker.timestamp)
|
duration: new Duration(0))
|
||||||
e.duration = new Duration(0)
|
|
||||||
|
|
||||||
// if this is not the first event, then we need to update the
|
// if this is not the first event, then we need to update the
|
||||||
// duration of the previous event
|
// duration of the previous event
|
||||||
|
@ -14,11 +14,11 @@ public class TwoLevelCategory extends Category {
|
|||||||
return e.description ==~ descriptionPattern
|
return e.description ==~ descriptionPattern
|
||||||
}
|
}
|
||||||
|
|
||||||
public Entry addEvent(Event e) {
|
public Event addEvent(Event e) {
|
||||||
def m = e.description =~ descriptionPattern
|
def m = e.description =~ descriptionPattern
|
||||||
|
|
||||||
e = new Event(e, description: m[0][1])
|
e = new Event(e, description: m[0][1])
|
||||||
|
|
||||||
return super.addEvent(e)
|
super.addEvent(e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,9 +17,8 @@ public class TicketCategory extends Category {
|
|||||||
return (e.description ==~ /.*#${ticketId}.*/)
|
return (e.description ==~ /.*#${ticketId}.*/)
|
||||||
}
|
}
|
||||||
|
|
||||||
public TicketEvent addEvent(Event e) {
|
public Event addEvent(Event e) {
|
||||||
TicketEvent te = new TicketEvent(this, e)
|
TicketEvent te = new TicketEvent(e)
|
||||||
events << te
|
events << te
|
||||||
return te
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ public class TicketEvent extends Event {
|
|||||||
|
|
||||||
public TicketEvent(String desc, String notes, String start, String duration) {
|
public TicketEvent(String desc, String notes, String start, String duration) {
|
||||||
|
|
||||||
super(desc, note, start, duration)
|
super(desc, notes, start, duration)
|
||||||
|
|
||||||
def m = desc =~ /.*#(\d+).*/
|
def m = desc =~ /.*#(\d+).*/
|
||||||
this.id = m[0][1] as int
|
this.id = m[0][1] as int
|
||||||
@ -27,4 +27,11 @@ public class TicketEvent extends Event {
|
|||||||
def m = description =~ /.*#(\d+).*/
|
def m = description =~ /.*#(\d+).*/
|
||||||
this.id = m[0][1] as int
|
this.id = m[0][1] as int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TicketEvent(Event e) {
|
||||||
|
super([:], e)
|
||||||
|
|
||||||
|
def m = description =~ /.*#(\d+).*/
|
||||||
|
this.id = m[0][1] as int
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user