*
*/
public static void setGavlKledning() {
ConstructionTypeManager constructionTypeManager = (ConstructionTypeManager) ModelUtil
.getBean("constructionTypeManager");
ConstructionTypeArticleManager constructionTypeArticleManager = (ConstructionTypeArticleManager) ModelUtil
.getBean("constructionTypeArticleManager");
OrderLineManager orderLineManager = (OrderLineManager) ModelUtil
.getBean("orderLineManager");
List<ConstructionType> garasjer = constructionTypeManager.findAllIncludeMaster();
Set<ConstructionTypeArticle> artikler;
ConstructionTypeArticle gavl = null;
ConstructionTypeArticle kledning = null;
for (ConstructionType garasje : garasjer) {
constructionTypeManager
.lazyLoad(
garasje,
new LazyLoadConstructionTypeEnum[] { LazyLoadConstructionTypeEnum.CONSTRUCTION_TYPE_ARTICLE });
artikler = garasje.getConstructionTypeArticles();
for (ConstructionTypeArticle artikkel : artikler) {
if (artikkel.getArticleName().equalsIgnoreCase("Gavl")) {
gavl = artikkel;
break;
}
}
ConstructionTypeArticle gavlkledning = null;
for (ConstructionTypeArticle artikkel : artikler) {
Set<ConstructionTypeArticle> gavlkledningArtikler;
if (artikkel.getArticleName().equalsIgnoreCase("Gavlkledning")) {
gavlkledning = artikkel;
constructionTypeManager
.lazyLoadArticle(
artikkel,
new LazyLoadConstructionTypeArticleEnum[] { LazyLoadConstructionTypeArticleEnum.CONSTRUCTION_TYPE_ARTICLES });
gavlkledningArtikler = artikkel
.getConstructionTypeArticles();
for (ConstructionTypeArticle gavlkledningArtikkel : gavlkledningArtikler) {
if (gavlkledningArtikkel.getArticleName()
.equalsIgnoreCase("Kledning")) {
gavlkledningArtikkel
.setConstructionTypeArticleRef(gavl);
kledning=gavlkledningArtikkel;
}
}
if(kledning!=null){
constructionTypeArticleManager.saveConstructionTypeArticle(kledning);
}
constructionTypeManager
.lazyLoadArticle(
gavlkledning,
new LazyLoadConstructionTypeArticleEnum[] { LazyLoadConstructionTypeArticleEnum.ORDER_LINE });
Set<OrderLine> orderLines = gavlkledning.getOrderLines();
Order order = null;
Set<OrderLine> orderOrderLines;
OrderLine gavlOrderLine = null;
for (OrderLine orderLine : orderLines) {
order = orderLine.getOrder();
orderLineManager
.lazyLoadOrder(
order,
new LazyLoadOrderEnum[] { LazyLoadOrderEnum.ORDER_LINES });
orderOrderLines = order.getOrderLines();
gavlOrderLine=null;
for (OrderLine orderOrderLine : orderOrderLines) {
if (orderOrderLine.getArticleName()
.equalsIgnoreCase("Gavl")) {
gavlOrderLine = orderOrderLine;
}
}
//if(gavlOrderLine!=null){
for (OrderLine orderOrderLine : orderOrderLines) {
if (orderOrderLine.getArticlePath()
.equalsIgnoreCase("Gavlkledning$Kledning")) {
if(gavlOrderLine==null){
gavlOrderLine=new OrderLine(null,orderOrderLine.getOrder(),gavl,null,null,null,null,null,null,null,"Gavl",null,1,null,null,null,null,null,null,null,null,null);
orderLineManager.saveOrderLine(gavlOrderLine);
}
orderOrderLine.setOrderLineRef(gavlOrderLine);
orderOrderLine.setArticlePath("Gavl$Kledning");
orderLineManager.saveOrderLine(orderOrderLine);
orderLineManager.lazyLoadTree(gavlOrderLine);
gavlOrderLine.setAttributeInfo(gavlOrderLine.getAttributesAsString());
orderLineManager.saveOrderLine(gavlOrderLine);
}
}
//}
// gavlkledning.removeOrderLine(orderLine);
}
// garasje.removeConstructionArticle(gavlkledning);
constructionTypeManager.saveConstructionType(garasje);
}
}
constructionTypeArticleManager.saveConstructionTypeArticle(gavl);
}
}