Initial commit
This commit is contained in:
commit
9f4008a775
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
build/
|
||||||
|
*.sw*
|
BIN
lib/compile/groovylint-0.5.12.jar
Normal file
BIN
lib/compile/groovylint-0.5.12.jar
Normal file
Binary file not shown.
BIN
lib/compile/joda-time-1.6.2.jar
Normal file
BIN
lib/compile/joda-time-1.6.2.jar
Normal file
Binary file not shown.
BIN
lib/compile/slf4j-api-1.6.1.jar
Normal file
BIN
lib/compile/slf4j-api-1.6.1.jar
Normal file
Binary file not shown.
BIN
lib/runtime/joda-time-1.6.2.jar
Normal file
BIN
lib/runtime/joda-time-1.6.2.jar
Normal file
Binary file not shown.
BIN
lib/runtime/logback-classic-0.9.26.jar
Normal file
BIN
lib/runtime/logback-classic-0.9.26.jar
Normal file
Binary file not shown.
BIN
lib/runtime/logback-core-0.9.26.jar
Normal file
BIN
lib/runtime/logback-core-0.9.26.jar
Normal file
Binary file not shown.
BIN
lib/runtime/slf4j-api-1.6.1.jar
Normal file
BIN
lib/runtime/slf4j-api-1.6.1.jar
Normal file
Binary file not shown.
15
src/main/com/jdbernard/timeanalyzer/Category.groovy
Normal file
15
src/main/com/jdbernard/timeanalyzer/Category.groovy
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
package com.jdbernard.timeanalyzer
|
||||||
|
|
||||||
|
public abstract class Category implements Comparable<T extends Category> {
|
||||||
|
|
||||||
|
List<Entry> entries
|
||||||
|
|
||||||
|
public abstract boolean matchesEvent(Event e)
|
||||||
|
public abstract Entry addEvent(Event e)
|
||||||
|
|
||||||
|
public Category() { entries = [] }
|
||||||
|
|
||||||
|
public int compareTo(C other) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
6
src/main/com/jdbernard/timeanalyzer/Entry.java
Normal file
6
src/main/com/jdbernard/timeanalyzer/Entry.java
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
package com.jdbernard.timanalyzer;
|
||||||
|
|
||||||
|
public class Entry extends Event {
|
||||||
|
|
||||||
|
public Category category;
|
||||||
|
}
|
13
src/main/com/jdbernard/timeanalyzer/Event.java
Normal file
13
src/main/com/jdbernard/timeanalyzer/Event.java
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
package com.jdbernard.timeanalyzer;
|
||||||
|
|
||||||
|
import org.joda.time.DateTime;
|
||||||
|
import org.joda.time.Duration;
|
||||||
|
|
||||||
|
public class Event {
|
||||||
|
|
||||||
|
public String description;
|
||||||
|
public String notes;
|
||||||
|
public DateTime start;
|
||||||
|
public Duration duration;
|
||||||
|
|
||||||
|
}
|
25
src/main/com/jdbernard/timeanalyzer/EventTransformation.java
Normal file
25
src/main/com/jdbernard/timeanalyzer/EventTransformation.java
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
package com.jdbernard.timeanalyzer;
|
||||||
|
|
||||||
|
public abstract class EventTransformation {
|
||||||
|
|
||||||
|
private Category category;
|
||||||
|
|
||||||
|
public EventTransformation(Category cat) {
|
||||||
|
this.category = cat;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if this transformation is applicable for a given event.
|
||||||
|
* @param e An event to match.
|
||||||
|
* @return *true* if this transformation is applicable to the given event,
|
||||||
|
* *false* otherwise.
|
||||||
|
*/
|
||||||
|
public abstract boolean matches(Event e);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Transform an entry.
|
||||||
|
* @param e The Event to transform.
|
||||||
|
* @return A new Entry.
|
||||||
|
*/
|
||||||
|
public abstract Entry transform(Event e);
|
||||||
|
}
|
21
src/main/com/jdbernard/timeanalyzer/EventTransformer.groovy
Normal file
21
src/main/com/jdbernard/timeanalyzer/EventTransformer.groovy
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
package com.jdbernard.timeanalyzer
|
||||||
|
|
||||||
|
public class EventTransformer {
|
||||||
|
|
||||||
|
List transformations
|
||||||
|
|
||||||
|
public EventTransformer(List transformations) {
|
||||||
|
this.transformations = transformations
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Transform an event. The first matching transformation is used.
|
||||||
|
* @param e The event to transform.
|
||||||
|
* @return The resulting Entry.
|
||||||
|
*/
|
||||||
|
public Entry transform(Event e) {
|
||||||
|
for (t : transformations)
|
||||||
|
if (t.matches(e))
|
||||||
|
return t.transform(t)
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
package com.quantumdigital.ithelp.timeanalyzer
|
||||||
|
|
||||||
|
import com.jdbernard.timeanalyzer.Category
|
||||||
|
|
||||||
|
public class ITHelpCategory extends Category {
|
||||||
|
|
||||||
|
public boolean matchesEvent(Event e) {
|
||||||
|
return (e.description ==~ /^ITHelp:.*/)
|
||||||
|
}
|
||||||
|
|
||||||
|
public ITHelpEntry addEvent(Event e) {
|
||||||
|
assert eventMatches(e)
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,5 @@
|
|||||||
|
package com.quantumdigital.ithelp.timeanalyzer
|
||||||
|
|
||||||
|
import com.jdbernard.timeanalyzer.Event
|
||||||
|
|
||||||
|
public class ITHelpEntry extends Entry
|
@ -0,0 +1,12 @@
|
|||||||
|
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
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
package com.quantumdigital.ithelp.timeanalyzer
|
||||||
|
|
||||||
|
import com.jdbernard.timeanalyzer.Category
|
||||||
|
|
||||||
|
public class TicketCategory extends Category {
|
||||||
|
|
||||||
|
public boolean matchesEvent(Event e) {
|
||||||
|
return (e.description ==~ /ITHelp:.*#\d+.*/)
|
||||||
|
}
|
||||||
|
|
||||||
|
public TicketEntry addEvent(Event e) {
|
||||||
|
assert eventMatches(e)
|
||||||
|
|
||||||
|
TicketEntry entry = new TicketEntry(e)
|
||||||
|
entries << entry
|
Loading…
x
Reference in New Issue
Block a user