JSONEscapeObject jsonResult = new JSONEscapeObject();
jsonResult.put("status", Constants.WEBSERVICE_STATUS_SUCCESS);
Long taxRegionId = Format.getLong(form.getTaxRegionId());
Long productClassId = Format.getLong(form.getProductClassId());
TaxRegion taxRegion = (TaxRegion) em.find(TaxRegion.class, taxRegionId);
ProductClass productClass = (ProductClass) em.find(ProductClass.class, productClassId);
Iterator<?> iterator = taxRegion.getProductClasses().iterator();
while (iterator.hasNext()) {
TaxRegionProduct p = (TaxRegionProduct) iterator.next();
if (p.getProductClass().getProductClassId().equals(productClass.getProductClassId())) {
jsonResult.put("status", Constants.WEBSERVICE_STATUS_FAILED);
jsonResult.put("message", "Product class already exist");
streamWebService(response, jsonResult.toHtmlString());
return null;
}