@SuppressWarnings("unchecked")
void registerDeviation(WindowInterface parentWindow) {
// henter ordrenr det skal lages ettersending for
String orderNr = JOptionPane.showInputDialog(parentWindow
.getComponent(), "Ordrenummer:");
Order order = null;
// List<OrderLine> orderLinesWithoutColli = null;
ArrayListModel orderLinesWithoutColli = null;
if (orderNr != null) {
// OrderManager orderManager = (OrderManager)
// ModelUtil.getBean("orderManager");
// finner ordre basert p� ordrenr
order = managerRepository.getOrderManager().findByOrderNr(orderNr);
if (order == null) {
if (!Util.showConfirmFrame(parentWindow, "Ordre ikke funnet",
"Ordre ble ikke funnet, vil du fortsette?")) {
return;
}
} else {
managerRepository.getOrderManager().lazyLoadOrder(
order,
new LazyLoadOrderEnum[] {
LazyLoadOrderEnum.ORDER_LINES,
LazyLoadOrderEnum.ORDER_LINE_ORDER_LINES });
// henter ordrelinjer som ikke er pakket
List<OrderLine> missing = order.getMissingCollies();
if (missing != null && missing.size() != 0) {
orderLinesWithoutColli = new ArrayListModel(missing);
}
}
} else {
if (!Util.showConfirmFrame(parentWindow, "Ordrenr ikke satt",
"Ordrenr er ikke satt, vil du fortsette?")) {
return;
}
}
// dersom ordre ikke er funnet m� det lages en ordre
if (order == null) {
order = createOrder(orderNr, parentWindow);
if (order.getOrderId() == null) {
return;
}
}
PostShipment postShipment = new PostShipment();
postShipment.setOrder(order);
Deviation deviation = new Deviation();
deviation.setPostShipment(postShipment);
deviation.setOrder(order);
deviation.setCustomerName(order.getCustomer().getFullName());
deviation.setCustomerNr(order.getCustomer().getCustomerNr());
deviation.setOrderNr(order.getOrderNr());
DeviationViewHandler deviationViewHandler = deviationViewHandlerFactory
.create(null, false, false, false, null, true);
DeviationModel deviationModel = new DeviationModel(deviation, true);