r2834 - in trunk/src: main/java/org/chorem/jtimer/ui/report main/resources/ftl main/resources/org/chorem/jtimer/ui/report/resources test/java/org/chorem/jtimer test/java/org/chorem/jtimer/ui/report test/resources/testdata
Author: echatellier Date: 2012-03-18 17:44:26 +0100 (Sun, 18 Mar 2012) New Revision: 2834 Url: http://chorem.org/repositories/revision/jtimer/2834 Log: #185 : Display date (date and time) on annotations Modified: trunk/src/main/java/org/chorem/jtimer/ui/report/ReportGenerator.java trunk/src/main/java/org/chorem/jtimer/ui/report/ReportUtils.java trunk/src/main/java/org/chorem/jtimer/ui/report/ReportView.java trunk/src/main/resources/ftl/reportByDay.ftl trunk/src/main/resources/ftl/reportByDay_fr.ftl trunk/src/main/resources/ftl/reportByMonth.ftl trunk/src/main/resources/ftl/reportByMonth_fr.ftl trunk/src/main/resources/ftl/reportByProject.ftl trunk/src/main/resources/ftl/reportByProject_fr.ftl trunk/src/main/resources/ftl/reportByWeek.ftl trunk/src/main/resources/ftl/reportByWeek_fr.ftl trunk/src/main/resources/ftl/reportByYear.ftl trunk/src/main/resources/ftl/reportByYear_fr.ftl trunk/src/main/resources/org/chorem/jtimer/ui/report/resources/ReportView.properties trunk/src/main/resources/org/chorem/jtimer/ui/report/resources/ReportView_fr.properties trunk/src/test/java/org/chorem/jtimer/AbstractJTimerTest.java trunk/src/test/java/org/chorem/jtimer/ui/report/ReportGeneratorTest.java trunk/src/test/resources/testdata/4.ann trunk/src/test/resources/testdata/5.ann Modified: trunk/src/main/java/org/chorem/jtimer/ui/report/ReportGenerator.java =================================================================== --- trunk/src/main/java/org/chorem/jtimer/ui/report/ReportGenerator.java 2012-03-17 10:47:17 UTC (rev 2833) +++ trunk/src/main/java/org/chorem/jtimer/ui/report/ReportGenerator.java 2012-03-18 16:44:26 UTC (rev 2834) @@ -86,7 +86,6 @@ freemarkerConfiguration.setTemplateLoader(templateLoader); freemarkerConfiguration.setObjectWrapper(new BeansWrapper()); - } /** @@ -97,11 +96,12 @@ * @param begin begin date * @param end end date * @param includeAnnotate include annotations + * @param includeAnnotateTime include annotations time * * @return report text */ public String getReportText(Type reportType, List<TimerProject> projects, - Date begin, Date end, boolean includeAnnotate) { + Date begin, Date end, boolean includeAnnotate, boolean includeAnnotateTime) { Template template = null; String content = null; @@ -131,7 +131,7 @@ } content = getReportContent(template, projects, begin, end, - includeAnnotate); + includeAnnotate, includeAnnotateTime); } catch (IOException e) { if (log.isErrorEnabled()) { log.error("Can't get freemarker template", e); @@ -153,6 +153,7 @@ * @param end end date * @param template freemarker template to use * @param includeAnnotate include annotations + * @param includeAnnotateTime include annotations time * * @return string content * @@ -163,7 +164,7 @@ */ protected String getReportContent(Template template, List<TimerProject> projects, Date begin, Date end, - boolean includeAnnotate) throws TemplateException, IOException { + boolean includeAnnotate, boolean includeAnnotateTime) throws TemplateException, IOException { // Create the root hash Map<String, Object> root = new HashMap<String, Object>(); @@ -172,6 +173,7 @@ root.put("begin", begin); root.put("end", end); root.put("annotations", includeAnnotate); + root.put("annotationsTime", includeAnnotateTime); root.put("utils", new ReportUtils()); Writer out = new StringWriter(); Modified: trunk/src/main/java/org/chorem/jtimer/ui/report/ReportUtils.java =================================================================== --- trunk/src/main/java/org/chorem/jtimer/ui/report/ReportUtils.java 2012-03-17 10:47:17 UTC (rev 2833) +++ trunk/src/main/java/org/chorem/jtimer/ui/report/ReportUtils.java 2012-03-18 16:44:26 UTC (rev 2834) @@ -28,7 +28,9 @@ import java.util.ArrayList; import java.util.Calendar; import java.util.Date; +import java.util.HashMap; import java.util.List; +import java.util.Map; import org.apache.commons.lang3.time.DurationFormatUtils; import org.chorem.jtimer.entities.TimerTask; @@ -412,9 +414,9 @@ * @param day day * @return annotations of the day */ - public List<String> getDailyTaskAnnotation(TimerTask task, Date day) { + public Map<Date, String> getDailyTaskAnnotation(TimerTask task, Date day) { - List<String> result = TimerTaskHelper.getAnnotation(task, day); + Map<Date, String> result = TimerTaskHelper.getAnnotationMap(task, day); return result; } @@ -430,10 +432,10 @@ * @param toDay to day (inclusive) * @return annotations of the week */ - public List<String> getWeeklyTaskAnnotation(TimerTask task, Date week, + public Map<Date, String> getWeeklyTaskAnnotation(TimerTask task, Date week, Date fromDay, Date toDay) { - List<String> result = new ArrayList<String>(); + Map<Date, String> result = new HashMap<Date, String>(); Calendar beginPeriodDate = Calendar.getInstance(); beginPeriodDate.setTime(week); @@ -451,9 +453,9 @@ if ((fromDay == null || fromDay.compareTo(loopPeriodDate.getTime()) <= 0) && (toDay == null || toDay.compareTo(loopPeriodDate .getTime()) >= 0)) { - List<String> anns = TimerTaskHelper - .getAnnotation(task, loopPeriodDate.getTime()); - result.addAll(anns); + Map<Date, String> anns = TimerTaskHelper + .getAnnotationMap(task, loopPeriodDate.getTime()); + result.putAll(anns); } loopPeriodDate.add(Calendar.DAY_OF_YEAR, 1); @@ -473,9 +475,9 @@ * @param toDay to day (inclusive) * @return annotations of the month */ - public List<String> getMonthlyTaskAnnotation(TimerTask task, Date month, + public Map<Date, String> getMonthlyTaskAnnotation(TimerTask task, Date month, Date fromDay, Date toDay) { - List<String> result = new ArrayList<String>(); + Map<Date, String> result = new HashMap<Date, String>(); Calendar beginPeriodDate = Calendar.getInstance(); beginPeriodDate.setTime(month); @@ -492,9 +494,9 @@ if ((fromDay == null || fromDay.compareTo(loopPeriodDate.getTime()) <= 0) && (toDay == null || toDay.compareTo(loopPeriodDate .getTime()) >= 0)) { - List<String> anns = TimerTaskHelper - .getAnnotation(task, loopPeriodDate.getTime()); - result.addAll(anns); + Map<Date, String> anns = TimerTaskHelper + .getAnnotationMap(task, loopPeriodDate.getTime()); + result.putAll(anns); } loopPeriodDate.add(Calendar.DAY_OF_YEAR, 1); @@ -514,10 +516,10 @@ * @param toDay to day (inclusive) * @return annotations of the year */ - public List<String> getYearlyTaskAnnotation(TimerTask task, Date year, + public Map<Date, String> getYearlyTaskAnnotation(TimerTask task, Date year, Date fromDay, Date toDay) { - List<String> result = new ArrayList<String>(); + Map<Date, String> result = new HashMap<Date, String>(); Calendar beginPeriodDate = Calendar.getInstance(); beginPeriodDate.setTime(year); @@ -535,9 +537,9 @@ if ((fromDay == null || fromDay.compareTo(loopPeriodDate.getTime()) <= 0) && (toDay == null || toDay.compareTo(loopPeriodDate .getTime()) >= 0)) { - List<String> anns = TimerTaskHelper - .getAnnotation(task, loopPeriodDate.getTime()); - result.addAll(anns); + Map<Date, String> anns = TimerTaskHelper + .getAnnotationMap(task, loopPeriodDate.getTime()); + result.putAll(anns); } loopPeriodDate.add(Calendar.DAY_OF_YEAR, 1); Modified: trunk/src/main/java/org/chorem/jtimer/ui/report/ReportView.java =================================================================== --- trunk/src/main/java/org/chorem/jtimer/ui/report/ReportView.java 2012-03-17 10:47:17 UTC (rev 2833) +++ trunk/src/main/java/org/chorem/jtimer/ui/report/ReportView.java 2012-03-18 16:44:26 UTC (rev 2834) @@ -108,6 +108,8 @@ /** Include annotations on reports */ protected JCheckBox checkIncludesAnnotations; + /** Include annotations time on reports */ + protected JCheckBox checkIncludesAnnotationsTime; /** Date pickers, from... to */ protected JXDatePicker datePickerFrom, datePickerTo; @@ -247,11 +249,18 @@ new Insets(1, 1, 1, 1), 0, 0)); // miscellaneous - checkIncludesAnnotations = new JCheckBox(getResourceMap().getString( + checkIncludesAnnotations = new JCheckBox(); + checkIncludesAnnotations.setAction(getContext().getActionMap(this).get( "reportAnnotations")); panelOption.add(checkIncludesAnnotations, new GridBagConstraints(0, 5, - 4, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, + 2, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(1, 1, 1, 1), 0, 0)); + checkIncludesAnnotationsTime = new JCheckBox(getResourceMap().getString( + "reportAnnotationsTime")); + checkIncludesAnnotationsTime.setEnabled(false); + panelOption.add(checkIncludesAnnotationsTime, new GridBagConstraints(2, 5, + 2, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, + new Insets(1, 1, 1, 1), 0, 0)); // panel form projects JPanel panelProjects = new JPanel(new BorderLayout()); @@ -386,6 +395,14 @@ } /** + * Show annotation checkbox checked. + */ + @Action + public void reportAnnotations() { + checkIncludesAnnotationsTime.setEnabled(checkIncludesAnnotations.isSelected()); + } + + /** * Make report. * * Set content in {@link #reportArea} text area. @@ -415,7 +432,8 @@ // make report String report = reportGenerator.getReportText(reportType, selectedProjects, datePickerFrom.getDate(), datePickerTo - .getDate(), checkIncludesAnnotations.isSelected()); + .getDate(), checkIncludesAnnotations.isSelected(), + checkIncludesAnnotationsTime.isSelected()); if (report != null && !report.isEmpty()) { reportArea.setText(report); Modified: trunk/src/main/resources/ftl/reportByDay.ftl =================================================================== --- trunk/src/main/resources/ftl/reportByDay.ftl 2012-03-17 10:47:17 UTC (rev 2833) +++ trunk/src/main/resources/ftl/reportByDay.ftl 2012-03-18 16:44:26 UTC (rev 2834) @@ -33,9 +33,9 @@ <#local taskTime=utils.getDailyTaskTime(subtask, periodTime?date)/> <#list 1..ident as i> </#list>- ${subtask.name}<#if taskTime > 0> : ${utils.formatDuration(taskTime)}</#if> <#if annotations> - <#local taskAnnotations=utils.getDailyTaskAnnotation(subtask, periodTime?date)/> - <#list taskAnnotations as taskAnnotation> -<#list 1..ident as i> </#list> * ${taskAnnotation} + <#local taskAnnTimes=utils.getDailyTaskAnnotation(subtask, periodTime?date)/> + <#list taskAnnTimes.keySet() as taskAnnTime> +<#list 1..ident as i> </#list> * <#if annotationsTime>${taskAnnTime?time?string.short} : </#if>${taskAnnTimes.get(taskAnnTime)} </#list> </#if> <@displaySubtaskReport task=subtask periodTime=periodTime identation=ident/> Modified: trunk/src/main/resources/ftl/reportByDay_fr.ftl =================================================================== --- trunk/src/main/resources/ftl/reportByDay_fr.ftl 2012-03-17 10:47:17 UTC (rev 2833) +++ trunk/src/main/resources/ftl/reportByDay_fr.ftl 2012-03-18 16:44:26 UTC (rev 2834) @@ -33,9 +33,9 @@ <#local taskTime=utils.getDailyTaskTime(subtask, periodTime?date)/> <#list 1..ident as i> </#list>- ${subtask.name}<#if taskTime > 0> : ${utils.formatDuration(taskTime)}</#if> <#if annotations> - <#local taskAnnotations=utils.getDailyTaskAnnotation(subtask, periodTime?date)/> - <#list taskAnnotations as taskAnnotation> -<#list 1..ident as i> </#list> * ${taskAnnotation} + <#local taskAnnTimes=utils.getDailyTaskAnnotation(subtask, periodTime?date)/> + <#list taskAnnTimes.keySet() as taskAnnTime> +<#list 1..ident as i> </#list> * <#if annotationsTime>${taskAnnTime?time?string.short} : </#if>${taskAnnTimes.get(taskAnnTime)} </#list> </#if> <@displaySubtaskReport task=subtask periodTime=periodTime identation=ident/> Modified: trunk/src/main/resources/ftl/reportByMonth.ftl =================================================================== --- trunk/src/main/resources/ftl/reportByMonth.ftl 2012-03-17 10:47:17 UTC (rev 2833) +++ trunk/src/main/resources/ftl/reportByMonth.ftl 2012-03-18 16:44:26 UTC (rev 2834) @@ -33,9 +33,9 @@ <#local taskTime=utils.getMonthlyTaskTime(subtask, periodTime?date, begin?date, end?date)/> <#list 1..ident as i> </#list>- ${subtask.name}<#if taskTime > 0> : ${utils.formatDuration(taskTime)}</#if> <#if annotations> - <#local taskAnnotations=utils.getMonthlyTaskAnnotation(subtask, periodTime?date, begin?date, end?date)/> - <#list taskAnnotations as taskAnnotation> -<#list 1..ident as i> </#list> * ${taskAnnotation} + <#local taskAnnTimes=utils.getMonthlyTaskAnnotation(subtask, periodTime?date, begin?date, end?date)/> + <#list taskAnnTimes.keySet() as taskAnnTime> +<#list 1..ident as i> </#list> * <#if annotationsTime>${taskAnnTime?datetime?string.short} : </#if>${taskAnnTimes.get(taskAnnTime)} </#list> </#if> <@displaySubtaskReport task=subtask periodTime=periodTime identation=ident/> Modified: trunk/src/main/resources/ftl/reportByMonth_fr.ftl =================================================================== --- trunk/src/main/resources/ftl/reportByMonth_fr.ftl 2012-03-17 10:47:17 UTC (rev 2833) +++ trunk/src/main/resources/ftl/reportByMonth_fr.ftl 2012-03-18 16:44:26 UTC (rev 2834) @@ -33,9 +33,9 @@ <#local taskTime=utils.getMonthlyTaskTime(subtask, periodTime?date, begin?date, end?date)/> <#list 1..ident as i> </#list>- ${subtask.name}<#if taskTime > 0> : ${utils.formatDuration(taskTime)}</#if> <#if annotations> - <#local taskAnnotations=utils.getMonthlyTaskAnnotation(subtask, periodTime?date, begin?date, end?date)/> - <#list taskAnnotations as taskAnnotation> -<#list 1..ident as i> </#list> * ${taskAnnotation} + <#local taskAnnTimes=utils.getMonthlyTaskAnnotation(subtask, periodTime?date, begin?date, end?date)/> + <#list taskAnnTimes.keySet() as taskAnnTime> +<#list 1..ident as i> </#list> * <#if annotationsTime>${taskAnnTime?datetime?string.short} : </#if>${taskAnnTimes.get(taskAnnTime)} </#list> </#if> <@displaySubtaskReport task=subtask periodTime=periodTime identation=ident/> Modified: trunk/src/main/resources/ftl/reportByProject.ftl =================================================================== --- trunk/src/main/resources/ftl/reportByProject.ftl 2012-03-17 10:47:17 UTC (rev 2833) +++ trunk/src/main/resources/ftl/reportByProject.ftl 2012-03-18 16:44:26 UTC (rev 2834) @@ -42,9 +42,9 @@ <#list 1..ident as i> </#list>- ${subtask.name}<#if taskTime > 0> : ${utils.formatDuration(taskTime)}</#if> <#if annotations> <#list periods as period> - <#local taskAnnotations=utils.getDailyTaskAnnotation(subtask, period?date)/> - <#list taskAnnotations as taskAnnotation> -<#list 1..ident as i> </#list> * ${taskAnnotation} + <#local taskAnnTimes=utils.getDailyTaskAnnotation(subtask, period?date)/> + <#list taskAnnTimes.keySet() as taskAnnTime> +<#list 1..ident as i> </#list> * <#if annotationsTime>${taskAnnTime?datetime?string.short} : </#if>${taskAnnTimes.get(taskAnnTime)} </#list> </#list> </#if> Modified: trunk/src/main/resources/ftl/reportByProject_fr.ftl =================================================================== --- trunk/src/main/resources/ftl/reportByProject_fr.ftl 2012-03-17 10:47:17 UTC (rev 2833) +++ trunk/src/main/resources/ftl/reportByProject_fr.ftl 2012-03-18 16:44:26 UTC (rev 2834) @@ -42,9 +42,9 @@ <#list 1..ident as i> </#list>- ${subtask.name}<#if taskTime > 0> : ${utils.formatDuration(taskTime)}</#if> <#if annotations> <#list periods as period> - <#local taskAnnotations=utils.getDailyTaskAnnotation(subtask, period?date)/> - <#list taskAnnotations as taskAnnotation> -<#list 1..ident as i> </#list> * ${taskAnnotation} + <#local taskAnnTimes=utils.getDailyTaskAnnotation(subtask, period?date)/> + <#list taskAnnTimes.keySet() as taskAnnTime> +<#list 1..ident as i> </#list> * <#if annotationsTime>${taskAnnTime?datetime?string.short} : </#if>${taskAnnTimes.get(taskAnnTime)} </#list> </#list> </#if> Modified: trunk/src/main/resources/ftl/reportByWeek.ftl =================================================================== --- trunk/src/main/resources/ftl/reportByWeek.ftl 2012-03-17 10:47:17 UTC (rev 2833) +++ trunk/src/main/resources/ftl/reportByWeek.ftl 2012-03-18 16:44:26 UTC (rev 2834) @@ -33,9 +33,9 @@ <#local taskTime=utils.getWeeklyTaskTime(subtask, periodTime?date, begin?date, end?date)/> <#list 1..ident as i> </#list>- ${subtask.name}<#if taskTime > 0> : ${utils.formatDuration(taskTime)}</#if> <#if annotations> - <#local taskAnnotations=utils.getWeeklyTaskAnnotation(subtask, periodTime?date, begin?date, end?date)/> - <#list taskAnnotations as taskAnnotation> -<#list 1..ident as i> </#list> * ${taskAnnotation} + <#local taskAnnTimes=utils.getWeeklyTaskAnnotation(subtask, periodTime?date, begin?date, end?date)/> + <#list taskAnnTimes.keySet() as taskAnnTime> +<#list 1..ident as i> </#list> * <#if annotationsTime>${taskAnnTime?datetime?string.short} : </#if>${taskAnnTimes.get(taskAnnTime)} </#list> </#if> <@displaySubtaskReport task=subtask periodTime=periodTime identation=ident/> Modified: trunk/src/main/resources/ftl/reportByWeek_fr.ftl =================================================================== --- trunk/src/main/resources/ftl/reportByWeek_fr.ftl 2012-03-17 10:47:17 UTC (rev 2833) +++ trunk/src/main/resources/ftl/reportByWeek_fr.ftl 2012-03-18 16:44:26 UTC (rev 2834) @@ -33,9 +33,9 @@ <#local taskTime=utils.getWeeklyTaskTime(subtask, periodTime?date, begin?date, end?date)/> <#list 1..ident as i> </#list>- ${subtask.name}<#if taskTime > 0> : ${utils.formatDuration(taskTime)}</#if> <#if annotations> - <#local taskAnnotations=utils.getWeeklyTaskAnnotation(subtask, periodTime?date, begin?date, end?date)/> - <#list taskAnnotations as taskAnnotation> -<#list 1..ident as i> </#list> * ${taskAnnotation} + <#local taskAnnTimes=utils.getWeeklyTaskAnnotation(subtask, periodTime?date, begin?date, end?date)/> + <#list taskAnnTimes.keySet() as taskAnnTime> +<#list 1..ident as i> </#list> * <#if annotationsTime>${taskAnnTime?datetime?string.short} : </#if>${taskAnnTimes.get(taskAnnTime)} </#list> </#if> <@displaySubtaskReport task=subtask periodTime=periodTime identation=ident/> Modified: trunk/src/main/resources/ftl/reportByYear.ftl =================================================================== --- trunk/src/main/resources/ftl/reportByYear.ftl 2012-03-17 10:47:17 UTC (rev 2833) +++ trunk/src/main/resources/ftl/reportByYear.ftl 2012-03-18 16:44:26 UTC (rev 2834) @@ -33,9 +33,9 @@ <#local taskTime=utils.getYearlyTaskTime(subtask, periodTime?date, begin?date, end?date)/> <#list 1..ident as i> </#list>- ${subtask.name}<#if taskTime > 0> : ${utils.formatDuration(taskTime)}</#if> <#if annotations> - <#local taskAnnotations=utils.getYearlyTaskAnnotation(subtask, periodTime?date, begin?date, end?date)/> - <#list taskAnnotations as taskAnnotation> -<#list 1..ident as i> </#list> * ${taskAnnotation} + <#local taskAnnTimes=utils.getYearlyTaskAnnotation(subtask, periodTime?date, begin?date, end?date)/> + <#list taskAnnTimes.keySet() as taskAnnTime> +<#list 1..ident as i> </#list> * <#if annotationsTime>${taskAnnTime?datetime?string.short} : </#if>${taskAnnTimes.get(taskAnnTime)} </#list> </#if> <@displaySubtaskReport task=subtask periodTime=periodTime identation=ident/> Modified: trunk/src/main/resources/ftl/reportByYear_fr.ftl =================================================================== --- trunk/src/main/resources/ftl/reportByYear_fr.ftl 2012-03-17 10:47:17 UTC (rev 2833) +++ trunk/src/main/resources/ftl/reportByYear_fr.ftl 2012-03-18 16:44:26 UTC (rev 2834) @@ -33,9 +33,9 @@ <#local taskTime=utils.getYearlyTaskTime(subtask, periodTime?date, begin?date, end?date)/> <#list 1..ident as i> </#list>- ${subtask.name}<#if taskTime > 0> : ${utils.formatDuration(taskTime)}</#if> <#if annotations> - <#local taskAnnotations=utils.getYearlyTaskAnnotation(subtask, periodTime?date, begin?date, end?date)/> - <#list taskAnnotations as taskAnnotation> -<#list 1..ident as i> </#list> * ${taskAnnotation} + <#local taskAnnTimes=utils.getYearlyTaskAnnotation(subtask, periodTime?date, begin?date, end?date)/> + <#list taskAnnTimes.keySet() as taskAnnTime> +<#list 1..ident as i> </#list> * <#if annotationsTime>${taskAnnTime?datetime?string.short} : </#if>${taskAnnTimes.get(taskAnnTime)} </#list> </#if> <@displaySubtaskReport task=subtask periodTime=periodTime identation=ident/> Modified: trunk/src/main/resources/org/chorem/jtimer/ui/report/resources/ReportView.properties =================================================================== --- trunk/src/main/resources/org/chorem/jtimer/ui/report/resources/ReportView.properties 2012-03-17 10:47:17 UTC (rev 2833) +++ trunk/src/main/resources/org/chorem/jtimer/ui/report/resources/ReportView.properties 2012-03-18 16:44:26 UTC (rev 2834) @@ -32,7 +32,7 @@ reportWeekly=Weekly reportYearly=Yearly reportByProject=By project -reportAnnotations=Include annotations +reportAnnotationsTime=with time reportProjects=Projects reportContent=Report reportProjectsList=Projects list @@ -43,6 +43,8 @@ previousWeek.Action.icon = date_previous.png previousWeek.Action.shortDescription = Previous week +reportAnnotations.Action.text = Include annotations + showHiddenProjects.Action.text = Show hidden projects showHiddenProjects.Action.shortDescription = Show hidden projects Modified: trunk/src/main/resources/org/chorem/jtimer/ui/report/resources/ReportView_fr.properties =================================================================== --- trunk/src/main/resources/org/chorem/jtimer/ui/report/resources/ReportView_fr.properties 2012-03-17 10:47:17 UTC (rev 2833) +++ trunk/src/main/resources/org/chorem/jtimer/ui/report/resources/ReportView_fr.properties 2012-03-18 16:44:26 UTC (rev 2834) @@ -32,7 +32,8 @@ reportWeekly=Par semaine reportYearly=Par ann\u00E9e reportByProject=Par projet -reportAnnotations=Inclure les annotations + +reportAnnotationsTime=avec l'heure reportProjects=Projets reportContent=Rapport reportProjectsList=Liste des projets @@ -44,6 +45,8 @@ showHiddenProjects.Action.text = Afficher les cach\u00E9s showHiddenProjects.Action.shortDescription = Afficher les cach\u00E9s +reportAnnotations.Action.text = Inclure les annotations + generateReport.Action.text = G\u00E9n\u00E9rer generateReport.Action.shortDescription = G\u00E9n\u00E9rer le report Modified: trunk/src/test/java/org/chorem/jtimer/AbstractJTimerTest.java =================================================================== --- trunk/src/test/java/org/chorem/jtimer/AbstractJTimerTest.java 2012-03-17 10:47:17 UTC (rev 2833) +++ trunk/src/test/java/org/chorem/jtimer/AbstractJTimerTest.java 2012-03-18 16:44:26 UTC (rev 2834) @@ -29,6 +29,7 @@ import java.io.IOException; import java.net.URL; import java.util.Collection; +import java.util.Locale; import java.util.Properties; import org.apache.commons.io.FileUtils; @@ -137,6 +138,10 @@ log.debug("Set up test"); } + // jtimer code use default system locale + // test are coded in en_US + Locale.setDefault(Locale.US); + initDataDirectory(); } Modified: trunk/src/test/java/org/chorem/jtimer/ui/report/ReportGeneratorTest.java =================================================================== --- trunk/src/test/java/org/chorem/jtimer/ui/report/ReportGeneratorTest.java 2012-03-17 10:47:17 UTC (rev 2833) +++ trunk/src/test/java/org/chorem/jtimer/ui/report/ReportGeneratorTest.java 2012-03-18 16:44:26 UTC (rev 2834) @@ -57,6 +57,7 @@ /** * Test report generation. + * * @throws ParseException */ @Test @@ -70,7 +71,8 @@ List<TimerProject> projects = new ArrayList<TimerProject>(); projects.addAll(testSaver.load()); ReportGenerator generator = new ReportGenerator(); - String content = generator.getReportText(ReportGenerator.Type.BY_DAY_REPORT, projects, d1, d2, false); + String content = generator.getReportText(ReportGenerator.Type.BY_DAY_REPORT, + projects, d1, d2, false, false); if (log.isDebugEnabled()) { log.debug("Daily report = " + content); @@ -103,9 +105,48 @@ } }*/ } - + /** + * Test report generation with annotation time. + * + * @throws ParseException + */ + @Test + public void getReportTextDailyAnnotationTime() throws ParseException { + + /*try { + FIXME saver.lock();*/ + + Date d1 = df.parse("November 1, 2008"); + Date d2 = df.parse("March 31, 2009"); + List<TimerProject> projects = new ArrayList<TimerProject>(); + projects.addAll(testSaver.load()); + ReportGenerator generator = new ReportGenerator(); + String content = generator.getReportText(ReportGenerator.Type.BY_DAY_REPORT, + projects, d1, d2, true, true); + + if (log.isDebugEnabled()) { + log.debug("Daily report = " + content); + } + + Assert.assertNotNull(content); + + // with annotations and time (* is important in test) + Assert.assertTrue(content.indexOf("* 2:10 PM : Test task and subtask time") > 0); + Assert.assertTrue(content.indexOf("* 12:00 AM : Not easy work") > 0); + + /*FIXME saver.unlock(); + } catch (DataLockingException e) { + if(log.isErrorEnabled()) { + log.error("getProjectFromFileTest error", e); + Assert.fail(); + } + }*/ + } + + /** * Test report generation. + * * @throws ParseException */ @Test @@ -119,7 +160,8 @@ List<TimerProject> projects = new ArrayList<TimerProject>(); projects.addAll(testSaver.load()); ReportGenerator generator = new ReportGenerator(); - String content = generator.getReportText(ReportGenerator.Type.BY_WEEK_REPORT, projects, d1, d2, true); + String content = generator.getReportText(ReportGenerator.Type.BY_WEEK_REPORT, + projects, d1, d2, true, false); if (log.isDebugEnabled()) { log.debug("Weekly report = " + content); @@ -136,9 +178,47 @@ Assert.assertTrue(content.indexOf("Add webservice") > 0); Assert.assertTrue(content.indexOf("Add workspace support") > 0); + // with annotations + Assert.assertTrue(content.indexOf("* Test task and subtask time") > 0); + Assert.assertTrue(content.indexOf("* Not easy work") > 0); + + /*FIXME saver.unlock(); + } catch (DataLockingException e) { + if(log.isErrorEnabled()) { + log.error("getProjectFromFileTest error", e); + Assert.fail(); + } + }*/ + } + + /** + * Test report generation with annotation time. + * + * @throws ParseException + */ + @Test + public void getReportTextMonthlyAnnotationTime() throws ParseException { + + /*try { + FIXME saver.lock();*/ + + Date d1 = df.parse("November 1, 2008"); + Date d2 = df.parse("March 31, 2009"); + List<TimerProject> projects = new ArrayList<TimerProject>(); + projects.addAll(testSaver.load()); + ReportGenerator generator = new ReportGenerator(); + String content = generator.getReportText(ReportGenerator.Type.BY_MONTH_REPORT, + projects, d1, d2, true, true); + + if (log.isDebugEnabled()) { + log.debug("Monthly report = " + content); + } + + Assert.assertNotNull(content); + // no annotations - Assert.assertTrue(content.indexOf("Test task and subtask time") > 0); - Assert.assertTrue(content.indexOf("Not easy work") > 0); + Assert.assertTrue(content.indexOf("* 2/3/09 2:10 PM : Test task and subtask time") > 0); + Assert.assertTrue(content.indexOf("* 12/11/08 12:00 AM : Not easy work") > 0); /*FIXME saver.unlock(); } catch (DataLockingException e) { @@ -164,7 +244,8 @@ List<TimerProject> projects = new ArrayList<TimerProject>(); projects.addAll(testSaver.load()); ReportGenerator generator = new ReportGenerator(); - String content = generator.getReportText(ReportGenerator.Type.BY_MONTH_REPORT, projects, d1, d2, false); + String content = generator.getReportText(ReportGenerator.Type.BY_MONTH_REPORT, + projects, d1, d2, false, false); if (log.isDebugEnabled()) { log.debug("Monthly report = " + content); @@ -209,7 +290,8 @@ List<TimerProject> projects = new ArrayList<TimerProject>(); projects.addAll(testSaver.load()); ReportGenerator generator = new ReportGenerator(); - String content = generator.getReportText(ReportGenerator.Type.BY_YEAR_REPORT, projects, d1, d2, false); + String content = generator.getReportText(ReportGenerator.Type.BY_YEAR_REPORT, + projects, d1, d2, false, false); if (log.isDebugEnabled()) { log.debug("Yearly report = " + content); @@ -255,7 +337,8 @@ List<TimerProject> projects = new ArrayList<TimerProject>(); projects.addAll(testSaver.load()); ReportGenerator generator = new ReportGenerator(); - String content = generator.getReportText(ReportGenerator.Type.BY_PROJECT_REPORT, projects, d1, d2, true); + String content = generator.getReportText(ReportGenerator.Type.BY_PROJECT_REPORT, + projects, d1, d2, true, false); if (log.isDebugEnabled()) { log.debug("Project report = " + content); @@ -273,9 +356,9 @@ Assert.assertTrue(content.indexOf("Add service layer") > 0); Assert.assertTrue(content.indexOf("Calendar to date") > 0); - // no annotations + // test annotations Assert.assertFalse(content.indexOf("Test task and subtask time") > 0); - Assert.assertTrue(content.indexOf("Not easy work") > 0); + Assert.assertTrue(content.indexOf("* Not easy work") > 0); /*FIXME saver.unlock(); } catch (DataLockingException e) { Modified: trunk/src/test/resources/testdata/4.ann =================================================================== --- trunk/src/test/resources/testdata/4.ann 2012-03-17 10:47:17 UTC (rev 2833) +++ trunk/src/test/resources/testdata/4.ann 2012-03-18 16:44:26 UTC (rev 2834) @@ -1 +1 @@ -1233615601 Test task and subtask time \ No newline at end of file +1233666601 Test task and subtask time \ No newline at end of file Modified: trunk/src/test/resources/testdata/5.ann =================================================================== --- trunk/src/test/resources/testdata/5.ann 2012-03-17 10:47:17 UTC (rev 2833) +++ trunk/src/test/resources/testdata/5.ann 2012-03-18 16:44:26 UTC (rev 2834) @@ -1 +1 @@ -1233615601 Test subtask time +1233621301 Test subtask time
participants (1)
-
echatellier@users.chorem.org