Bug #1387: Fix bug

Possible fix of the first problem. It looks into the
SchedulingDataForVersion instead of the data to see the status in the
database instead of in memory so the synchronizations sent to the
database are ok.
This commit is contained in:
Óscar González Fernández 2012-03-26 18:46:32 +02:00 committed by Jacobo Aragunde Pérez
parent 16e3d1860e
commit d6468ddd1c

View file

@ -57,7 +57,6 @@ import org.libreplan.business.orders.entities.SchedulingState.Type;
import org.libreplan.business.orders.entities.TaskSource.TaskSourceSynchronization;
import org.libreplan.business.planner.entities.Task;
import org.libreplan.business.planner.entities.TaskElement;
import org.libreplan.business.planner.entities.TaskGroup;
import org.libreplan.business.planner.entities.TaskPositionConstraint;
import org.libreplan.business.qualityforms.entities.QualityForm;
import org.libreplan.business.qualityforms.entities.TaskQualityForm;
@ -291,7 +290,7 @@ public abstract class OrderElement extends IntegrationEntity implements
SchedulingDataForVersion schedulingDataForVersion) {
List<TaskSourceSynchronization> result = new ArrayList<TaskSourceSynchronization>();
if (isSchedulingPoint()) {
if(isSchedulingPointButItWasNot()) {
if (itWasntSchedulingPoint()) {
//this element was a container but now it's a scheduling point
//we have to remove the TaskSource which contains a TaskGroup instead of TaskElement
removeTaskSource(result);
@ -329,9 +328,10 @@ public abstract class OrderElement extends IntegrationEntity implements
&& getTaskSource().getTask() instanceof Task;
}
private boolean isSchedulingPointButItWasNot() {
return getTaskSource() != null
&& getTaskSource().getTask() instanceof TaskGroup;
private boolean itWasntSchedulingPoint() {
SchedulingDataForVersion currentVersionOnDB = getCurrentVersionOnDB();
return SchedulingState.Type.SCHEDULING_POINT != currentVersionOnDB
.getSchedulingStateType();
}
private List<TaskSourceSynchronization> childrenSynchronizations() {
@ -416,11 +416,16 @@ public abstract class OrderElement extends IntegrationEntity implements
}
private TaskSource getOnDBTaskSource() {
SchedulingDataForVersion schedulingDataForVersion = getCurrentVersionOnDB();
return schedulingDataForVersion.getTaskSource();
}
SchedulingDataForVersion getCurrentVersionOnDB() {
OrderVersion version = getCurrentSchedulingData()
.getOriginOrderVersion();
SchedulingDataForVersion schedulingDataForVersion = schedulingDatasForVersion
.get(version);
return schedulingDataForVersion.getTaskSource();
return schedulingDataForVersion;
}
private TaskSourceSynchronization taskSourceRemoval() {