TaxRegionProductCust taxRegionProductCust = (TaxRegionProductCust) em.find(TaxRegionProductCust.class, trProductCustId);
Tax tax = (Tax) em.find(Tax.class, taxId);
Iterator<?> iterator = taxRegionProductCust.getTaxes().iterator();
while (iterator.hasNext()) {
TaxRegionProductCustTax t = (TaxRegionProductCustTax) iterator.next();
if (t.getTax().getTaxId().equals(tax.getTaxId())) {
jsonResult.put("status", Constants.WEBSERVICE_STATUS_FAILED);
jsonResult.put("message", "Tax code already exist");
streamWebService(response, jsonResult.toHtmlString());
return null;
}
}
TaxRegionProductCustTax trProductCustTax = new TaxRegionProductCustTax();
trProductCustTax.setTaxRegionProductCust(taxRegionProductCust);
trProductCustTax.setTax(tax);
trProductCustTax.setRecUpdateBy(adminBean.getUser().getUserId());
trProductCustTax.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
trProductCustTax.setRecCreateBy(adminBean.getUser().getUserId());
trProductCustTax.setRecCreateDatetime(new Date(System.currentTimeMillis()));
em.persist(trProductCustTax);
String result = getJSONProduct(request, taxRegionProductCust.getTaxRegionProduct());
streamWebService(response, result);