Migrated to jdb-build-1.9, documentation.

This commit is contained in:
Jonathan Bernard 2012-08-30 06:33:35 -07:00
parent d076b739f5
commit 10677e5705
31 changed files with 128 additions and 102 deletions

View File

@ -1,7 +1,7 @@
<project name="Time Analyzer" default="compile">
<property file="project.properties"/>
<import file="jdb-build-1.5.xml"/>
<import file="jdb-build-1.9.xml"/>
<target name="init"/>

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<project name="Jonathan Bernard Build Common">
<project name="Jonathan Bernard Build Common"
xmlns:ivy="antlib:org.apache.ivy.ant">
<property environment="env"/>
@ -16,7 +17,7 @@
<property name="build.dir" value="${basedir}/build"/>
<property name="lib.dir" value="${basedir}/lib"/>
<property name="resources.dir" value="${basedir}/resources"/>
<property name="lib.local" value="true"/>
<property name="splash.image" value="splash.png"/>
<!--======== PATHS ========-->
<path id="groovy.classpath">
@ -32,13 +33,13 @@
</path>
<path id="compile-libs">
<fileset dir="${build.dir}/lib/compile">
<fileset dir="${build.dir}/lib/compile/jar">
<include name="*.jar"/>
</fileset>
</path>
<path id="runtime-libs">
<fileset dir="${build.dir}/lib/runtime">
<fileset dir="${build.dir}/lib/runtime/jar">
<include name="*.jar"/>
</fileset>
</path>
@ -53,25 +54,43 @@
classname="org.codehaus.groovy.ant.Groovy"/>
</target>
<target name="init"/>
<target name="clean" depends="-init">
<delete dir="${build.dir}"/>
</target>
<!--======== LIBRARY TARGETS ========-->
<target name="lib" depends="-lib-local,-lib-ivy"/>
<target name="-lib" depends="-lib-local,-lib-ivy,lib"/>
<target name="lib"/>
<target name="-lib-ivy" unless="${lib.local}"/>
<target name="-init-ivy">
<ivy:settings id="ivy.settings" file="ivysettings.xml"/>
</target>
<target name="-lib-ivy" depends="-init-ivy" unless="${lib.local}">
<ivy:retrieve settingsRef="ivy.settings"
pattern="${lib.dir}/[conf]/[type]/[artifact]-[revision].[ext]"
conf="compile,runtime"/>
</target>
<target name="-lib-groovy" if="${lib.local}">
<copy todir="${build.dir}/lib/runtime/jar">
<fileset dir="${env.GROOVY_HOME}/embeddable"/>
</copy>
</target>
<target name="-lib-local" if="${lib.local}">
<echo message="Resolving libraries locally."/>
<mkdir dir="${build.dir}/lib/compile"/>
<mkdir dir="${build.dir}/lib/runtime"/>
<copy todir="${build.dir}/lib/compile" failonerror="false">
<fileset dir="${lib.dir}/compile"/>
<mkdir dir="${build.dir}/lib/compile/jar"/>
<mkdir dir="${build.dir}/lib/runtime/jar"/>
<copy todir="${build.dir}/lib/compile/jar" failonerror="false">
<fileset dir="${lib.dir}/compile/jar"/>
</copy>
<copy todir="${build.dir}/lib/runtime" failonerror="false">
<fileset dir="${lib.dir}/runtime"/>
<copy todir="${build.dir}/lib/runtime/jar" failonerror="false">
<fileset dir="${lib.dir}/runtime/jar"/>
</copy>
</target>
@ -90,14 +109,15 @@
<propertyfile file="${versioning.file}">
<entry key="version" value="${new-version}" operation="="
type="string"/>
<entry key="build.number" value="0" type="int" operation="="/>
</propertyfile>
</target>
<!--======== COMPILATION TARGETS ========-->
<target name="-compile-groovy" depends="-init,-init-groovy,lib">
<target name="-compile-groovy" depends="-init,-init-groovy,-lib,-lib-groovy">
<mkdir dir="${build.dir}/main/classes"/>
<groovyc srcdir="${src.dir}/main" destdir="${build.dir}/main/classes"
includeAntRuntime="false">
fork="true" includeAntRuntime="false">
<classpath>
<path refid="groovy.classpath"/>
@ -107,7 +127,7 @@
</groovyc>
</target>
<target name="-compile-java" depends="-init,lib">
<target name="-compile-java" depends="-init,-lib">
<mkdir dir="${build.dir}/main/classes"/>
<javac srcdir="${src.dir}/main" destdir="${build.dir}/main/classes"
includeAntRuntime="false" classpathref="compile-libs"/>
@ -176,18 +196,47 @@
</target>
<!--======== BUILD TARGETS ========-->
<target name="-build-modular"
<target name="-build-modular-lib" unless="executable.jar"
depends="compile,increment-build-number,resources">
<jar destfile="${build.dir}/${name}-${version}.${build.number}.jar"
basedir="${build.dir}/main/classes"/>
</target>
<target name="-build-modular-executable" if="executable.jar"
depends="compile,increment-build-number,resources">
<pathconvert property="jar.classpath" pathsep=" " refid="runtime-libs">
<mapper>
<chainedmapper>
<!-- remove absolute path -->
<flattenmapper />
<!-- add lib/ prefix -->
<globmapper from="*" to="lib/*" />
</chainedmapper>
</mapper>
</pathconvert>
<jar destfile="${build.dir}/${name}-${version}.${build.number}.jar"
basedir="${build.dir}/main/classes">
<manifest>
<attribute name="Main-Class" value="${main.class}"/>
<attribute name="Class-Path" value="${jar.classpath}"/>
<attribute name="SplashScreen-Image" value="${splash.image}"/>
</manifest>
</jar>
</target>
<target name="-build-modular"
depends="-build-modular-lib,-build-modular-executable"/>
<target name="-build-packed-libs"
depends="compile,increment-build-number,resources">
<unjar destdir="${build.dir}/main/classes">
<fileset dir="${build.dir}/lib/runtime"/>
<fileset dir="${build.dir}/lib/runtime/jar"/>
</unjar>
<jar destfile="${build.dir}/${name}-${version}.${build.number}.jar"

Binary file not shown.

View File

@ -1,4 +1,5 @@
#Sat, 22 Jan 2011 19:30:42 -0600
#Wed, 29 Aug 2012 15:10:32 -0700
name=time-analyzer
version=0.1
build.number=4
build.number=5
lib.local=true

Binary file not shown.

View File

@ -0,0 +1,46 @@
import com.jdbernard.timeanalyzer.processors.*
import com.jdbernard.timeanalyzer.categories.*
import com.jdbernard.timeanalyzer.categorizationplans.*
import com.jdbernard.timeanalyzer.chart.*
import com.jdbernard.timeanalyzer.events.*
import com.jdbernard.timestamper.core.*
import com.quantumdigital.ithelp.timeanalyzer.*
import org.joda.time.*
import org.joda.time.format.*
import org.jfree.chart.*
import org.jfree.data.general.*
import org.jfree.util.SortOrder
tep = new TimelineEventProcessor()
tep.exclusions << ~/.*Home.*/
pf = PeriodFormat.getDefault()
topcat = new FilteredCategory("Top Category")
twoLevelCatPlan = new TwoLevelCategorizationPlan()
descriptionBasedCatPlan = new DescriptionBasedCategorizationPlan()
topcat.categorizationPlans << twoLevelCatPlan
topcat.categorizationPlans << descriptionBasedCatPlan
loadEvents = { file, processor ->
fileSource = new FileTimelineSource(file.toURI())
timeline = fileSource.read()
return processor.process(timeline) }
makePieDataset = { category ->
DefaultPieDataset dpds = new DefaultPieDataset()
category.categories.each { cat ->
dpds.setValue(cat.description, cat.duration.standardSeconds) }
category.events.each { entry ->
dpds.setValue(entry.description, entry.duration.standardSeconds) }
dpds.sortByValues(SortOrder.DESCENDING)
return dpds }
makeFrame = { categoryName, dataset ->
return new ChartFrame(categoryName,
ChartFactory.createPieChart("Time Spent", dataset, true, true, false)) }
createDailyCategory = { file, processor ->
events = loadEvents(file)

View File

@ -47,11 +47,9 @@ public abstract class Category implements Comparable<Category> {
* made and the `Event` matches.*/
public Event addEvent(Event event) {
// see if we have or can create a subcategory that will hold this event
Event addedEvent = addToSubcategory(event)
// no, let's just add it on ourself
if (!addedEvent) {
// Try first to add it to a subcategory (or create a new subcategory).
if (!addToSubcategory(event)) {
// Cannot add to a subcategory, add to ourselves.
events << event
addedEvent = event }

View File

@ -4,13 +4,9 @@ import com.jdbernard.timeanalyzer.events.Event
public class GeneralCategory extends Category {
public GeneralCategory() {
this("General")
}
public GeneralCategory() { this("General") }
public GeneralCategory(String description) {
super(description)
}
public GeneralCategory(String description) { super(description) }
public boolean matchesEvent(Event e) { true }

View File

@ -11,15 +11,12 @@ public class TimeIntervalCategoryFilter implements CategoryFilter {
ReadableInterval interval
public TimeIntervalCategoryFilter(ReadableInterval interval) {
this.interval = interval
}
this.interval = interval }
public TimeIntervalCategoryFilter(ReadableInstant start,
ReadableInstant end) {
this.interval = new Interval(start, end)
}
this.interval = new Interval(start, end) }
public boolean matchesEvent(Event event) {
return interval.contains(event.start)
}
return interval.contains(event.start) }
}

View File

@ -13,9 +13,7 @@ public class TimelineEventProcessor {
public TimelineEventProcessor() {}
public TimelineEventProcessor(List exclusions) {
this.exclusions = exclusions
}
public TimelineEventProcessor(List exclusions) { this.exclusions = exclusions }
public List<Event> process(Timeline timeline) {
List<Event> events = []
@ -31,15 +29,12 @@ public class TimelineEventProcessor {
// duration of the previous event
if (events.size > 0) {
Event lastEvent = events[-1]
lastEvent.duration = new Duration(lastEvent.start, e.start)
}
lastEvent.duration = new Duration(lastEvent.start, e.start) }
events << e
}
events << e }
def excluded = events.findAll { event ->
exclusions.any { exclusion -> event.description ==~ exclusion }
}
exclusions.any { exclusion -> event.description ==~ exclusion } }
return events - excluded
}

View File

@ -1,56 +0,0 @@
import com.jdbernard.timeanalyzer.*
import com.jdbernard.timestamper.core.*
import com.quantumdigital.ithelp.timeanalyzer.*
import org.joda.time.*
import org.joda.time.format.*
import org.jfree.chart.*
import org.jfree.data.general.*
import org.jfree.util.SortOrder
tep = new TimelineEventProcessor()
tep.exclusions << ~/Going Home/
pf = PeriodFormat.getDefault()
fileSource = new FileTimelineSource(new File("timeline.jdbernard.txt").toURI())
timeline = fileSource.read()
events = tep.process(timeline)
topcat = new FilteredCategory("Top Category")
topcat.filters << new TimeIntervalCategoryFilter(
new DateTime(2011, 1, 24, 0, 0, 0, 0), new DateTime(2011, 1, 25, 0, 0, 0, 0))
twoLevelCatPlan = new TwoLevelCategorizationPlan()
descriptionBasedCatPlan = new DescriptionBasedCategorizationPlan()
topcat.categorizationPlans << twoLevelCatPlan
topcat.categorizationPlans << descriptionBasedCatPlan
ithelpcat = new TwoLevelCategory("ITHelp")
ticketCatPlan = new TicketCategorizationPlan()
ithelpcat.categorizationPlans << ticketCatPlan
ithelpcat.categorizationPlans << descriptionBasedCatPlan
topcat.categories << ithelpcat
events.each { if (topcat.matchesEvent(it)) topcat.addEvent(it) }
makePieDataset = { category ->
DefaultPieDataset dpds = new DefaultPieDataset()
category.categories.each { cat ->
dpds.setValue(cat.description, cat.duration.standardSeconds) }
category.events.each { entry ->
dpds.setValue(entry.description, entry.duration.standardSeconds) }
dpds.sortByValues(SortOrder.DESCENDING)
return dpds
}
topcatDataset = makePieDataset(topcat)
ithelpDataset = makePieDataset(ithelpcat)
topcatFrame = new ChartFrame("Top Category",
ChartFactory.createPieChart("Time Spent", topcatDataset, true, true, false))
ithelpFrame = new ChartFrame("ITHelp",
ChartFactory.createPieChart("Time Spent", ithelpDataset, true, true, false))