Rename method to reflect better meaning

FEA: ItEr61S08TimeUnitConfigurablePlanning
This commit is contained in:
Óscar González Fernández 2010-10-08 16:27:56 +02:00
parent 5afea4ffb1
commit 2efb683984
11 changed files with 39 additions and 36 deletions

View file

@ -399,25 +399,25 @@ public class LeftTasksTreeRow extends GenericForwardComposer {
getNameBox().setTooltiptext(task.getName());
getStartDateBox().setValue(
task.getBeginDate().toDateApproximation());
task.getBeginDate().toDayRoundedDate());
getStartDateBox().setDisabled(!canChangeStartDate());
getStartDateTextBox().setDisabled(!canChangeStartDate());
getEndDateBox().setValue(task.getEndDate().toDateApproximation());
getEndDateBox().setValue(task.getEndDate().toDayRoundedDate());
getEndDateBox().setDisabled(!canChangeEndDate());
getEndDateTextBox().setDisabled(!canChangeEndDate());
getStartDateTextBox().setValue(
asString(task.getBeginDate().toDateApproximation()));
asString(task.getBeginDate().toDayRoundedDate()));
getEndDateTextBox().setValue(
asString(task.getEndDate().toDateApproximation()));
asString(task.getEndDate().toDayRoundedDate()));
} else {
nameLabel.setValue(task.getName());
nameLabel.setTooltiptext(task.getName());
startDateLabel.setValue(asString(task.getBeginDate()
.toDateApproximation()));
.toDayRoundedDate()));
endDateLabel.setValue(asString(task.getEndDate()
.toDateApproximation()));
.toDayRoundedDate()));
}
}

View file

@ -354,7 +354,7 @@ public class TaskComponent extends Div implements AfterCompose {
void doUpdateSize(String size) {
int pixels = stripPx(size);
DateTime end = new DateTime(this.task.getBeginDate()
.toDateApproximation().getTime()).plus(getMapper().toDuration(
.toDayRoundedDate().getTime()).plus(getMapper().toDuration(
pixels));
this.task.resizeTo(end.toLocalDate());
updateWidth();
@ -461,7 +461,7 @@ public class TaskComponent extends Div implements AfterCompose {
if (task.getConsolidatedline() != null) {
int pixels = getMapper().toPixels(
LocalDate.fromDateFields(task.getConsolidatedline()
.toDateApproximation()))
.toDayRoundedDate()))
- CONSOLIDATED_MARK_HALF_WIDTH;
String position = pixels + "px";
response(null, new AuInvoke(this, "moveConsolidatedline", position));
@ -498,7 +498,7 @@ public class TaskComponent extends Div implements AfterCompose {
private Duration fromStartUntil(Date until) {
DateTime start = new DateTime(this.task.getBeginDate()
.toDateApproximation().getTime());
.toDayRoundedDate().getTime());
DateTime end = new DateTime(until.getTime());
Duration duration = end.isAfter(start) ? new Duration(start, end)
: Duration.ZERO;

View file

@ -97,8 +97,8 @@ public class TaskEditFormComposer extends GenericForwardComposer {
TaskDTO result = new TaskDTO();
result.name = task.getName();
result.beginDate = task.getBeginDate().toDateApproximation();
result.endDate = task.getEndDate().toDateApproximation();
result.beginDate = task.getBeginDate().toDayRoundedDate();
result.endDate = task.getEndDate().toDayRoundedDate();
result.notes = task.getNotes();
result.deadlineDate = task.getDeadline();

View file

@ -74,7 +74,7 @@ public enum DependencyType {
@Override
public Date calculateStartDestinyTask(Task originalTask,
Date current) {
return getBigger(originalTask.getEndDate().toDateApproximation(),
return getBigger(originalTask.getEndDate().toDayRoundedDate(),
current);
}
@ -104,7 +104,7 @@ public enum DependencyType {
@Override
public Date calculateStartDestinyTask(Task originTask, Date current) {
return getBigger(originTask.getBeginDate().toDateApproximation(),
return getBigger(originTask.getBeginDate().toDayRoundedDate(),
current);
}
@ -128,7 +128,7 @@ public enum DependencyType {
@Override
public Date calculateEndDestinyTask(Task originTask, Date current) {
return getBigger(originTask.getEndDate().toDateApproximation(),
return getBigger(originTask.getEndDate().toDayRoundedDate(),
current);
}

View file

@ -87,8 +87,11 @@ public abstract class GanttDate implements Comparable<GanttDate> {
public abstract <R> R byCases(ICases<R> cases);
// TODO remove this method
public abstract Date toDateApproximation();
/**
* Converts this {@link GanttDate} to a date that is the start of the day
* represented by this {@link GanttDate}
*/
public abstract Date toDayRoundedDate();
public static class LocalDateBased extends GanttDate {
@ -124,7 +127,7 @@ public abstract class GanttDate implements Comparable<GanttDate> {
}
@Override
public Date toDateApproximation() {
public Date toDayRoundedDate() {
return localDate.toDateTimeAtStartOfDay().toDate();
}

View file

@ -183,13 +183,13 @@ public abstract class Task implements ITaskFundamentalProperties {
}
public long getLengthMilliseconds() {
return getEndDate().toDateApproximation().getTime()
- getBeginDate().toDateApproximation().getTime();
return getEndDate().toDayRoundedDate().getTime()
- getBeginDate().toDayRoundedDate().getTime();
}
public ReadableDuration getLength() {
return new Duration(getBeginDate().toDateApproximation().getTime(),
getEndDate().toDateApproximation().getTime());
return new Duration(getBeginDate().toDayRoundedDate().getTime(),
getEndDate().toDayRoundedDate().getTime());
}
public void addVisibilityPropertiesChangeListener(
@ -387,7 +387,7 @@ public abstract class Task implements ITaskFundamentalProperties {
}
public LocalDate getBeginDateAsLocalDate() {
return LocalDate.fromDateFields(getBeginDate().toDateApproximation());
return LocalDate.fromDateFields(getBeginDate().toDayRoundedDate());
}
}

View file

@ -76,7 +76,7 @@ public class CriticalPathCalculator<T extends ITaskFundamentalProperties> {
return null;
}
GanttDate ganttDate = Collections.min(getStartDates());
return LocalDate.fromDateFields(ganttDate.toDateApproximation());
return LocalDate.fromDateFields(ganttDate.toDayRoundedDate());
}
private List<GanttDate> getStartDates() {
@ -173,7 +173,7 @@ public class CriticalPathCalculator<T extends ITaskFundamentalProperties> {
.plusDays(earliestStart));
date = constraint.applyTo(date);
earliestStart = Days.daysBetween(initDate,
LocalDate.fromDateFields(date.toDateApproximation()))
LocalDate.fromDateFields(date.toDayRoundedDate()))
.getDays();
}
node.setEarliestStart(earliestStart);
@ -247,7 +247,7 @@ public class CriticalPathCalculator<T extends ITaskFundamentalProperties> {
GanttDate date = GanttDate.createFrom(initDate.plusDays(latestFinish - duration));
date = constraint.applyTo(date);
int daysBetween = Days.daysBetween(initDate,
LocalDate.fromDateFields(date.toDateApproximation()))
LocalDate.fromDateFields(date.toDayRoundedDate()))
.getDays();
latestFinish = daysBetween + duration;
}

View file

@ -109,13 +109,13 @@ public class Node<T extends ITaskFundamentalProperties> {
}
LocalDate beginDate = new LocalDate(task.getBeginDate()
.toDateApproximation());
.toDayRoundedDate());
LocalDate endDate = getTaskEndDate();
return Days.daysBetween(beginDate, endDate).getDays();
}
private LocalDate getTaskEndDate() {
return new LocalDate(task.getEndDate().toDateApproximation());
return new LocalDate(task.getEndDate().toDayRoundedDate());
}
@Override

View file

@ -321,18 +321,18 @@ public class TimeTracker {
}
private LocalDate endPlusOneMonth(Task task) {
Date taskEnd = max(task.getEndDate().toDateApproximation(),
Date taskEnd = max(task.getEndDate().toDayRoundedDate(),
task.getDeadline());
return new LocalDate(taskEnd).plusMonths(1);
}
private LocalDate startMinusTwoWeeks(Task task) {
// the deadline could be before the start
Date start = min(task.getBeginDate().toDateApproximation(),
Date start = min(task.getBeginDate().toDayRoundedDate(),
task.getDeadline());
// the last consolidated value could be before the start
if (task.getConsolidatedline() != null) {
start = min(start, task.getConsolidatedline().toDateApproximation());
start = min(start, task.getConsolidatedline().toDayRoundedDate());
}
return new LocalDate(start).minusWeeks(2);
}

View file

@ -113,9 +113,9 @@ public class CriticalPathCalculatorTest {
private int daysBetweenStartAndEnd(ITaskFundamentalProperties task) {
LocalDate start = LocalDate.fromDateFields(task.getBeginDate()
.toDateApproximation());
.toDayRoundedDate());
LocalDate end = LocalDate.fromDateFields(task.getEndDate()
.toDateApproximation());
.toDayRoundedDate());
return Days.daysBetween(start, end).getDays();
}

View file

@ -216,7 +216,7 @@ public class TaskElementAdapter implements ITaskElementAdapter {
}
@Override
public Date toDateApproximation() {
public Date toDayRoundedDate() {
return date.toDateTimeAtStartOfDay().toDate();
}
@ -322,7 +322,7 @@ public class TaskElementAdapter implements ITaskElementAdapter {
Integer hours = taskElement.getSumOfHoursAllocated();
if (hours == 0) {
return getBeginDate().toDateApproximation();
return getBeginDate().toDayRoundedDate();
} else {
BigDecimal percentage = new BigDecimal(assignedHours)
.setScale(2).divide(new BigDecimal(hours),
@ -387,12 +387,12 @@ public class TaskElementAdapter implements ITaskElementAdapter {
private LocalDate calculateLimitDate(BigDecimal advancePercentage) {
if (advancePercentage.compareTo(BigDecimal.ZERO) == 0) {
return new LocalDate(getBeginDate().toDateApproximation());
return new LocalDate(getBeginDate().toDayRoundedDate());
}
Long totalMillis = taskElement.getLengthMilliseconds();
Long advanceMillis = advancePercentage.multiply(
new BigDecimal(totalMillis)).longValue();
return new LocalDate(getBeginDate().toDateApproximation().getTime()
return new LocalDate(getBeginDate().toDayRoundedDate().getTime()
+ advanceMillis).plusDays(1);
}