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.onap.policy.pap.xacml.rest.controller;
 
  23 import java.io.IOException;
 
  24 import java.io.PrintWriter;
 
  25 import java.io.UnsupportedEncodingException;
 
  26 import java.util.ArrayList;
 
  27 import java.util.Arrays;
 
  28 import java.util.HashMap;
 
  29 import java.util.List;
 
  33 import javax.servlet.http.HttpServletRequest;
 
  34 import javax.servlet.http.HttpServletResponse;
 
  36 import org.apache.commons.lang.StringUtils;
 
  37 import org.json.JSONObject;
 
  38 import org.onap.policy.common.logging.flexlogger.FlexLogger;
 
  39 import org.onap.policy.common.logging.flexlogger.Logger;
 
  40 import org.onap.policy.pap.xacml.rest.XACMLPapServlet;
 
  41 import org.onap.policy.pap.xacml.rest.util.JsonMessage;
 
  42 import org.onap.policy.rest.dao.CommonClassDao;
 
  43 import org.onap.policy.rest.jpa.DCAEuuid;
 
  44 import org.onap.policy.rest.jpa.MicroServiceAttribute;
 
  45 import org.onap.policy.rest.jpa.MicroServiceConfigName;
 
  46 import org.onap.policy.rest.jpa.MicroServiceLocation;
 
  47 import org.onap.policy.rest.jpa.MicroServiceModels;
 
  48 import org.onap.policy.rest.jpa.UserInfo;
 
  49 import org.onap.policy.rest.util.MSAttributeObject;
 
  50 import org.onap.policy.rest.util.MSModelUtils;
 
  51 import org.springframework.beans.factory.annotation.Autowired;
 
  52 import org.springframework.http.MediaType;
 
  53 import org.springframework.stereotype.Controller;
 
  54 import org.springframework.web.bind.annotation.RequestMapping;
 
  55 import org.springframework.web.servlet.ModelAndView;
 
  57 import com.fasterxml.jackson.databind.DeserializationFeature;
 
  58 import com.fasterxml.jackson.databind.JsonNode;
 
  59 import com.fasterxml.jackson.databind.ObjectMapper;
 
  60 import com.google.gson.Gson;
 
  63 public class MicroServiceDictionaryController {
 
  64         private static final Logger LOGGER  = FlexLogger.getLogger(MicroServiceDictionaryController.class);
 
  66         private static CommonClassDao commonClassDao;
 
  68         public static void setCommonClassDao(CommonClassDao commonClassDao) {
 
  69                 MicroServiceDictionaryController.commonClassDao = commonClassDao;
 
  73         public MicroServiceDictionaryController(CommonClassDao commonClassDao){
 
  74                 MicroServiceDictionaryController.commonClassDao = commonClassDao;
 
  77         public MicroServiceDictionaryController(){}     
 
  79         public UserInfo getUserInfo(String loginId){
 
  80                 UserInfo name = (UserInfo) commonClassDao.getEntityItem(UserInfo.class, "userLoginId", loginId);
 
  84     private static String SUCCESSKEY= "successMapKey";
 
  85     private static String SUCCESS = "success";
 
  86     private static String OPERATION = "operation";
 
  87     private static String GETDICTIONARY = "getDictionary";
 
  88     private static String ERROR = "error";
 
  89     private static String DICTIONARYDBQUERY = "dictionaryDBQuery";
 
  90     private HashMap<String,MSAttributeObject > classMap;
 
  91     private List<String> modelList = new ArrayList<>();
 
  95         MSModelUtils utils = new MSModelUtils(XACMLPapServlet.getMsOnapName(), XACMLPapServlet.getMsPolicyName());
 
  96         private MicroServiceModels newModel;
 
  99         @RequestMapping(value={"/get_DCAEUUIDDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
 
 100         public void getDCAEUUIDDictionaryByNameEntityData(HttpServletRequest request, HttpServletResponse response){
 
 102                         Map<String, Object> model = new HashMap<>();
 
 103                         ObjectMapper mapper = new ObjectMapper();
 
 104                         model.put("dcaeUUIDDictionaryDatas", mapper.writeValueAsString(commonClassDao.getDataByColumn(DCAEuuid.class, "name")));
 
 105                         JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
 
 106                         JSONObject j = new JSONObject(msg);
 
 107                         response.getWriter().write(j.toString());
 
 114         @RequestMapping(value={"/get_DCAEUUIDData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
 
 115         public void getDCAEUUIDDictionaryEntityData(HttpServletRequest request, HttpServletResponse response){
 
 117                         Map<String, Object> model = new HashMap<>();
 
 118                         ObjectMapper mapper = new ObjectMapper();
 
 119                         model.put("dcaeUUIDDictionaryDatas", mapper.writeValueAsString(commonClassDao.getData(DCAEuuid.class)));
 
 120                         JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
 
 121                         JSONObject j = new JSONObject(msg);
 
 122             response.addHeader(SUCCESSKEY, SUCCESS);    
 
 123             response.addHeader(OPERATION, GETDICTIONARY);
 
 124                         response.getWriter().write(j.toString());
 
 127             response.setStatus(HttpServletResponse.SC_BAD_REQUEST);                             
 
 128             response.addHeader(ERROR, DICTIONARYDBQUERY);
 
 133         @RequestMapping(value={"/ms_dictionary/save_dcaeUUID"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
 
 134         public ModelAndView saveDCAEUUIDDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
 
 136                         boolean duplicateflag = false;
 
 137             boolean isFakeUpdate = false;
 
 138             boolean fromAPI = false;
 
 139             if (request.getParameter("apiflag")!=null && request.getParameter("apiflag").equalsIgnoreCase("api")) {
 
 142                         ObjectMapper mapper = new ObjectMapper();
 
 143                         mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
 
 144                         JsonNode root = mapper.readTree(request.getReader());
 
 147                 dCAEuuid = (DCAEuuid)mapper.readValue(root.get("dictionaryFields").toString(), DCAEuuid.class);
 
 149                 //check if update operation or create, get id for data to be updated and update attributeData
 
 150                 if (request.getParameter(OPERATION).equals("update")) {
 
 151                         List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(dCAEuuid.getName(), "name", DCAEuuid.class);
 
 153                         DCAEuuid data = (DCAEuuid) duplicateData.get(0);
 
 163                 dCAEuuid = (DCAEuuid)mapper.readValue(root.get("dcaeUUIDDictionaryData").toString(), DCAEuuid.class);
 
 165                         if(dCAEuuid.getId() == 0){
 
 166                                 List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(dCAEuuid.getName(), "name", DCAEuuid.class);
 
 167                                 if(!duplicateData.isEmpty()){
 
 168                                         duplicateflag = true;
 
 170                                         commonClassDao.save(dCAEuuid);
 
 174                                         commonClassDao.update(dCAEuuid); 
 
 177             String responseString = "";
 
 179                 responseString = "Duplicate";
 
 181                 responseString = mapper.writeValueAsString(commonClassDao.getData(DCAEuuid.class));
 
 185                 if (responseString!=null && !responseString.equals("Duplicate")) {
 
 187                         responseString = "Exists";
 
 189                         responseString = "Success";
 
 192                 ModelAndView result = new ModelAndView();
 
 193                 result.setViewName(responseString);
 
 196                 response.setCharacterEncoding("UTF-8");
 
 197                 response.setContentType("application / json");
 
 198                 request.setCharacterEncoding("UTF-8");
 
 200                 PrintWriter out = response.getWriter();
 
 201                 JSONObject j = new JSONObject("{dcaeUUIDDictionaryDatas: " + responseString + "}");
 
 202                 out.write(j.toString());
 
 205         }catch (Exception e){
 
 206                         response.setCharacterEncoding("UTF-8");
 
 207                         request.setCharacterEncoding("UTF-8");
 
 208                         PrintWriter out = response.getWriter();
 
 209                         out.write(e.getMessage());
 
 215         @RequestMapping(value={"/ms_dictionary/remove_dcaeuuid"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
 
 216         public ModelAndView removeDCAEUUIDDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException {
 
 218                         ObjectMapper mapper = new ObjectMapper();
 
 219                         mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
 
 220                         JsonNode root = mapper.readTree(request.getReader());
 
 221                         DCAEuuid dCAEuuid = (DCAEuuid)mapper.readValue(root.get("data").toString(), DCAEuuid.class);
 
 222                         commonClassDao.delete(dCAEuuid);
 
 223                         response.setCharacterEncoding("UTF-8");
 
 224                         response.setContentType("application / json");
 
 225                         request.setCharacterEncoding("UTF-8");
 
 227                         PrintWriter out = response.getWriter();
 
 229                         String responseString = mapper.writeValueAsString(commonClassDao.getData(DCAEuuid.class));
 
 230                         JSONObject j = new JSONObject("{dcaeUUIDDictionaryDatas: " + responseString + "}");
 
 231                         out.write(j.toString());
 
 237                         response.setCharacterEncoding("UTF-8");
 
 238                         request.setCharacterEncoding("UTF-8");
 
 239                         PrintWriter out = response.getWriter();
 
 240                         out.write(e.getMessage());
 
 246         @RequestMapping(value={"/get_MicroServiceConfigNameDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
 
 247         public void getMicroServiceConfigNameByNameDictionaryEntityData(HttpServletRequest request, HttpServletResponse response){
 
 249                         Map<String, Object> model = new HashMap<>();
 
 250                         ObjectMapper mapper = new ObjectMapper();
 
 251                         model.put("microServiceCongigNameDictionaryDatas", mapper.writeValueAsString(commonClassDao.getDataByColumn(MicroServiceConfigName.class, "name")));
 
 252                         JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
 
 253                         JSONObject j = new JSONObject(msg);
 
 254                         response.getWriter().write(j.toString());
 
 263         @RequestMapping(value={"/get_MicroServiceConfigNameData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
 
 264         public void getMicroServiceConfigNameDictionaryEntityData(HttpServletRequest request, HttpServletResponse response){
 
 266                         Map<String, Object> model = new HashMap<>();
 
 267                         ObjectMapper mapper = new ObjectMapper();
 
 268                         model.put("microServiceCongigNameDictionaryDatas", mapper.writeValueAsString(commonClassDao.getData(MicroServiceConfigName.class)));
 
 269                         JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
 
 270                         JSONObject j = new JSONObject(msg);
 
 271             response.addHeader(SUCCESSKEY, SUCCESS);    
 
 272             response.addHeader(OPERATION, GETDICTIONARY);
 
 273                         response.getWriter().write(j.toString());
 
 276             response.setStatus(HttpServletResponse.SC_BAD_REQUEST);                             
 
 277             response.addHeader(ERROR, DICTIONARYDBQUERY);
 
 282         @RequestMapping(value={"/ms_dictionary/save_configName"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
 
 283         public ModelAndView saveMicroServiceConfigNameDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
 
 285                         boolean duplicateflag = false;
 
 286             boolean isFakeUpdate = false;
 
 287             boolean fromAPI = false;
 
 288             if (request.getParameter("apiflag")!=null && request.getParameter("apiflag").equalsIgnoreCase("api")) {
 
 291                         ObjectMapper mapper = new ObjectMapper();
 
 292                         mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
 
 293                         JsonNode root = mapper.readTree(request.getReader());
 
 294             MicroServiceConfigName microServiceConfigName;
 
 296                 microServiceConfigName = (MicroServiceConfigName)mapper.readValue(root.get("dictionaryFields").toString(), MicroServiceConfigName.class);
 
 298                 //check if update operation or create, get id for data to be updated and update attributeData
 
 299                 if (request.getParameter(OPERATION).equals("update")) {
 
 300                     List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(microServiceConfigName.getName(), "name", MicroServiceConfigName.class);
 
 302                     MicroServiceConfigName data = (MicroServiceConfigName) duplicateData.get(0);
 
 307                         microServiceConfigName.setId(1);
 
 309                         microServiceConfigName.setId(id);
 
 313                 microServiceConfigName = (MicroServiceConfigName)mapper.readValue(root.get("microServiceCongigNameDictionaryData").toString(), MicroServiceConfigName.class);
 
 315                         if(microServiceConfigName.getId() == 0){
 
 316                                 List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(microServiceConfigName.getName(), "name", MicroServiceConfigName.class);
 
 317                                 if(!duplicateData.isEmpty()){
 
 318                                         duplicateflag = true;
 
 320                                         commonClassDao.save(microServiceConfigName);
 
 324                                         commonClassDao.update(microServiceConfigName); 
 
 327             String responseString = "";
 
 329                 responseString = "Duplicate";
 
 331                 responseString = mapper.writeValueAsString(commonClassDao.getData(MicroServiceConfigName.class));
 
 335                 if (responseString!=null && !responseString.equals("Duplicate")) {
 
 337                         responseString = "Exists";
 
 339                         responseString = "Success";
 
 342                 ModelAndView result = new ModelAndView();
 
 343                 result.setViewName(responseString);
 
 346                 response.setCharacterEncoding("UTF-8");
 
 347                 response.setContentType("application / json");
 
 348                 request.setCharacterEncoding("UTF-8");
 
 350                 PrintWriter out = response.getWriter();
 
 351                 JSONObject j = new JSONObject("{microServiceCongigNameDictionaryDatas: " + responseString + "}");
 
 352                 out.write(j.toString());
 
 355         }catch (Exception e){
 
 356                         response.setCharacterEncoding("UTF-8");
 
 357                         request.setCharacterEncoding("UTF-8");
 
 358                         PrintWriter out = response.getWriter();
 
 359                         out.write(e.getMessage());
 
 365         @RequestMapping(value={"/ms_dictionary/remove_msConfigName"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
 
 366         public ModelAndView removeMicroServiceConfigNameDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException {
 
 368                         ObjectMapper mapper = new ObjectMapper();
 
 369                         mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
 
 370                         JsonNode root = mapper.readTree(request.getReader());
 
 371                         MicroServiceConfigName microServiceConfigName = (MicroServiceConfigName)mapper.readValue(root.get("data").toString(), MicroServiceConfigName.class);
 
 372                         commonClassDao.delete(microServiceConfigName);
 
 373                         response.setCharacterEncoding("UTF-8");
 
 374                         response.setContentType("application / json");
 
 375                         request.setCharacterEncoding("UTF-8");
 
 377                         PrintWriter out = response.getWriter();
 
 379                         String responseString = mapper.writeValueAsString(commonClassDao.getData(MicroServiceConfigName.class));
 
 380                         JSONObject j = new JSONObject("{microServiceCongigNameDictionaryDatas: " + responseString + "}");
 
 381                         out.write(j.toString());
 
 387                         response.setCharacterEncoding("UTF-8");
 
 388                         request.setCharacterEncoding("UTF-8");
 
 389                         PrintWriter out = response.getWriter();
 
 390                         out.write(e.getMessage());
 
 395         @RequestMapping(value={"/get_MicroServiceLocationDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
 
 396         public void getMicroServiceLocationByNameDictionaryEntityData(HttpServletRequest request, HttpServletResponse response){
 
 398                         Map<String, Object> model = new HashMap<>();
 
 399                         ObjectMapper mapper = new ObjectMapper();
 
 400                         model.put("microServiceLocationDictionaryDatas", mapper.writeValueAsString(commonClassDao.getDataByColumn(MicroServiceLocation.class, "name")));
 
 401                         JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
 
 402                         JSONObject j = new JSONObject(msg);
 
 403                         response.getWriter().write(j.toString());
 
 410         @RequestMapping(value={"/get_MicroServiceLocationData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
 
 411         public void getMicroServiceLocationDictionaryEntityData(HttpServletRequest request, HttpServletResponse response){
 
 413                         Map<String, Object> model = new HashMap<>();
 
 414                         ObjectMapper mapper = new ObjectMapper();
 
 415                         model.put("microServiceLocationDictionaryDatas", mapper.writeValueAsString(commonClassDao.getData(MicroServiceLocation.class)));
 
 416                         JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
 
 417                         JSONObject j = new JSONObject(msg);
 
 418             response.addHeader(SUCCESSKEY, SUCCESS);    
 
 419             response.addHeader(OPERATION, GETDICTIONARY);
 
 420                         response.getWriter().write(j.toString());
 
 423             response.setStatus(HttpServletResponse.SC_BAD_REQUEST);                             
 
 424             response.addHeader(ERROR, DICTIONARYDBQUERY);
 
 429         @RequestMapping(value={"/ms_dictionary/save_location"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
 
 430         public ModelAndView saveMicroServiceLocationDictionary(HttpServletRequest request, HttpServletResponse response)throws UnsupportedEncodingException, IOException{
 
 432                         boolean duplicateflag = false;
 
 433             boolean isFakeUpdate = false;
 
 434             boolean fromAPI = false;
 
 435             if (request.getParameter("apiflag")!=null && request.getParameter("apiflag").equalsIgnoreCase("api")) {
 
 438                         ObjectMapper mapper = new ObjectMapper();
 
 439                         mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
 
 440                         JsonNode root = mapper.readTree(request.getReader());
 
 441             MicroServiceLocation microServiceLocation;
 
 443                 microServiceLocation = (MicroServiceLocation)mapper.readValue(root.get("dictionaryFields").toString(), MicroServiceLocation.class);
 
 445                 //check if update operation or create, get id for data to be updated and update attributeData
 
 446                 if (request.getParameter(OPERATION).equals("update")) {
 
 447                     List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(microServiceLocation.getName(), "name", MicroServiceLocation.class);
 
 449                     MicroServiceLocation data = (MicroServiceLocation) duplicateData.get(0);
 
 454                         microServiceLocation.setId(1);
 
 456                         microServiceLocation.setId(id);
 
 460                 microServiceLocation = (MicroServiceLocation)mapper.readValue(root.get("microServiceLocationDictionaryData").toString(), MicroServiceLocation.class);
 
 462                         if(microServiceLocation.getId() == 0){
 
 463                                 List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(microServiceLocation.getName(), "name", MicroServiceLocation.class);
 
 464                                 if(!duplicateData.isEmpty()){
 
 465                                         duplicateflag = true;
 
 467                                         commonClassDao.save(microServiceLocation);
 
 471                                         commonClassDao.update(microServiceLocation); 
 
 474             String responseString = "";
 
 476                 responseString = "Duplicate";
 
 478                 responseString = mapper.writeValueAsString(commonClassDao.getData(MicroServiceLocation.class));
 
 482                 if (responseString!=null && !responseString.equals("Duplicate")) {
 
 484                         responseString = "Exists";
 
 486                         responseString = "Success";
 
 489                 ModelAndView result = new ModelAndView();
 
 490                 result.setViewName(responseString);
 
 493                 response.setCharacterEncoding("UTF-8");
 
 494                 response.setContentType("application / json");
 
 495                 request.setCharacterEncoding("UTF-8");
 
 497                 PrintWriter out = response.getWriter();
 
 498                 JSONObject j = new JSONObject("{microServiceLocationDictionaryDatas: " + responseString + "}");
 
 499                 out.write(j.toString());
 
 502                 }catch (Exception e){
 
 503                         response.setCharacterEncoding("UTF-8");
 
 504                         request.setCharacterEncoding("UTF-8");
 
 505                         PrintWriter out = response.getWriter();
 
 506                         out.write(e.getMessage());
 
 512         @RequestMapping(value={"/ms_dictionary/remove_msLocation"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
 
 513         public ModelAndView removeMicroServiceLocationDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException {
 
 515                         ObjectMapper mapper = new ObjectMapper();
 
 516                         mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
 
 517                         JsonNode root = mapper.readTree(request.getReader());
 
 518                         MicroServiceLocation microServiceLocation = (MicroServiceLocation)mapper.readValue(root.get("data").toString(), MicroServiceLocation.class);
 
 519                         commonClassDao.delete(microServiceLocation);
 
 520                         response.setCharacterEncoding("UTF-8");
 
 521                         response.setContentType("application / json");
 
 522                         request.setCharacterEncoding("UTF-8");
 
 524                         PrintWriter out = response.getWriter();
 
 526                         String responseString = mapper.writeValueAsString(commonClassDao.getData(MicroServiceLocation.class));
 
 527                         JSONObject j = new JSONObject("{microServiceLocationDictionaryDatas: " + responseString + "}");
 
 528                         out.write(j.toString());
 
 534                         response.setCharacterEncoding("UTF-8");
 
 535                         request.setCharacterEncoding("UTF-8");
 
 536                         PrintWriter out = response.getWriter();
 
 537                         out.write(e.getMessage());
 
 542     @RequestMapping(value={"/get_MicroServiceAttributeDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
 
 543     public void getMicroServiceAttributeByNameDictionaryEntityData(HttpServletRequest request, HttpServletResponse response){
 
 545             Map<String, Object> model = new HashMap<>();
 
 546             ObjectMapper mapper = new ObjectMapper();
 
 547             model.put("microServiceAttributeDictionaryDatas", mapper.writeValueAsString(commonClassDao.getDataByColumn(MicroServiceAttribute.class, "name")));
 
 548             JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
 
 549             JSONObject j = new JSONObject(msg);
 
 550             response.getWriter().write(j.toString());
 
 557     @RequestMapping(value={"/get_MicroServiceAttributeData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
 
 558     public void getMicroServiceAttributeDictionaryEntityData(HttpServletRequest request, HttpServletResponse response){
 
 560             Map<String, Object> model = new HashMap<>();
 
 561             ObjectMapper mapper = new ObjectMapper();
 
 562             model.put("microServiceAttributeDictionaryDatas", mapper.writeValueAsString(commonClassDao.getData(MicroServiceAttribute.class)));
 
 563             JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
 
 564             JSONObject j = new JSONObject(msg);
 
 565             response.addHeader(SUCCESSKEY, SUCCESS);    
 
 566             response.addHeader(OPERATION, GETDICTIONARY);
 
 567             response.getWriter().write(j.toString());
 
 571             response.setStatus(HttpServletResponse.SC_BAD_REQUEST);                             
 
 572             response.addHeader(ERROR, DICTIONARYDBQUERY);
 
 577     @RequestMapping(value={"/ms_dictionary/save_modelAttribute"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
 
 578     public ModelAndView saveMicroServiceAttributeDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
 
 580             boolean duplicateflag = false;
 
 581             boolean fromAPI = false;
 
 582             if (request.getParameter("apiflag")!=null && request.getParameter("apiflag").equalsIgnoreCase("api")) {
 
 586             ObjectMapper mapper = new ObjectMapper();
 
 587             mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
 
 588             JsonNode root = mapper.readTree(request.getReader());
 
 590             MicroServiceAttribute microServiceAttribute;
 
 592                 microServiceAttribute = (MicroServiceAttribute)mapper.readValue(root.get("dictionaryFields").toString(), MicroServiceAttribute.class);
 
 594                 //check if update operation or create, get id for data to be updated and update attributeData
 
 595                 if (request.getParameter(OPERATION).equals("update")) {
 
 596                     MicroServiceAttribute initialAttribute = (MicroServiceAttribute)mapper.readValue(root.get("initialFields").toString(), MicroServiceAttribute.class);
 
 598                     String checkValue = initialAttribute.getName() + ":" + initialAttribute.getValue() + ":" + initialAttribute.getModelName();
 
 599                     List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(checkValue, "name:value:modelName", MicroServiceAttribute.class);
 
 601                     for (int i= 0; i<duplicateData.size(); i++){
 
 602                         MicroServiceAttribute data = (MicroServiceAttribute) duplicateData.get(0);
 
 605                     microServiceAttribute.setId(id);                
 
 608                 microServiceAttribute = (MicroServiceAttribute)mapper.readValue(root.get("modelAttributeDictionaryData").toString(), MicroServiceAttribute.class);
 
 611             if(microServiceAttribute.getId() == 0){
 
 612                 String checkValue = microServiceAttribute.getName() + ":" + microServiceAttribute.getValue() + ":" + microServiceAttribute.getModelName();
 
 613                 List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(checkValue, "name:value:modelName", MicroServiceAttribute.class);
 
 614                 if(!duplicateData.isEmpty()){
 
 615                     duplicateflag = true;
 
 617                         commonClassDao.save(microServiceAttribute);
 
 620                 commonClassDao.update(microServiceAttribute); 
 
 623             String responseString = "";
 
 625                 responseString = "Duplicate";
 
 627                 responseString = mapper.writeValueAsString(commonClassDao.getData(MicroServiceAttribute.class));
 
 631                 if (responseString!=null && !responseString.equals("Duplicate")) {
 
 632                     responseString = "Success";
 
 634                 ModelAndView result = new ModelAndView();
 
 635                 result.setViewName(responseString);
 
 638                 response.setCharacterEncoding("UTF-8");
 
 639                 response.setContentType("application / json");
 
 640                 request.setCharacterEncoding("UTF-8");
 
 642                 PrintWriter out = response.getWriter();
 
 643                 JSONObject j = new JSONObject("{microServiceAttributeDictionaryDatas: " + responseString + "}");
 
 644                 out.write(j.toString());
 
 649             response.setCharacterEncoding("UTF-8");
 
 650             request.setCharacterEncoding("UTF-8");
 
 651             PrintWriter out = response.getWriter();
 
 652             out.write(e.getMessage());
 
 658     @RequestMapping(value={"/ms_dictionary/remove_modelAttribute"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
 
 659     public ModelAndView removeMicroServiceAttributeDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
 
 661             ObjectMapper mapper = new ObjectMapper();
 
 662             mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
 
 663             JsonNode root = mapper.readTree(request.getReader());
 
 664             MicroServiceAttribute microServiceAttribute = (MicroServiceAttribute)mapper.readValue(root.get("data").toString(), MicroServiceAttribute.class);
 
 665             commonClassDao.delete(microServiceAttribute);
 
 666             response.setCharacterEncoding("UTF-8");
 
 667             response.setContentType("application / json");
 
 668             request.setCharacterEncoding("UTF-8");
 
 670             PrintWriter out = response.getWriter();
 
 672             String responseString = mapper.writeValueAsString(MicroServiceDictionaryController.commonClassDao.getData(MicroServiceAttribute.class));
 
 673             JSONObject j = new JSONObject("{microServiceAttributeDictionaryDatas: " + responseString + "}");
 
 674             out.write(j.toString());
 
 680             response.setCharacterEncoding("UTF-8");
 
 681             request.setCharacterEncoding("UTF-8");
 
 682             PrintWriter out = response.getWriter();
 
 683             out.write(e.getMessage());
 
 689         @RequestMapping(value={"/get_MicroServiceModelsDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
 
 690         public void getMicroServiceModelsDictionaryByNameEntityData(HttpServletRequest request, HttpServletResponse response){
 
 692                         Map<String, Object> model = new HashMap<>();
 
 693                         ObjectMapper mapper = new ObjectMapper();
 
 694                         model.put("microServiceModelsDictionaryDatas", mapper.writeValueAsString(commonClassDao.getDataByColumn(MicroServiceModels.class, "modelName")));
 
 695                         JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
 
 696                         JSONObject j = new JSONObject(msg);
 
 697                         response.getWriter().write(j.toString());
 
 704     @RequestMapping(value={"/get_MicroServiceModelsDataByVersion"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
 
 705     public void getMicroServiceModelsDictionaryByVersionEntityData(HttpServletRequest request, HttpServletResponse response){
 
 707             Map<String, Object> model = new HashMap<>();
 
 708             ObjectMapper mapper = new ObjectMapper();
 
 709             JsonNode root = mapper.readTree(request.getReader());
 
 710             String modelName = null;
 
 711             if (root.get("microServiceModelsDictionaryData").has("modelName")){
 
 712                 modelName = root.get("microServiceModelsDictionaryData").get("modelName").asText().replace("\"", "");
 
 714              if (modelName!=null){
 
 715                     model.put("microServiceModelsDictionaryDatas", mapper.writeValueAsString(commonClassDao.getDataById(MicroServiceModels.class, "modelName", modelName)));
 
 717                  model.put(ERROR, "No model name given");
 
 719             JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
 
 720             JSONObject j = new JSONObject(msg);
 
 721             response.getWriter().write(j.toString());
 
 728         @RequestMapping(value={"/get_MicroServiceModelsData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
 
 729         public void getMicroServiceModelsDictionaryEntityData(HttpServletRequest request, HttpServletResponse response){
 
 731                         Map<String, Object> model = new HashMap<>();
 
 732                         ObjectMapper mapper = new ObjectMapper();
 
 733                         model.put("microServiceModelsDictionaryDatas", mapper.writeValueAsString(commonClassDao.getData(MicroServiceModels.class)));
 
 734                         JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
 
 735                         JSONObject j = new JSONObject(msg);
 
 736             response.addHeader(SUCCESSKEY, SUCCESS);    
 
 737             response.addHeader(OPERATION, GETDICTIONARY);
 
 738                         response.getWriter().write(j.toString());
 
 741             response.setStatus(HttpServletResponse.SC_BAD_REQUEST);                             
 
 742             response.addHeader(ERROR, DICTIONARYDBQUERY);
 
 747     @RequestMapping(value={"/get_MicroServiceModelsDataServiceVersion"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
 
 748     public void getMicroServiceModelsDictionaryEntityDataServiceVersion(HttpServletRequest request, HttpServletResponse response){
 
 750             Map<String, Object> model = new HashMap<>();
 
 751             ObjectMapper mapper = new ObjectMapper();
 
 752             List<String> data = new ArrayList<>();
 
 753             List<Object> datas = commonClassDao.getData(MicroServiceModels.class);
 
 754             for(int i = 0; i < datas.size(); i++){
 
 755                 MicroServiceModels msmodel = (MicroServiceModels) datas.get(i);
 
 756                 if (!data.contains(msmodel.getModelName())){
 
 757                         data.add(msmodel.getModelName() + "-v" + msmodel.getVersion());
 
 760             model.put("microServiceModelsDictionaryDatas", mapper.writeValueAsString(data));
 
 761             JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
 
 762             JSONObject j = new JSONObject(msg);
 
 763             response.addHeader("successMapKey", "success"); 
 
 764             response.addHeader("operation", "getDictionary");
 
 765             response.getWriter().write(j.toString());
 
 769             response.setStatus(HttpServletResponse.SC_BAD_REQUEST);                             
 
 770             response.addHeader("error", "dictionaryDBQuery");
 
 775     @RequestMapping(value={"/get_MicroServiceModelsDataByClass"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
 
 776     public void getMicroServiceModelsDictionaryClassEntityData(HttpServletRequest request, HttpServletResponse response){
 
 778             Map<String, Object> model = new HashMap<>();
 
 779             ObjectMapper mapper = new ObjectMapper();
 
 780             model.put("microServiceModelsDictionaryClassDatas", mapper.writeValueAsString(modelList));
 
 781             JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
 
 782             JSONObject j = new JSONObject(msg);
 
 783             response.addHeader(SUCCESSKEY, SUCCESS);    
 
 784             response.addHeader(OPERATION, GETDICTIONARY);
 
 785             response.getWriter().write(j.toString());
 
 789             response.setStatus(HttpServletResponse.SC_BAD_REQUEST);                             
 
 790             response.addHeader(ERROR, DICTIONARYDBQUERY);
 
 795         @RequestMapping(value={"/ms_dictionary/save_model"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
 
 796         public ModelAndView saveMicroServiceModelsDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
 
 798                         boolean duplicateflag = false;
 
 799                         boolean fromAPI = false;
 
 800                         this.newModel = new MicroServiceModels();
 
 801                         if (request.getParameter("apiflag")!=null && request.getParameter("apiflag").equalsIgnoreCase("api")) {
 
 804                         ObjectMapper mapper = new ObjectMapper();
 
 805                         mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
 
 806                         JsonNode root = mapper.readTree(request.getReader());
 
 807                         MicroServiceModels microServiceModels = new MicroServiceModels();
 
 808                         String userId = null;
 
 810                         if(root.has("modelType")){
 
 811                                 JsonNode dataType = root.get("modelType");
 
 812                                 String modelType= dataType.toString();
 
 813                                 if(modelType.contains("yml")){
 
 814                                         if (root.has("microServiceModelsDictionaryData")){
 
 815                                                 if (root.get("microServiceModelsDictionaryData").has("description")){
 
 816                                                         microServiceModels.setDescription(root.get("microServiceModelsDictionaryData").get("description").asText().replace("\"", ""));
 
 818                                                 if (root.get("microServiceModelsDictionaryData").has("modelName")){
 
 819                                                         microServiceModels.setModelName(root.get("microServiceModelsDictionaryData").get("modelName").asText().replace("\"", ""));
 
 820                                                         this.newModel.setModelName(microServiceModels.getModelName());
 
 822                                                 if (root.get("microServiceModelsDictionaryData").has("version")){
 
 823                                                         microServiceModels.setVersion(root.get("microServiceModelsDictionaryData").get("version").asText().replace("\"", ""));
 
 824                                                         this.newModel.setVersion(microServiceModels.getVersion());
 
 828                                         MSAttributeObject mainClass  = null;
 
 829                                         classMap = new HashMap<>();
 
 830                                         JsonNode data = root.get("classMap");
 
 831                                         ObjectMapper mapper1 = new ObjectMapper();
 
 832                                         String data1 = data.toString().substring(1, data.toString().length()-1);
 
 833                                         data1 = data1.replace("\\", "");
 
 834                                         data1=data1.replace("\"{","{");
 
 835                                         data1=data1.replace("}\"","}");
 
 836                                         JSONObject jsonObject = new JSONObject(data1);
 
 837                                         Set<String> keys = jsonObject.keySet();
 
 838                                         for(String key : keys){
 
 839                                                 String value = jsonObject.get(key).toString();
 
 840                                                 MSAttributeObject msAttributeObject = mapper1.readValue(value, MSAttributeObject.class);
 
 841                                                 classMap.put(key, msAttributeObject);
 
 844                                         userId = root.get("userid").textValue();
 
 845                                         mainClass = classMap.get(this.newModel.getModelName());
 
 846                                         this.newModel.setDependency("[]");
 
 847                                         String value = new Gson().toJson(mainClass.getSubClass());
 
 848                                         this.newModel.setSub_attributes(value);
 
 849                                         String attributes= mainClass.getAttribute().toString().replace("{", "").replace("}", "");
 
 850                                         int equalsIndexForAttributes= attributes.indexOf("=");
 
 851                                         String atttributesAfterFirstEquals= attributes.substring(equalsIndexForAttributes+1);
 
 852                                         this.newModel.setAttributes(atttributesAfterFirstEquals);
 
 853                                         String refAttributes= mainClass.getRefAttribute().toString().replace("{", "").replace("}", "");
 
 854                                         int equalsIndex= refAttributes.indexOf("=");
 
 855                                         String refAttributesAfterFirstEquals= refAttributes.substring(equalsIndex+1);
 
 856                                         this.newModel.setRef_attributes(refAttributesAfterFirstEquals);
 
 857                                         this.newModel.setEnumValues(mainClass.getEnumType().toString().replace("{", "").replace("}", ""));
 
 858                                         this.newModel.setAnnotation(mainClass.getMatchingSet().toString().replace("{", "").replace("}", ""));
 
 862                                                 microServiceModels = (MicroServiceModels)mapper.readValue(root.get("dictionaryFields").toString(), MicroServiceModels.class);
 
 865                                                 //check if update operation or create, get id for data to be updated and update attributeData
 
 866                                                 if (request.getParameter(OPERATION).equals("update")) {
 
 867                                                         String checkName = microServiceModels.getModelName() + ":" + microServiceModels.getVersion();
 
 868                                                         List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(checkName, "modelName:version", MicroServiceModels.class);
 
 870                                                         for (int i=0; i< duplicateData.size(); i++){
 
 871                                                                 MicroServiceModels data = (MicroServiceModels) duplicateData.get(0);
 
 874                                                         microServiceModels.setId(id);
 
 875                                                         microServiceModels.setUserCreatedBy(this.getUserInfo(userId));
 
 879                                                 if (root.has("microServiceModelsDictionaryData")){
 
 880                                                         if (root.get("microServiceModelsDictionaryData").has("description")){
 
 881                                                                 microServiceModels.setDescription(root.get("microServiceModelsDictionaryData").get("description").asText().replace("\"", ""));
 
 883                                                         if (root.get("microServiceModelsDictionaryData").has("modelName")){
 
 884                                                                 microServiceModels.setModelName(root.get("microServiceModelsDictionaryData").get("modelName").asText().replace("\"", ""));
 
 885                                                                 this.newModel.setModelName(microServiceModels.getModelName());
 
 887                                                         if (root.get("microServiceModelsDictionaryData").has("version")){
 
 888                                                                 microServiceModels.setVersion(root.get("microServiceModelsDictionaryData").get("version").asText().replace("\"", ""));
 
 889                                                                 this.newModel.setVersion(microServiceModels.getVersion());
 
 892                                                 if(root.has("classMap")){
 
 893                                                         classMap = new HashMap<>();
 
 894                                                         JsonNode data = root.get("classMap");
 
 895                                                         ObjectMapper mapper1 = new ObjectMapper();
 
 896                                                         String data1 = data.toString().substring(1, data.toString().length()-1);
 
 897                                                         data1 = data1.replace("\\", "");
 
 898                                                         JSONObject jsonObject = new JSONObject(data1);
 
 899                                                         Set<String> keys = jsonObject.keySet();
 
 900                                                         for(String key : keys){
 
 901                                                                 String value = jsonObject.get(key).toString();
 
 902                                                                 MSAttributeObject msAttributeObject = mapper1.readValue(value, MSAttributeObject.class);
 
 903                                                                 classMap.put(key, msAttributeObject);
 
 906                                                 userId = root.get("userid").textValue();
 
 907                                                 addValuesToNewModel(classMap);
 
 912                         microServiceModels.setAttributes(this.newModel.getAttributes());
 
 913                         microServiceModels.setRef_attributes(this.newModel.getRef_attributes());
 
 914                         microServiceModels.setDependency(this.newModel.getDependency());
 
 915                         microServiceModels.setModelName(this.newModel.getModelName());
 
 916                         microServiceModels.setSub_attributes(this.newModel.getSub_attributes());
 
 917                         microServiceModels.setVersion(this.newModel.getVersion());
 
 918                         microServiceModels.setEnumValues(this.newModel.getEnumValues());
 
 919                         microServiceModels.setAnnotation(this.newModel.getAnnotation());
 
 921                         if(microServiceModels.getId() == 0){
 
 922                                 String checkName = microServiceModels.getModelName() + ":" + microServiceModels.getVersion();
 
 923                                 List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(checkName, "modelName:version", MicroServiceModels.class);
 
 924                                 if(!duplicateData.isEmpty()){
 
 925                                         duplicateflag = true;
 
 927                                         microServiceModels.setUserCreatedBy(this.getUserInfo(userId));
 
 928                                         commonClassDao.save(microServiceModels);
 
 931                                 commonClassDao.update(microServiceModels); 
 
 933                         String responseString = "";
 
 935                                 responseString = "Duplicate";
 
 937                                 responseString = mapper.writeValueAsString(commonClassDao.getData(MicroServiceModels.class));
 
 941                                 if (responseString!=null && !responseString.equals("Duplicate")) {
 
 942                                         responseString = "Success";
 
 944                                 ModelAndView result = new ModelAndView();
 
 945                                 result.setViewName(responseString);
 
 948                                 response.setCharacterEncoding("UTF-8");
 
 949                                 response.setContentType("application / json");
 
 950                                 request.setCharacterEncoding("UTF-8");
 
 952                                 PrintWriter out = response.getWriter();
 
 953                                 JSONObject j = new JSONObject("{microServiceModelsDictionaryDatas: " + responseString + "}");
 
 954                                 out.write(j.toString());
 
 957                 }catch (Exception e){
 
 958                         response.setCharacterEncoding("UTF-8");
 
 959                         request.setCharacterEncoding("UTF-8");
 
 960                         PrintWriter out = response.getWriter();
 
 961                         out.write(e.getMessage());
 
 967         @RequestMapping(value={"/ms_dictionary/remove_msModel"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
 
 968         public ModelAndView removeMicroServiceModelsDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException {
 
 970                         ObjectMapper mapper = new ObjectMapper();
 
 971                         mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
 
 972                         JsonNode root = mapper.readTree(request.getReader());
 
 973                         MicroServiceModels microServiceModels = (MicroServiceModels)mapper.readValue(root.get("data").toString(), MicroServiceModels.class);
 
 974                         commonClassDao.delete(microServiceModels);
 
 975                         response.setCharacterEncoding("UTF-8");
 
 976                         response.setContentType("application / json");
 
 977                         request.setCharacterEncoding("UTF-8");
 
 979                         PrintWriter out = response.getWriter();
 
 981                         String responseString = mapper.writeValueAsString(commonClassDao.getData(MicroServiceModels.class));
 
 982                         JSONObject j = new JSONObject("{microServiceModelsDictionaryDatas: " + responseString + "}");
 
 983                         out.write(j.toString());
 
 989                         response.setCharacterEncoding("UTF-8");
 
 990                         request.setCharacterEncoding("UTF-8");
 
 991                         PrintWriter out = response.getWriter();
 
 992                         out.write(e.getMessage());
 
 997         private void addValuesToNewModel(HashMap<String,MSAttributeObject > classMap) {
 
 998                 new MicroServiceModels();
 
 999                 //Loop  through the classmap and pull out the required info for the new file.
 
1000                 MSAttributeObject mainClass  = null;
 
1001                 ArrayList<String> dependency = null;
 
1002                 String subAttribute = null;
 
1004                 mainClass = classMap.get(this.newModel.getModelName());
 
1006                 if (mainClass !=null){
 
1007                         String dependTemp = StringUtils.replaceEach(mainClass.getDependency(), new String[]{"[", "]", " "}, new String[]{"", "", ""});
 
1008                         dependency = new ArrayList<String>(Arrays.asList(dependTemp.split(",")));       
 
1009                         dependency = getFullDependencyList(dependency);
 
1010                         for (String element : dependency){
 
1011                                 MSAttributeObject temp = new MSAttributeObject();
 
1012                                 temp = classMap.get(element);
 
1014                                         mainClass.addAllRefAttribute(temp.getRefAttribute());
 
1015                                         mainClass.addAllAttribute(temp.getAttribute());
 
1018                         subAttribute = utils.createSubAttributes(dependency, classMap, this.newModel.getModelName());
 
1020                         subAttribute = "{}";
 
1021                         this.newModel.setDependency("");
 
1024                 if (mainClass != null && mainClass.getDependency()==null){
 
1025                         mainClass.setDependency("");
 
1027                 if(mainClass != null){
 
1028                         this.newModel.setDependency(mainClass.getDependency());
 
1029                         this.newModel.setSub_attributes(subAttribute);
 
1030                         this.newModel.setAttributes(mainClass.getAttribute().toString().replace("{", "").replace("}", ""));
 
1031                         this.newModel.setRef_attributes(mainClass.getRefAttribute().toString().replace("{", "").replace("}", ""));
 
1032                         this.newModel.setEnumValues(mainClass.getEnumType().toString().replace("{", "").replace("}", ""));
 
1033                         this.newModel.setAnnotation(mainClass.getMatchingSet().toString().replace("{", "").replace("}", ""));
 
1037         private ArrayList<String> getFullDependencyList(ArrayList<String> dependency) {
 
1038                 ArrayList<String> returnList = new ArrayList<>();
 
1039                 ArrayList<String> workingList = new ArrayList<>();
 
1040                 returnList.addAll(dependency);
 
1041                 for (String element : dependency ){
 
1042                         if (classMap.containsKey(element)){
 
1043                                 MSAttributeObject value = classMap.get(element);                        
 
1044                                 String rawValue = StringUtils.replaceEach(value.getDependency(), new String[]{"[", "]"}, new String[]{"", ""});
 
1045                                 workingList = new ArrayList<String>(Arrays.asList(rawValue.split(",")));        
 
1046                                 for(String depend : workingList){
 
1047                                         if (!returnList.contains(depend) && !depend.isEmpty()){
 
1048                                                 returnList.add(depend.trim());
 
1049                                                 //getFullDepedency(workingList)