2  * ============LICENSE_START=======================================================
 
   4  * ================================================================================
 
   5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
 
   6  * ================================================================================
 
   7  * Licensed under the Apache License, Version 2.0 (the "License");
 
   8  * you may not use this file except in compliance with the License.
 
   9  * You may obtain a copy of the License at
 
  11  *      http://www.apache.org/licenses/LICENSE-2.0
 
  13  * Unless required by applicable law or agreed to in writing, software
 
  14  * distributed under the License is distributed on an "AS IS" BASIS,
 
  15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
  16  * See the License for the specific language governing permissions and
 
  17  * limitations under the License.
 
  18  * ============LICENSE_END=========================================================
 
  21 package org.openecomp.policy.pap.xacml.rest.controller;
 
  23 import java.io.PrintWriter;
 
  24 import java.util.ArrayList;
 
  25 import java.util.Arrays;
 
  26 import java.util.HashMap;
 
  27 import java.util.List;
 
  31 import javax.servlet.http.HttpServletRequest;
 
  32 import javax.servlet.http.HttpServletResponse;
 
  34 import org.apache.commons.lang.StringUtils;
 
  35 import org.json.JSONObject;
 
  36 import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
 
  37 import org.openecomp.policy.common.logging.flexlogger.Logger;
 
  38 import org.openecomp.policy.pap.xacml.rest.XACMLPapServlet;
 
  39 import org.openecomp.policy.pap.xacml.rest.util.JsonMessage;
 
  40 import org.openecomp.policy.rest.dao.CommonClassDao;
 
  41 import org.openecomp.policy.rest.jpa.DCAEuuid;
 
  42 import org.openecomp.policy.rest.jpa.MicroServiceAttribute;
 
  43 import org.openecomp.policy.rest.jpa.MicroServiceConfigName;
 
  44 import org.openecomp.policy.rest.jpa.MicroServiceLocation;
 
  45 import org.openecomp.policy.rest.jpa.MicroServiceModels;
 
  46 import org.openecomp.policy.rest.jpa.UserInfo;
 
  47 import org.openecomp.policy.rest.util.MSAttributeObject;
 
  48 import org.openecomp.policy.rest.util.MSModelUtils;
 
  49 import org.springframework.beans.factory.annotation.Autowired;
 
  50 import org.springframework.http.MediaType;
 
  51 import org.springframework.stereotype.Controller;
 
  52 import org.springframework.web.bind.annotation.RequestMapping;
 
  53 import org.springframework.web.servlet.ModelAndView;
 
  55 import com.fasterxml.jackson.databind.DeserializationFeature;
 
  56 import com.fasterxml.jackson.databind.JsonNode;
 
  57 import com.fasterxml.jackson.databind.ObjectMapper;
 
  58 import com.google.gson.Gson;
 
  61 public class MicroServiceDictionaryController {
 
  62         private static final Logger LOGGER  = FlexLogger.getLogger(MicroServiceDictionaryController.class);
 
  64         private static CommonClassDao commonClassDao;
 
  67         public MicroServiceDictionaryController(CommonClassDao commonClassDao){
 
  68                 MicroServiceDictionaryController.commonClassDao = commonClassDao;
 
  71         public MicroServiceDictionaryController(){}     
 
  73         public UserInfo getUserInfo(String loginId){
 
  74                 UserInfo name = (UserInfo) commonClassDao.getEntityItem(UserInfo.class, "userLoginId", loginId);
 
  78     private static String SUCCESSKEY= "successMapKey";
 
  79     private static String SUCCESS = "success";
 
  80     private static String OPERATION = "operation";
 
  81     private static String GETDICTIONARY = "getDictionary";
 
  82     private static String ERROR = "error";
 
  83     private static String DICTIONARYDBQUERY = "dictionaryDBQuery";
 
  84     private HashMap<String,MSAttributeObject > classMap;
 
  85     private List<String> modelList = new ArrayList<>();
 
  89         MSModelUtils utils = new MSModelUtils(XACMLPapServlet.getMsEcompName(), XACMLPapServlet.getMsPolicyName());
 
  90         private MicroServiceModels newModel;
 
  93         @RequestMapping(value={"/get_DCAEUUIDDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
 
  94         public void getDCAEUUIDDictionaryByNameEntityData(HttpServletRequest request, HttpServletResponse response){
 
  96                         Map<String, Object> model = new HashMap<>();
 
  97                         ObjectMapper mapper = new ObjectMapper();
 
  98                         model.put("dcaeUUIDDictionaryDatas", mapper.writeValueAsString(commonClassDao.getDataByColumn(DCAEuuid.class, "name")));
 
  99                         JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
 
 100                         JSONObject j = new JSONObject(msg);
 
 101                         response.getWriter().write(j.toString());
 
 108         @RequestMapping(value={"/get_DCAEUUIDData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
 
 109         public void getDCAEUUIDDictionaryEntityData(HttpServletRequest request, HttpServletResponse response){
 
 111                         Map<String, Object> model = new HashMap<>();
 
 112                         ObjectMapper mapper = new ObjectMapper();
 
 113                         model.put("dcaeUUIDDictionaryDatas", mapper.writeValueAsString(commonClassDao.getData(DCAEuuid.class)));
 
 114                         JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
 
 115                         JSONObject j = new JSONObject(msg);
 
 116             response.addHeader(SUCCESSKEY, SUCCESS);    
 
 117             response.addHeader(OPERATION, GETDICTIONARY);
 
 118                         response.getWriter().write(j.toString());
 
 121             response.setStatus(HttpServletResponse.SC_BAD_REQUEST);                             
 
 122             response.addHeader(ERROR, DICTIONARYDBQUERY);
 
 123             LOGGER.error(e.getMessage());
 
 127         @RequestMapping(value={"/ms_dictionary/save_dcaeUUID"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
 
 128         public ModelAndView saveDCAEUUIDDictionary(HttpServletRequest request, HttpServletResponse response) throws Exception{
 
 130                         boolean duplicateflag = false;
 
 131             boolean isFakeUpdate = false;
 
 132             boolean fromAPI = false;
 
 133             if (request.getParameter("apiflag")!=null && request.getParameter("apiflag").equalsIgnoreCase("api")) {
 
 136                         ObjectMapper mapper = new ObjectMapper();
 
 137                         mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
 
 138                         JsonNode root = mapper.readTree(request.getReader());
 
 141                 dCAEuuid = (DCAEuuid)mapper.readValue(root.get("dictionaryFields").toString(), DCAEuuid.class);
 
 143                 //check if update operation or create, get id for data to be updated and update attributeData
 
 144                 if (request.getParameter(OPERATION).equals("update")) {
 
 145                         List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(dCAEuuid.getName(), "name", DCAEuuid.class);
 
 147                         DCAEuuid data = (DCAEuuid) duplicateData.get(0);
 
 157                 dCAEuuid = (DCAEuuid)mapper.readValue(root.get("dcaeUUIDDictionaryData").toString(), DCAEuuid.class);
 
 159                         if(dCAEuuid.getId() == 0){
 
 160                                 List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(dCAEuuid.getName(), "name", DCAEuuid.class);
 
 161                                 if(!duplicateData.isEmpty()){
 
 162                                         duplicateflag = true;
 
 164                                         commonClassDao.save(dCAEuuid);
 
 168                                         commonClassDao.update(dCAEuuid); 
 
 171             String responseString = "";
 
 173                 responseString = "Duplicate";
 
 175                 responseString = mapper.writeValueAsString(commonClassDao.getData(DCAEuuid.class));
 
 179                 if (responseString!=null && !responseString.equals("Duplicate")) {
 
 181                         responseString = "Exists";
 
 183                         responseString = "Success";
 
 186                 ModelAndView result = new ModelAndView();
 
 187                 result.setViewName(responseString);
 
 190                 response.setCharacterEncoding("UTF-8");
 
 191                 response.setContentType("application / json");
 
 192                 request.setCharacterEncoding("UTF-8");
 
 194                 PrintWriter out = response.getWriter();
 
 195                 JSONObject j = new JSONObject("{dcaeUUIDDictionaryDatas: " + responseString + "}");
 
 196                 out.write(j.toString());
 
 199         }catch (Exception e){
 
 200                         response.setCharacterEncoding("UTF-8");
 
 201                         request.setCharacterEncoding("UTF-8");
 
 202                         PrintWriter out = response.getWriter();
 
 203                         out.write(e.getMessage());
 
 208         @RequestMapping(value={"/ms_dictionary/remove_dcaeuuid"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
 
 209         public ModelAndView removeDCAEUUIDDictionary(HttpServletRequest request, HttpServletResponse response) throws Exception {
 
 211                         ObjectMapper mapper = new ObjectMapper();
 
 212                         mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
 
 213                         JsonNode root = mapper.readTree(request.getReader());
 
 214                         DCAEuuid dCAEuuid = (DCAEuuid)mapper.readValue(root.get("data").toString(), DCAEuuid.class);
 
 215                         commonClassDao.delete(dCAEuuid);
 
 216                         response.setCharacterEncoding("UTF-8");
 
 217                         response.setContentType("application / json");
 
 218                         request.setCharacterEncoding("UTF-8");
 
 220                         PrintWriter out = response.getWriter();
 
 222                         String responseString = mapper.writeValueAsString(commonClassDao.getData(DCAEuuid.class));
 
 223                         JSONObject j = new JSONObject("{dcaeUUIDDictionaryDatas: " + responseString + "}");
 
 224                         out.write(j.toString());
 
 230                         response.setCharacterEncoding("UTF-8");
 
 231                         request.setCharacterEncoding("UTF-8");
 
 232                         PrintWriter out = response.getWriter();
 
 233                         out.write(e.getMessage());
 
 239         @RequestMapping(value={"/get_MicroServiceConfigNameDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
 
 240         public void getMicroServiceConfigNameByNameDictionaryEntityData(HttpServletRequest request, HttpServletResponse response){
 
 242                         Map<String, Object> model = new HashMap<>();
 
 243                         ObjectMapper mapper = new ObjectMapper();
 
 244                         model.put("microServiceCongigNameDictionaryDatas", mapper.writeValueAsString(commonClassDao.getDataByColumn(MicroServiceConfigName.class, "name")));
 
 245                         JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
 
 246                         JSONObject j = new JSONObject(msg);
 
 247                         response.getWriter().write(j.toString());
 
 256         @RequestMapping(value={"/get_MicroServiceConfigNameData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
 
 257         public void getMicroServiceConfigNameDictionaryEntityData(HttpServletRequest request, HttpServletResponse response){
 
 259                         Map<String, Object> model = new HashMap<>();
 
 260                         ObjectMapper mapper = new ObjectMapper();
 
 261                         model.put("microServiceCongigNameDictionaryDatas", mapper.writeValueAsString(commonClassDao.getData(MicroServiceConfigName.class)));
 
 262                         JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
 
 263                         JSONObject j = new JSONObject(msg);
 
 264             response.addHeader(SUCCESSKEY, SUCCESS);    
 
 265             response.addHeader(OPERATION, GETDICTIONARY);
 
 266                         response.getWriter().write(j.toString());
 
 269             response.setStatus(HttpServletResponse.SC_BAD_REQUEST);                             
 
 270             response.addHeader(ERROR, DICTIONARYDBQUERY);
 
 271             LOGGER.error(e.getMessage());
 
 275         @RequestMapping(value={"/ms_dictionary/save_configName"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
 
 276         public ModelAndView saveMicroServiceConfigNameDictionary(HttpServletRequest request, HttpServletResponse response) throws Exception{
 
 278                         boolean duplicateflag = false;
 
 279             boolean isFakeUpdate = false;
 
 280             boolean fromAPI = false;
 
 281             if (request.getParameter("apiflag")!=null && request.getParameter("apiflag").equalsIgnoreCase("api")) {
 
 284                         ObjectMapper mapper = new ObjectMapper();
 
 285                         mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
 
 286                         JsonNode root = mapper.readTree(request.getReader());
 
 287             MicroServiceConfigName microServiceConfigName;
 
 289                 microServiceConfigName = (MicroServiceConfigName)mapper.readValue(root.get("dictionaryFields").toString(), MicroServiceConfigName.class);
 
 291                 //check if update operation or create, get id for data to be updated and update attributeData
 
 292                 if (request.getParameter(OPERATION).equals("update")) {
 
 293                     List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(microServiceConfigName.getName(), "name", MicroServiceConfigName.class);
 
 295                     MicroServiceConfigName data = (MicroServiceConfigName) duplicateData.get(0);
 
 300                         microServiceConfigName.setId(1);
 
 302                         microServiceConfigName.setId(id);
 
 306                 microServiceConfigName = (MicroServiceConfigName)mapper.readValue(root.get("microServiceCongigNameDictionaryData").toString(), MicroServiceConfigName.class);
 
 308                         if(microServiceConfigName.getId() == 0){
 
 309                                 List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(microServiceConfigName.getName(), "name", MicroServiceConfigName.class);
 
 310                                 if(!duplicateData.isEmpty()){
 
 311                                         duplicateflag = true;
 
 313                                         commonClassDao.save(microServiceConfigName);
 
 317                                         commonClassDao.update(microServiceConfigName); 
 
 320             String responseString = "";
 
 322                 responseString = "Duplicate";
 
 324                 responseString = mapper.writeValueAsString(commonClassDao.getData(MicroServiceConfigName.class));
 
 328                 if (responseString!=null && !responseString.equals("Duplicate")) {
 
 330                         responseString = "Exists";
 
 332                         responseString = "Success";
 
 335                 ModelAndView result = new ModelAndView();
 
 336                 result.setViewName(responseString);
 
 339                 response.setCharacterEncoding("UTF-8");
 
 340                 response.setContentType("application / json");
 
 341                 request.setCharacterEncoding("UTF-8");
 
 343                 PrintWriter out = response.getWriter();
 
 344                 JSONObject j = new JSONObject("{microServiceCongigNameDictionaryDatas: " + responseString + "}");
 
 345                 out.write(j.toString());
 
 348         }catch (Exception e){
 
 349                         response.setCharacterEncoding("UTF-8");
 
 350                         request.setCharacterEncoding("UTF-8");
 
 351                         PrintWriter out = response.getWriter();
 
 352                         out.write(e.getMessage());
 
 357         @RequestMapping(value={"/ms_dictionary/remove_msConfigName"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
 
 358         public ModelAndView removeMicroServiceConfigNameDictionary(HttpServletRequest request, HttpServletResponse response) throws Exception {
 
 360                         ObjectMapper mapper = new ObjectMapper();
 
 361                         mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
 
 362                         JsonNode root = mapper.readTree(request.getReader());
 
 363                         MicroServiceConfigName microServiceConfigName = (MicroServiceConfigName)mapper.readValue(root.get("data").toString(), MicroServiceConfigName.class);
 
 364                         commonClassDao.delete(microServiceConfigName);
 
 365                         response.setCharacterEncoding("UTF-8");
 
 366                         response.setContentType("application / json");
 
 367                         request.setCharacterEncoding("UTF-8");
 
 369                         PrintWriter out = response.getWriter();
 
 371                         String responseString = mapper.writeValueAsString(commonClassDao.getData(MicroServiceConfigName.class));
 
 372                         JSONObject j = new JSONObject("{microServiceCongigNameDictionaryDatas: " + responseString + "}");
 
 373                         out.write(j.toString());
 
 379                         response.setCharacterEncoding("UTF-8");
 
 380                         request.setCharacterEncoding("UTF-8");
 
 381                         PrintWriter out = response.getWriter();
 
 382                         out.write(e.getMessage());
 
 387         @RequestMapping(value={"/get_MicroServiceLocationDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
 
 388         public void getMicroServiceLocationByNameDictionaryEntityData(HttpServletRequest request, HttpServletResponse response){
 
 390                         Map<String, Object> model = new HashMap<>();
 
 391                         ObjectMapper mapper = new ObjectMapper();
 
 392                         model.put("microServiceLocationDictionaryDatas", mapper.writeValueAsString(commonClassDao.getDataByColumn(MicroServiceLocation.class, "name")));
 
 393                         JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
 
 394                         JSONObject j = new JSONObject(msg);
 
 395                         response.getWriter().write(j.toString());
 
 402         @RequestMapping(value={"/get_MicroServiceLocationData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
 
 403         public void getMicroServiceLocationDictionaryEntityData(HttpServletRequest request, HttpServletResponse response){
 
 405                         Map<String, Object> model = new HashMap<>();
 
 406                         ObjectMapper mapper = new ObjectMapper();
 
 407                         model.put("microServiceLocationDictionaryDatas", mapper.writeValueAsString(commonClassDao.getData(MicroServiceLocation.class)));
 
 408                         JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
 
 409                         JSONObject j = new JSONObject(msg);
 
 410             response.addHeader(SUCCESSKEY, SUCCESS);    
 
 411             response.addHeader(OPERATION, GETDICTIONARY);
 
 412                         response.getWriter().write(j.toString());
 
 415             response.setStatus(HttpServletResponse.SC_BAD_REQUEST);                             
 
 416             response.addHeader(ERROR, DICTIONARYDBQUERY);
 
 417             LOGGER.error(e.getMessage());
 
 421         @RequestMapping(value={"/ms_dictionary/save_location"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
 
 422         public ModelAndView saveMicroServiceLocationDictionary(HttpServletRequest request, HttpServletResponse response) throws Exception{
 
 424                         boolean duplicateflag = false;
 
 425             boolean isFakeUpdate = false;
 
 426             boolean fromAPI = false;
 
 427             if (request.getParameter("apiflag")!=null && request.getParameter("apiflag").equalsIgnoreCase("api")) {
 
 430                         ObjectMapper mapper = new ObjectMapper();
 
 431                         mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
 
 432                         JsonNode root = mapper.readTree(request.getReader());
 
 433             MicroServiceLocation microServiceLocation;
 
 435                 microServiceLocation = (MicroServiceLocation)mapper.readValue(root.get("dictionaryFields").toString(), MicroServiceLocation.class);
 
 437                 //check if update operation or create, get id for data to be updated and update attributeData
 
 438                 if (request.getParameter(OPERATION).equals("update")) {
 
 439                     List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(microServiceLocation.getName(), "name", MicroServiceLocation.class);
 
 441                     MicroServiceLocation data = (MicroServiceLocation) duplicateData.get(0);
 
 446                         microServiceLocation.setId(1);
 
 448                         microServiceLocation.setId(id);
 
 452                 microServiceLocation = (MicroServiceLocation)mapper.readValue(root.get("microServiceLocationDictionaryData").toString(), MicroServiceLocation.class);
 
 454                         if(microServiceLocation.getId() == 0){
 
 455                                 List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(microServiceLocation.getName(), "name", MicroServiceLocation.class);
 
 456                                 if(!duplicateData.isEmpty()){
 
 457                                         duplicateflag = true;
 
 459                                         commonClassDao.save(microServiceLocation);
 
 463                                         commonClassDao.update(microServiceLocation); 
 
 466             String responseString = "";
 
 468                 responseString = "Duplicate";
 
 470                 responseString = mapper.writeValueAsString(commonClassDao.getData(MicroServiceLocation.class));
 
 474                 if (responseString!=null && !responseString.equals("Duplicate")) {
 
 476                         responseString = "Exists";
 
 478                         responseString = "Success";
 
 481                 ModelAndView result = new ModelAndView();
 
 482                 result.setViewName(responseString);
 
 485                 response.setCharacterEncoding("UTF-8");
 
 486                 response.setContentType("application / json");
 
 487                 request.setCharacterEncoding("UTF-8");
 
 489                 PrintWriter out = response.getWriter();
 
 490                 JSONObject j = new JSONObject("{microServiceLocationDictionaryDatas: " + responseString + "}");
 
 491                 out.write(j.toString());
 
 494                 }catch (Exception e){
 
 495                         response.setCharacterEncoding("UTF-8");
 
 496                         request.setCharacterEncoding("UTF-8");
 
 497                         PrintWriter out = response.getWriter();
 
 498                         out.write(e.getMessage());
 
 503         @RequestMapping(value={"/ms_dictionary/remove_msLocation"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
 
 504         public ModelAndView removeMicroServiceLocationDictionary(HttpServletRequest request, HttpServletResponse response) throws Exception {
 
 506                         ObjectMapper mapper = new ObjectMapper();
 
 507                         mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
 
 508                         JsonNode root = mapper.readTree(request.getReader());
 
 509                         MicroServiceLocation microServiceLocation = (MicroServiceLocation)mapper.readValue(root.get("data").toString(), MicroServiceLocation.class);
 
 510                         commonClassDao.delete(microServiceLocation);
 
 511                         response.setCharacterEncoding("UTF-8");
 
 512                         response.setContentType("application / json");
 
 513                         request.setCharacterEncoding("UTF-8");
 
 515                         PrintWriter out = response.getWriter();
 
 517                         String responseString = mapper.writeValueAsString(commonClassDao.getData(MicroServiceLocation.class));
 
 518                         JSONObject j = new JSONObject("{microServiceLocationDictionaryDatas: " + responseString + "}");
 
 519                         out.write(j.toString());
 
 525                         response.setCharacterEncoding("UTF-8");
 
 526                         request.setCharacterEncoding("UTF-8");
 
 527                         PrintWriter out = response.getWriter();
 
 528                         out.write(e.getMessage());
 
 533     @RequestMapping(value={"/get_MicroServiceAttributeDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
 
 534     public void getMicroServiceAttributeByNameDictionaryEntityData(HttpServletRequest request, HttpServletResponse response){
 
 536             Map<String, Object> model = new HashMap<>();
 
 537             ObjectMapper mapper = new ObjectMapper();
 
 538             model.put("microServiceAttributeDictionaryDatas", mapper.writeValueAsString(commonClassDao.getDataByColumn(MicroServiceAttribute.class, "name")));
 
 539             JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
 
 540             JSONObject j = new JSONObject(msg);
 
 541             response.getWriter().write(j.toString());
 
 544             LOGGER.error(e.getMessage());
 
 548     @RequestMapping(value={"/get_MicroServiceAttributeData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
 
 549     public void getMicroServiceAttributeDictionaryEntityData(HttpServletRequest request, HttpServletResponse response){
 
 551             Map<String, Object> model = new HashMap<>();
 
 552             ObjectMapper mapper = new ObjectMapper();
 
 553             model.put("microServiceAttributeDictionaryDatas", mapper.writeValueAsString(commonClassDao.getData(MicroServiceAttribute.class)));
 
 554             JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
 
 555             JSONObject j = new JSONObject(msg);
 
 556             response.addHeader(SUCCESSKEY, SUCCESS);    
 
 557             response.addHeader(OPERATION, GETDICTIONARY);
 
 558             response.getWriter().write(j.toString());
 
 562             response.setStatus(HttpServletResponse.SC_BAD_REQUEST);                             
 
 563             response.addHeader(ERROR, DICTIONARYDBQUERY);
 
 564             LOGGER.error(e.getMessage());
 
 568     @RequestMapping(value={"/ms_dictionary/save_modelAttribute"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
 
 569     public ModelAndView saveMicroServiceAttributeDictionary(HttpServletRequest request, HttpServletResponse response) throws Exception{
 
 571             boolean duplicateflag = false;
 
 572             boolean fromAPI = false;
 
 573             if (request.getParameter("apiflag")!=null && request.getParameter("apiflag").equalsIgnoreCase("api")) {
 
 577             ObjectMapper mapper = new ObjectMapper();
 
 578             mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
 
 579             JsonNode root = mapper.readTree(request.getReader());
 
 581             MicroServiceAttribute microServiceAttribute;
 
 583                 microServiceAttribute = (MicroServiceAttribute)mapper.readValue(root.get("dictionaryFields").toString(), MicroServiceAttribute.class);
 
 585                 //check if update operation or create, get id for data to be updated and update attributeData
 
 586                 if (request.getParameter(OPERATION).equals("update")) {
 
 587                     MicroServiceAttribute initialAttribute = (MicroServiceAttribute)mapper.readValue(root.get("initialFields").toString(), MicroServiceAttribute.class);
 
 589                     String checkValue = initialAttribute.getName() + ":" + initialAttribute.getValue() + ":" + initialAttribute.getModelName();
 
 590                     List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(checkValue, "name:value:modelName", MicroServiceAttribute.class);
 
 592                     for (int i= 0; i<duplicateData.size(); i++){
 
 593                         MicroServiceAttribute data = (MicroServiceAttribute) duplicateData.get(0);
 
 596                     microServiceAttribute.setId(id);                
 
 599                 microServiceAttribute = (MicroServiceAttribute)mapper.readValue(root.get("modelAttributeDictionaryData").toString(), MicroServiceAttribute.class);
 
 602             if(microServiceAttribute.getId() == 0){
 
 603                 String checkValue = microServiceAttribute.getName() + ":" + microServiceAttribute.getValue() + ":" + microServiceAttribute.getModelName();
 
 604                 List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(checkValue, "name:value:modelName", MicroServiceAttribute.class);
 
 605                 if(!duplicateData.isEmpty()){
 
 606                     duplicateflag = true;
 
 608                         commonClassDao.save(microServiceAttribute);
 
 611                 commonClassDao.update(microServiceAttribute); 
 
 614             String responseString = "";
 
 616                 responseString = "Duplicate";
 
 618                 responseString = mapper.writeValueAsString(commonClassDao.getData(MicroServiceAttribute.class));
 
 622                 if (responseString!=null && !responseString.equals("Duplicate")) {
 
 623                     responseString = "Success";
 
 625                 ModelAndView result = new ModelAndView();
 
 626                 result.setViewName(responseString);
 
 629                 response.setCharacterEncoding("UTF-8");
 
 630                 response.setContentType("application / json");
 
 631                 request.setCharacterEncoding("UTF-8");
 
 633                 PrintWriter out = response.getWriter();
 
 634                 JSONObject j = new JSONObject("{microServiceAttributeDictionaryDatas: " + responseString + "}");
 
 635                 out.write(j.toString());
 
 640             response.setCharacterEncoding("UTF-8");
 
 641             request.setCharacterEncoding("UTF-8");
 
 642             PrintWriter out = response.getWriter();
 
 643             out.write(e.getMessage());
 
 648     @RequestMapping(value={"/ms_dictionary/remove_modelAttribute"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
 
 649     public ModelAndView removeMicroServiceAttributeDictionary(HttpServletRequest request, HttpServletResponse response) throws Exception {
 
 651             ObjectMapper mapper = new ObjectMapper();
 
 652             mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
 
 653             JsonNode root = mapper.readTree(request.getReader());
 
 654             MicroServiceAttribute microServiceAttribute = (MicroServiceAttribute)mapper.readValue(root.get("data").toString(), MicroServiceAttribute.class);
 
 655             commonClassDao.delete(microServiceAttribute);
 
 656             response.setCharacterEncoding("UTF-8");
 
 657             response.setContentType("application / json");
 
 658             request.setCharacterEncoding("UTF-8");
 
 660             PrintWriter out = response.getWriter();
 
 662             String responseString = mapper.writeValueAsString(MicroServiceDictionaryController.commonClassDao.getData(MicroServiceAttribute.class));
 
 663             JSONObject j = new JSONObject("{microServiceAttributeDictionaryDatas: " + responseString + "}");
 
 664             out.write(j.toString());
 
 669             LOGGER.error(e.getMessage());
 
 670             response.setCharacterEncoding("UTF-8");
 
 671             request.setCharacterEncoding("UTF-8");
 
 672             PrintWriter out = response.getWriter();
 
 673             out.write(e.getMessage());
 
 679         @RequestMapping(value={"/get_MicroServiceModelsDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
 
 680         public void getMicroServiceModelsDictionaryByNameEntityData(HttpServletRequest request, HttpServletResponse response){
 
 682                         Map<String, Object> model = new HashMap<>();
 
 683                         ObjectMapper mapper = new ObjectMapper();
 
 684                         model.put("microServiceModelsDictionaryDatas", mapper.writeValueAsString(commonClassDao.getDataByColumn(MicroServiceModels.class, "modelName")));
 
 685                         JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
 
 686                         JSONObject j = new JSONObject(msg);
 
 687                         response.getWriter().write(j.toString());
 
 690                          LOGGER.error(e.getMessage());
 
 694     @RequestMapping(value={"/get_MicroServiceModelsDataByVersion"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
 
 695     public void getMicroServiceModelsDictionaryByVersionEntityData(HttpServletRequest request, HttpServletResponse response){
 
 697             Map<String, Object> model = new HashMap<>();
 
 698             ObjectMapper mapper = new ObjectMapper();
 
 699             JsonNode root = mapper.readTree(request.getReader());
 
 700             String modelName = null;
 
 701             if (root.get("microServiceModelsDictionaryData").has("modelName")){
 
 702                 modelName = root.get("microServiceModelsDictionaryData").get("modelName").asText().replace("\"", "");
 
 704              if (modelName!=null){
 
 705                     model.put("microServiceModelsDictionaryDatas", mapper.writeValueAsString(commonClassDao.getDataById(MicroServiceModels.class, "modelName", modelName)));
 
 707                  model.put(ERROR, "No model name given");
 
 709             JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
 
 710             JSONObject j = new JSONObject(msg);
 
 711             response.getWriter().write(j.toString());
 
 714             LOGGER.error(e.getMessage());
 
 718         @RequestMapping(value={"/get_MicroServiceModelsData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
 
 719         public void getMicroServiceModelsDictionaryEntityData(HttpServletRequest request, HttpServletResponse response){
 
 721                         Map<String, Object> model = new HashMap<>();
 
 722                         ObjectMapper mapper = new ObjectMapper();
 
 723                         model.put("microServiceModelsDictionaryDatas", mapper.writeValueAsString(commonClassDao.getData(MicroServiceModels.class)));
 
 724                         JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
 
 725                         JSONObject j = new JSONObject(msg);
 
 726             response.addHeader(SUCCESSKEY, SUCCESS);    
 
 727             response.addHeader(OPERATION, GETDICTIONARY);
 
 728                         response.getWriter().write(j.toString());
 
 731             response.setStatus(HttpServletResponse.SC_BAD_REQUEST);                             
 
 732             response.addHeader(ERROR, DICTIONARYDBQUERY);
 
 733             LOGGER.error(e.getMessage());
 
 737     @RequestMapping(value={"/get_MicroServiceModelsDataServiceVersion"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
 
 738     public void getMicroServiceModelsDictionaryEntityDataServiceVersion(HttpServletRequest request, HttpServletResponse response){
 
 740             Map<String, Object> model = new HashMap<>();
 
 741             ObjectMapper mapper = new ObjectMapper();
 
 742             List<String> data = new ArrayList<>();
 
 743             List<Object> datas = commonClassDao.getData(MicroServiceModels.class);
 
 744             for(int i = 0; i < datas.size(); i++){
 
 745                 MicroServiceModels msmodel = (MicroServiceModels) datas.get(i);
 
 746                 if (!data.contains(msmodel.getModelName())){
 
 747                         data.add(msmodel.getModelName() + "-v" + msmodel.getVersion());
 
 750             model.put("microServiceModelsDictionaryDatas", mapper.writeValueAsString(data));
 
 751             JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
 
 752             JSONObject j = new JSONObject(msg);
 
 753             response.addHeader("successMapKey", "success"); 
 
 754             response.addHeader("operation", "getDictionary");
 
 755             response.getWriter().write(j.toString());
 
 759             response.setStatus(HttpServletResponse.SC_BAD_REQUEST);                             
 
 760             response.addHeader("error", "dictionaryDBQuery");
 
 765     @RequestMapping(value={"/get_MicroServiceModelsDataByClass"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
 
 766     public void getMicroServiceModelsDictionaryClassEntityData(HttpServletRequest request, HttpServletResponse response){
 
 768             Map<String, Object> model = new HashMap<>();
 
 769             ObjectMapper mapper = new ObjectMapper();
 
 770             model.put("microServiceModelsDictionaryClassDatas", mapper.writeValueAsString(modelList));
 
 771             JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
 
 772             JSONObject j = new JSONObject(msg);
 
 773             response.addHeader(SUCCESSKEY, SUCCESS);    
 
 774             response.addHeader(OPERATION, GETDICTIONARY);
 
 775             response.getWriter().write(j.toString());
 
 779             response.setStatus(HttpServletResponse.SC_BAD_REQUEST);                             
 
 780             response.addHeader(ERROR, DICTIONARYDBQUERY);
 
 781             LOGGER.error(e.getMessage());
 
 785         @RequestMapping(value={"/ms_dictionary/save_model"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
 
 786         public ModelAndView saveMicroServiceModelsDictionary(HttpServletRequest request, HttpServletResponse response) throws Exception{
 
 788                         boolean duplicateflag = false;
 
 789                         boolean fromAPI = false;
 
 790                         this.newModel = new MicroServiceModels();
 
 791                         if (request.getParameter("apiflag")!=null && request.getParameter("apiflag").equalsIgnoreCase("api")) {
 
 794                         ObjectMapper mapper = new ObjectMapper();
 
 795                         mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
 
 796                         JsonNode root = mapper.readTree(request.getReader());
 
 797                         MicroServiceModels microServiceModels = new MicroServiceModels();
 
 798                         String userId = null;
 
 800                         if(root.has("modelType")){
 
 801                                 JsonNode dataType = root.get("modelType");
 
 802                                 String modelType= dataType.toString();
 
 803                                 if(modelType.contains("yml")){
 
 804                                         if (root.has("microServiceModelsDictionaryData")){
 
 805                                                 if (root.get("microServiceModelsDictionaryData").has("description")){
 
 806                                                         microServiceModels.setDescription(root.get("microServiceModelsDictionaryData").get("description").asText().replace("\"", ""));
 
 808                                                 if (root.get("microServiceModelsDictionaryData").has("modelName")){
 
 809                                                         microServiceModels.setModelName(root.get("microServiceModelsDictionaryData").get("modelName").asText().replace("\"", ""));
 
 810                                                         this.newModel.setModelName(microServiceModels.getModelName());
 
 812                                                 if (root.get("microServiceModelsDictionaryData").has("version")){
 
 813                                                         microServiceModels.setVersion(root.get("microServiceModelsDictionaryData").get("version").asText().replace("\"", ""));
 
 814                                                         this.newModel.setVersion(microServiceModels.getVersion());
 
 818                                         MSAttributeObject mainClass  = null;
 
 819                                         classMap = new HashMap<>();
 
 820                                         JsonNode data = root.get("classMap");
 
 821                                         ObjectMapper mapper1 = new ObjectMapper();
 
 822                                         String data1 = data.toString().substring(1, data.toString().length()-1);
 
 823                                         data1 = data1.replace("\\", "");
 
 824                                         data1=data1.replace("\"{","{");
 
 825                                         data1=data1.replace("}\"","}");
 
 826                                         JSONObject jsonObject = new JSONObject(data1);
 
 827                                         Set<String> keys = jsonObject.keySet();
 
 828                                         for(String key : keys){
 
 829                                                 String value = jsonObject.get(key).toString();
 
 830                                                 MSAttributeObject msAttributeObject = mapper1.readValue(value, MSAttributeObject.class);
 
 831                                                 classMap.put(key, msAttributeObject);
 
 834                                         userId = root.get("userid").textValue();
 
 835                                         mainClass = classMap.get(this.newModel.getModelName());
 
 836                                         this.newModel.setDependency("[]");
 
 837                                         String value = new Gson().toJson(mainClass.getSubClass());
 
 838                                         this.newModel.setSub_attributes(value);
 
 839                                         String attributes= mainClass.getAttribute().toString().replace("{", "").replace("}", "");
 
 840                                         int equalsIndexForAttributes= attributes.indexOf("=");
 
 841                                         String atttributesAfterFirstEquals= attributes.substring(equalsIndexForAttributes+1);
 
 842                                         this.newModel.setAttributes(atttributesAfterFirstEquals);
 
 843                                         String refAttributes= mainClass.getRefAttribute().toString().replace("{", "").replace("}", "");
 
 844                                         int equalsIndex= refAttributes.indexOf("=");
 
 845                                         String refAttributesAfterFirstEquals= refAttributes.substring(equalsIndex+1);
 
 846                                         this.newModel.setRef_attributes(refAttributesAfterFirstEquals);
 
 847                                         this.newModel.setEnumValues(mainClass.getEnumType().toString().replace("{", "").replace("}", ""));
 
 848                                         this.newModel.setAnnotation(mainClass.getMatchingSet().toString().replace("{", "").replace("}", ""));
 
 852                                                 microServiceModels = (MicroServiceModels)mapper.readValue(root.get("dictionaryFields").toString(), MicroServiceModels.class);
 
 855                                                 //check if update operation or create, get id for data to be updated and update attributeData
 
 856                                                 if (request.getParameter(OPERATION).equals("update")) {
 
 857                                                         String checkName = microServiceModels.getModelName() + ":" + microServiceModels.getVersion();
 
 858                                                         List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(checkName, "modelName:version", MicroServiceModels.class);
 
 860                                                         for (int i=0; i< duplicateData.size(); i++){
 
 861                                                                 MicroServiceModels data = (MicroServiceModels) duplicateData.get(0);
 
 864                                                         microServiceModels.setId(id);
 
 865                                                         microServiceModels.setUserCreatedBy(this.getUserInfo(userId));
 
 869                                                 if (root.has("microServiceModelsDictionaryData")){
 
 870                                                         if (root.get("microServiceModelsDictionaryData").has("description")){
 
 871                                                                 microServiceModels.setDescription(root.get("microServiceModelsDictionaryData").get("description").asText().replace("\"", ""));
 
 873                                                         if (root.get("microServiceModelsDictionaryData").has("modelName")){
 
 874                                                                 microServiceModels.setModelName(root.get("microServiceModelsDictionaryData").get("modelName").asText().replace("\"", ""));
 
 875                                                                 this.newModel.setModelName(microServiceModels.getModelName());
 
 877                                                         if (root.get("microServiceModelsDictionaryData").has("version")){
 
 878                                                                 microServiceModels.setVersion(root.get("microServiceModelsDictionaryData").get("version").asText().replace("\"", ""));
 
 879                                                                 this.newModel.setVersion(microServiceModels.getVersion());
 
 882                                                 if(root.has("classMap")){
 
 883                                                         classMap = new HashMap<>();
 
 884                                                         JsonNode data = root.get("classMap");
 
 885                                                         ObjectMapper mapper1 = new ObjectMapper();
 
 886                                                         String data1 = data.toString().substring(1, data.toString().length()-1);
 
 887                                                         data1 = data1.replace("\\", "");
 
 888                                                         JSONObject jsonObject = new JSONObject(data1);
 
 889                                                         Set<String> keys = jsonObject.keySet();
 
 890                                                         for(String key : keys){
 
 891                                                                 String value = jsonObject.get(key).toString();
 
 892                                                                 MSAttributeObject msAttributeObject = mapper1.readValue(value, MSAttributeObject.class);
 
 893                                                                 classMap.put(key, msAttributeObject);
 
 896                                                 userId = root.get("userid").textValue();
 
 897                                                 addValuesToNewModel(classMap);
 
 902                         microServiceModels.setAttributes(this.newModel.getAttributes());
 
 903                         microServiceModels.setRef_attributes(this.newModel.getRef_attributes());
 
 904                         microServiceModels.setDependency(this.newModel.getDependency());
 
 905                         microServiceModels.setModelName(this.newModel.getModelName());
 
 906                         microServiceModels.setSub_attributes(this.newModel.getSub_attributes());
 
 907                         microServiceModels.setVersion(this.newModel.getVersion());
 
 908                         microServiceModels.setEnumValues(this.newModel.getEnumValues());
 
 909                         microServiceModels.setAnnotation(this.newModel.getAnnotation());
 
 911                         if(microServiceModels.getId() == 0){
 
 912                                 String checkName = microServiceModels.getModelName() + ":" + microServiceModels.getVersion();
 
 913                                 List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(checkName, "modelName:version", MicroServiceModels.class);
 
 914                                 if(!duplicateData.isEmpty()){
 
 915                                         duplicateflag = true;
 
 917                                         microServiceModels.setUserCreatedBy(this.getUserInfo(userId));
 
 918                                         commonClassDao.save(microServiceModels);
 
 921                                 commonClassDao.update(microServiceModels); 
 
 923                         String responseString = "";
 
 925                                 responseString = "Duplicate";
 
 927                                 responseString = mapper.writeValueAsString(commonClassDao.getData(MicroServiceModels.class));
 
 931                                 if (responseString!=null && !responseString.equals("Duplicate")) {
 
 932                                         responseString = "Success";
 
 934                                 ModelAndView result = new ModelAndView();
 
 935                                 result.setViewName(responseString);
 
 938                                 response.setCharacterEncoding("UTF-8");
 
 939                                 response.setContentType("application / json");
 
 940                                 request.setCharacterEncoding("UTF-8");
 
 942                                 PrintWriter out = response.getWriter();
 
 943                                 JSONObject j = new JSONObject("{microServiceModelsDictionaryDatas: " + responseString + "}");
 
 944                                 out.write(j.toString());
 
 947                 }catch (Exception e){
 
 948                         response.setCharacterEncoding("UTF-8");
 
 949                         request.setCharacterEncoding("UTF-8");
 
 950                         PrintWriter out = response.getWriter();
 
 951                         out.write(e.getMessage());
 
 956         @RequestMapping(value={"/ms_dictionary/remove_msModel"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
 
 957         public ModelAndView removeMicroServiceModelsDictionary(HttpServletRequest request, HttpServletResponse response) throws Exception {
 
 959                         ObjectMapper mapper = new ObjectMapper();
 
 960                         mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
 
 961                         JsonNode root = mapper.readTree(request.getReader());
 
 962                         MicroServiceModels microServiceModels = (MicroServiceModels)mapper.readValue(root.get("data").toString(), MicroServiceModels.class);
 
 963                         commonClassDao.delete(microServiceModels);
 
 964                         response.setCharacterEncoding("UTF-8");
 
 965                         response.setContentType("application / json");
 
 966                         request.setCharacterEncoding("UTF-8");
 
 968                         PrintWriter out = response.getWriter();
 
 970                         String responseString = mapper.writeValueAsString(commonClassDao.getData(MicroServiceModels.class));
 
 971                         JSONObject j = new JSONObject("{microServiceModelsDictionaryDatas: " + responseString + "}");
 
 972                         out.write(j.toString());
 
 978                         response.setCharacterEncoding("UTF-8");
 
 979                         request.setCharacterEncoding("UTF-8");
 
 980                         PrintWriter out = response.getWriter();
 
 981                         out.write(e.getMessage());
 
 986         private void addValuesToNewModel(HashMap<String,MSAttributeObject > classMap) {
 
 987                 new MicroServiceModels();
 
 988                 //Loop  through the classmap and pull out the required info for the new file.
 
 989                 MSAttributeObject mainClass  = null;
 
 990                 ArrayList<String> dependency = null;
 
 991                 String subAttribute = null;
 
 993                 mainClass = classMap.get(this.newModel.getModelName());
 
 995                 if (mainClass !=null){
 
 996                         String dependTemp = StringUtils.replaceEach(mainClass.getDependency(), new String[]{"[", "]", " "}, new String[]{"", "", ""});
 
 997                         dependency = new ArrayList<String>(Arrays.asList(dependTemp.split(",")));       
 
 998                         dependency = getFullDependencyList(dependency);
 
 999                         for (String element : dependency){
 
1000                                 MSAttributeObject temp = new MSAttributeObject();
 
1001                                 temp = classMap.get(element);
 
1003                                         mainClass.addAllRefAttribute(temp.getRefAttribute());
 
1004                                         mainClass.addAllAttribute(temp.getAttribute());
 
1007                         subAttribute = utils.createSubAttributes(dependency, classMap, this.newModel.getModelName());
 
1009                         subAttribute = "{}";
 
1010                         this.newModel.setDependency("");
 
1013                 if (mainClass != null && mainClass.getDependency()==null){
 
1014                         mainClass.setDependency("");
 
1017                 this.newModel.setDependency(mainClass.getDependency());
 
1018                 this.newModel.setSub_attributes(subAttribute.toString());
 
1019                 this.newModel.setAttributes(mainClass.getAttribute().toString().replace("{", "").replace("}", ""));
 
1020                 this.newModel.setRef_attributes(mainClass.getRefAttribute().toString().replace("{", "").replace("}", ""));
 
1021         this.newModel.setEnumValues(mainClass.getEnumType().toString().replace("{", "").replace("}", ""));
 
1022         this.newModel.setAnnotation(mainClass.getMatchingSet().toString().replace("{", "").replace("}", ""));
 
1026         private ArrayList<String> getFullDependencyList(ArrayList<String> dependency) {
 
1027                 ArrayList<String> returnList = new ArrayList<>();
 
1028                 ArrayList<String> workingList = new ArrayList<>();
 
1029                 returnList.addAll(dependency);
 
1030                 for (String element : dependency ){
 
1031                         if (classMap.containsKey(element)){
 
1032                                 MSAttributeObject value = classMap.get(element);                        
 
1033                                 String rawValue = StringUtils.replaceEach(value.getDependency(), new String[]{"[", "]"}, new String[]{"", ""});
 
1034                                 workingList = new ArrayList<String>(Arrays.asList(rawValue.split(",")));        
 
1035                                 for(String depend : workingList){
 
1036                                         if (!returnList.contains(depend) && !depend.isEmpty()){
 
1037                                                 returnList.add(depend.trim());
 
1038                                                 //getFullDepedency(workingList)