Refactored to remove Entry and use Event everywhere.

This commit is contained in:
Jonathan Bernard
2011-01-18 07:20:56 -06:00
parent ab1c7f2393
commit e4a3b967de
13 changed files with 127 additions and 121 deletions

View File

@ -3,28 +3,27 @@ package com.quantumdigital.ithelp.timeanalyzer
import com.jdbernard.timeanalyzer.Category
import com.jdbernard.timeanalyzer.CategorizationPlan
import com.jdbernard.timeanalyzer.Event
import com.jdbernard.timeanalyzer.Entry
public class TicketCategorizationPlan implements CategorizationPlan {
private static def TICKET_PATTERN = ~/.*#(\d+).*/
public boolean deservesNewCategory(Event e, List<Entry> el) {
public boolean deservesNewCategory(Event e, List<Event> el) {
return e.description ==~ TICKET_PATTERN
}
public Category newCategory(Event e, List<Entry> el) {
public Category newCategory(Event e, List<Event> el) {
def m = e.description =~ TICKET_PATTERN
return new TicketCategory(m[0][1] as int)
}
public List<Entry> findEntriesToRecategorize(Event e,
List<Entry> existingEntries) {
public List<Event> findEventsToRecategorize(Event e,
List<Event> existingEvents) {
def m = e.description =~ TICKET_PATTERN
int ticketId = m[0][1] as int
return existingEntries.findAll {
return existingEvents.findAll {
it.description ==~ /.*#${ticketId}.*/ }
}
}

View File

@ -17,9 +17,9 @@ public class TicketCategory extends Category {
return (e.description ==~ /.*#${ticketId}.*/)
}
public TicketEntry addEvent(Event e) {
TicketEntry te = new TicketEntry(this, e)
entries << te
public TicketEvent addEvent(Event e) {
TicketEvent te = new TicketEvent(this, e)
events << te
return te
}
}

View File

@ -1,16 +1,30 @@
package com.quantumdigital.ithelp.timeanalyzer
import com.jdbernard.timeanalyzer.Entry
import com.jdbernard.timeanalyzer.Event
public class TicketEntry extends Entry {
public class TicketEvent extends Event {
public int id
public final int id
public TicketEntry(TicketCategory category, Event e) {
super(category, e)
public TicketEvent(String desc, String notes, String start, String duration) {
def m = e.description =~ /.*#(\d+).*/
super(desc, note, start, duration)
def m = desc =~ /.*#(\d+).*/
this.id = m[0][1] as int
}
public TicketEvent(Map params) {
super(params)
def m = description =~ /.*#(\d+).*/
this.id = m[0][1] as int
}
public TicketEvent(Map params, Event e) {
super(params, e)
def m = description =~ /.*#(\d+).*/
this.id = m[0][1] as int
}
}