2011-01-18 07:20:56 -06:00

30 lines
875 B
Groovy

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