Untitled
unknown
plain_text
6 months ago
29 kB
2
Indexable
package com.jnj.mdm.controllers; /* * ssaha32 6/8/2019 */ import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import java.util.stream.Collectors; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.json.simple.JSONArray; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.servlet.ModelAndView; import com.jnj.mdm.beans.ContextUser; import com.jnj.mdm.common.Constants; import com.jnj.mdm.entity.Country; import com.jnj.mdm.entity.Group; import com.jnj.mdm.entity.GroupCountries; import com.jnj.mdm.entity.GroupRelation; import com.jnj.mdm.entity.Lov; import com.jnj.mdm.entity.PrdAssocView; import com.jnj.mdm.entity.ProductCategory; import com.jnj.mdm.entity.ProductSubcategory; import com.jnj.mdm.entity.Region; import com.jnj.mdm.entity.Role; import com.jnj.mdm.entity.User; import com.jnj.mdm.exception.CategoryException; import com.jnj.mdm.security.SecurityViewHelper; import com.jnj.mdm.services.AdminServices; import com.jnj.mdm.services.AjaxServices; import com.jnj.mdm.services.CategoryService; import com.jnj.mdm.services.UserServices; @Controller public class CategoryController { @Autowired private CategoryService categoryService; @Autowired private AjaxServices ajaxServices; @Autowired private UserServices userServices; @Autowired private AdminServices adminServices; private static final String RELATION_VIEW = "addRelation"; private static final String CATEGORY_VIEW = "addCategory"; private static final String SUB_CATEGORY_VIEW = "addSubCategory"; // private static final String CATEGORY_VIEW = "categoryViewList"; private static final String GROUP_VIEW = "groupViewList"; private static final String APPROVED_GROUP_REL = "approvedGroupRel"; private static final String EDIT_GROUP = "editGroup"; private static final String PRDT_GRP_ASOCI = "addAssociation"; private static final String EDIT_PRDT_GRP_ASOCI = "editAssociation"; private static final Log LOGGER = LogFactory.getLog(CategoryController.class); private static final String PRODUCT_ASSOC_VIEW = "productAssociationViewList"; private static final String EDIT_GROUP_RELATION = "editGroupRelation"; private static final String REPORT_VIEW = "rprtFrSbCtgry"; private static final String RELATION_REPORT_VIEW = "rprtFrReltn"; @RequestMapping(value = "/addRelation.view") public ModelAndView addRelation(HttpServletRequest req, HttpServletResponse res) throws Exception { ModelAndView modelAndView = new ModelAndView(RELATION_VIEW); List categories = categoryService.getAllCategoriesOrSubCategories("CATEGORY"); modelAndView.addObject("categories", categories); List subcategories = categoryService.getAllCategoriesOrSubCategories("SUBCATEGORY"); modelAndView.addObject("subcategories", subcategories); modelAndView.addObject("pageIdentifier", Constants.MASTER_DATA_REQUEST); return modelAndView; } @RequestMapping(value = "/addCategory.view") public ModelAndView addCategory(HttpServletRequest req, HttpServletResponse res) throws Exception { ModelAndView modelAndView = new ModelAndView(CATEGORY_VIEW); List<Region> regions = adminServices.getRegions(); List<String> regionNames = regions.stream().map(Region::getRegionCode).collect(Collectors.toList()); modelAndView.addObject("regionNames", regionNames); for (String string : regionNames) { Region region = regions.stream().filter(obj -> string.equals(obj.getRegionCode())).findAny().orElse(null); List<Country> countries = new ArrayList<Country>(region != null ? region.getCountries() : null); if (countries != null && !countries.isEmpty()) { Comparator<Country> sortByCountryName = (Country c1, Country c2) -> c1.getCountryName() .compareTo(c2.getCountryName()); java.util.Collections.sort(countries, sortByCountryName); modelAndView.addObject(string.replace(" ", "_"), countries); } } modelAndView.addObject("pageIdentifier", Constants.MASTER_DATA_REQUEST); return modelAndView; } @RequestMapping(value = "/addSubCategory.view") public ModelAndView addSubCategory(HttpServletRequest req, HttpServletResponse res) throws Exception { ModelAndView modelAndView = new ModelAndView(SUB_CATEGORY_VIEW); List<Group> groupList = adminServices.getTableListForUser(Group.class, "groupType", "CATEGORY"); modelAndView.addObject("groupList", groupList); List<Region> regions = adminServices.getRegions(); List<String> regionNames = regions.stream().map(Region::getRegionName).collect(Collectors.toList()); modelAndView.addObject("regionNames", regionNames); for (String string : regionNames) { Region region = regions.stream().filter(obj -> string.equals(obj.getRegionName())).findAny().orElse(null); List<Country> countries = new ArrayList<Country>(region != null ? region.getCountries() : null); if (countries != null && !countries.isEmpty()) { Comparator<Country> sortByCountryName = (Country c1, Country c2) -> c1.getCountryName() .compareTo(c2.getCountryName()); java.util.Collections.sort(countries, sortByCountryName); modelAndView.addObject(string.replace(" ", "_"), countries); } } modelAndView.addObject("pageIdentifier", Constants.MASTER_DATA_REQUEST); return modelAndView; } @RequestMapping(value = "/editGroup.view") public ModelAndView editGroup(HttpServletRequest req, HttpServletResponse res) throws Exception { ContextUser currentUser = SecurityViewHelper.getUser(); ModelAndView modelAndView = new ModelAndView(EDIT_GROUP); String id = req.getParameter("groupId"); int groupId; List<GroupCountries> countriesId = new ArrayList(); if (id != null && !id.isEmpty()) { groupId = Integer.parseInt(id); List<Region> regions = adminServices.getRegions(); List<String> regionNames = regions.stream().map(Region::getRegionCode).collect(Collectors.toList()); modelAndView.addObject("regionNames", regionNames); Group groupCat = new Group(); groupCat = categoryService.getGroupById(groupId); countriesId = categoryService.getGroupCountries(groupCat.getVersionId()); for (String string : regionNames) { // currentCountries.clear(); Region region = regions.stream().filter(obj -> string.equals(obj.getRegionCode())).findAny() .orElse(null); List<Country> countries = new ArrayList<Country>(region != null ? region.getCountries() : null); List<Country> currentCountries = new ArrayList<Country>(); if (countries != null && !countries.isEmpty()) { Comparator<Country> sortByCountryName = (Country c1, Country c2) -> c1.getCountryName() .compareTo(c2.getCountryName()); java.util.Collections.sort(countries, sortByCountryName); for (GroupCountries countryId : countriesId) { for (Country country : countries) { if ((countryId.getCountryId().equals(country.getCountryId()))) { currentCountries.add(country); } } } countries.removeAll(currentCountries); modelAndView.addObject(string, countries); modelAndView.addObject("selected" + string, currentCountries); } } modelAndView.addObject("groupCat", groupCat); List<Integer> staticCntries = categoryService.getCntriesUsedInRltn(groupId); modelAndView.addObject("staticCntries", staticCntries); } return modelAndView; } @RequestMapping(value = "/saveCategory.view") public ModelAndView saveCategory(HttpServletRequest req, HttpServletResponse res) { ModelAndView modelAndView = new ModelAndView(CATEGORY_VIEW); String categoryName = req.getParameter("categoryName"); String[] Aspac = req.getParameterValues("ASPAC"); String[] Latam = req.getParameterValues("LATAM"); String[] Na = req.getParameterValues("NA"); String[] Emea = req.getParameterValues("EMEA"); String type = req.getParameter("type"); String groupId = req.getParameter("groupId"); boolean isDuplicate = false; boolean isSaved = false; String errorMsg = "Some error occurred"; String resultStatus = ""; String resultText = ""; try { isSaved = categoryService.saveOrUpdateCategory(groupId, categoryName, Aspac, Latam, Na, Emea); } catch (Exception e) { LOGGER.debug(e); /* * if (e instanceof DuplicateKeyException) { isDuplicate = true; } */ if (e instanceof CategoryException) { errorMsg = e.getMessage(); } e.printStackTrace(); } if (!isSaved) { resultText = "Category Addition Failed"; resultStatus = "danger"; } else { resultText = "This category was successfully saved."; resultStatus = "success"; } HttpSession session = req.getSession(true); session.setAttribute("resultMessage", resultText); modelAndView.setViewName("redirect:/groupViewPage.view?type=" + Constants.MDM_GROUP_UNDER_REVIEW_CATEGORY); // modelAndView.addObject("pageIdentifier", Constants.MASTER_DATA_REQUEST); return modelAndView; } @RequestMapping(value = "/saveSubCategory.view") public ModelAndView saveSubCategory(HttpServletRequest req, HttpServletResponse res) { ModelAndView modelAndView = new ModelAndView(CATEGORY_VIEW); String[] subCategoryName = req.getParameterValues("subCategory"); String[] subCategoryDesc = req.getParameterValues("subCategoryDesc"); boolean isSaved = false; String errorMsg = "Some error occurred"; for (int i = 0; i < subCategoryName.length; i++) { try { isSaved = categoryService.saveCategory("SUBCATEGORY", subCategoryName[i], subCategoryDesc[i], null, null, null, null); } catch (Exception e) { LOGGER.debug(e); if (e instanceof CategoryException) { errorMsg = e.getMessage(); } e.printStackTrace(); } } Map<String, String> map = new HashMap<String, String>(); String resultText; String resultStatus; if (!isSaved) { resultText = "Topic Addition Failed"; resultStatus = "danger"; } else { resultText = "Topic(s) saved successfully"; resultStatus = "success"; } HttpSession session = req.getSession(true); session.setAttribute("resultMessage", resultText); modelAndView.setViewName("redirect:/groupViewPage.view?type=" + Constants.MDM_GROUP_UNDER_REVIEW_SUBCATEGORY); //modelAndView.addObject("type", Constants.MDM_GROUP_UNDER_REVIEW_SUBCATEGORY); return modelAndView; } private String getUserRole(HttpSession session) { User user = (User) session.getAttribute("user"); String role=null; if (user == null) { ContextUser currentUser = SecurityViewHelper.getUser(); user = userServices.getUser(currentUser); session.setAttribute("user", user); } if(user!=null && user.getRoles()!=null && !user.getRoles().isEmpty()) { List<String> userRoles = user.getRoles().stream().map(Role::getRoleDesc).collect(Collectors.toList()); role = userRoles.stream() .filter(string -> (string.equals("category_admin") || string.equals("super_admin"))).findAny() .orElse(null); } return role; } @RequestMapping(value = "/groupViewPage.view") public ModelAndView getAllGroupListUnderReview(HttpServletRequest req, HttpServletResponse res) { ModelAndView modelAndView = new ModelAndView(GROUP_VIEW); ContextUser currentUser = SecurityViewHelper.getUser(); modelAndView.addObject("currentUser", currentUser.getNtid()); String tableName = req.getParameter("type"); modelAndView.addObject("table", tableName); HttpSession session = req.getSession(true); String role = getUserRole(session); modelAndView.addObject("isCtgryAdmin", role != null ? role : ""); String[] adminRole = { "ROLE_Super Admin" }; Boolean isUserAdmin = false; if (SecurityViewHelper.allGranted(adminRole)) { isUserAdmin = new Boolean(true); } modelAndView.addObject("isUserAdmin", isUserAdmin); modelAndView.addObject("pageIdentifier", Constants.MASTER_DATA_REQUEST); return modelAndView; } @RequestMapping(value = "/saveRelation.view") public ModelAndView saveRelation(HttpServletRequest req, HttpServletResponse res) { ModelAndView modelAndView = new ModelAndView(RELATION_VIEW); Long categoryId = Long.parseLong(req.getParameter("categoryId")); String[] subCatGroupId = req.getParameterValues("subgroupId"); int countryId = Integer.parseInt(req.getParameter("country")); boolean isDuplicate = false; boolean isSaved = false; String errorMsg = "Some error occurred"; String resultStatus = ""; String resultText = ""; try { if (subCatGroupId != null && subCatGroupId.length > 0) { for (int i = 0; i < subCatGroupId.length; i++) { Integer subGrpId = Integer.parseInt(subCatGroupId[i]); String[] subTa = req.getParameterValues("subTa_" + subGrpId); isSaved = categoryService.saveRelation(categoryId, subGrpId, countryId, subTa); } } } catch (Exception e) { LOGGER.debug(e); if (e instanceof CategoryException) { isDuplicate = true; errorMsg = e.getMessage(); } e.printStackTrace(); } if (!isSaved) { resultText = "Operation Failed"; resultStatus = "danger"; } else { resultText = "Relation added successfully"; resultStatus = "success"; } // modelAndView.setViewName("redirect:/groupRelPage.view"); modelAndView.addObject("type", Constants.MDM_PENDING_REL_GROUP); modelAndView.addObject("resultMessage", resultText); // modelAndView.addObject("resultMessage", // resultStatus.equals("success") ? "Relation Added Successfully" : "Relation // Addition Failed"); // modelAndView.addObject("pageIdentifier", Constants.MASTER_DATA_REQUEST); modelAndView.setViewName("redirect:/groupRelPage.view"); return modelAndView; } @RequestMapping(value = "/groupRelPage.view") public ModelAndView getAllApprovedRelationGroup(HttpServletRequest req, HttpServletResponse res) { HttpSession session = req.getSession(true); ModelAndView modelAndView = new ModelAndView(APPROVED_GROUP_REL); modelAndView.addObject("table", req.getParameter("type")); modelAndView.addObject("pageIdentifier", Constants.MASTER_DATA_REQUEST); String role = getUserRole(session); modelAndView.addObject("isCtgryAdmin", role != null ? role : ""); ContextUser currentUser = SecurityViewHelper.getUser(); modelAndView.addObject("currentUser", currentUser.getNtid()); String[] adminRole = { "ROLE_Super Admin" }; Boolean isUserAdmin = false; if (SecurityViewHelper.allGranted(adminRole)) { isUserAdmin = new Boolean(true); } List categories = categoryService.getAllCategoriesOrSubCategories("CATEGORY"); modelAndView.addObject("categories", categories); modelAndView.addObject("isUserAdmin", isUserAdmin); return modelAndView; } @RequestMapping(value = "/productAssocViewpage.view") public ModelAndView productAssocViewpage(HttpServletRequest req, HttpServletResponse res) { HttpSession session = req.getSession(true); ModelAndView modelAndView = new ModelAndView(PRODUCT_ASSOC_VIEW); modelAndView.addObject("pageIdentifier", Constants.MASTER_DATA_REQUEST); String role = getUserRole(session); modelAndView.addObject("isCtgryAdmin", role != null ? role : ""); ContextUser currentUser = SecurityViewHelper.getUser(); modelAndView.addObject("currentUser", currentUser.getNtid()); String[] adminRole = { "ROLE_Super Admin" }; Boolean isUserAdmin = false; if (SecurityViewHelper.allGranted(adminRole)) { isUserAdmin = new Boolean(true); } modelAndView.addObject("isUserAdmin", isUserAdmin); return modelAndView; } @RequestMapping(value = "/productGroupAssociation.view") public ModelAndView productGroupAssociation(HttpServletRequest req, HttpServletResponse res) { ModelAndView modelAndView = new ModelAndView(PRDT_GRP_ASOCI); List<Lov> list = adminServices.getTableListForUser(Lov.class, "identifierFieldName", "PROD CAT GRP"); if (list != null && !list.isEmpty()) { String[] groups = list.get(0).getLovValue().split(","); modelAndView.addObject("groups", groups); } modelAndView.addObject("countries", adminServices.getCountries()); return modelAndView; } @RequestMapping(value = "/saveAssociation.view", method = RequestMethod.POST) public ModelAndView saveAssociation(HttpServletRequest req, HttpServletResponse res, @ModelAttribute("frmAssociation") ProductCategory productCategory) { ModelAndView modelAndView = new ModelAndView(APPROVED_GROUP_REL); // change Long success=0L; boolean isLastCount=false; Integer country = Integer.parseInt(req.getParameter("country")); String submitType = req.getParameter("submitType"); Integer totalSubTaCount=null; List proCatIds = new ArrayList(); if (submitType.equalsIgnoreCase("Add")) { totalSubTaCount = Integer.parseInt(req.getParameter("tot_subta")); for(int i=1; i<=totalSubTaCount; i++) { String[] subCategories = req.getParameterValues("subCategory_"+i); String subTa = req.getParameter("subta_"+i); if(subCategories!=null) { success=categoryService.saveAssociation(productCategory, subTa, country, subCategories, submitType); if(success>0) proCatIds.add(success); } } } else if(submitType.equalsIgnoreCase("Edit")) { String[] subCategories = req.getParameterValues("subCategory"); success = categoryService.saveAssociation(productCategory, productCategory.getTaSubType(), country, subCategories, submitType); } String resultText = ""; boolean mailSent=false; if (success == 0) { resultText = "Try again later!"; } else if (success == -1L) { resultText = "Selected combination of Country, Product Name, Category and Subtherapeutic Area already exist"; } else if (success>0) { if(proCatIds!=null) { mailSent = categoryService.mailForAssoc(proCatIds); } if(!mailSent) resultText = "Association saved successfully but error in sending mail"; else resultText = "Association saved successfully"; } else if (success == -3L) { resultText = "Association saved successfully"; } HttpSession session = req.getSession(); session.setAttribute("resultMessage", resultText); modelAndView.setViewName("redirect:/productAssocViewpage.view"); modelAndView.addObject("resultMessage", resultText); return modelAndView; } @RequestMapping(value = "/editProductGroupAssociation.view") public ModelAndView editProductGroupAssociation(HttpServletRequest req, HttpServletResponse res) { ModelAndView modelAndView = new ModelAndView(EDIT_PRDT_GRP_ASOCI); List<Lov> list = adminServices.getTableListForUser(Lov.class, "identifierFieldName", "PROD CAT GRP"); Long proCatId = req.getParameter("proCatId") != null ? Long.parseLong(req.getParameter("proCatId")) : null; if (proCatId != null) { // productCategory = categoryService.getProductCategoryGroupById(proCatId); // Product product = productService.getApprovedProduct(productCategory.getMdmId()); // String countryName = categoryService.getCountry(product.getCountryId()).getCountryName(); PrdAssocView prdAssocView = categoryService.getPrdtAsoctn(proCatId); modelAndView.addObject("productName", prdAssocView.getProductName()); modelAndView.addObject("categoryName", prdAssocView.getCategoryName()); modelAndView.addObject("countryName", prdAssocView.getCountryName()); modelAndView.addObject("countryId", prdAssocView.getCountryId()); modelAndView.addObject("selectedSubTA", prdAssocView.getTaSubType()); if (list != null && !list.isEmpty()) { String[] groups = list.get(0).getLovValue().split(","); modelAndView.addObject("groups", groups); } StringBuffer options = new StringBuffer(""); options.append("<option role='option' value='0'>" + Constants.DFLT_OPT + "</option>"); List<Group> categories = categoryService.getCategoriesfromCntry(prdAssocView.getCountryId()); modelAndView.addObject("categoryId", prdAssocView.getCategoryId()); categories.forEach((data) -> { options.append( "<option role='option' value=" + data.getGroupId() + ">" + data.getGroupName() + "</option>"); }); modelAndView.addObject("options", options); modelAndView.addObject("proCat", prdAssocView); StringBuffer subtaOptions = new StringBuffer(""); subtaOptions.append("<option role='option' value=''>" + Constants.DFLT_OPT + "</option>"); List<String> prodSubTas = categoryService.getProdSubTas(Integer.valueOf(prdAssocView.getMdmId())); prodSubTas.forEach((data) -> { if(data.equalsIgnoreCase(prdAssocView.getTaSubType())) { subtaOptions.append( "<option role='option' value=\"" + data + "\" selected='selected' >" + data + "</option>"); } else { subtaOptions.append( "<option role='option' value=\"" + data + "\">" + data + "</option>"); } }); modelAndView.addObject("subtaOptions", subtaOptions); List<Group> subCategories = categoryService.getSubCat(Integer.parseInt(prdAssocView.getCategoryId()), prdAssocView.getTaSubType()); List<ProductSubcategory> slctdSbCtgris = categoryService.getSubCategoryByProCatId(proCatId); StringBuffer subCatOptions = new StringBuffer(""); if (subCategories != null && !subCategories.isEmpty()) { for (Group group : subCategories) { boolean flag = true; for (ProductSubcategory slctteGrp : slctdSbCtgris) { if (group.getGroupId().intValue() == slctteGrp.getSubcategoryId().intValue()) { subCatOptions.append("<option role='option' value=" + group.getGroupId() + " selected='selected' >" + group.getGroupName() + "</option>"); flag = false; break; } } if (flag) subCatOptions.append("<option role='option' value=" + group.getGroupId() + ">" + group.getGroupName() + "</option>"); } } System.out.println("subCatOptions : " + subCatOptions); modelAndView.addObject("subCatOptions", subCatOptions); } modelAndView.addObject("countries", adminServices.getCountries()); return modelAndView; } @RequestMapping(value = "/editGroupRelation.view") public ModelAndView editGroupRelation(HttpServletRequest req, HttpServletResponse res) throws Exception { ModelAndView modelAndView = new ModelAndView(EDIT_GROUP_RELATION); int groupRelId = Integer.parseInt(req.getParameter("groupRelId")); GroupRelation groupRelation = categoryService.getGroupRelById(groupRelId); modelAndView.addObject("groupRelation", groupRelation); Country country = categoryService.getCountry(groupRelation.getCountryId()); modelAndView.addObject("country", country); Group category = null; Group subCategory = null; List<Group> groups = (List<Group>) categoryService.getGroupAndSubGroupById(groupRelation.getGroupId(), groupRelation.getSubGroupId()); if (groups != null && !groups.isEmpty() && groups.size() == 2) { if (groups.get(0).getGroupType().equals("CATEGORY")) { category = groups.get(0); subCategory = groups.get(1); } else { subCategory = groups.get(0); category = groups.get(1); } modelAndView.addObject("category", category); modelAndView.addObject("subCategory", subCategory); } else { LOGGER.error("Error occured during fetch data from Group table in editGroupRelation()"); } String slctdSubTa = groupRelation.getSubTa(); List<Lov> list = ajaxServices.getSubTaForCountryId(country.getCountryId()); StringBuffer options = new StringBuffer(""); JSONArray array = new JSONArray(); for (Lov lov : list) { String value = lov.getLovName().replaceAll(" ", "_"); if (slctdSubTa.contains(lov.getLovName())) { options.append("<option role='option' value=" + value + " selected='selected' >" + lov.getLovValue() + "</option>"); array.add(value); } else { options.append("<option role='option' value=" + value + ">" + lov.getLovValue() + "</option>"); } } modelAndView.addObject("options", options); modelAndView.addObject("lstSubTa", array); // RELATION SUB TA VALIDATION FROM PRODUCT ASSOCIATION Object isIdExist = categoryService.isIdExist(category.getGroupId(), country.getCountryId(),subCategory.getGroupId()); modelAndView.addObject("isIdExist", isIdExist); return modelAndView; } @RequestMapping(value = "/updateRelation.view") public ModelAndView updateRelation(HttpServletRequest req, HttpServletResponse res) { HttpSession session = req.getSession(true); ModelAndView modelAndView = new ModelAndView( "redirect:/groupRelPage.view?type=" + Constants.MDM_PENDING_REL_GROUP); String[] subTas = req.getParameterValues("subTa"); Integer groupRelId = Integer.parseInt(req.getParameter("groupRelId")); boolean isDuplicate = false; boolean isSaved = false; String errorMsg = "Some error occurred"; String resultStatus = ""; String resultText = ""; try { isSaved = categoryService.updateRelation(groupRelId, subTas); } catch (Exception e) { LOGGER.debug(e); if (e instanceof CategoryException) { isDuplicate = true; errorMsg = e.getMessage(); } e.printStackTrace(); } if (!isSaved) { resultText = "Relation Updation Failed"; resultStatus = "danger"; } else { resultText = "Relation Updated Successfully"; resultStatus = "success"; } return modelAndView; } @RequestMapping(value = "/subCategoryReport.view") public ModelAndView subCategoryReport(HttpServletRequest req, HttpServletResponse res) { HttpSession session = req.getSession(true); ModelAndView modelAndView = new ModelAndView(REPORT_VIEW); List<Group> subCategories = categoryService.getGroups(Constants.MDM_GROUP_APPROVED_SUBCATEGORY, 1, Integer.MAX_VALUE, "GROUP_NAME", "asc", null, false); modelAndView.addObject("subCategories", subCategories); String subCategory = req.getParameter("subCategory"); categoryService.setSbCtgryId(subCategory != null ? Integer.parseInt(subCategory) : null); modelAndView.addObject("sbCtgryId", subCategory); String[] adminRole = { "ROLE_Super Admin" }; Boolean isUserAdmin = false; if (SecurityViewHelper.allGranted(adminRole)) { isUserAdmin = new Boolean(true); } modelAndView.addObject("isUserAdmin", isUserAdmin); modelAndView.addObject("pageIdentifier", Constants.MDM_REPORTS); return modelAndView; } @RequestMapping(value = "/relationReport.view") public ModelAndView relationReport(HttpServletRequest req, HttpServletResponse res) { HttpSession session = req.getSession(true); ModelAndView modelAndView = new ModelAndView(RELATION_REPORT_VIEW); /* * List<Group> subCategories = * categoryService.getGroups(Constants.MDM_GROUP_APPROVED_SUBCATEGORY, 1, * Integer.MAX_VALUE, "GROUP_NAME", "asc",null); * modelAndView.addObject("subCategories", subCategories); * * String subCategory = req.getParameter("subCategory"); * categoryService.setSbCtgryId(subCategory!=null ? * Integer.parseInt(subCategory) : null); modelAndView.addObject("sbCtgryId", * subCategory); */ List<Group> categories = categoryService.getGroups(Constants.MDM_GROUP_APPROVED_CATEGORY, 1, Integer.MAX_VALUE, "GROUP_NAME", "asc", null, false); modelAndView.addObject("categories", categories); String category = req.getParameter("category"); categoryService.setCtgryId(category != null ? Integer.parseInt(category) : null); String subCategory = req.getParameter("subCategory"); categoryService.setSbCtgryId(subCategory != null ? Integer.parseInt(subCategory) : null); modelAndView.addObject("ctgryId", category); modelAndView.addObject("pageIdentifier", Constants.MDM_REPORTS); String[] adminRole = { "ROLE_Super Admin" }; Boolean isUserAdmin = false; if (SecurityViewHelper.allGranted(adminRole)) { isUserAdmin = new Boolean(true); } modelAndView.addObject("isUserAdmin", isUserAdmin); return modelAndView; } }
Editor is loading...
Leave a Comment