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 el) { return e.description ==~ TICKET_PATTERN } public Category newCategory(Event e, List el) { def m = e.description =~ TICKET_PATTERN return new TicketCategory(m[0][1] as int) } public List findEntriesToRecategorize(Event e, List existingEntries) { def m = e.description =~ TICKET_PATTERN int ticketId = m[0][1] as int return existingEntries.findAll { it.description ==~ /.*#${ticketId}.*/ } } }