JSONEscapeObject jsonResult = new JSONEscapeObject();
jsonResult.put("status", Constants.WEBSERVICE_STATUS_SUCCESS);
Long trProductId = Format.getLong(form.getTaxRegionProductId());
Long custClassId = Format.getLong(form.getCustClassId());
TaxRegionProduct taxRegionProduct = (TaxRegionProduct) em.find(TaxRegionProduct.class, trProductId);
CustomerClass customerClass = (CustomerClass) em.find(CustomerClass.class, custClassId);
Iterator<?> iterator = taxRegionProduct.getCustomerClasses().iterator();
while (iterator.hasNext()) {
TaxRegionProductCust c = (TaxRegionProductCust) iterator.next();
if (c.getCustomerClass().getCustClassId().equals(customerClass.getCustClassId())) {
jsonResult.put("status", Constants.WEBSERVICE_STATUS_FAILED);
jsonResult.put("message", "Customer class already exist");
streamWebService(response, jsonResult.toHtmlString());
return null;
}