Finised initial implementation. Need to test.
This commit is contained in:
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +0,0 @@
|
||||
package com.quantumdigital.ithelp.timeanalyzer
|
||||
|
||||
import com.jdbernard.timeanalyzer.Event
|
||||
|
||||
public class ITHelpEntry extends Entry
|
@ -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
|
||||
}
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user