ItEr37S17CUCalculoValorGanadoItEr36S19: Sharing the same code to fill the earned value chart in both views.
This commit is contained in:
parent
dc2c07c537
commit
4961fcb8b0
3 changed files with 51 additions and 66 deletions
|
|
@ -24,14 +24,20 @@ import static org.navalplanner.web.I18nHelper._;
|
|||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.SortedMap;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import org.joda.time.LocalDate;
|
||||
import org.zkforge.timeplot.Plotinfo;
|
||||
import org.zkforge.timeplot.Timeplot;
|
||||
import org.zkforge.timeplot.geometry.TimeGeometry;
|
||||
import org.zkforge.timeplot.geometry.ValueGeometry;
|
||||
import org.zkoss.ganttz.util.Interval;
|
||||
|
||||
|
||||
|
|
@ -253,4 +259,38 @@ public abstract class EarnedValueChartFiller extends ChartFiller {
|
|||
indicators.put(EarnedValueType.SPI, spi);
|
||||
}
|
||||
|
||||
protected abstract Set<EarnedValueType> getSelectedIndicators();
|
||||
|
||||
@Override
|
||||
public void fillChart(Timeplot chart, Interval interval, Integer size) {
|
||||
chart.getChildren().clear();
|
||||
chart.invalidate();
|
||||
resetMinimumAndMaximumValueForChart();
|
||||
|
||||
calculateValues(interval);
|
||||
|
||||
List<Plotinfo> plotinfos = new ArrayList<Plotinfo>();
|
||||
for (EarnedValueType indicator : getSelectedIndicators()) {
|
||||
Plotinfo plotinfo = createPlotInfo(indicators.get(indicator),
|
||||
interval, indicator.getColor());
|
||||
plotinfos.add(plotinfo);
|
||||
}
|
||||
|
||||
if (plotinfos.isEmpty()) {
|
||||
// If user doesn't select any indicator, it is needed to create
|
||||
// a default Plotinfo in order to avoid errors on Timemplot
|
||||
plotinfos.add(new Plotinfo());
|
||||
}
|
||||
|
||||
ValueGeometry valueGeometry = getValueGeometry();
|
||||
TimeGeometry timeGeometry = getTimeGeometry(interval);
|
||||
|
||||
for (Plotinfo plotinfo : plotinfos) {
|
||||
appendPlotinfo(chart, plotinfo, valueGeometry, timeGeometry);
|
||||
}
|
||||
|
||||
chart.setWidth(size + "px");
|
||||
chart.setHeight("100px");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -307,7 +307,7 @@ public abstract class CompanyPlanningModel implements ICompanyPlanningModel {
|
|||
}
|
||||
}
|
||||
|
||||
private Set<EarnedValueType> getSelectedIndicators() {
|
||||
private Set<EarnedValueType> getEarnedValueSelectedIndicators() {
|
||||
Set<EarnedValueType> result = new HashSet<EarnedValueType>();
|
||||
for (Checkbox checkbox : earnedValueChartConfigurationCheckboxes) {
|
||||
if (checkbox.isChecked()) {
|
||||
|
|
@ -638,38 +638,6 @@ public abstract class CompanyPlanningModel implements ICompanyPlanningModel {
|
|||
|
||||
private class CompanyEarnedValueChartFiller extends EarnedValueChartFiller {
|
||||
|
||||
@Override
|
||||
public void fillChart(Timeplot chart, Interval interval, Integer size) {
|
||||
chart.getChildren().clear();
|
||||
chart.invalidate();
|
||||
resetMinimumAndMaximumValueForChart();
|
||||
|
||||
calculateValues(interval);
|
||||
|
||||
List<Plotinfo> plotinfos = new ArrayList<Plotinfo>();
|
||||
for (EarnedValueType indicator : getSelectedIndicators()) {
|
||||
Plotinfo plotinfo = createPlotInfo(indicators.get(indicator),
|
||||
interval, indicator.getColor());
|
||||
plotinfos.add(plotinfo);
|
||||
}
|
||||
|
||||
if (plotinfos.isEmpty()) {
|
||||
// If user doesn't select any indicator, it is needed to create
|
||||
// a default Plotinfo in order to avoid errors on Timemplot
|
||||
plotinfos.add(new Plotinfo());
|
||||
}
|
||||
|
||||
ValueGeometry valueGeometry = getValueGeometry();
|
||||
TimeGeometry timeGeometry = getTimeGeometry(interval);
|
||||
|
||||
for (Plotinfo plotinfo : plotinfos) {
|
||||
appendPlotinfo(chart, plotinfo, valueGeometry, timeGeometry);
|
||||
}
|
||||
|
||||
chart.setWidth(size + "px");
|
||||
chart.setHeight("100px");
|
||||
}
|
||||
|
||||
protected void calculateBudgetedCostWorkScheduled(Interval interval) {
|
||||
List<TaskElement> list = taskElementDAO.list(TaskElement.class);
|
||||
|
||||
|
|
@ -736,6 +704,10 @@ public abstract class CompanyPlanningModel implements ICompanyPlanningModel {
|
|||
advanceCost, interval.getStart(), interval.getFinish()));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Set<EarnedValueType> getSelectedIndicators() {
|
||||
return getEarnedValueSelectedIndicators();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -323,7 +323,7 @@ public abstract class OrderPlanningModel implements IOrderPlanningModel {
|
|||
}
|
||||
}
|
||||
|
||||
private Set<EarnedValueType> getSelectedIndicators() {
|
||||
private Set<EarnedValueType> getEarnedValueSelectedIndicators() {
|
||||
Set<EarnedValueType> result = new HashSet<EarnedValueType>();
|
||||
for (Checkbox checkbox : earnedValueChartConfigurationCheckboxes) {
|
||||
if (checkbox.isChecked()) {
|
||||
|
|
@ -701,38 +701,6 @@ public abstract class OrderPlanningModel implements IOrderPlanningModel {
|
|||
this.order = orderReloaded;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillChart(Timeplot chart, Interval interval, Integer size) {
|
||||
chart.getChildren().clear();
|
||||
chart.invalidate();
|
||||
resetMinimumAndMaximumValueForChart();
|
||||
|
||||
calculateValues(interval);
|
||||
|
||||
List<Plotinfo> plotinfos = new ArrayList<Plotinfo>();
|
||||
for (EarnedValueType indicator : getSelectedIndicators()) {
|
||||
Plotinfo plotinfo = createPlotInfo(indicators.get(indicator),
|
||||
interval, indicator.getColor());
|
||||
plotinfos.add(plotinfo);
|
||||
}
|
||||
|
||||
if (plotinfos.isEmpty()) {
|
||||
// If user doesn't select any indicator, it is needed to create
|
||||
// a default Plotinfo in order to avoid errors on Timemplot
|
||||
plotinfos.add(new Plotinfo());
|
||||
}
|
||||
|
||||
ValueGeometry valueGeometry = getValueGeometry();
|
||||
TimeGeometry timeGeometry = getTimeGeometry(interval);
|
||||
|
||||
for (Plotinfo plotinfo : plotinfos) {
|
||||
appendPlotinfo(chart, plotinfo, valueGeometry, timeGeometry);
|
||||
}
|
||||
|
||||
chart.setWidth(size + "px");
|
||||
chart.setHeight("100px");
|
||||
}
|
||||
|
||||
protected void calculateBudgetedCostWorkScheduled(Interval interval) {
|
||||
List<TaskElement> list = order
|
||||
.getAllChildrenAssociatedTaskElements();
|
||||
|
|
@ -803,6 +771,11 @@ public abstract class OrderPlanningModel implements IOrderPlanningModel {
|
|||
advanceCost, interval.getStart(), interval.getFinish()));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Set<EarnedValueType> getSelectedIndicators() {
|
||||
return getEarnedValueSelectedIndicators();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue