ItEr44S16CUAsignacionRecursosEspecificosAPlanificacionItEr37S10: Moving copy methods from model to entity.
This makes easier to copy new fields
This commit is contained in:
parent
d4b36e8f90
commit
0fc24014d6
2 changed files with 21 additions and 21 deletions
|
|
@ -187,6 +187,24 @@ public class StretchesFunction extends AssignmentFunction {
|
|||
*/
|
||||
private Type desiredType;
|
||||
|
||||
public StretchesFunction copy() {
|
||||
StretchesFunction result = StretchesFunction.create();
|
||||
result.resetToStrechesFrom(this);
|
||||
return result;
|
||||
}
|
||||
|
||||
public void resetToStrechesFrom(StretchesFunction from) {
|
||||
this.removeAllStretches();
|
||||
for (Stretch each : from.getStretches()) {
|
||||
Stretch newStretch = new Stretch();
|
||||
newStretch.setDate(each.getDate());
|
||||
newStretch.setLengthPercentage(each.getLengthPercentage());
|
||||
newStretch.setAmountWorkPercentage(each
|
||||
.getAmountWorkPercentage());
|
||||
this.addStretch(newStretch);
|
||||
}
|
||||
}
|
||||
|
||||
public void setStretches(List<Stretch> stretches) {
|
||||
this.stretches = stretches;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ public class StretchesFunctionModel implements IStretchesFunctionModel {
|
|||
if (stretchesFunction != null) {
|
||||
assignmentFunctionDAO.reattach(stretchesFunction);
|
||||
this.originalStretchesFunction = stretchesFunction;
|
||||
this.stretchesFunction = copy(stretchesFunction);
|
||||
this.stretchesFunction = stretchesFunction.copy();
|
||||
|
||||
this.task = task;
|
||||
forceLoadTask();
|
||||
|
|
@ -106,25 +106,6 @@ public class StretchesFunctionModel implements IStretchesFunctionModel {
|
|||
task.getCalendar();
|
||||
}
|
||||
|
||||
private static StretchesFunction copy(StretchesFunction stretchesFunction) {
|
||||
StretchesFunction copy = StretchesFunction.create();
|
||||
copyStretches(stretchesFunction, copy);
|
||||
return copy;
|
||||
}
|
||||
|
||||
private static void copyStretches(StretchesFunction original,
|
||||
StretchesFunction copy) {
|
||||
copy.removeAllStretches();
|
||||
for (Stretch stretch : original.getStretches()) {
|
||||
Stretch newStretch = new Stretch();
|
||||
newStretch.setDate(stretch.getDate());
|
||||
newStretch.setLengthPercentage(stretch.getLengthPercentage());
|
||||
newStretch.setAmountWorkPercentage(stretch
|
||||
.getAmountWorkPercentage());
|
||||
copy.addStretch(newStretch);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Stretch> getStretches() {
|
||||
if (stretchesFunction == null) {
|
||||
|
|
@ -152,7 +133,8 @@ public class StretchesFunctionModel implements IStretchesFunctionModel {
|
|||
}
|
||||
|
||||
if (originalStretchesFunction != null) {
|
||||
copyStretches(stretchesFunction, originalStretchesFunction);
|
||||
originalStretchesFunction
|
||||
.resetToStrechesFrom(stretchesFunction);
|
||||
stretchesFunction = originalStretchesFunction;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue