Finised initial implementation. Need to test.

This commit is contained in:
Jonathan Bernard
2011-01-10 00:24:08 -06:00
parent 9f4008a775
commit 68b51640af
12 changed files with 242 additions and 78 deletions

View File

@ -1,15 +1,58 @@
package com.quantumdigital.ithelp.timeanalyzer
import com.jdbernard.timeanalyzer.Category
import com.jdbernard.timeanalyzer.Entry
import com.jdbernard.timeanalyzer.Event
public class ITHelpCategory extends Category {
private def ithelpPattern = ~/^ITHelp:(.*)$/
private def ticketPattern = ~/^ITHelp:.*#(\d+).*/
public boolean matchesEvent(Event e) {
return (e.description ==~ /^ITHelp:.*/)
return (e.description ==~ ithelpPattern)
}
public ITHelpEntry addEvent(Event e) {
assert eventMatches(e)
public Entry addEvent(Event e) {
Entry entry
// try to add to an existing category
entry = addToSubcategory(e)
// no existing category matches
if (!entry) {
// see if it is a new ticket entry
def ticketMatch = e.description =~ ticketPattern
// if is a new ticket
if(ticketMatch) {
// parse the ticket number
int ticketId = ticketMatch[0][1] as int
// create the category
TicketCategory category = new TicketCategory(ticketId)
// add the category to our list
categories << category
// add the event to the category
entry = category.addEvent(e)
}
// not a new ticket, use the general logic for adding
else {
// add a general entry to this category
entry = super.addEvent(e)
// adjust the description (remove the ITHelp tag)
def m = entry.description =~ ithelpPattern
entry.description = m[0][1]
}
}
return entry
}
}

View File

@ -1,5 +0,0 @@
package com.quantumdigital.ithelp.timeanalyzer
import com.jdbernard.timeanalyzer.Event
public class ITHelpEntry extends Entry

View File

@ -1,12 +0,0 @@
package com.quantumdigital.ithelp.timeanalyzer
import com.jdbernard.timeanalyzer.EventTransformation
public class ITHelpEventTransformation extends EventTransformation {
public boolean matches(Event e) {
return e.description ==~ /^ITHelp: .*/
}
public Entry
}

View File

@ -1,15 +1,20 @@
package com.quantumdigital.ithelp.timeanalyzer
import com.jdbernard.timeanalyzer.Category
import com.jdbernard.timeanalyzer.Event
public class TicketCategory extends Category {
public boolean matchesEvent(Event e) {
return (e.description ==~ /ITHelp:.*#\d+.*/)
public final int ticketId
public TicketCategory(int ticketId) {
super()
this.ticketId = ticketId
this.description = "Ticket #${ticketId}"
}
public TicketEntry addEvent(Event e) {
assert eventMatches(e)
public boolean matchesEvent(Event e) {
return (e.description ==~ /ITHelp:.*#${ticketId}.*/)
}
TicketEntry entry = new TicketEntry(e)
entries << entry
}

View File

@ -0,0 +1,17 @@
package com.quantumdigital.ithelp.timeanalyzer
import com.jdbernard.timeanalyzer.Entry
import com.jdbernard.timeanalyzer.Event
public class TicketEntry extends Entry {
public int id
public TicketEntry(ITHelpCategory category, Event e) {
super(category, e)
def m = e.description =~ /^ITHelp:(.*#(\d+).*)$/
this.description = m[0][1]
this.id = m[0][2] as int
}
}