Refactored to remove Entry and use Event everywhere.
This commit is contained in:
@ -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}.*/ }
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user