@Test public void testLoad() { boolean isLocalTesting = true; MsModelUtils controller = new MsModelUtils(); String fileName = null; Map<String, String> result = null; try { ClassLoader classLoader = getClass().getClassLoader(); fileName = new File(classLoader.getResource("TESTMODEL-v1806.yml").getFile()).getAbsolutePath(); } catch (Exception e1) { logger.error("Exception Occured while loading file" + e1); } if (isLocalTesting) { try { result = controller.load(fileName); } catch (IOException e) { logger.error("testLoad", e); result = null; } catch (ParserException e) { logger.error("testLoad", e); } assertTrue(result != null && !result.isEmpty()); logger.debug("result : " + result); } logger.debug("testLoad: exit"); }
public Map<String, String> load(String fileName) throws IOException, ParserException { File newConfiguration = new File(fileName); StringBuilder orderInfo = new StringBuilder("["); Yaml yaml = new Yaml(); LinkedHashMap<Object, Object> yamlMap = null; try (InputStream is = new FileInputStream(newConfiguration)) { yamlMap = yaml.load(is); } catch (FileNotFoundException e) { logger.error(e); } catch (Exception e) { logger.error(e); throw new ParserException("Invalid TOSCA Model format. Please make sure it is a valid YAML file"); } LinkedHashMap<String, String> settings = new LinkedHashMap<>(); if (yamlMap == null) { return settings; } String message = validations(yamlMap); if (message != null) { settings.put(ERROR, message); return settings; } findNode(yamlMap); if (!isDuplicatedAttributes && orderedElements != null && !orderedElements.isEmpty()) { orderedElements.stream().forEach(string -> { orderInfo.append(string); orderInfo.append(","); logger.info("Content: " + string); }); orderInfo.append("]"); dataOrderInfo = orderInfo.toString(); dataOrderInfo = dataOrderInfo.replace(",]", "]"); logger.info("dataOrderInfo :" + dataOrderInfo); } List<String> path = new ArrayList<>(); serializeMap(settings, new StringBuilder(), path, yamlMap); return settings; }
MsModelUtils { public Map<String, String> load(String fileName) throws IOException, ParserException { File newConfiguration = new File(fileName); StringBuilder orderInfo = new StringBuilder("["); Yaml yaml = new Yaml(); LinkedHashMap<Object, Object> yamlMap = null; try (InputStream is = new FileInputStream(newConfiguration)) { yamlMap = yaml.load(is); } catch (FileNotFoundException e) { logger.error(e); } catch (Exception e) { logger.error(e); throw new ParserException("Invalid TOSCA Model format. Please make sure it is a valid YAML file"); } LinkedHashMap<String, String> settings = new LinkedHashMap<>(); if (yamlMap == null) { return settings; } String message = validations(yamlMap); if (message != null) { settings.put(ERROR, message); return settings; } findNode(yamlMap); if (!isDuplicatedAttributes && orderedElements != null && !orderedElements.isEmpty()) { orderedElements.stream().forEach(string -> { orderInfo.append(string); orderInfo.append(","); logger.info("Content: " + string); }); orderInfo.append("]"); dataOrderInfo = orderInfo.toString(); dataOrderInfo = dataOrderInfo.replace(",]", "]"); logger.info("dataOrderInfo :" + dataOrderInfo); } List<String> path = new ArrayList<>(); serializeMap(settings, new StringBuilder(), path, yamlMap); return settings; } }
MsModelUtils { public Map<String, String> load(String fileName) throws IOException, ParserException { File newConfiguration = new File(fileName); StringBuilder orderInfo = new StringBuilder("["); Yaml yaml = new Yaml(); LinkedHashMap<Object, Object> yamlMap = null; try (InputStream is = new FileInputStream(newConfiguration)) { yamlMap = yaml.load(is); } catch (FileNotFoundException e) { logger.error(e); } catch (Exception e) { logger.error(e); throw new ParserException("Invalid TOSCA Model format. Please make sure it is a valid YAML file"); } LinkedHashMap<String, String> settings = new LinkedHashMap<>(); if (yamlMap == null) { return settings; } String message = validations(yamlMap); if (message != null) { settings.put(ERROR, message); return settings; } findNode(yamlMap); if (!isDuplicatedAttributes && orderedElements != null && !orderedElements.isEmpty()) { orderedElements.stream().forEach(string -> { orderInfo.append(string); orderInfo.append(","); logger.info("Content: " + string); }); orderInfo.append("]"); dataOrderInfo = orderInfo.toString(); dataOrderInfo = dataOrderInfo.replace(",]", "]"); logger.info("dataOrderInfo :" + dataOrderInfo); } List<String> path = new ArrayList<>(); serializeMap(settings, new StringBuilder(), path, yamlMap); return settings; } MsModelUtils();  MsModelUtils(CommonClassDao commonClassDao);  MsModelUtils(String onap, String policy); }
MsModelUtils { public Map<String, String> load(String fileName) throws IOException, ParserException { File newConfiguration = new File(fileName); StringBuilder orderInfo = new StringBuilder("["); Yaml yaml = new Yaml(); LinkedHashMap<Object, Object> yamlMap = null; try (InputStream is = new FileInputStream(newConfiguration)) { yamlMap = yaml.load(is); } catch (FileNotFoundException e) { logger.error(e); } catch (Exception e) { logger.error(e); throw new ParserException("Invalid TOSCA Model format. Please make sure it is a valid YAML file"); } LinkedHashMap<String, String> settings = new LinkedHashMap<>(); if (yamlMap == null) { return settings; } String message = validations(yamlMap); if (message != null) { settings.put(ERROR, message); return settings; } findNode(yamlMap); if (!isDuplicatedAttributes && orderedElements != null && !orderedElements.isEmpty()) { orderedElements.stream().forEach(string -> { orderInfo.append(string); orderInfo.append(","); logger.info("Content: " + string); }); orderInfo.append("]"); dataOrderInfo = orderInfo.toString(); dataOrderInfo = dataOrderInfo.replace(",]", "]"); logger.info("dataOrderInfo :" + dataOrderInfo); } List<String> path = new ArrayList<>(); serializeMap(settings, new StringBuilder(), path, yamlMap); return settings; } MsModelUtils();  MsModelUtils(CommonClassDao commonClassDao);  MsModelUtils(String onap, String policy); Map<String, MsAttributeObject> processEpackage(String file, ModelType model); void getAttributes(String className, String dependency, EPackage root); String checkDefultValue(String defultValue); String checkRequiredPattern(int upper, int lower); JSONObject buildJavaObject(Map<String, String> map); Map<String, String> getRefAttributeList(EPackage root, String className, String superClass); boolean isRequiredAttribute(EObject obj, String className); Map<String, String> getAttributeList(EPackage root, String className, String superClass); String arrayCheck(int upperBound); List<String> getDependencyList(EClassifier eclassifier); Map<String, String> buildSubList(Map<String, String> subClassAttributes,
                    Map<String, MsAttributeObject> classMap, String className); Map<String, Map<String, String>> recursiveReference(Map<String, MsAttributeObject> classMap,
                    String className); String createJson(Map<String, MsAttributeObject> classMap, String className); Map<String, String> getRefclass(Map<String, MsAttributeObject> classMap, String className); String createSubAttributes(List<String> dependency, Map<String, MsAttributeObject> classMap,
                    String modelName); List<String> getFullDependencyList(List<String> dependency, Map<String, MsAttributeObject> classMap); String parseTosca(String fileName); Map<String, String> load(String fileName); int stringBetweenDots(String str); void stringBetweenDotsForDataFields(String str); }
MsModelUtils { public Map<String, String> load(String fileName) throws IOException, ParserException { File newConfiguration = new File(fileName); StringBuilder orderInfo = new StringBuilder("["); Yaml yaml = new Yaml(); LinkedHashMap<Object, Object> yamlMap = null; try (InputStream is = new FileInputStream(newConfiguration)) { yamlMap = yaml.load(is); } catch (FileNotFoundException e) { logger.error(e); } catch (Exception e) { logger.error(e); throw new ParserException("Invalid TOSCA Model format. Please make sure it is a valid YAML file"); } LinkedHashMap<String, String> settings = new LinkedHashMap<>(); if (yamlMap == null) { return settings; } String message = validations(yamlMap); if (message != null) { settings.put(ERROR, message); return settings; } findNode(yamlMap); if (!isDuplicatedAttributes && orderedElements != null && !orderedElements.isEmpty()) { orderedElements.stream().forEach(string -> { orderInfo.append(string); orderInfo.append(","); logger.info("Content: " + string); }); orderInfo.append("]"); dataOrderInfo = orderInfo.toString(); dataOrderInfo = dataOrderInfo.replace(",]", "]"); logger.info("dataOrderInfo :" + dataOrderInfo); } List<String> path = new ArrayList<>(); serializeMap(settings, new StringBuilder(), path, yamlMap); return settings; } MsModelUtils();  MsModelUtils(CommonClassDao commonClassDao);  MsModelUtils(String onap, String policy); Map<String, MsAttributeObject> processEpackage(String file, ModelType model); void getAttributes(String className, String dependency, EPackage root); String checkDefultValue(String defultValue); String checkRequiredPattern(int upper, int lower); JSONObject buildJavaObject(Map<String, String> map); Map<String, String> getRefAttributeList(EPackage root, String className, String superClass); boolean isRequiredAttribute(EObject obj, String className); Map<String, String> getAttributeList(EPackage root, String className, String superClass); String arrayCheck(int upperBound); List<String> getDependencyList(EClassifier eclassifier); Map<String, String> buildSubList(Map<String, String> subClassAttributes,
                    Map<String, MsAttributeObject> classMap, String className); Map<String, Map<String, String>> recursiveReference(Map<String, MsAttributeObject> classMap,
                    String className); String createJson(Map<String, MsAttributeObject> classMap, String className); Map<String, String> getRefclass(Map<String, MsAttributeObject> classMap, String className); String createSubAttributes(List<String> dependency, Map<String, MsAttributeObject> classMap,
                    String modelName); List<String> getFullDependencyList(List<String> dependency, Map<String, MsAttributeObject> classMap); String parseTosca(String fileName); Map<String, String> load(String fileName); int stringBetweenDots(String str); void stringBetweenDotsForDataFields(String str);  }