From 8188f3c1905e8e10308db2fb0b3cf6fe39562aff Mon Sep 17 00:00:00 2001 From: Ignacio Diaz Teijido Date: Wed, 14 Sep 2011 20:13:24 +0200 Subject: [PATCH] [Bug #1178] Showing EffortDuration in reports instead of BigDecimal Some new scriptlet classes were added FEA: ItEr75S04BugFixing --- .../CompletedEstimatedHoursPerTaskDTO.java | 15 ++- .../dtos/HoursWorkedPerResourceDTO.java | 13 +- .../dtos/HoursWorkedPerWorkerInAMonthDTO.java | 12 +- .../dtos/SchedulingProgressPerOrderDTO.java | 18 +-- .../dtos/WorkingProgressPerTaskDTO.java | 21 ++-- .../business/resources/daos/ResourceDAO.java | 7 +- .../main/jasper/completedEstimatedHours.jrxml | 6 +- .../hoursWorkedPerWorkerInAMonthReport.jrxml | 14 +-- .../jasper/hoursWorkedPerWorkerReport.jrxml | 22 ++-- .../schedulingProgressPerOrderReport.jrxml | 6 +- .../jasper/workingProgressPerTaskReport.jrxml | 6 +- ...HoursWorkedPerWorkerInAMonthScriptlet.java | 45 +++++++ .../HoursWorkedPerWorkerScriptlet.java | 119 ++++++++++++++++++ .../web/reports/RealHoursScriptlet.java | 42 +++++++ 14 files changed, 277 insertions(+), 69 deletions(-) create mode 100644 navalplanner-webapp/src/main/java/org/navalplanner/web/reports/HoursWorkedPerWorkerInAMonthScriptlet.java create mode 100644 navalplanner-webapp/src/main/java/org/navalplanner/web/reports/HoursWorkedPerWorkerScriptlet.java create mode 100644 navalplanner-webapp/src/main/java/org/navalplanner/web/reports/RealHoursScriptlet.java diff --git a/navalplanner-business/src/main/java/org/navalplanner/business/reports/dtos/CompletedEstimatedHoursPerTaskDTO.java b/navalplanner-business/src/main/java/org/navalplanner/business/reports/dtos/CompletedEstimatedHoursPerTaskDTO.java index 9d19cf7ae..3c14755c8 100644 --- a/navalplanner-business/src/main/java/org/navalplanner/business/reports/dtos/CompletedEstimatedHoursPerTaskDTO.java +++ b/navalplanner-business/src/main/java/org/navalplanner/business/reports/dtos/CompletedEstimatedHoursPerTaskDTO.java @@ -21,13 +21,13 @@ package org.navalplanner.business.reports.dtos; -import java.math.BigDecimal; import java.util.List; import org.joda.time.LocalDate; import org.navalplanner.business.common.Registry; import org.navalplanner.business.planner.entities.DayAssignment; import org.navalplanner.business.planner.entities.Task; +import org.navalplanner.business.workingday.EffortDuration; import org.navalplanner.business.workreports.daos.IWorkReportLineDAO; import org.navalplanner.business.workreports.entities.WorkReportLine; @@ -48,7 +48,7 @@ public class CompletedEstimatedHoursPerTaskDTO { private Integer partialPlannedHours; - private BigDecimal realHours; + private EffortDuration realHours; private CompletedEstimatedHoursPerTaskDTO() { workReportLineDAO = Registry.getWorkReportLineDAO(); @@ -87,8 +87,8 @@ public class CompletedEstimatedHoursPerTaskDTO { return result; } - public BigDecimal calculateRealHours(Task task, LocalDate date) { - BigDecimal result = BigDecimal.ZERO; + public EffortDuration calculateRealHours(Task task, LocalDate date) { + EffortDuration result = EffortDuration.zero(); final List workReportLines = workReportLineDAO .findByOrderElementAndChildren(task.getOrderElement()); @@ -99,8 +99,7 @@ public class CompletedEstimatedHoursPerTaskDTO { for (WorkReportLine workReportLine : workReportLines) { final LocalDate workReportLineDate = new LocalDate(workReportLine.getDate()); if (date == null || workReportLineDate.compareTo(date) <= 0) { - result = result.add(workReportLine.getEffort() - .toHoursAsDecimalWithScale(2)); + result = EffortDuration.sum(result, workReportLine.getEffort()); } } return result; @@ -130,11 +129,11 @@ public class CompletedEstimatedHoursPerTaskDTO { this.partialPlannedHours = partialPlannedHours; } - public BigDecimal getRealHours() { + public EffortDuration getRealHours() { return realHours; } - public void setRealHours(BigDecimal realHours) { + public void setRealHours(EffortDuration realHours) { this.realHours = realHours; } diff --git a/navalplanner-business/src/main/java/org/navalplanner/business/reports/dtos/HoursWorkedPerResourceDTO.java b/navalplanner-business/src/main/java/org/navalplanner/business/reports/dtos/HoursWorkedPerResourceDTO.java index 267d76dec..8f85e9bc2 100644 --- a/navalplanner-business/src/main/java/org/navalplanner/business/reports/dtos/HoursWorkedPerResourceDTO.java +++ b/navalplanner-business/src/main/java/org/navalplanner/business/reports/dtos/HoursWorkedPerResourceDTO.java @@ -21,7 +21,6 @@ package org.navalplanner.business.reports.dtos; -import java.math.BigDecimal; import java.util.Date; import java.util.Set; @@ -29,6 +28,7 @@ import org.joda.time.LocalDate; import org.joda.time.LocalTime; import org.navalplanner.business.labels.entities.Label; import org.navalplanner.business.resources.entities.Resource; +import org.navalplanner.business.workingday.EffortDuration; import org.navalplanner.business.workreports.entities.WorkReportLine; import org.navalplanner.business.workreports.valueobjects.DescriptionValue; @@ -42,7 +42,7 @@ public class HoursWorkedPerResourceDTO implements Comparable { private LocalTime clockFinish; - private BigDecimal effort; + private EffortDuration effort; private String orderElementCode; @@ -52,15 +52,14 @@ public class HoursWorkedPerResourceDTO implements Comparable { private String labels; - public HoursWorkedPerResourceDTO( -Resource resource, + public HoursWorkedPerResourceDTO(Resource resource, WorkReportLine workReportLine) { this.workerName = resource.getName(); this.date = workReportLine.getDate(); this.clockStart = workReportLine.getClockStart(); this.clockFinish = workReportLine.getClockFinish(); - this.effort = workReportLine.getEffort().toHoursAsDecimalWithScale(2); + this.effort = workReportLine.getEffort(); this.orderElementCode = workReportLine.getOrderElement().getCode(); this.orderElementName = workReportLine.getOrderElement().getName(); this.descriptionValues = descriptionValuesAsString(workReportLine.getDescriptionValues()); @@ -83,11 +82,11 @@ Resource resource, return (result.length() > 0) ? result.substring(0, result.length() - 2) : result; } - public BigDecimal getEffort() { + public EffortDuration getEffort() { return effort; } - public void setEffort(BigDecimal effort) { + public void setEffort(EffortDuration effort) { this.effort = effort; } diff --git a/navalplanner-business/src/main/java/org/navalplanner/business/reports/dtos/HoursWorkedPerWorkerInAMonthDTO.java b/navalplanner-business/src/main/java/org/navalplanner/business/reports/dtos/HoursWorkedPerWorkerInAMonthDTO.java index 786188a04..2d5d6f68d 100644 --- a/navalplanner-business/src/main/java/org/navalplanner/business/reports/dtos/HoursWorkedPerWorkerInAMonthDTO.java +++ b/navalplanner-business/src/main/java/org/navalplanner/business/reports/dtos/HoursWorkedPerWorkerInAMonthDTO.java @@ -21,27 +21,27 @@ package org.navalplanner.business.reports.dtos; -import java.math.BigDecimal; - import org.navalplanner.business.resources.entities.Worker; +import org.navalplanner.business.workingday.EffortDuration; public class HoursWorkedPerWorkerInAMonthDTO { private String workerName; - private BigDecimal numHours; + private EffortDuration numHours; - public HoursWorkedPerWorkerInAMonthDTO(Worker worker, BigDecimal numHours) { + public HoursWorkedPerWorkerInAMonthDTO(Worker worker, + EffortDuration numHours) { this.workerName = worker.getName(); this.numHours = numHours; } - public BigDecimal getNumHours() { + public EffortDuration getNumHours() { return numHours; } - public void setNumHours(BigDecimal numHours) { + public void setNumHours(EffortDuration numHours) { this.numHours = numHours; } diff --git a/navalplanner-business/src/main/java/org/navalplanner/business/reports/dtos/SchedulingProgressPerOrderDTO.java b/navalplanner-business/src/main/java/org/navalplanner/business/reports/dtos/SchedulingProgressPerOrderDTO.java index 286c8975f..39b056fe9 100644 --- a/navalplanner-business/src/main/java/org/navalplanner/business/reports/dtos/SchedulingProgressPerOrderDTO.java +++ b/navalplanner-business/src/main/java/org/navalplanner/business/reports/dtos/SchedulingProgressPerOrderDTO.java @@ -35,6 +35,7 @@ import org.navalplanner.business.orders.daos.IOrderDAO; import org.navalplanner.business.orders.entities.Order; import org.navalplanner.business.planner.entities.DayAssignment; import org.navalplanner.business.planner.entities.Task; +import org.navalplanner.business.workingday.EffortDuration; import org.navalplanner.business.workreports.daos.IWorkReportLineDAO; import org.navalplanner.business.workreports.entities.WorkReportLine; @@ -57,7 +58,7 @@ public class SchedulingProgressPerOrderDTO { private Integer partialPlannedHours; - private BigDecimal realHours; + private EffortDuration realHours; private BigDecimal averageProgress; @@ -107,7 +108,8 @@ public class SchedulingProgressPerOrderDTO { // Progress calculations this.imputedProgress = (totalPlannedHours != 0) ? new Double( - realHours.doubleValue() +realHours + .toHoursAsDecimalWithScale(2).doubleValue() / totalPlannedHours.doubleValue()) : new Double(0); this.plannedProgress = (totalPlannedHours != 0) ? new Double( partialPlannedHours / totalPlannedHours.doubleValue()) @@ -115,7 +117,8 @@ public class SchedulingProgressPerOrderDTO { // Differences calculations this.costDifference = calculateCostDifference(averageProgress, - new BigDecimal(totalPlannedHours), realHours); + new BigDecimal(totalPlannedHours), + realHours.toHoursAsDecimalWithScale(2)); this.planningDifference = calculatePlanningDifference(averageProgress, new BigDecimal(totalPlannedHours), new BigDecimal( partialPlannedHours)); @@ -168,8 +171,8 @@ public class SchedulingProgressPerOrderDTO { .roundToHours(); } - public BigDecimal calculateRealHours(Order order, LocalDate date) { - BigDecimal result = BigDecimal.ZERO; + public EffortDuration calculateRealHours(Order order, LocalDate date) { + EffortDuration result = EffortDuration.zero(); final List workReportLines = workReportLineDAO .findByOrderElementAndChildren(order); @@ -177,8 +180,7 @@ public class SchedulingProgressPerOrderDTO { for (WorkReportLine workReportLine : workReportLines) { final LocalDate workReportLineDate = new LocalDate(workReportLine.getDate()); if (date == null || workReportLineDate.compareTo(date) <= 0) { - result = result.add(workReportLine.getEffort() - .toHoursAsDecimalWithScale(2)); + result = EffortDuration.sum(result, workReportLine.getEffort()); } } return result; @@ -196,7 +198,7 @@ public class SchedulingProgressPerOrderDTO { return partialPlannedHours; } - public BigDecimal getRealHours() { + public EffortDuration getRealHours() { return realHours; } diff --git a/navalplanner-business/src/main/java/org/navalplanner/business/reports/dtos/WorkingProgressPerTaskDTO.java b/navalplanner-business/src/main/java/org/navalplanner/business/reports/dtos/WorkingProgressPerTaskDTO.java index 776db4aaa..58a4e5b9d 100644 --- a/navalplanner-business/src/main/java/org/navalplanner/business/reports/dtos/WorkingProgressPerTaskDTO.java +++ b/navalplanner-business/src/main/java/org/navalplanner/business/reports/dtos/WorkingProgressPerTaskDTO.java @@ -29,6 +29,7 @@ import org.joda.time.LocalDate; import org.navalplanner.business.common.Registry; import org.navalplanner.business.planner.entities.DayAssignment; import org.navalplanner.business.planner.entities.Task; +import org.navalplanner.business.workingday.EffortDuration; import org.navalplanner.business.workreports.daos.IWorkReportLineDAO; import org.navalplanner.business.workreports.entities.WorkReportLine; @@ -49,7 +50,7 @@ public class WorkingProgressPerTaskDTO { private Integer partialPlannedHours; - private BigDecimal realHours; + private EffortDuration realHours; private BigDecimal averageProgress; @@ -82,11 +83,14 @@ public class WorkingProgressPerTaskDTO { this.averageProgress = task.getOrderElement().getAdvancePercentage(date); this.imputedProgress = (totalPlannedHours != 0) ? new Double( - realHours.doubleValue() / totalPlannedHours.doubleValue()) +realHours + .toHoursAsDecimalWithScale(2).doubleValue() + / totalPlannedHours.doubleValue()) : new Double(0); this.plannedProgress = (totalPlannedHours != 0) ? new Double(partialPlannedHours / totalPlannedHours.doubleValue()) : new Double(0); this.costDifference = calculateCostDifference(averageProgress, - new BigDecimal(totalPlannedHours), realHours); + new BigDecimal(totalPlannedHours), + realHours.toHoursAsDecimalWithScale(2)); this.planningDifference = calculatePlanningDifference(averageProgress, new BigDecimal(totalPlannedHours), new BigDecimal( partialPlannedHours)); @@ -118,8 +122,8 @@ public class WorkingProgressPerTaskDTO { return result; } - public BigDecimal calculateRealHours(Task task, LocalDate date) { - BigDecimal result = BigDecimal.ZERO; + public EffortDuration calculateRealHours(Task task, LocalDate date) { + EffortDuration result = EffortDuration.zero(); final List workReportLines = workReportLineDAO .findByOrderElementAndChildren(task.getOrderElement()); @@ -130,8 +134,7 @@ public class WorkingProgressPerTaskDTO { for (WorkReportLine workReportLine : workReportLines) { final LocalDate workReportLineDate = new LocalDate(workReportLine.getDate()); if (date == null || workReportLineDate.compareTo(date) <= 0) { - result = result.add(workReportLine.getEffort() - .toHoursAsDecimalWithScale(2)); + result = EffortDuration.sum(result, workReportLine.getEffort()); } } return result; @@ -161,11 +164,11 @@ public class WorkingProgressPerTaskDTO { this.partialPlannedHours = partialPlannedHours; } - public BigDecimal getRealHours() { + public EffortDuration getRealHours() { return realHours; } - public void setRealHours(BigDecimal realHours) { + public void setRealHours(EffortDuration realHours) { this.realHours = realHours; } diff --git a/navalplanner-business/src/main/java/org/navalplanner/business/resources/daos/ResourceDAO.java b/navalplanner-business/src/main/java/org/navalplanner/business/resources/daos/ResourceDAO.java index ef3a105b6..61731fed3 100644 --- a/navalplanner-business/src/main/java/org/navalplanner/business/resources/daos/ResourceDAO.java +++ b/navalplanner-business/src/main/java/org/navalplanner/business/resources/daos/ResourceDAO.java @@ -21,7 +21,6 @@ package org.navalplanner.business.resources.daos; -import java.math.BigDecimal; import java.util.ArrayList; import java.util.Date; import java.util.Iterator; @@ -232,11 +231,11 @@ public class ResourceDAO extends IntegrationEntityDAO implements for (Object row: rows) { Object[] columns = (Object[]) row; Worker worker = (Worker) findExistingEntity((Long) columns[0]); - BigDecimal numHours = (EffortDuration.seconds(((Long) columns[1]) - .intValue())).toHoursAsDecimalWithScale(2); + EffortDuration effort = EffortDuration.seconds(((Long) columns[1]) + .intValue()); HoursWorkedPerWorkerInAMonthDTO dto = new HoursWorkedPerWorkerInAMonthDTO( - worker, numHours); + worker, effort); result.add(dto); } return result; diff --git a/navalplanner-webapp/src/main/jasper/completedEstimatedHours.jrxml b/navalplanner-webapp/src/main/jasper/completedEstimatedHours.jrxml index f580baecc..005e0bc00 100644 --- a/navalplanner-webapp/src/main/jasper/completedEstimatedHours.jrxml +++ b/navalplanner-webapp/src/main/jasper/completedEstimatedHours.jrxml @@ -1,5 +1,5 @@ - + @@ -10,7 +10,7 @@ - + @@ -237,7 +237,7 @@ - + diff --git a/navalplanner-webapp/src/main/jasper/hoursWorkedPerWorkerInAMonthReport.jrxml b/navalplanner-webapp/src/main/jasper/hoursWorkedPerWorkerInAMonthReport.jrxml index f45ae7314..ba50044da 100644 --- a/navalplanner-webapp/src/main/jasper/hoursWorkedPerWorkerInAMonthReport.jrxml +++ b/navalplanner-webapp/src/main/jasper/hoursWorkedPerWorkerInAMonthReport.jrxml @@ -1,15 +1,15 @@ - + - - - - + + + + @@ -123,7 +123,7 @@ - + @@ -138,7 +138,7 @@ - + diff --git a/navalplanner-webapp/src/main/jasper/hoursWorkedPerWorkerReport.jrxml b/navalplanner-webapp/src/main/jasper/hoursWorkedPerWorkerReport.jrxml index 6b117385a..6197979e1 100644 --- a/navalplanner-webapp/src/main/jasper/hoursWorkedPerWorkerReport.jrxml +++ b/navalplanner-webapp/src/main/jasper/hoursWorkedPerWorkerReport.jrxml @@ -1,5 +1,5 @@ - + @@ -11,18 +11,18 @@ - + - - - + + + - - - + + + @@ -55,7 +55,7 @@ - + @@ -175,7 +175,7 @@ - + @@ -330,7 +330,7 @@ - + diff --git a/navalplanner-webapp/src/main/jasper/schedulingProgressPerOrderReport.jrxml b/navalplanner-webapp/src/main/jasper/schedulingProgressPerOrderReport.jrxml index 864782ab1..6a1b162e6 100644 --- a/navalplanner-webapp/src/main/jasper/schedulingProgressPerOrderReport.jrxml +++ b/navalplanner-webapp/src/main/jasper/schedulingProgressPerOrderReport.jrxml @@ -1,5 +1,5 @@ - + @@ -12,7 +12,7 @@ - + @@ -196,7 +196,7 @@ - + diff --git a/navalplanner-webapp/src/main/jasper/workingProgressPerTaskReport.jrxml b/navalplanner-webapp/src/main/jasper/workingProgressPerTaskReport.jrxml index 724ff18f8..1ba1d238f 100644 --- a/navalplanner-webapp/src/main/jasper/workingProgressPerTaskReport.jrxml +++ b/navalplanner-webapp/src/main/jasper/workingProgressPerTaskReport.jrxml @@ -1,5 +1,5 @@ - + @@ -10,7 +10,7 @@ - + @@ -290,7 +290,7 @@ - + diff --git a/navalplanner-webapp/src/main/java/org/navalplanner/web/reports/HoursWorkedPerWorkerInAMonthScriptlet.java b/navalplanner-webapp/src/main/java/org/navalplanner/web/reports/HoursWorkedPerWorkerInAMonthScriptlet.java new file mode 100644 index 000000000..96d2eae62 --- /dev/null +++ b/navalplanner-webapp/src/main/java/org/navalplanner/web/reports/HoursWorkedPerWorkerInAMonthScriptlet.java @@ -0,0 +1,45 @@ +/* + * This file is part of NavalPlan + * + * Copyright (C) 2011 - ComtecSF, S.L + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +package org.navalplanner.web.reports; + +import net.sf.jasperreports.engine.JRDefaultScriptlet; +import net.sf.jasperreports.engine.JRScriptletException; + +import org.navalplanner.business.workingday.EffortDuration; + +/** + * This class will be used to implement methods that could be called from jrxml + * to make calculations over {@link EffortDuration} elements. + * + * @author Ignacio Diaz Teijido + * + */ +public class HoursWorkedPerWorkerInAMonthScriptlet extends JRDefaultScriptlet { + + /** + * Method used in hoursWorkedPerWorkerInAMonthReport.jrxml + * + * @return + * @throws JRScriptletException + */ + public String getNumHours() throws JRScriptletException { + EffortDuration effort = (EffortDuration) this.getFieldValue("numHours"); + return effort.toFormattedString(); + } +} diff --git a/navalplanner-webapp/src/main/java/org/navalplanner/web/reports/HoursWorkedPerWorkerScriptlet.java b/navalplanner-webapp/src/main/java/org/navalplanner/web/reports/HoursWorkedPerWorkerScriptlet.java new file mode 100644 index 000000000..318d1880f --- /dev/null +++ b/navalplanner-webapp/src/main/java/org/navalplanner/web/reports/HoursWorkedPerWorkerScriptlet.java @@ -0,0 +1,119 @@ +/* + * This file is part of NavalPlan + * + * Copyright (C) 2011 - ComtecSF, S.L + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +package org.navalplanner.web.reports; + +import java.util.HashSet; +import java.util.Set; + +import net.sf.jasperreports.engine.JRAbstractScriptlet; +import net.sf.jasperreports.engine.JRScriptletException; + +import org.navalplanner.business.workingday.EffortDuration; + +/** + * This class will be used to implement methods that could be called from + * hoursWoerkedPerWorkerReport.jrxml to make calculations over + * {@link EffortDuration} elements. + * + * @author Ignacio Diaz Teijido + * + */ +public class HoursWorkedPerWorkerScriptlet extends JRAbstractScriptlet { + + private Set efforts = new HashSet(); + + public String getEffort() throws JRScriptletException { + EffortDuration effort = (EffortDuration) this.getFieldValue("effort"); + return effort.toFormattedString(); + } + + public String getSumEffort() throws JRScriptletException { + return (String) this.getVariableValue("sumHoursPerDay"); + } + + public String getEffortWorker() throws JRScriptletException { + return (String) this.getVariableValue("sumHoursPerWorker"); + } + + @Override + public void afterDetailEval() throws JRScriptletException { + // We use the set because elements could be processed twice depending on + // the report + EffortDuration current = (EffortDuration) this.getFieldValue("effort"); + if (!efforts.contains(current)) { + // The effort of the worker is the sum of all efforts. + EffortDuration effortWorker = EffortDuration.sum(current, + EffortDuration.parseFromFormattedString((String) this + .getVariableValue("sumHoursPerWorker"))); + this.setVariableValue("sumHoursPerWorker", + effortWorker.toFormattedString()); + // We calculate here the effort for a particular day + EffortDuration effort = EffortDuration.sum(current, EffortDuration + .parseFromFormattedString((String) this + .getVariableValue("sumHoursPerDay"))); + this.setVariableValue("sumHoursPerDay", effort.toFormattedString()); + efforts.add(current); + } + } + + @Override + public void afterColumnInit() throws JRScriptletException { + + } + + @Override + public void afterGroupInit(String arg0) throws JRScriptletException { + + } + + @Override + public void afterPageInit() throws JRScriptletException { + + } + + @Override + public void afterReportInit() throws JRScriptletException { + + } + + @Override + public void beforeColumnInit() throws JRScriptletException { + + } + + @Override + public void beforeDetailEval() throws JRScriptletException { + + } + + @Override + public void beforeGroupInit(String arg0) throws JRScriptletException { + + } + + @Override + public void beforePageInit() throws JRScriptletException { + + } + + @Override + public void beforeReportInit() throws JRScriptletException { + + } +} diff --git a/navalplanner-webapp/src/main/java/org/navalplanner/web/reports/RealHoursScriptlet.java b/navalplanner-webapp/src/main/java/org/navalplanner/web/reports/RealHoursScriptlet.java new file mode 100644 index 000000000..3c30cc6d8 --- /dev/null +++ b/navalplanner-webapp/src/main/java/org/navalplanner/web/reports/RealHoursScriptlet.java @@ -0,0 +1,42 @@ +/* + * This file is part of NavalPlan + * + * Copyright (C) 2011 - ComtecSF, S.L + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +package org.navalplanner.web.reports; + +import net.sf.jasperreports.engine.JRDefaultScriptlet; +import net.sf.jasperreports.engine.JRScriptletException; + +import org.navalplanner.business.workingday.EffortDuration; + +/** + * This class will be used to implement methods that could be called from + * hoursWorkedPerWorkerReport.jrxml, completedEstimatedHours.jrxml and + * workingProgressPerTask.jrxml to make calculations over {@link EffortDuration} + * elements. + * + * @author Ignacio Diaz Teijido + * + */ +public class RealHoursScriptlet extends JRDefaultScriptlet { + + public String getRealHours() throws JRScriptletException { + EffortDuration effort = (EffortDuration) this + .getFieldValue("realHours"); + return effort.toFormattedString(); + } +}