Commit e327d0b3 by Tuomas Riihimäki

Merge branch 'multiBugFromProductOption' into 'master'

fixet product option multiplation bug

asiat monistu, ei monistu enää perkele. Lisätty poisto jotta pääsen monistuneista eroon!

See merge request !345
2 parents fdc7e910 537fd8cb
...@@ -90,4 +90,7 @@ public interface ProductBeanLocal { ...@@ -90,4 +90,7 @@ public interface ProductBeanLocal {
ProductOption findOptionById(Integer id); ProductOption findOptionById(Integer id);
void deleteProductOptionGroup(ProductOptionGroup group);
Product reload(Product product);
} }
...@@ -101,7 +101,7 @@ Each class, interface, nested class and nested interface has its own separate pa ...@@ -101,7 +101,7 @@ Each class, interface, nested class and nested interface has its own separate pa
<LI>Nested Class Summary<LI>Field Summary<LI>Constructor Summary<LI>Method Summary <LI>Nested Class Summary<LI>Field Summary<LI>Constructor Summary<LI>Method Summary
<P> <P>
<LI>Field Detail<LI>Constructor Detail<LI>Method Detail</UL> <LI>Field Detail<LI>Constructor Detail<LI>Method Detail</UL>
Each summary entry contains the first sentence from the detailed description for that item. The summary entries are alphabetical, while the detailed descriptions are in the priority they appear in the source code. This preserves the logical groupings established by the programmer.</BLOCKQUOTE> Each summary entry contains the first sentence from the detailed description for that item. The summary entries are alphabetical, while the detailed descriptions are in the order they appear in the source code. This preserves the logical groupings established by the programmer.</BLOCKQUOTE>
</BLOCKQUOTE> </BLOCKQUOTE>
<H3> <H3>
Annotation Type</H3> Annotation Type</H3>
......
...@@ -642,5 +642,23 @@ public class ProductBean implements ProductBeanLocal { ...@@ -642,5 +642,23 @@ public class ProductBean implements ProductBeanLocal {
return productOptionFacade.find(id); return productOptionFacade.find(id);
} }
@Override
public void deleteProductOptionGroup(ProductOptionGroup group) {
ProductOptionGroup managedGroup = productOptionGroupFacade.reload(group);
managedGroup.getProduct().getProductOptionGroups().remove(managedGroup);
managedGroup.setDefaultOption(null);
productOptionGroupFacade.remove(managedGroup);
}
@Override
public Product reload(Product product) {
return productFacade.reload(product);
}
} }
...@@ -112,6 +112,9 @@ ...@@ -112,6 +112,9 @@
<p:column> <p:column>
<p:commandButton ajax="false" action="#{productView.editProductOptionGroup}" value="#{i18n['edit']}" /> <p:commandButton ajax="false" action="#{productView.editProductOptionGroup}" value="#{i18n['edit']}" />
</p:column> </p:column>
<p:column>
<p:commandButton ajax="false" action="#{productView.deleteProductOptionGroup}" value="#{i18n['delete']}" />
</p:column>
</p:dataTable> </p:dataTable>
</h:form> </h:form>
......
...@@ -157,7 +157,7 @@ public class ProductView extends GenericCDIView { ...@@ -157,7 +157,7 @@ public class ProductView extends GenericCDIView {
{ {
this.productOptionGroup = new ProductOptionGroup(); this.productOptionGroup = new ProductOptionGroup();
this.productOptionGroup.setProduct(product); this.productOptionGroup.setProduct(product);
//this.product.getProductOptionGroups().add(this.productOptionGroup);
return "/product/editProductOptionGroup"; return "/product/editProductOptionGroup";
} }
...@@ -170,10 +170,18 @@ public class ProductView extends GenericCDIView { ...@@ -170,10 +170,18 @@ public class ProductView extends GenericCDIView {
public String editProductOptionGroup() public String editProductOptionGroup()
{ {
this.productOptionGroup = productOptionGroups.getRowData(); this.productOptionGroup = productOptionGroups.getRowData();
//this.productOptionGroup = prodbean.refreshProductOptionGroup(this.productOptionGroup);
return "/product/editProductOptionGroup"; return "/product/editProductOptionGroup";
} }
public void deleteProductOptionGroup()
{
prodbean.deleteProductOptionGroup(productOptionGroups.getRowData());
this.product = prodbean.findById(product.getId());
}
public String editDiscount() public String editDiscount()
{ {
discount = productDiscounts.getRowData(); discount = productDiscounts.getRowData();
...@@ -235,11 +243,6 @@ public class ProductView extends GenericCDIView { ...@@ -235,11 +243,6 @@ public class ProductView extends GenericCDIView {
this.productOption.setProductOptionGroup(this.productOptionGroup); this.productOption.setProductOptionGroup(this.productOptionGroup);
this.productOptionGroup.getOptions().add(this.productOption); this.productOptionGroup.getOptions().add(this.productOption);
/*
if(productOptionGroup.getId() != null) {
prodbean.createProductOption(this.productOption);
}
*/
this.productOption = null; this.productOption = null;
} }
...@@ -253,17 +256,10 @@ public class ProductView extends GenericCDIView { ...@@ -253,17 +256,10 @@ public class ProductView extends GenericCDIView {
} }
prodbean.mergeChanges(product); prodbean.mergeChanges(product);
// need to update this instance productOptionGroup = null;
//productOptionGroup = product.getProductOptionGroups().get(product.getProductOptionGroups().indexOf(productOptionGroup));
/*
for(ProductOption option : productOptionGroup.getOptions()) {
if(!option.getProductOptionGroup().equals(productOptionGroup))
option.setProductOptionGroup(productOptionGroup);
prodbean.createOrMerge(option);
}
productOptionGroup = null;*/ // flush product, I liek id's for everyone
product = prodbean.reload(product);
return "/product/edit"; return "/product/edit";
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!