public void transfer(Order order) throws ValidationException {
Scenario sourceScenario = getSourceScenario();
Scenario destinationScenario = getDestinationScenario();
if (sourceScenario == null) {
throw new ValidationException(
_("Please select a source scenario"));
}
if (destinationScenario == null) {
throw new ValidationException(
_("Please, select a destination scenario"));
}
if (sourceScenario.getId().equals(destinationScenario.getId())) {
throw new ValidationException(
_("Source and destination scenarios should be different"));
}
orderDAO.save(order);
OrderVersion sourceOrderVersion = order
.getOrderVersionFor(sourceScenario);
if (sourceOrderVersion == null) {
throw new RuntimeException(
"Project version must not be null for source scenario");
}
OrderVersion destinationOrderVersion = order
.getOrderVersionFor(destinationScenario);
if ((destinationOrderVersion != null)
&& (sourceOrderVersion.getId().equals(destinationOrderVersion
.getId()))) {
throw new ValidationException(
_("Project version is the same in source and destination scenarios"));
}
order.useSchedulingDataFor(sourceOrderVersion);