- private static final Logger LOGGER = FlexLogger.getLogger(SafePolicyController.class);
-
- private static CommonClassDao commonClassDao;
- private static String duplicateResponseString = "Duplicate";
- private static String operation = "operation";
- private static String apiflag = "apiflag";
- private static String utf8 = "UTF-8";
- private static String applicationJsonContentType = "application / json";
-
- @Autowired
- public SafePolicyController(CommonClassDao commonClassDao){
- SafePolicyController.commonClassDao = commonClassDao;
- }
-
- public SafePolicyController(){}
-
- public UserInfo getUserInfo(String loginId){
- return (UserInfo) commonClassDao.getEntityItem(UserInfo.class, "userLoginId", loginId);
- }
-
- @RequestMapping(value = { "/get_RiskTypeDataByName" }, method = {
- org.springframework.web.bind.annotation.RequestMethod.GET }, produces = MediaType.APPLICATION_JSON_VALUE)
- public void getRiskTypeDictionaryByNameEntityData(HttpServletResponse response) {
- try {
- Map<String, Object> model = new HashMap<>();
- ObjectMapper mapper = new ObjectMapper();
- model.put("riskTypeDictionaryDatas", mapper.writeValueAsString(commonClassDao.getDataByColumn(RiskType.class, "name")));
- JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
- JSONObject j = new JSONObject(msg);
- response.getWriter().write(j.toString());
- } catch (Exception e) {
- LOGGER.error("Exception Occured"+e);
- }
- }
-
- @RequestMapping(value = { "/get_RiskTypeData" }, method = {
- org.springframework.web.bind.annotation.RequestMethod.GET }, produces = MediaType.APPLICATION_JSON_VALUE)
- public void getOnapNameDictionaryEntityData(HttpServletResponse response) {
- try {
- Map<String, Object> model = new HashMap<>();
- ObjectMapper mapper = new ObjectMapper();
- model.put("riskTypeDictionaryDatas", mapper.writeValueAsString(commonClassDao.getData(RiskType.class)));
- JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
- JSONObject j = new JSONObject(msg);
- response.addHeader("successMapKey", "success");
- response.addHeader(operation, "getDictionary");
- response.getWriter().write(j.toString());
- } catch (Exception e) {
- LOGGER.error(e);
- response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
- response.addHeader("error", "dictionaryDBQuery");
- }
- }
-
- @RequestMapping(value = { "/sp_dictionary/save_riskType" }, method = {
- org.springframework.web.bind.annotation.RequestMethod.POST })
- public ModelAndView saveRiskTypeDictionary(HttpServletRequest request, HttpServletResponse response)
- throws IOException {
- try {
- boolean duplicateflag = false;
- boolean isFakeUpdate = false;
- boolean fromAPI = false;
- if (request.getParameter(apiflag)!=null && ("api").equalsIgnoreCase(request.getParameter(apiflag))) {
- fromAPI = true;
- }
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
- JsonNode root = mapper.readTree(request.getReader());
+ private static CommonClassDao commonClassDao;
+ private static String duplicateResponseString = "Duplicate";
+ private static String operation = "operation";
+ private static String riskTypeDatas = "riskTypeDictionaryDatas";
+ private static String safePolicyWarningDatas = "safePolicyWarningDatas";
+
+ @Autowired
+ public SafePolicyController(CommonClassDao commonClassDao){
+ SafePolicyController.commonClassDao = commonClassDao;
+ }
+
+ public void setCommonClassDao(CommonClassDao commonClassDao){
+ SafePolicyController.commonClassDao = commonClassDao;
+ }
+
+ public SafePolicyController(){
+ super();
+ }
+
+ private DictionaryUtils getDictionaryUtilsInstance(){
+ return DictionaryUtils.getDictionaryUtils();
+ }
+
+ @RequestMapping(value = { "/get_RiskTypeDataByName" }, method = {RequestMethod.GET }, produces = MediaType.APPLICATION_JSON_VALUE)
+ public void getRiskTypeDictionaryByNameEntityData(HttpServletResponse response) {
+ DictionaryUtils utils = getDictionaryUtilsInstance();
+ utils.getDataByEntity(response, riskTypeDatas, "name", RiskType.class);
+ }
+
+ @RequestMapping(value = { "/get_RiskTypeData" }, method = {RequestMethod.GET }, produces = MediaType.APPLICATION_JSON_VALUE)
+ public void getRiskTypeDictionaryEntityData(HttpServletResponse response) {
+ DictionaryUtils utils = getDictionaryUtilsInstance();
+ utils.getData(response, riskTypeDatas, RiskType.class);
+ }
+
+ @RequestMapping(value = { "/sp_dictionary/save_riskType" }, method = {RequestMethod.POST })
+ public ModelAndView saveRiskTypeDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException {
+ DictionaryUtils utils = getDictionaryUtilsInstance();
+ try {
+ boolean fromAPI = utils.isRequestFromAPI(request);
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ JsonNode root = mapper.readTree(request.getReader());