ITaskFundamentalProperties now works with GanttDates

FEA: ItEr61S08TimeUnitConfigurablePlanning
This commit is contained in:
Óscar González Fernández 2010-10-06 14:22:32 +02:00
parent 07df77601f
commit 6c61f36d28
19 changed files with 191 additions and 120 deletions

View file

@ -31,6 +31,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.joda.time.LocalDate;
import org.zkoss.ganttz.adapters.IDisabilityConfiguration;
import org.zkoss.ganttz.data.GanttDate;
import org.zkoss.ganttz.data.Task;
import org.zkoss.ganttz.util.ComponentsFinder;
import org.zkoss.util.Locales;
@ -384,7 +385,7 @@ public class LeftTasksTreeRow extends GenericForwardComposer {
task.setName(getNameBox().getValue());
} else if (updatedComponent == getStartDateBox()) {
Date begin = getStartDateBox().getValue();
task.moveTo(LocalDate.fromDateFields(begin));
task.moveTo(GanttDate.createFrom(begin));
} else if (updatedComponent == getEndDateBox()) {
Date newEnd = getEndDateBox().getValue();
task.resizeTo(LocalDate.fromDateFields(newEnd));
@ -397,21 +398,26 @@ public class LeftTasksTreeRow extends GenericForwardComposer {
getNameBox().setDisabled(!canRenameTask());
getNameBox().setTooltiptext(task.getName());
getStartDateBox().setValue(task.getBeginDate());
getStartDateBox().setValue(
task.getBeginDate().toDateApproximation());
getStartDateBox().setDisabled(!canChangeStartDate());
getStartDateTextBox().setDisabled(!canChangeStartDate());
getEndDateBox().setValue(task.getEndDate());
getEndDateBox().setValue(task.getEndDate().toDateApproximation());
getEndDateBox().setDisabled(!canChangeEndDate());
getEndDateTextBox().setDisabled(!canChangeEndDate());
getStartDateTextBox().setValue(asString(task.getBeginDate()));
getEndDateTextBox().setValue(asString(task.getEndDate()));
getStartDateTextBox().setValue(
asString(task.getBeginDate().toDateApproximation()));
getEndDateTextBox().setValue(
asString(task.getEndDate().toDateApproximation()));
} else {
nameLabel.setValue(task.getName());
nameLabel.setTooltiptext(task.getName());
startDateLabel.setValue(asString(task.getBeginDate()));
endDateLabel.setValue(asString(task.getEndDate()));
startDateLabel.setValue(asString(task.getBeginDate()
.toDateApproximation()));
endDateLabel.setValue(asString(task.getEndDate()
.toDateApproximation()));
}
}

View file

@ -35,6 +35,7 @@ import org.joda.time.DateTime;
import org.joda.time.Duration;
import org.joda.time.LocalDate;
import org.zkoss.ganttz.adapters.IDisabilityConfiguration;
import org.zkoss.ganttz.data.GanttDate;
import org.zkoss.ganttz.data.Milestone;
import org.zkoss.ganttz.data.Task;
import org.zkoss.ganttz.data.Task.IReloadResourcesTextRequested;
@ -340,9 +341,9 @@ public class TaskComponent extends Div implements AfterCompose {
}
void doUpdatePosition(String leftX, String topY) {
Date startBeforeMoving = this.task.getBeginDate();
GanttDate startBeforeMoving = this.task.getBeginDate();
LocalDate newPosition = getMapper().toDate(stripPx(leftX));
this.task.moveTo(newPosition);
this.task.moveTo(GanttDate.createFrom(newPosition));
boolean remainsInOriginalPosition = this.task.getBeginDate().equals(
startBeforeMoving);
if (remainsInOriginalPosition) {
@ -352,8 +353,9 @@ public class TaskComponent extends Div implements AfterCompose {
void doUpdateSize(String size) {
int pixels = stripPx(size);
DateTime end = new DateTime(this.task.getBeginDate().getTime())
.plus(getMapper().toDuration(pixels));
DateTime end = new DateTime(this.task.getBeginDate()
.toDateApproximation().getTime()).plus(getMapper().toDuration(
pixels));
this.task.resizeTo(end.toLocalDate());
updateWidth();
}
@ -494,7 +496,8 @@ public class TaskComponent extends Div implements AfterCompose {
}
private Duration fromStartUntil(Date until) {
DateTime start = new DateTime(this.task.getBeginDate().getTime());
DateTime start = new DateTime(this.task.getBeginDate()
.toDateApproximation().getTime());
DateTime end = new DateTime(until.getTime());
Duration duration = end.isAfter(start) ? new Duration(start, end)
: Duration.ZERO;

View file

@ -22,7 +22,7 @@ package org.zkoss.ganttz;
import java.util.Date;
import org.joda.time.LocalDate;
import org.zkoss.ganttz.data.GanttDate;
import org.zkoss.ganttz.data.Task;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.util.GenericForwardComposer;
@ -97,8 +97,8 @@ public class TaskEditFormComposer extends GenericForwardComposer {
TaskDTO result = new TaskDTO();
result.name = task.getName();
result.beginDate = task.getBeginDate();
result.endDate = task.getEndDate();
result.beginDate = task.getBeginDate().toDateApproximation();
result.endDate = task.getEndDate().toDateApproximation();
result.notes = task.getNotes();
result.deadlineDate = task.getDeadline();
@ -107,8 +107,8 @@ public class TaskEditFormComposer extends GenericForwardComposer {
private void copyFromDTO(TaskDTO taskDTO, Task currentTask) {
currentTask.setName(taskDTO.name);
currentTask.setBeginDate(taskDTO.beginDate);
currentTask.resizeTo(LocalDate.fromDateFields(taskDTO.endDate));
currentTask.setBeginDate(GanttDate.createFrom(taskDTO.beginDate));
currentTask.resizeTo(GanttDate.createFrom(taskDTO.endDate));
currentTask.setNotes(taskDTO.notes);
currentTask.setDeadline(taskDTO.deadlineDate);
}

View file

@ -25,7 +25,10 @@ import java.util.Collections;
import java.util.Date;
import java.util.List;
import org.joda.time.LocalDate;
import org.joda.time.DateTime;
import org.zkoss.ganttz.data.GanttDate.CustomDate;
import org.zkoss.ganttz.data.GanttDate.ICases;
import org.zkoss.ganttz.data.GanttDate.LocalDateBased;
import org.zkoss.ganttz.data.constraint.Constraint;
/**
@ -84,12 +87,36 @@ public class DefaultFundamentalProperties implements ITaskFundamentalProperties
this.name = name;
}
public Date getBeginDate() {
return new Date(beginDate);
private static GanttDate toGanttDate(long milliseconds) {
return GanttDate.createFrom(new DateTime(milliseconds).toLocalDate());
}
public void setBeginDate(Date beginDate) {
this.beginDate = beginDate.getTime();
private static long toMilliseconds(GanttDate date) {
return date.byCases(new ICases<Long>() {
@Override
public Long on(LocalDateBased localDateBased) {
return localDateBased.getLocalDate().toDateTimeAtStartOfDay()
.getMillis();
}
@Override
public Long on(CustomDate customType) {
throw new UnsupportedOperationException("no custom "
+ GanttDate.class.getSimpleName() + " for "
+ DefaultFundamentalProperties.class.getSimpleName());
}
});
}
@Override
public GanttDate getBeginDate() {
return toGanttDate(beginDate);
}
@Override
public void setBeginDate(GanttDate beginDate) {
this.beginDate = toMilliseconds(beginDate);
}
public long getLengthMilliseconds() {
@ -97,13 +124,13 @@ public class DefaultFundamentalProperties implements ITaskFundamentalProperties
}
@Override
public Date getEndDate() {
return new Date(beginDate + getLengthMilliseconds());
public GanttDate getEndDate() {
return toGanttDate(beginDate + getLengthMilliseconds());
}
@Override
public void setEndDate(Date endDate) {
this.lengthMilliseconds = endDate.getTime() - beginDate;
public void setEndDate(GanttDate endDate) {
this.lengthMilliseconds = toMilliseconds(endDate) - beginDate;
}
public String getNotes() {
@ -155,8 +182,8 @@ public class DefaultFundamentalProperties implements ITaskFundamentalProperties
}
@Override
public void moveTo(LocalDate date) {
setBeginDate(date.toDateTimeAtStartOfDay().toDate());
public void moveTo(GanttDate date) {
setBeginDate(date);
}
@Override

View file

@ -73,7 +73,8 @@ public enum DependencyType {
@Override
public Date calculateStartDestinyTask(Task originalTask,
Date current) {
return getBigger(originalTask.getEndDate(), current);
return getBigger(originalTask.getEndDate().toDateApproximation(),
current);
}
public <V> List<Constraint<Date>> getStartConstraints(V source,
@ -102,7 +103,8 @@ public enum DependencyType {
@Override
public Date calculateStartDestinyTask(Task originTask, Date current) {
return getBigger(originTask.getBeginDate(), current);
return getBigger(originTask.getBeginDate().toDateApproximation(),
current);
}
public <V> List<Constraint<Date>> getStartConstraints(V source,
@ -125,7 +127,8 @@ public enum DependencyType {
@Override
public Date calculateEndDestinyTask(Task originTask, Date current) {
return getBigger(originTask.getEndDate(), current);
return getBigger(originTask.getEndDate().toDateApproximation(),
current);
}
@Override

View file

@ -180,7 +180,7 @@ public class GanttDiagramGraph<V, D> {
@Override
public Date getEndDateFor(Task task) {
return task.getEndDate();
return task.getEndDate().toDateApproximation();
}
@Override
@ -202,17 +202,17 @@ public class GanttDiagramGraph<V, D> {
@Override
public void setEndDateFor(Task task, Date newEnd) {
task.setEndDate(newEnd);
task.setEndDate(GanttDate.createFrom(newEnd));
}
@Override
public Date getStartDate(Task task) {
return task.getBeginDate();
return task.getBeginDate().toDateApproximation();
}
@Override
public void setStartDateFor(Task task, Date newStart) {
task.setBeginDate(newStart);
task.setBeginDate(GanttDate.createFrom(newStart));
}
@Override
@ -228,7 +228,8 @@ public class GanttDiagramGraph<V, D> {
@Override
public Date getSmallestBeginDateFromChildrenFor(Task container) {
return ((TaskContainer) container).getSmallestBeginDateFromChildren();
return ((TaskContainer) container)
.getSmallestBeginDateFromChildren().toDateApproximation();
}
@Override

View file

@ -24,7 +24,6 @@ import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import org.joda.time.LocalDate;
import org.zkoss.ganttz.data.constraint.Constraint;
/**
@ -39,9 +38,9 @@ public interface ITaskFundamentalProperties {
/**
* Sets the beginDate.
*/
public void setBeginDate(Date beginDate);
public void setBeginDate(GanttDate beginDate);
public Date getBeginDate();
public GanttDate getBeginDate();
/**
* The deadline associated to the task. It can return null if has no
@ -53,9 +52,9 @@ public interface ITaskFundamentalProperties {
public Date getConsolidatedline();
public Date getEndDate();
public GanttDate getEndDate();
public void setEndDate(Date endDate);
public void setEndDate(GanttDate endDate);
public String getNotes();
@ -77,7 +76,7 @@ public interface ITaskFundamentalProperties {
List<Constraint<Date>> getStartConstraints();
public void moveTo(LocalDate date);
public void moveTo(GanttDate date);
public boolean isSubcontracted();

View file

@ -155,12 +155,15 @@ public abstract class Task implements ITaskFundamentalProperties {
Validate.notNull(dependenciesEnforcerHook);
}
public void setBeginDate(Date newStart) {
Date previousValue = fundamentalProperties.getBeginDate();
Date previousEnd = fundamentalProperties.getEndDate();
public void setBeginDate(GanttDate newStart) {
GanttDate previousValue = fundamentalProperties.getBeginDate();
GanttDate previousEnd = fundamentalProperties.getEndDate();
fundamentalProperties.setBeginDate(newStart);
dependenciesEnforcerHook.setStartDate(previousValue, previousEnd,
newStart);
Date newStartDate = newStart != null ? newStart.toDateApproximation()
: null;
dependenciesEnforcerHook.setStartDate(
previousValue.toDateApproximation(),
previousEnd.toDateApproximation(), newStartDate);
}
private void reloadResourcesTextIfChange(Date newDate, Date previousDate) {
@ -169,23 +172,27 @@ public abstract class Task implements ITaskFundamentalProperties {
}
}
public void fireChangesForPreviousValues(Date previousStart,
Date previousEnd) {
dependenciesEnforcerHook.setStartDate(previousStart, previousEnd,
fundamentalProperties.getBeginDate());
dependenciesEnforcerHook.setNewEnd(previousEnd, getEndDate());
public void fireChangesForPreviousValues(GanttDate previousStart,
GanttDate previousEnd) {
dependenciesEnforcerHook.setStartDate(previousStart
.toDateApproximation(), previousEnd.toDateApproximation(),
fundamentalProperties.getBeginDate().toDateApproximation());
dependenciesEnforcerHook.setNewEnd(previousEnd.toDateApproximation(),
getEndDate().toDateApproximation());
}
public Date getBeginDate() {
return new Date(fundamentalProperties.getBeginDate().getTime());
public GanttDate getBeginDate() {
return fundamentalProperties.getBeginDate();
}
public long getLengthMilliseconds() {
return getEndDate().getTime() - getBeginDate().getTime();
return getEndDate().toDateApproximation().getTime()
- getBeginDate().toDateApproximation().getTime();
}
public ReadableDuration getLength() {
return new Duration(getBeginDate().getTime(), getEndDate().getTime());
return new Duration(getBeginDate().toDateApproximation().getTime(),
getEndDate().toDateApproximation().getTime());
}
public void addVisibilityPropertiesChangeListener(
@ -209,7 +216,7 @@ public abstract class Task implements ITaskFundamentalProperties {
}
@Override
public Date getEndDate() {
public GanttDate getEndDate() {
return fundamentalProperties.getEndDate();
}
@ -218,12 +225,12 @@ public abstract class Task implements ITaskFundamentalProperties {
return Constraint.emptyConstraint();
}
return violationNotificator.withListener(DateConstraint
.biggerOrEqualThan(getEndDate()));
.biggerOrEqualThan(getEndDate().toDateApproximation()));
}
public Constraint<Date> getEndDateBiggerThanStartDate() {
return violationNotificator.withListener(DateConstraint
.biggerOrEqualThan(getBeginDate()));
.biggerOrEqualThan(getBeginDate().toDateApproximation()));
}
public String getNotes() {
@ -238,18 +245,22 @@ public abstract class Task implements ITaskFundamentalProperties {
}
@Override
public void setEndDate(Date value) {
public void setEndDate(GanttDate value) {
if (value == null) {
return;
}
Date previousEnd = fundamentalProperties.getEndDate();
GanttDate previousEnd = fundamentalProperties.getEndDate();
fundamentalProperties.setEndDate(value);
dependenciesEnforcerHook.setNewEnd(previousEnd,
fundamentalProperties.getEndDate());
dependenciesEnforcerHook.setNewEnd(previousEnd.toDateApproximation(),
fundamentalProperties.getEndDate().toDateApproximation());
}
public void resizeTo(LocalDate date) {
setEndDate(date.toDateTimeAtStartOfDay().toDate());
resizeTo(GanttDate.createFrom(date));
}
public void resizeTo(GanttDate date) {
setEndDate(date);
}
public void removed() {
@ -292,12 +303,12 @@ public abstract class Task implements ITaskFundamentalProperties {
return fundamentalProperties.getResourcesText();
}
public void moveTo(LocalDate date) {
Date previousStart = getBeginDate();
Date previousEnd = getEndDate();
public void moveTo(GanttDate date) {
Date previousStart = getBeginDate().toDateApproximation();
Date previousEnd = getEndDate().toDateApproximation();
fundamentalProperties.moveTo(date);
dependenciesEnforcerHook.setStartDate(previousStart, previousEnd, date
.toDateTimeAtStartOfDay().toDate());
dependenciesEnforcerHook.setStartDate(previousStart, previousEnd,
date.toDateApproximation());
}
@Override
@ -380,7 +391,7 @@ public abstract class Task implements ITaskFundamentalProperties {
}
public LocalDate getBeginDateAsLocalDate() {
return LocalDate.fromDateFields(getBeginDate());
return LocalDate.fromDateFields(getBeginDate().toDateApproximation());
}
}

View file

@ -23,7 +23,6 @@ package org.zkoss.ganttz.data;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import org.zkoss.ganttz.util.WeakReferencedListeners;
@ -88,30 +87,30 @@ public class TaskContainer extends Task {
return tasks;
}
public Date getSmallestBeginDateFromChildren() {
public GanttDate getSmallestBeginDateFromChildren() {
if (tasks.isEmpty()) {
return getBeginDate();
}
return getSmallest(getStartDates());
}
private List<Date> getStartDates() {
ArrayList<Date> result = new ArrayList<Date>();
private List<GanttDate> getStartDates() {
ArrayList<GanttDate> result = new ArrayList<GanttDate>();
for (Task task : tasks) {
result.add(task.getBeginDate());
}
return result;
}
private List<Date> getEndDates() {
ArrayList<Date> result = new ArrayList<Date>();
private List<GanttDate> getEndDates() {
ArrayList<GanttDate> result = new ArrayList<GanttDate>();
for (Task task : tasks) {
result.add(task.getEndDate());
}
return result;
}
public Date getBiggestDateFromChildren() {
public GanttDate getBiggestDateFromChildren() {
if (tasks.isEmpty()) {
return getEndDate();
}

View file

@ -21,6 +21,7 @@
package org.zkoss.ganttz.data.criticalpath;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
@ -31,6 +32,7 @@ import java.util.Set;
import org.joda.time.Days;
import org.joda.time.LocalDate;
import org.zkoss.ganttz.data.DependencyType;
import org.zkoss.ganttz.data.GanttDate;
import org.zkoss.ganttz.data.IDependency;
import org.zkoss.ganttz.data.ITaskFundamentalProperties;
import org.zkoss.ganttz.data.constraint.Constraint;
@ -75,15 +77,16 @@ public class CriticalPathCalculator<T extends ITaskFundamentalProperties> {
if (initialTasks.isEmpty()) {
return null;
}
GanttDate ganttDate = Collections.min(getStartDates());
return LocalDate.fromDateFields(ganttDate.toDateApproximation());
}
Date result = initialTasks.get(0).getBeginDate();
for (T task : initialTasks) {
Date date = task.getBeginDate();
if (date.compareTo(result) < 0) {
result = date;
}
private List<GanttDate> getStartDates() {
List<GanttDate> result = new ArrayList<GanttDate>();
for (T task : graph.getInitialTasks()) {
result.add(task.getBeginDate());
}
return new LocalDate(result);
return result;
}
private InitialNode<T> createBeginningOfProjectNode() {

View file

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

View file

@ -321,13 +321,15 @@ public class TimeTracker {
}
private LocalDate endPlusOneMonth(Task task) {
Date taskEnd = max(task.getEndDate(), task.getDeadline());
Date taskEnd = max(task.getEndDate().toDateApproximation(),
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(), task.getDeadline());
Date start = min(task.getBeginDate().toDateApproximation(),
task.getDeadline());
// the last consolidated value could be before the start
if (task.getConsolidatedline() != null) {
start = min(start, task.getConsolidatedline());

View file

@ -36,6 +36,7 @@ import org.joda.time.Days;
import org.joda.time.LocalDate;
import org.junit.Test;
import org.zkoss.ganttz.data.DependencyType;
import org.zkoss.ganttz.data.GanttDate;
import org.zkoss.ganttz.data.IDependency;
import org.zkoss.ganttz.data.ITaskFundamentalProperties;
import org.zkoss.ganttz.data.constraint.Constraint;
@ -106,13 +107,15 @@ public class CriticalPathCalculatorTest {
return dependency;
}
private Date toDate(LocalDate localDate) {
return localDate.toDateTimeAtStartOfDay().toDate();
private GanttDate toDate(LocalDate localDate) {
return GanttDate.createFrom(localDate);
}
private int daysBetweenStartAndEnd(ITaskFundamentalProperties task) {
LocalDate start = LocalDate.fromDateFields(task.getBeginDate());
LocalDate end = LocalDate.fromDateFields(task.getEndDate());
LocalDate start = LocalDate.fromDateFields(task.getBeginDate()
.toDateApproximation());
LocalDate end = LocalDate.fromDateFields(task.getEndDate()
.toDateApproximation());
return Days.daysBetween(start, end).getDays();
}

View file

@ -152,10 +152,16 @@ public class TaskElementAdapter implements ITaskElementAdapter {
}
public static GanttDate toGantt(IntraDayDate date) {
if (date == null) {
return null;
}
return new GanttDateAdapter(date);
}
public static IntraDayDate toIntraDay(GanttDate date) {
if (date == null) {
return null;
}
return date.byCases(new Cases<GanttDateAdapter, IntraDayDate>(
GanttDateAdapter.class) {
@ -172,6 +178,9 @@ public class TaskElementAdapter implements ITaskElementAdapter {
}
public static LocalDate toLocalDate(GanttDate date) {
if (date == null) {
return null;
}
return toIntraDay(date).getDate();
}
@ -251,40 +260,38 @@ public class TaskElementAdapter implements ITaskElementAdapter {
}
@Override
public Date getBeginDate() {
return taskElement.getStartDate();
public GanttDate getBeginDate() {
return toGantt(taskElement.getIntraDayStartDate());
}
@Override
public void setBeginDate(final Date beginDate) {
setBeginDate(beginDate != null ? LocalDate
.fromDateFields(beginDate) : null);
}
private void setBeginDate(final LocalDate beginDate) {
public void setBeginDate(final GanttDate beginDate) {
transactionService
.runOnReadOnlyTransaction(new IOnTransaction<Void>() {
@Override
public Void execute() {
stepsBeforePossibleReallocation();
taskElement.moveTo(currentScenario, beginDate);
taskElement.moveTo(currentScenario,
toIntraDay(beginDate));
return null;
}
});
}
@Override
public Date getEndDate() {
return taskElement.getEndDate();
public GanttDate getEndDate() {
return toGantt(taskElement.getIntraDayEndDate());
}
public void setEndDate(final Date endDate) {
@Override
public void setEndDate(final GanttDate endDate) {
transactionService
.runOnReadOnlyTransaction(new IOnTransaction<Void>() {
@Override
public Void execute() {
stepsBeforePossibleReallocation();
taskElement.resizeTo(currentScenario, endDate);
taskElement.resizeTo(currentScenario,
toIntraDay(endDate));
return null;
}
});
@ -308,7 +315,7 @@ public class TaskElementAdapter implements ITaskElementAdapter {
}
if (hours == 0) {
return getBeginDate();
return getBeginDate().toDateApproximation();
} else {
BigDecimal percentage = new BigDecimal(assignedHours)
.setScale(2).divide(new BigDecimal(hours),
@ -365,7 +372,8 @@ public class TaskElementAdapter implements ITaskElementAdapter {
Long totalMillis = taskElement.getLengthMilliseconds();
Long advanceMillis = advancePercentage.multiply(
new BigDecimal(totalMillis)).longValue();
return new LocalDate(getBeginDate().getTime() + advanceMillis);
return new LocalDate(getBeginDate().toDateApproximation().getTime()
+ advanceMillis);
}
@Override
@ -596,11 +604,11 @@ public class TaskElementAdapter implements ITaskElementAdapter {
}
@Override
public void moveTo(LocalDate date) {
public void moveTo(GanttDate date) {
setBeginDate(date);
if (taskElement instanceof Task) {
Task task = (Task) taskElement;
task.explicityMoved(date);
task.explicityMoved(toLocalDate(date));
}
}

View file

@ -60,6 +60,7 @@ import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.zkoss.ganttz.data.GanttDate;
import org.zkoss.ganttz.extensions.IContextWithPlannerTask;
/**
@ -195,8 +196,8 @@ public class ResourceAllocationModel implements IResourceAllocationModel {
private void applyAllocationWithDateChangesNotification(
IOnTransaction<?> allocationDoer) {
org.zkoss.ganttz.data.Task ganttTask = context.getTask();
Date previousStartDate = ganttTask.getBeginDate();
Date previousEnd = ganttTask.getEndDate();
GanttDate previousStartDate = ganttTask.getBeginDate();
GanttDate previousEnd = ganttTask.getEndDate();
transactionService.runOnReadOnlyTransaction(allocationDoer);
ganttTask.fireChangesForPreviousValues(previousStartDate, previousEnd);
}

View file

@ -56,6 +56,7 @@ import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.zkoss.ganttz.data.GanttDate;
import org.zkoss.ganttz.extensions.IContextWithPlannerTask;
/**
@ -136,8 +137,8 @@ public class AdvanceConsolidationModel implements IAdvanceConsolidationModel {
public void accept() {
if (context != null && orderElement != null && isVisibleAdvances()) {
org.zkoss.ganttz.data.Task ganttTask = context.getTask();
Date previousStartDate = ganttTask.getBeginDate();
Date previousEnd = ganttTask.getEndDate();
GanttDate previousStartDate = ganttTask.getBeginDate();
GanttDate previousEnd = ganttTask.getEndDate();
createConsolidationIfNeeded();

View file

@ -36,6 +36,7 @@ import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.zkoss.ganttz.data.GanttDate;
/**
* Model for UI operations related with subcontract process and
@ -124,8 +125,8 @@ public class SubcontractModel implements ISubcontractModel {
}
private void recalculateTaskLength() {
Date previousStartDate = ganttTask.getBeginDate();
Date previousEnd = ganttTask.getEndDate();
GanttDate previousStartDate = ganttTask.getBeginDate();
GanttDate previousEnd = ganttTask.getEndDate();
task.setStartDate(startDate);
task.setEndDate(endDate);

View file

@ -23,7 +23,6 @@ import static org.navalplanner.business.i18n.I18nHelper._;
import static org.zkoss.ganttz.util.LongOperationFeedback.and;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@ -45,6 +44,7 @@ import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.zkoss.ganttz.adapters.IDomainAndBeansMapper;
import org.zkoss.ganttz.data.GanttDate;
import org.zkoss.ganttz.data.GanttDiagramGraph;
import org.zkoss.ganttz.data.GanttDiagramGraph.DeferedNotifier;
import org.zkoss.ganttz.data.Task;
@ -145,8 +145,9 @@ public class ReassignCommand implements IReassignCommand {
final int total = reassignations.size();
for (final WithAssociatedEntity each : reassignations) {
Task ganttTask = each.ganntTask;
final Date previousBeginDate = ganttTask.getBeginDate();
final Date previousEnd = ganttTask.getEndDate();
final GanttDate previousBeginDate = ganttTask
.getBeginDate();
final GanttDate previousEnd = ganttTask.getEndDate();
transactionService
.runOnReadOnlyTransaction(reassignmentTransaction(each));

View file

@ -24,6 +24,7 @@ import java.util.List;
import org.apache.commons.lang.Validate;
import org.joda.time.LocalDate;
import org.navalplanner.web.planner.TaskElementAdapter;
import org.zkoss.ganttz.data.Task;
/**
@ -62,8 +63,8 @@ public class ReassignConfiguration {
}
private boolean isAfterDate(Task each) {
LocalDate start = LocalDate.fromDateFields(each.getBeginDate());
LocalDate end = LocalDate.fromDateFields(each.getEndDate());
LocalDate start = TaskElementAdapter.toLocalDate(each.getBeginDate());
LocalDate end = TaskElementAdapter.toLocalDate(each.getEndDate());
return start.compareTo(date) > 0 || end.compareTo(date) > 0;
}