Commit daebe7bd by Tuukka Kivilahti

fixet product option multiplation bug

1 parent fdc7e910
......@@ -90,4 +90,5 @@ public interface ProductBeanLocal {
ProductOption findOptionById(Integer id);
void deleteProductOptionGroup(ProductOptionGroup group);
}
......@@ -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
<P>
<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>
<H3>
Annotation Type</H3>
......
......@@ -642,5 +642,27 @@ public class ProductBean implements ProductBeanLocal {
return productOptionFacade.find(id);
}
@Override
public void deleteProductOptionGroup(ProductOptionGroup group) {
ProductOptionGroup managedGroup = productOptionGroupFacade.reload(group);
managedGroup.getProduct().getProductOptionGroups().remove(managedGroup);
managedGroup.setDefaultOption(null);
/*
List<ProductOption> options
for(ProductOption o : group.getOptions()) {
productOptionFacade.merge(o);
// group.getOptions().remove(o);
productOptionFacade.remove(o);
}
*/
// group.setOptions(new ArrayList<>());
productOptionGroupFacade.remove(managedGroup);
}
}
......@@ -112,6 +112,9 @@
<p:column>
<p:commandButton ajax="false" action="#{productView.editProductOptionGroup}" value="#{i18n['edit']}" />
</p:column>
<p:column>
<p:commandButton ajax="false" action="#{productView.deleteProductOptionGroup}" value="#{i18n['delete']}" />
</p:column>
</p:dataTable>
</h:form>
......
......@@ -174,6 +174,14 @@ public class ProductView extends GenericCDIView {
return "/product/editProductOptionGroup";
}
public void deleteProductOptionGroup()
{
prodbean.deleteProductOptionGroup(productOptionGroups.getRowData());
this.product = prodbean.findById(product.getId());
}
public String editDiscount()
{
discount = productDiscounts.getRowData();
......@@ -253,17 +261,10 @@ public class ProductView extends GenericCDIView {
}
prodbean.mergeChanges(product);
// need to update this instance
//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;
productOptionGroup = null;*/
// flush product, I liek id's for everyone
product = prodbean.findById(product.getId());
return "/product/edit";
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!