private void addNodeType(PropertyDefinition artifact, ServiceTemplate toscaTemplate) throws ArtifactProcessorException { //Add basic fields for the node NodeType toscaNodeType = new NodeType(); toscaNodeType.setDerived_from(DERIVEDFROM); toscaNodeType.setVersion(artifact.getVersion()); toscaNodeType.setDescription(""); if(artifact.getParameters()!=null) { Map<String, org.openecomp.sdc.tosca.datatypes.model.PropertyDefinition> toscaPropertyMap = new HashMap<>(); toscaNodeType.setProperties(toscaPropertyMap); //Add properties from parameters of PD for (Parameter pdParameter : artifact.getParameters()) { addProperty(toscaNodeType, pdParameter); } } // This is where it adds node in node Map and adds the map in tosca template Map<String,NodeType> toscaNodeMap = new HashMap<>(); toscaNodeMap.put(artifact.getKind(),toscaNodeType); toscaTemplate.setNode_types(toscaNodeMap); }
String version = nodeType.getVersion(); Log.info("ReadArtifact for "+ kind + " with version "+version); propertyDefinitionObj.setKind(kind); Map<String, org.openecomp.sdc.tosca.datatypes.model.PropertyDefinition> propertyDefinitionFromTOSCA = nodeType.getProperties(); if(null != propertyDefinitionFromTOSCA){ for (String propertyName : propertyDefinitionFromTOSCA.keySet()) {
private void addProperty(NodeType toscaNodeType, Parameter pdParameter) throws ArtifactProcessorException { if(!StringUtils.isBlank(pdParameter.getName())&& !pdParameter.getName().matches(".*\\s+.*")) { Log.info("Adding parameter " + pdParameter.getName() + " in node type"); org.openecomp.sdc.tosca.datatypes.model.PropertyDefinition toscaProperty = new org.openecomp.sdc.tosca.datatypes.model.PropertyDefinition(); toscaProperty.setType(StringUtils.isBlank(pdParameter.getType()) ? "string" : pdParameter.getType()); toscaProperty.set_default(pdParameter.getDefaultValue()); toscaProperty.setDescription(pdParameter.getDescription()); toscaProperty.setRequired(pdParameter.isRequired()); toscaNodeType.getProperties().put(pdParameter.getName(), toscaProperty); } else { String message ="Parameter name is empty,null or contains whitespace"; Log.error(message); throw new ArtifactProcessorException(message); } }
String version = nodeType.getVersion(); Log.info("ReadArtifact for " + kind + " with version " + version); propertyDefinitionObj.setKind(kind); nodeType.getProperties(); if (null != propertyDefinitionFromTOSCA) { for (String propertyName : propertyDefinitionFromTOSCA.keySet()) {
private void addProperty(NodeType toscaNodeType, Parameter pdParameter) throws ArtifactProcessorException { if (!StringUtils.isBlank(pdParameter.getName()) && !pdParameter.getName().matches(".*\\s+.*")) { Log.info("Adding parameter " + pdParameter.getName() + " in node type"); org.openecomp.sdc.tosca.datatypes.model.PropertyDefinition toscaProperty = new org.openecomp.sdc.tosca.datatypes.model.PropertyDefinition(); toscaProperty.setType( StringUtils.isBlank(pdParameter.getType()) ? "string" : pdParameter.getType()); toscaProperty.set_default(pdParameter.getDefaultValue()); toscaProperty.setDescription(pdParameter.getDescription()); toscaProperty.setRequired(pdParameter.isRequired()); toscaNodeType.getProperties().put(pdParameter.getName(), toscaProperty); } else { String message = "Parameter name is empty,null or contains whitespace"; Log.error(message); throw new ArtifactProcessorException(message); } }
private void addNodeType(PropertyDefinition artifact, ServiceTemplate toscaTemplate) throws ArtifactProcessorException { // Add basic fields for the node NodeType toscaNodeType = new NodeType(); toscaNodeType.setDerived_from(DERIVEDFROM); toscaNodeType.setVersion(artifact.getVersion()); toscaNodeType.setDescription(""); if (artifact.getParameters() != null) { Map<String, org.openecomp.sdc.tosca.datatypes.model.PropertyDefinition> toscaPropertyMap = new HashMap<>(); toscaNodeType.setProperties(toscaPropertyMap); // Add properties from parameters of PD for (Parameter pdParameter : artifact.getParameters()) { addProperty(toscaNodeType, pdParameter); } } // This is where it adds node in node Map and adds the map in tosca template Map<String, NodeType> toscaNodeMap = new HashMap<>(); toscaNodeMap.put(artifact.getKind(), toscaNodeType); toscaTemplate.setNode_types(toscaNodeMap); }