}
@SuppressWarnings("unchecked")
public void checkCollies(WindowInterface window) throws ProTransException {
if (!refreshing) {
OverviewManager overviewManager = (OverviewManager) ModelUtil
.getBean(packable.getManagerName());
if (!defaultColliesGenerated()) {
packable.setDefaultColliesGenerated(1);
overviewManager.saveObject(packable);
List<Colli> collies = packable.getColliList();
List<OrderLine> orderLines = packable.getOrderLineList();
Colli tmpColli;
tmpColli = new Colli(null,
packable.getOrder(), null, null, null, null,
packable.getPostShipment(), null, null);
if (collies == null) {
collies = new ArrayList<Colli>();
}
// sjekk om kollier Takstol,Gavl,Gulvspon,Garasjepakke er med
// for
// ordre,
// sjekk mot artikler
Set<String> colliNames = colliSetup.keySet();
if (colliNames != null) {
for (String colliName : colliNames) {
tmpColli.setColliName(colliName);
if (!collies.contains(tmpColli)) {
if(!Hibernate.isInitialized(packable.getCollies())){
initializePackable(packable);
}
if (shouldHaveColli(orderLines, colliSetup
.get(colliName),
packable.getTransportable())) {
Colli newColli = new Colli(null, tmpColli
.getOrder(), tmpColli.getColliName(),
null, null, null, tmpColli
.getPostShipment(), null, null);
packable.addColli(newColli);
if (colliName.equalsIgnoreCase("Takstein")) {
checkTakstein(orderLines, newColli, window);
}
managerRepository.getColliManager().saveColli(
newColli);
}
}
}
}
overviewManager.saveObject(packable);
setPackable(packable, null);
}
}
}