Move methods for getting efforts representations

FEA: ItEr68OTS05IntroducionLimiteSobreasignacionCalendarios
This commit is contained in:
Óscar González Fernández 2011-01-17 20:00:12 +01:00
parent b2b21b61a1
commit bdc66d29af
3 changed files with 29 additions and 13 deletions

View file

@ -134,17 +134,6 @@ public class CalendarExceptionType extends IntegrationEntity {
return capacity.getStandardEffort();
}
public String getStandardEffortStr() {
return asString(getCapacity().getStandardEffort());
}
public String getExtraEffortStr() {
if (getCapacity().getAllowedExtraEffort() == null) {
return _("unlimited");
}
return asString(getCapacity().getAllowedExtraEffort());
}
private String asString(EffortDuration duration) {
if (duration == null) {
return "";

View file

@ -19,10 +19,15 @@
package org.navalplanner.business.calendars.entities;
import static org.navalplanner.business.i18n.I18nHelper._;
import java.util.EnumMap;
import org.apache.commons.lang.Validate;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.navalplanner.business.workingday.EffortDuration;
import org.navalplanner.business.workingday.EffortDuration.Granularity;
/**
* This class is intended as a Hibernate component. It's formed by two
@ -92,6 +97,28 @@ public class Capacity {
}
}
public String getStandardEffortString() {
return asString(getStandardEffort());
}
public String getExtraEffortString() {
if (getAllowedExtraEffort() == null) {
return _("unlimited");
}
return asString(getAllowedExtraEffort());
}
private static String asString(EffortDuration duration) {
if (duration == null) {
return "";
}
EnumMap<Granularity, Integer> values = duration.decompose();
Integer hours = values.get(Granularity.HOURS);
Integer minutes = values.get(Granularity.MINUTES);
Integer seconds = values.get(Granularity.SECONDS);
return hours + ":" + minutes + ":" + seconds;
}
@Override
public boolean equals(Object obj) {
if (obj instanceof Capacity) {

View file

@ -38,8 +38,8 @@
<label value="@{exceptionDayType.name}" />
<label value="@{exceptionDayType.color}" />
<label value="@{exceptionDayType.overAssignableStr}" />
<label value="@{exceptionDayType.standardEffortStr}" />
<label value="@{exceptionDayType.extraEffortStr}" />
<label value="@{exceptionDayType.capacity.standardEffortString}" />
<label value="@{exceptionDayType.capacity.extraEffortString}" />
<!-- Operation -->
<hbox>