aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core
diff options
context:
space:
mode:
authorvasraz <vasyl.razinkov@est.tech>2021-03-22 15:33:06 +0000
committerChristophe Closset <christophe.closset@intl.att.com>2021-03-24 06:59:47 +0000
commitd378c37fbd1ecec7b43394926f1ca32a695e07de (patch)
tree5c8a085f8732f980d871d966ac49361644efa698 /openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core
parenta6ae7294ecd336d7e88f915710b08e2658eaee00 (diff)
Reformat openecomp-be
Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech> Issue-ID: SDC-3449 Change-Id: I13e02322f8e00820cc5a1d85752caaeda9bf10d1
Diffstat (limited to 'openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core')
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/AbstractPnfdTransformationEngine.java16
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/PnfdNodeTemplateTransformationEngine.java65
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/PnfdNodeTypeTransformationEngine.java14
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/PnfdQueryExecutor.java43
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/PnfdTransformationDescriptorReader.java24
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/factory/PnfdBlockParserFactory.java6
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/AbstractPnfdBlockParser.java83
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/ConversionDefinitionYamlParser.java17
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/ConversionQueryYamlParser.java9
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/NodeTemplateYamlParser.java10
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/NodeTypeYamlParser.java19
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/ParameterDefinitionYamlParser.java9
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/PnfdConversionStrategyYamlParser.java28
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/PnfdCustomNodeTypeBlockParser.java22
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/PnfdInputBlockParser.java12
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/PnfdNodeTemplateBlockParser.java18
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/PnfdNodeTypeBlockParser.java22
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/TransformationYamlParser.java53
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/strategy/CopyConversionStrategy.java3
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/strategy/ReplaceConversionStrategy.java4
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/strategy/ReplaceInListConversionStrategy.java16
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/AbstractToscaConverter.java97
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/AbstractToscaSolConverter.java19
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/GlobalSubstitutionServiceTemplate.java53
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/InvalidToscaDefinitionImportException.java7
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaConverterImpl.java77
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaConverterUtil.java79
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaDefinitionImportHandler.java94
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaSolConverterVnf.java2
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaSolModelDrivenConverterPnf.java16
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/VnfTopologyTemplateConverter.java87
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/factory/ToscaConverterFactoryImpl.java14
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/services/ServiceTemplateReaderServiceImpl.java9
33 files changed, 375 insertions, 672 deletions
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/AbstractPnfdTransformationEngine.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/AbstractPnfdTransformationEngine.java
index 2391ed6ecc..f97b1d37b2 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/AbstractPnfdTransformationEngine.java
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/AbstractPnfdTransformationEngine.java
@@ -16,7 +16,6 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.core.converter.impl.pnfd;
import java.io.IOException;
@@ -38,23 +37,19 @@ import org.openecomp.sdc.logging.api.LoggerFactory;
public abstract class AbstractPnfdTransformationEngine implements PnfdTransformationEngine {
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractPnfdTransformationEngine.class);
-
protected final ServiceTemplate templateTo;
protected final ServiceTemplateReaderService templateFrom;
- private final PnfdTransformationDescriptorReader pnfdTransformationDescriptorReader =
- new PnfdTransformationDescriptorReader();
+ private final PnfdTransformationDescriptorReader pnfdTransformationDescriptorReader = new PnfdTransformationDescriptorReader();
+ private final String descriptorResourcePath;
protected TransformationDescription transformationDescription;
protected Map<TransformationBlock, List<Transformation>> transformationGroupByBlockMap;
- private final String descriptorResourcePath;
- public AbstractPnfdTransformationEngine(final ServiceTemplateReaderService templateFrom,
- final ServiceTemplate templateTo) {
+ public AbstractPnfdTransformationEngine(final ServiceTemplateReaderService templateFrom, final ServiceTemplate templateTo) {
this(templateFrom, templateTo, "pnfdTransformationTemplate/model-driven-conversion.yaml");
}
//used for tests purposes
- AbstractPnfdTransformationEngine(final ServiceTemplateReaderService templateFrom,
- final ServiceTemplate templateTo,
+ AbstractPnfdTransformationEngine(final ServiceTemplateReaderService templateFrom, final ServiceTemplate templateTo,
final String descriptorResourcePath) {
this.templateFrom = templateFrom;
this.templateTo = templateTo;
@@ -66,7 +61,7 @@ public abstract class AbstractPnfdTransformationEngine implements PnfdTransforma
*/
protected void readDefinition() {
try (final InputStream resourceAsStream = getClass().getClassLoader().getResourceAsStream(descriptorResourcePath)) {
- if (resourceAsStream == null) {
+ if (resourceAsStream == null) {
if (LOGGER.isErrorEnabled()) {
LOGGER.error("Could not find resource '{}'", descriptorResourcePath);
}
@@ -82,5 +77,4 @@ public abstract class AbstractPnfdTransformationEngine implements PnfdTransforma
* Executes all transformations specified in the descriptor.
*/
protected abstract void executeTransformations();
-
}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/PnfdNodeTemplateTransformationEngine.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/PnfdNodeTemplateTransformationEngine.java
index 3c996462fe..8ce29b8d6e 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/PnfdNodeTemplateTransformationEngine.java
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/PnfdNodeTemplateTransformationEngine.java
@@ -16,7 +16,6 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.core.converter.impl.pnfd;
import java.util.Collections;
@@ -40,15 +39,13 @@ import org.openecomp.core.converter.pnfd.model.TransformationBlock;
*/
public class PnfdNodeTemplateTransformationEngine extends AbstractPnfdTransformationEngine {
- public PnfdNodeTemplateTransformationEngine(final ServiceTemplateReaderService templateFrom,
- final ServiceTemplate templateTo) {
+ public PnfdNodeTemplateTransformationEngine(final ServiceTemplateReaderService templateFrom, final ServiceTemplate templateTo) {
super(templateFrom, templateTo);
}
//used for tests purposes
- PnfdNodeTemplateTransformationEngine(final ServiceTemplateReaderService templateFrom,
- final ServiceTemplate templateTo,
- final String descriptorResourcePath) {
+ PnfdNodeTemplateTransformationEngine(final ServiceTemplateReaderService templateFrom, final ServiceTemplate templateTo,
+ final String descriptorResourcePath) {
super(templateFrom, templateTo, descriptorResourcePath);
}
@@ -75,7 +72,6 @@ public class PnfdNodeTemplateTransformationEngine extends AbstractPnfdTransforma
}
}
-
/**
* Execute all transformations specified in the descriptor.
*/
@@ -88,8 +84,7 @@ public class PnfdNodeTemplateTransformationEngine extends AbstractPnfdTransforma
if (CollectionUtils.isEmpty(transformationSet)) {
return;
}
- transformationGroupByBlockMap = transformationSet.stream()
- .filter(Transformation::isValid)
+ transformationGroupByBlockMap = transformationSet.stream().filter(Transformation::isValid)
.collect(Collectors.groupingBy(Transformation::getBlock));
executeCustomTypeTransformations();
final Map<String, String> inputsToConvertMap = executeNodeTemplateTransformations();
@@ -98,56 +93,45 @@ public class PnfdNodeTemplateTransformationEngine extends AbstractPnfdTransforma
/**
* Parses all topology_template node_template.
- * @return
- * A map containing any input that was called with a get_input TOSCA function and its getInputFunction
- * transformation name
+ *
+ * @return A map containing any input that was called with a get_input TOSCA function and its getInputFunction transformation name
*/
private Map<String, String> executeNodeTemplateTransformations() {
- final List<Transformation> transformationList = transformationGroupByBlockMap
- .get(TransformationBlock.NODE_TEMPLATE);
+ final List<Transformation> transformationList = transformationGroupByBlockMap.get(TransformationBlock.NODE_TEMPLATE);
if (CollectionUtils.isEmpty(transformationList)) {
return Collections.emptyMap();
}
-
final Map<String, String> inputsToConvertMap = new HashMap<>();
- transformationList.forEach(transformation ->
- PnfdBlockParserFactory.getInstance().get(transformation).ifPresent(pnfParser -> {
- pnfParser.parse(templateFrom, templateTo);
- if (pnfParser.getInputAndTransformationNameMap().isPresent()) {
- inputsToConvertMap.putAll(pnfParser.getInputAndTransformationNameMap().get());
- }
- }));
+ transformationList.forEach(transformation -> PnfdBlockParserFactory.getInstance().get(transformation).ifPresent(pnfParser -> {
+ pnfParser.parse(templateFrom, templateTo);
+ if (pnfParser.getInputAndTransformationNameMap().isPresent()) {
+ inputsToConvertMap.putAll(pnfParser.getInputAndTransformationNameMap().get());
+ }
+ }));
return inputsToConvertMap;
}
/**
* Parses all topology_template inputs called with a get_input TOSCA function.
- * @param inputsToConvertMap A map containing the topology_template input name and its conversion definition name
+ *
+ * @param inputsToConvertMap A map containing the topology_template input name and its conversion definition name
*/
private void executeGetInputFunctionTransformations(final Map<String, String> inputsToConvertMap) {
- final List<Transformation> transformationListOfGetInputFunction = transformationGroupByBlockMap
- .get(TransformationBlock.GET_INPUT_FUNCTION);
-
- if(MapUtils.isEmpty(inputsToConvertMap) || CollectionUtils.isEmpty(transformationListOfGetInputFunction)) {
+ final List<Transformation> transformationListOfGetInputFunction = transformationGroupByBlockMap.get(TransformationBlock.GET_INPUT_FUNCTION);
+ if (MapUtils.isEmpty(inputsToConvertMap) || CollectionUtils.isEmpty(transformationListOfGetInputFunction)) {
return;
}
-
final Map<String, List<Transformation>> transformationByName = transformationListOfGetInputFunction.stream()
.collect(Collectors.groupingBy(Transformation::getName));
-
inputsToConvertMap.forEach((inputName, transformationName) -> {
final List<Transformation> transformationList = transformationByName.get(transformationName);
if (!CollectionUtils.isEmpty(transformationList)) {
- final Transformation transformation = transformationList.stream()
- .findFirst().orElse(null);
+ final Transformation transformation = transformationList.stream().findFirst().orElse(null);
if (transformation != null) {
final Map<String, Object> conversionQueryMap = new HashMap<>();
conversionQueryMap.put(inputName, null);
- transformation.setConversionQuery(
- ConversionQueryYamlParser.parse(conversionQueryMap).orElse(null)
- );
- PnfdBlockParserFactory.getInstance().get(transformation)
- .ifPresent(pnfParser -> pnfParser.parse(templateFrom, templateTo));
+ transformation.setConversionQuery(ConversionQueryYamlParser.parse(conversionQueryMap).orElse(null));
+ PnfdBlockParserFactory.getInstance().get(transformation).ifPresent(pnfParser -> pnfParser.parse(templateFrom, templateTo));
}
}
});
@@ -157,14 +141,11 @@ public class PnfdNodeTemplateTransformationEngine extends AbstractPnfdTransforma
* Parses a Customized Node Type that extend from a valid ONAP NodeType.
*/
private void executeCustomTypeTransformations() {
- final List<Transformation> transformationList = transformationGroupByBlockMap
- .get((TransformationBlock.CUSTOM_NODE_TYPE));
+ final List<Transformation> transformationList = transformationGroupByBlockMap.get((TransformationBlock.CUSTOM_NODE_TYPE));
if (CollectionUtils.isEmpty(transformationList)) {
return;
}
- transformationList.forEach(transformation ->
- PnfdBlockParserFactory.getInstance().get(transformation).ifPresent(pnfdBlockParser ->
- pnfdBlockParser.parse(templateFrom, templateTo)));
+ transformationList.forEach(transformation -> PnfdBlockParserFactory.getInstance().get(transformation)
+ .ifPresent(pnfdBlockParser -> pnfdBlockParser.parse(templateFrom, templateTo)));
}
-
}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/PnfdNodeTypeTransformationEngine.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/PnfdNodeTypeTransformationEngine.java
index 48d06b67a4..3e6cca4609 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/PnfdNodeTypeTransformationEngine.java
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/PnfdNodeTypeTransformationEngine.java
@@ -16,7 +16,6 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.core.converter.impl.pnfd;
import java.util.Set;
@@ -33,8 +32,7 @@ import org.openecomp.core.converter.pnfd.model.TransformationBlock;
*/
public class PnfdNodeTypeTransformationEngine extends AbstractPnfdTransformationEngine {
- public PnfdNodeTypeTransformationEngine(final ServiceTemplateReaderService templateFrom,
- final ServiceTemplate templateTo) {
+ public PnfdNodeTypeTransformationEngine(final ServiceTemplateReaderService templateFrom, final ServiceTemplate templateTo) {
super(templateFrom, templateTo);
}
@@ -57,16 +55,12 @@ public class PnfdNodeTypeTransformationEngine extends AbstractPnfdTransformation
return;
}
final Set<Transformation> validNodeTypeTransformationSet = transformationSet.stream()
- .filter(transformation -> transformation.getBlock() == TransformationBlock.NODE_TYPE)
- .filter(Transformation::isValid)
+ .filter(transformation -> transformation.getBlock() == TransformationBlock.NODE_TYPE).filter(Transformation::isValid)
.collect(Collectors.toSet());
-
if (CollectionUtils.isEmpty(validNodeTypeTransformationSet)) {
return;
}
- validNodeTypeTransformationSet.forEach(transformation ->
- PnfdBlockParserFactory.getInstance().get(transformation).ifPresent(pnfdBlockParser ->
- pnfdBlockParser.parse(templateFrom, templateTo)));
+ validNodeTypeTransformationSet.forEach(transformation -> PnfdBlockParserFactory.getInstance().get(transformation)
+ .ifPresent(pnfdBlockParser -> pnfdBlockParser.parse(templateFrom, templateTo)));
}
-
}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/PnfdQueryExecutor.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/PnfdQueryExecutor.java
index 890dedb2a7..375dd2aa1a 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/PnfdQueryExecutor.java
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/PnfdQueryExecutor.java
@@ -16,7 +16,6 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.core.converter.impl.pnfd;
import java.util.List;
@@ -33,36 +32,32 @@ import org.openecomp.core.converter.pnfd.model.ConversionQuery;
public class PnfdQueryExecutor {
private PnfdQueryExecutor() {
-
}
/**
* Finds if a YAML object contains the provided YAML query.
- * @param conversionQuery The query
- * @param yamlObject The YAML object to be searched
- * @return
- * {@code true} if the YAML query structure was found in the YAML object, {@code false} otherwise.
+ *
+ * @param conversionQuery The query
+ * @param yamlObject The YAML object to be searched
+ * @return {@code true} if the YAML query structure was found in the YAML object, {@code false} otherwise.
*/
public static boolean find(final ConversionQuery conversionQuery, final Object yamlObject) {
return find(conversionQuery.getQuery(), yamlObject);
}
/**
- * Recursive structure combined with {@link #findMap(Map, Map)} to find if a YAML object contains the provided YAML query.
- * Compares the objects if it's a scalar value, otherwise go further in the YAML hierarchical structure
- * calling the {@link #findMap(Map, Map)}.
- * @param query The current query
- * @param yamlObject The current YAML object to be searched
- * @return
- * {@code true} if the YAML query structure was found in the YAML object, {@code false} otherwise.
+ * Recursive structure combined with {@link #findMap(Map, Map)} to find if a YAML object contains the provided YAML query. Compares the objects if
+ * it's a scalar value, otherwise go further in the YAML hierarchical structure calling the {@link #findMap(Map, Map)}.
+ *
+ * @param query The current query
+ * @param yamlObject The current YAML object to be searched
+ * @return {@code true} if the YAML query structure was found in the YAML object, {@code false} otherwise.
*/
private static boolean find(final Object query, final Object yamlObject) {
if (query == null) {
return true;
}
-
checkSupportedQueryType(query);
-
if (query instanceof String) {
return query.equals(yamlObject);
}
@@ -74,20 +69,18 @@ public class PnfdQueryExecutor {
/**
* Recursive structure combined with {@link #find(Object, Object)} to find if a YAML object contains the provided YAML query. *
- * @param query The query current object
- * @param yamlObject The YAML object to be searched
- * @return
- * {@code true} if the YAML query structure was found in the YAML object, {@code false} otherwise.
+ *
+ * @param query The query current object
+ * @param yamlObject The YAML object to be searched
+ * @return {@code true} if the YAML query structure was found in the YAML object, {@code false} otherwise.
*/
private static boolean findMap(final Map query, final Map yamlObject) {
if (MapUtils.isEmpty(query) || MapUtils.isEmpty(yamlObject)) {
return false;
}
-
if (!yamlObject.keySet().containsAll(query.keySet())) {
return false;
}
-
return query.entrySet().parallelStream().allMatch(queryEntryObj -> {
final Entry queryEntry = (Entry) queryEntryObj;
return find(queryEntry.getValue(), yamlObject.get(queryEntry.getKey()));
@@ -96,7 +89,8 @@ public class PnfdQueryExecutor {
/**
* Checks the supported types for a query.
- * @param query the query to check
+ *
+ * @param query the query to check
*/
private static void checkSupportedQueryType(final Object query) {
if (query instanceof String || query instanceof Map) {
@@ -105,9 +99,6 @@ public class PnfdQueryExecutor {
if (query instanceof List || query instanceof Set) {
throw new QueryOperationNotSupportedException("Yaml list query is not supported yet");
}
- throw new QueryOperationNotSupportedException(
- String.format("Yaml query operation for '%s' is not supported yet", query.getClass())
- );
+ throw new QueryOperationNotSupportedException(String.format("Yaml query operation for '%s' is not supported yet", query.getClass()));
}
-
}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/PnfdTransformationDescriptorReader.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/PnfdTransformationDescriptorReader.java
index d040c93d09..a4dcc8a27a 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/PnfdTransformationDescriptorReader.java
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/PnfdTransformationDescriptorReader.java
@@ -16,7 +16,6 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.core.converter.impl.pnfd;
import java.io.FileNotFoundException;
@@ -45,20 +44,19 @@ public class PnfdTransformationDescriptorReader {
/**
* Parse the transformation description to {@link TransformationDescription} class.
- * @return
- * The {@link TransformationDescription} instance.
+ *
+ * @return The {@link TransformationDescription} instance.
*/
public TransformationDescription parse(final InputStream transformationDescriptionInputStream) {
final List<Object> transformationList = readDescriptionYaml(transformationDescriptionInputStream);
final Set<Transformation> transformationSet = parseTransformationList(transformationList);
-
return new TransformationDescription(transformationSet);
}
/**
* Reads the description file that has the required YAML format.
- * @return
- * The yaml parsed to Object
+ *
+ * @return The yaml parsed to Object
*/
private List<Object> readDescriptionYaml(final InputStream transformationDescriptionPath) {
try (final InputStream fileInputStream = transformationDescriptionPath) {
@@ -73,19 +71,15 @@ public class PnfdTransformationDescriptorReader {
/**
* Parse the transformation list represented in a YAML object to {@link Transformation}.
- * @param transformationYamlList the YAML object read from the transformation description file
- * @return
- * The set of transformations represented as {@link Transformation} class
+ *
+ * @param transformationYamlList the YAML object read from the transformation description file
+ * @return The set of transformations represented as {@link Transformation} class
*/
private Set<Transformation> parseTransformationList(final List<Object> transformationYamlList) {
if (CollectionUtils.isEmpty(transformationYamlList)) {
return Collections.emptySet();
}
-
- return transformationYamlList.stream()
- .map(conversionMap -> TransformationYamlParser.parse((Map<String, Object>) conversionMap).orElse(null))
- .filter(Objects::nonNull)
- .collect(Collectors.toSet());
+ return transformationYamlList.stream().map(conversionMap -> TransformationYamlParser.parse((Map<String, Object>) conversionMap).orElse(null))
+ .filter(Objects::nonNull).collect(Collectors.toSet());
}
-
}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/factory/PnfdBlockParserFactory.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/factory/PnfdBlockParserFactory.java
index 12dd790c9d..0b3c5c944e 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/factory/PnfdBlockParserFactory.java
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/factory/PnfdBlockParserFactory.java
@@ -16,13 +16,12 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.core.converter.impl.pnfd.factory;
import java.util.Optional;
+import org.openecomp.core.converter.impl.pnfd.parser.PnfdCustomNodeTypeBlockParser;
import org.openecomp.core.converter.impl.pnfd.parser.PnfdInputBlockParser;
import org.openecomp.core.converter.impl.pnfd.parser.PnfdNodeTemplateBlockParser;
-import org.openecomp.core.converter.impl.pnfd.parser.PnfdCustomNodeTypeBlockParser;
import org.openecomp.core.converter.impl.pnfd.parser.PnfdNodeTypeBlockParser;
import org.openecomp.core.converter.pnfd.model.Transformation;
import org.openecomp.core.converter.pnfd.parser.PnfdBlockParser;
@@ -31,6 +30,7 @@ import org.openecomp.core.converter.pnfd.parser.PnfdBlockParser;
* Factory for {@link PnfdBlockParser}.
*/
public class PnfdBlockParserFactory {
+
private static PnfdBlockParserFactory instance;
private PnfdBlockParserFactory() {
@@ -40,7 +40,6 @@ public class PnfdBlockParserFactory {
if (instance == null) {
instance = new PnfdBlockParserFactory();
}
-
return instance;
}
@@ -59,5 +58,4 @@ public class PnfdBlockParserFactory {
return Optional.empty();
}
}
-
}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/AbstractPnfdBlockParser.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/AbstractPnfdBlockParser.java
index 056d07aed0..fcf6ec8735 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/AbstractPnfdBlockParser.java
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/AbstractPnfdBlockParser.java
@@ -16,7 +16,6 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.core.converter.impl.pnfd.parser;
import com.google.common.collect.ImmutableMap;
@@ -48,11 +47,10 @@ public abstract class AbstractPnfdBlockParser implements PnfdBlockParser {
}
/**
- * Parses a PNFD block based on the {@link Transformation} provided during the {@link PnfdBlockParser}
- * instantiation.
+ * Parses a PNFD block based on the {@link Transformation} provided during the {@link PnfdBlockParser} instantiation.
*
* @param templateFrom the original PNFD template
- * @param templateTo the resulting PNFD template
+ * @param templateTo the resulting PNFD template
*/
public void parse(final ServiceTemplateReaderService templateFrom, final ServiceTemplate templateTo) {
this.templateFrom = templateFrom;
@@ -64,8 +62,7 @@ public abstract class AbstractPnfdBlockParser implements PnfdBlockParser {
}
/**
- * Applies all specified conversions in {@link Transformation#getConversionDefinitionList()} for the given
- * blockYamlObject.
+ * Applies all specified conversions in {@link Transformation#getConversionDefinitionList()} for the given blockYamlObject.
*
* @param blockYamlObject the block content as a YAML object
*/
@@ -76,37 +73,31 @@ public abstract class AbstractPnfdBlockParser implements PnfdBlockParser {
final List<ConversionDefinition> conversionDefinitionList = transformation.getConversionDefinitionList();
final Map<String, Object> parsedBlockYamlObject = new HashMap<>();
final String blockName = blockYamlObject.keySet().iterator().next();
- conversionDefinitionList.stream()
- .filter(conversionDefinition -> conversionDefinition.getConversionQuery().isValidAttributeQuery())
+ conversionDefinitionList.stream().filter(conversionDefinition -> conversionDefinition.getConversionQuery().isValidAttributeQuery())
.forEach(conversionDefinition -> {
- final Map<String, Object> query =
- (Map<String, Object>) conversionDefinition.getConversionQuery().getQuery();
+ final Map<String, Object> query = (Map<String, Object>) conversionDefinition.getConversionQuery().getQuery();
final Map<String, Object> blockAttributeMap = (Map<String, Object>) blockYamlObject.get(blockName);
- final Optional<Map<String, Object>> parsedBlockAttributeMap = buildParsedBlock(query, blockAttributeMap
- , conversionDefinition);
- parsedBlockAttributeMap.ifPresent(convertedNodeTemplateAttributeMap1 ->
- mergeYamlObjects(parsedBlockYamlObject, convertedNodeTemplateAttributeMap1)
- );
+ final Optional<Map<String, Object>> parsedBlockAttributeMap = buildParsedBlock(query, blockAttributeMap, conversionDefinition);
+ parsedBlockAttributeMap
+ .ifPresent(convertedNodeTemplateAttributeMap1 -> mergeYamlObjects(parsedBlockYamlObject, convertedNodeTemplateAttributeMap1));
});
-
write(blockName, parsedBlockYamlObject);
}
/**
* Writes the block in the resulting {@link ServiceTemplate} {@link #templateTo}.
*
- * @param blockName the name of the block
+ * @param blockName the name of the block
* @param parsedBlockYamlObject the block content as a YAML object
*/
protected abstract void write(final String blockName, final Map<String, Object> parsedBlockYamlObject);
/**
- * Uses the provided attribute query to find a attribute in the original YAML object and apply the provided
- * conversion.
+ * Uses the provided attribute query to find a attribute in the original YAML object and apply the provided conversion.
*
- * @param attributeQuery the attribute query
+ * @param attributeQuery the attribute query
* @param fromNodeTemplateAttributeMap the original YAML object
- * @param conversionDefinition the conversion
+ * @param conversionDefinition the conversion
* @return the rebuilt original YAML object with the converted attribute
*/
protected abstract Optional<Map<String, Object>> buildParsedBlock(final Map<String, Object> attributeQuery,
@@ -116,28 +107,22 @@ public abstract class AbstractPnfdBlockParser implements PnfdBlockParser {
/**
* Merges two YAML objects.
*
- * @param originalMap original YAML object
+ * @param originalMap original YAML object
* @param toBeMergedMap YAML object to be merged
* @return the new YAML object representing the merge result.
*/
- protected Map<String, Object> mergeYamlObjects(final Map<String, Object> originalMap,
- final Map<String, Object> toBeMergedMap) {
- toBeMergedMap.forEach(
- (key, value) -> originalMap.merge(key, value,
- (toBeMergedValue, originalValue) -> {
- if (originalValue instanceof Map) {
- return mergeYamlObjects((Map) originalValue, (Map) toBeMergedValue);
- }
- return originalValue;
- })
- );
-
+ protected Map<String, Object> mergeYamlObjects(final Map<String, Object> originalMap, final Map<String, Object> toBeMergedMap) {
+ toBeMergedMap.forEach((key, value) -> originalMap.merge(key, value, (toBeMergedValue, originalValue) -> {
+ if (originalValue instanceof Map) {
+ return mergeYamlObjects((Map) originalValue, (Map) toBeMergedValue);
+ }
+ return originalValue;
+ }));
return originalMap;
}
/**
- * Executes the provided {@link #transformation getConversionQuery} YAML query to find the blocks to be parsed in
- * {@link #templateFrom}.
+ * Executes the provided {@link #transformation getConversionQuery} YAML query to find the blocks to be parsed in {@link #templateFrom}.
*
* @return The YAML blocks found
*/
@@ -154,12 +139,12 @@ public abstract class AbstractPnfdBlockParser implements PnfdBlockParser {
final Map<String, Object> yamlMap = (Map<String, Object>) yamlObject;
return yamlMap.containsKey(PnfTransformationToken.GET_INPUT.getName());
}
-
return false;
}
/**
* Extracts the value from an YAML Object.
+ *
* @param yamlObject
* @return The Object value from the yamlObject parameter.
*/
@@ -168,7 +153,6 @@ public abstract class AbstractPnfdBlockParser implements PnfdBlockParser {
final Map<String, Object> yamlMap = (Map<String, Object>) yamlObject;
return (String) yamlMap.values().stream().findFirst().orElse(null);
}
-
return null;
}
@@ -183,18 +167,15 @@ public abstract class AbstractPnfdBlockParser implements PnfdBlockParser {
/**
* Finds all the derived node types from the provided node types.
*
- * @param rootNodeTypeMap a map with the root node types to find the derived ones
+ * @param rootNodeTypeMap a map with the root node types to find the derived ones
* @param derivedNodeTypeMap a map that will be filled with the derived node types
*/
- private void findAllDerivedNodeType(final Map<String, Object> rootNodeTypeMap,
- final Map<String, Object> derivedNodeTypeMap) {
- templateFrom.getNodeTypes().entrySet().stream()
- .filter(nodeEntry -> rootNodeTypeMap.containsKey(extractObjectValue(nodeEntry.getValue())))
+ private void findAllDerivedNodeType(final Map<String, Object> rootNodeTypeMap, final Map<String, Object> derivedNodeTypeMap) {
+ templateFrom.getNodeTypes().entrySet().stream().filter(nodeEntry -> rootNodeTypeMap.containsKey(extractObjectValue(nodeEntry.getValue())))
.forEach(nodeEntry -> {
if (!derivedNodeTypeMap.containsKey(nodeEntry.getKey())) {
derivedNodeTypeMap.put(nodeEntry.getKey(), nodeEntry.getValue());
- final ImmutableMap<String, Object> newRootNodeTypeMap = ImmutableMap
- .of(nodeEntry.getKey(), nodeEntry.getValue());
+ final ImmutableMap<String, Object> newRootNodeTypeMap = ImmutableMap.of(nodeEntry.getKey(), nodeEntry.getValue());
findAllDerivedNodeType(newRootNodeTypeMap, derivedNodeTypeMap);
}
});
@@ -202,6 +183,7 @@ public abstract class AbstractPnfdBlockParser implements PnfdBlockParser {
/**
* Fetches all Custom NodeTypes based on the query result.
+ *
* @return a map with all custom Node Types that matches with the query result.
*/
protected Map<String, Object> fetchCustomNodeType() {
@@ -211,16 +193,13 @@ public abstract class AbstractPnfdBlockParser implements PnfdBlockParser {
}
final ConversionQuery conversionQuery = transformation.getConversionQuery();
final Map<String, Object> customNodeTypesMap = new HashMap<>();
- nodeTypesMap.entrySet().stream()
- .filter(nodeEntry -> PnfdQueryExecutor.find(conversionQuery, nodeEntry.getValue()))
- .forEach(customNode -> {
- attributeValueToBeConverted = extractObjectValue(customNode.getValue());
- customNodeTypesMap.put(customNode.getKey(), customNode.getValue());
- });
+ nodeTypesMap.entrySet().stream().filter(nodeEntry -> PnfdQueryExecutor.find(conversionQuery, nodeEntry.getValue())).forEach(customNode -> {
+ attributeValueToBeConverted = extractObjectValue(customNode.getValue());
+ customNodeTypesMap.put(customNode.getKey(), customNode.getValue());
+ });
final Map<String, Object> childNodeTypeMap = new HashMap<>();
findAllDerivedNodeType(customNodeTypesMap, childNodeTypeMap);
customNodeTypesMap.putAll(childNodeTypeMap);
return customNodeTypesMap;
}
-
}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/ConversionDefinitionYamlParser.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/ConversionDefinitionYamlParser.java
index 2ea9f2dc93..28d066d972 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/ConversionDefinitionYamlParser.java
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/ConversionDefinitionYamlParser.java
@@ -16,7 +16,6 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.core.converter.impl.pnfd.parser;
import java.util.Map;
@@ -36,29 +35,25 @@ public class ConversionDefinitionYamlParser {
private static final Logger LOGGER = LoggerFactory.getLogger(ConversionDefinitionYamlParser.class);
private ConversionDefinitionYamlParser() {
-
}
/**
* Parses the given a YAML object to a {@link ConversionDefinition} instance.
- * @param conversionYaml the YAML object representing a conversion definition
- * @return
- * A new instance of {@link ConversionDefinition}.
+ *
+ * @param conversionYaml the YAML object representing a conversion definition
+ * @return A new instance of {@link ConversionDefinition}.
*/
public static Optional<ConversionDefinition> parse(final Map<String, Object> conversionYaml) {
- final ConversionQuery conversionQuery = ConversionQueryYamlParser
- .parse(conversionYaml.get(PnfTransformationToken.QUERY.getName())).orElse(null);
+ final ConversionQuery conversionQuery = ConversionQueryYamlParser.parse(conversionYaml.get(PnfTransformationToken.QUERY.getName()))
+ .orElse(null);
if (conversionQuery == null) {
LOGGER.warn("Invalid '{}' for '{}'", PnfTransformationToken.QUERY.getName(), conversionYaml.toString());
return Optional.empty();
}
final String toName = (String) conversionYaml.get(PnfTransformationToken.TO_NAME.getName());
final PnfdConversionStrategy toValue = PnfdConversionStrategyYamlParser
- .parse((Map<String, Object>) conversionYaml.get(PnfTransformationToken.TO_VALUE.getName()))
- .orElse(null);
+ .parse((Map<String, Object>) conversionYaml.get(PnfTransformationToken.TO_VALUE.getName())).orElse(null);
final String toGetInput = (String) conversionYaml.get(PnfTransformationToken.TO_GET_INPUT.getName());
-
return Optional.of(new ConversionDefinition(conversionQuery, toName, toValue, toGetInput));
}
-
}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/ConversionQueryYamlParser.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/ConversionQueryYamlParser.java
index 374bf3702f..451498228c 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/ConversionQueryYamlParser.java
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/ConversionQueryYamlParser.java
@@ -16,7 +16,6 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.core.converter.impl.pnfd.parser;
import java.util.Optional;
@@ -28,20 +27,18 @@ import org.openecomp.core.converter.pnfd.model.ConversionQuery;
public class ConversionQueryYamlParser {
private ConversionQueryYamlParser() {
-
}
/**
* Parses the given a YAML object to a {@link ConversionQuery} instance.
- * @param conversionYaml the YAML object representing a conversion query
- * @return
- * A new instance of {@link ConversionQuery}.
+ *
+ * @param conversionYaml the YAML object representing a conversion query
+ * @return A new instance of {@link ConversionQuery}.
*/
public static Optional<ConversionQuery> parse(final Object conversionYaml) {
if (conversionYaml == null) {
return Optional.empty();
}
-
return Optional.of(new ConversionQuery(conversionYaml));
}
}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/NodeTemplateYamlParser.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/NodeTemplateYamlParser.java
index fdf276f37d..354256e57f 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/NodeTemplateYamlParser.java
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/NodeTemplateYamlParser.java
@@ -16,7 +16,6 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.core.converter.impl.pnfd.parser;
import java.util.List;
@@ -33,9 +32,9 @@ public class NodeTemplateYamlParser {
/**
* Parses the given a YAML object to a {@link NodeTemplate} instance.
- * @param nodeTemplateYaml the YAML object representing a TOSCA Node Template
- * @return
- * A new instance of {@link NodeTemplate}.
+ *
+ * @param nodeTemplateYaml the YAML object representing a TOSCA Node Template
+ * @return A new instance of {@link NodeTemplate}.
*/
public static NodeTemplate parse(final Map<String, Object> nodeTemplateYaml) {
final NodeTemplate nodeTemplate = new NodeTemplate();
@@ -47,9 +46,6 @@ public class NodeTemplateYamlParser {
nodeTemplate.setDirectives((List<String>) nodeTemplateYaml.get("directives"));
nodeTemplate.setMetadata((Map<String, String>) nodeTemplateYaml.get("metadata"));
nodeTemplate.setInterfaces((Map<String, Object>) nodeTemplateYaml.get("interfaces"));
-
return nodeTemplate;
}
-
-
}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/NodeTypeYamlParser.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/NodeTypeYamlParser.java
index b0b52e0c40..585d9e1bbf 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/NodeTypeYamlParser.java
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/NodeTypeYamlParser.java
@@ -16,7 +16,6 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.core.converter.impl.pnfd.parser;
import java.util.List;
@@ -39,6 +38,7 @@ public class NodeTypeYamlParser {
/**
* Parses the given a YAML object to a {@link NodeType} instance.
+ *
* @param nodeTypeYaml the YAML object representing a TOSCA Node Type
* @return A new instance of {@link NodeType}.
*/
@@ -48,20 +48,13 @@ public class NodeTypeYamlParser {
nodeType.setDerived_from((String) nodeTypeYaml.get(ToscaTagNamesEnum.DERIVED_FROM.getElementName()));
nodeType.setDescription((String) nodeTypeYaml.get(ToscaTagNamesEnum.DESCRIPTION.getElementName()));
nodeType.setVersion((String) nodeTypeYaml.get("version"));
- nodeType.setProperties(
- (Map<String, PropertyDefinition>) nodeTypeYaml.get(ToscaTagNamesEnum.PROPERTIES.getElementName()));
+ nodeType.setProperties((Map<String, PropertyDefinition>) nodeTypeYaml.get(ToscaTagNamesEnum.PROPERTIES.getElementName()));
nodeType.setArtifacts((Map<String, ArtifactDefinition>) nodeTypeYaml.get("artifacts"));
nodeType.setMetadata((Map<String, String>) nodeTypeYaml.get("metadata"));
- nodeType.setInterfaces(
- (Map<String, Object>) nodeTypeYaml.get(ToscaTagNamesEnum.INTERFACES.getElementName()));
- nodeType.setRequirements(
- (List<Map<String, RequirementDefinition>>) nodeTypeYaml.get(ToscaTagNamesEnum.REQUIREMENTS.getElementName()));
- nodeType.setCapabilities(
- (Map<String, CapabilityDefinition>) nodeTypeYaml.get(ToscaTagNamesEnum.CAPABILITIES.getElementName()));
- nodeType.setAttributes(
- (Map<String, AttributeDefinition>) nodeTypeYaml.get(ToscaTagNamesEnum.ATTRIBUTES.getElementName()));
-
+ nodeType.setInterfaces((Map<String, Object>) nodeTypeYaml.get(ToscaTagNamesEnum.INTERFACES.getElementName()));
+ nodeType.setRequirements((List<Map<String, RequirementDefinition>>) nodeTypeYaml.get(ToscaTagNamesEnum.REQUIREMENTS.getElementName()));
+ nodeType.setCapabilities((Map<String, CapabilityDefinition>) nodeTypeYaml.get(ToscaTagNamesEnum.CAPABILITIES.getElementName()));
+ nodeType.setAttributes((Map<String, AttributeDefinition>) nodeTypeYaml.get(ToscaTagNamesEnum.ATTRIBUTES.getElementName()));
return nodeType;
}
-
}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/ParameterDefinitionYamlParser.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/ParameterDefinitionYamlParser.java
index 4158deb9fe..53b0759a62 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/ParameterDefinitionYamlParser.java
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/ParameterDefinitionYamlParser.java
@@ -16,13 +16,11 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.core.converter.impl.pnfd.parser;
import java.util.Map;
import org.onap.sdc.tosca.datatypes.model.EntrySchema;
import org.onap.sdc.tosca.datatypes.model.ParameterDefinition;
-import org.onap.sdc.tosca.datatypes.model.Status;
/**
* Handles YAML from/to {@link ParameterDefinition} conversions
@@ -34,9 +32,9 @@ public class ParameterDefinitionYamlParser {
/**
* Parses the given a YAML object to a {@link ParameterDefinition} instance.
- * @param parameterDefinitionYaml the YAML object representing a TOSCA Parameter Definition
- * @return
- * A new instance of {@link ParameterDefinition}.
+ *
+ * @param parameterDefinitionYaml the YAML object representing a TOSCA Parameter Definition
+ * @return A new instance of {@link ParameterDefinition}.
*/
public static ParameterDefinition parse(final Map<String, Object> parameterDefinitionYaml) {
final ParameterDefinition parameterDefinition = new ParameterDefinition();
@@ -51,7 +49,6 @@ public class ParameterDefinitionYamlParser {
parameterDefinition.setRequired((Boolean) parameterDefinitionYaml.get("required"));
parameterDefinition.setType((String) parameterDefinitionYaml.get("type"));
parameterDefinition.setStatus((String) parameterDefinitionYaml.get("status"));
-
return parameterDefinition;
}
}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/PnfdConversionStrategyYamlParser.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/PnfdConversionStrategyYamlParser.java
index dee16749ae..d927bc9537 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/PnfdConversionStrategyYamlParser.java
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/PnfdConversionStrategyYamlParser.java
@@ -16,19 +16,17 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.core.converter.impl.pnfd.parser;
import java.util.List;
import java.util.Map;
import java.util.Optional;
-import org.openecomp.core.converter.pnfd.model.ConversionStrategyType;
-import org.openecomp.core.converter.pnfd.model.PnfTransformationToken;
import org.openecomp.core.converter.impl.pnfd.strategy.CopyConversionStrategy;
-import org.openecomp.core.converter.pnfd.strategy.PnfdConversionStrategy;
import org.openecomp.core.converter.impl.pnfd.strategy.ReplaceConversionStrategy;
import org.openecomp.core.converter.impl.pnfd.strategy.ReplaceInListConversionStrategy;
-
+import org.openecomp.core.converter.pnfd.model.ConversionStrategyType;
+import org.openecomp.core.converter.pnfd.model.PnfTransformationToken;
+import org.openecomp.core.converter.pnfd.strategy.PnfdConversionStrategy;
/**
* Handles YAML from/to {@link PnfdConversionStrategy} conversions.
@@ -36,24 +34,20 @@ import org.openecomp.core.converter.impl.pnfd.strategy.ReplaceInListConversionSt
public class PnfdConversionStrategyYamlParser {
private PnfdConversionStrategyYamlParser() {
-
}
/**
* Parses the given YAML object to a {@link PnfdConversionStrategy} instance.
- * @param strategyYaml the YAML object representing a conversion strategy
- * @return
- * A new instance of {@link PnfdConversionStrategy}.
+ *
+ * @param strategyYaml the YAML object representing a conversion strategy
+ * @return A new instance of {@link PnfdConversionStrategy}.
*/
public static Optional<PnfdConversionStrategy> parse(final Map<String, Object> strategyYaml) {
- final Optional<ConversionStrategyType> optionalStrategy = ConversionStrategyType.parse(
- (String) strategyYaml.get(PnfTransformationToken.STRATEGY.getName())
- );
-
+ final Optional<ConversionStrategyType> optionalStrategy = ConversionStrategyType
+ .parse((String) strategyYaml.get(PnfTransformationToken.STRATEGY.getName()));
if (!optionalStrategy.isPresent()) {
return Optional.empty();
}
-
final ConversionStrategyType strategyType = optionalStrategy.get();
if (strategyType == ConversionStrategyType.COPY) {
return Optional.of(new CopyConversionStrategy());
@@ -64,11 +58,9 @@ public class PnfdConversionStrategyYamlParser {
return Optional.of(new ReplaceConversionStrategy(from, to));
}
if (strategyType == ConversionStrategyType.REPLACE_IN_LIST) {
- return Optional.of(new ReplaceInListConversionStrategy(
- (List<Map<String, Object>>) strategyYaml.get(PnfTransformationToken.LIST.getName()))
- );
+ return Optional
+ .of(new ReplaceInListConversionStrategy((List<Map<String, Object>>) strategyYaml.get(PnfTransformationToken.LIST.getName())));
}
return Optional.empty();
}
-
}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/PnfdCustomNodeTypeBlockParser.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/PnfdCustomNodeTypeBlockParser.java
index 3efde199b4..f242e9f1d2 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/PnfdCustomNodeTypeBlockParser.java
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/PnfdCustomNodeTypeBlockParser.java
@@ -16,7 +16,6 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.core.converter.impl.pnfd.parser;
import java.util.Collections;
@@ -45,21 +44,19 @@ public class PnfdCustomNodeTypeBlockParser extends AbstractPnfdBlockParser {
if (customNodeTypeMap.isEmpty() || MapUtils.isEmpty(nodeTemplateMap)) {
return Collections.emptySet();
}
- return customNodeTypeMap.entrySet().stream()
- .map(customNode -> {
- final Map<String, Object> map = new HashMap<>();
- nodeTemplateMap.entrySet().stream()
- .filter(nodeTemplate ->
- extractObjectValue(nodeTemplate.getValue()).equalsIgnoreCase(customNode.getKey()))
- .forEach(nodeType -> map.put(nodeType.getKey(), nodeType.getValue()));
- return map;
- }).collect(Collectors.toSet());
+ return customNodeTypeMap.entrySet().stream().map(customNode -> {
+ final Map<String, Object> map = new HashMap<>();
+ nodeTemplateMap.entrySet().stream()
+ .filter(nodeTemplate -> extractObjectValue(nodeTemplate.getValue()).equalsIgnoreCase(customNode.getKey()))
+ .forEach(nodeType -> map.put(nodeType.getKey(), nodeType.getValue()));
+ return map;
+ }).collect(Collectors.toSet());
}
@Override
protected Optional<Map<String, Object>> buildParsedBlock(final Map<String, Object> attributeQuery,
- final Map<String, Object> fromNodeTemplateAttributeMap,
- final ConversionDefinition conversionDefinition) {
+ final Map<String, Object> fromNodeTemplateAttributeMap,
+ final ConversionDefinition conversionDefinition) {
//cannot query for more than one attribute
if (attributeQuery.keySet().size() > 1) {
return Optional.empty();
@@ -84,5 +81,4 @@ public class PnfdCustomNodeTypeBlockParser extends AbstractPnfdBlockParser {
DataModelUtil.addNodeTemplate(templateTo, nodeTemplateName, parsedNodeTemplate);
}
}
-
}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/PnfdInputBlockParser.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/PnfdInputBlockParser.java
index 4ce7b2e1c7..ddb3fe24fd 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/PnfdInputBlockParser.java
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/PnfdInputBlockParser.java
@@ -16,7 +16,6 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.core.converter.impl.pnfd.parser;
import com.google.common.collect.ImmutableMap;
@@ -42,8 +41,8 @@ public class PnfdInputBlockParser extends AbstractPnfdBlockParser {
}
@Override
- protected Optional<Map<String, Object>> buildParsedBlock(final Map<String, Object> attributeQuery,
- final Map<String, Object> originalAttributeMap, final ConversionDefinition conversionDefinition) {
+ protected Optional<Map<String, Object>> buildParsedBlock(final Map<String, Object> attributeQuery, final Map<String, Object> originalAttributeMap,
+ final ConversionDefinition conversionDefinition) {
//cannot query for more than one attribute
if (attributeQuery.keySet().size() > 1) {
return Optional.empty();
@@ -59,7 +58,6 @@ public class PnfdInputBlockParser extends AbstractPnfdBlockParser {
(Map<String, Object>) originalAttributeMap.get(attribute), conversionDefinition);
builtInput.ifPresent(builtInput1 -> parsedInput.put(attribute, builtInput1));
}
-
return parsedInput.isEmpty() ? Optional.empty() : Optional.of(parsedInput);
}
@@ -78,16 +76,12 @@ public class PnfdInputBlockParser extends AbstractPnfdBlockParser {
if (MapUtils.isEmpty(inputsMap)) {
return Collections.emptySet();
}
-
return inputsMap.entrySet().stream()
- .filter(inputMapEntry -> PnfdQueryExecutor
- .find(conversionQuery, ImmutableMap.of(inputMapEntry.getKey(), inputMapEntry.getValue()))
- )
+ .filter(inputMapEntry -> PnfdQueryExecutor.find(conversionQuery, ImmutableMap.of(inputMapEntry.getKey(), inputMapEntry.getValue())))
.map(inputMapEntry -> {
final Map<String, Object> map = new HashMap<>();
map.put(inputMapEntry.getKey(), inputMapEntry.getValue());
return map;
}).collect(Collectors.toSet());
}
-
}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/PnfdNodeTemplateBlockParser.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/PnfdNodeTemplateBlockParser.java
index 5d7a6049cd..713cbf9dba 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/PnfdNodeTemplateBlockParser.java
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/PnfdNodeTemplateBlockParser.java
@@ -16,7 +16,6 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.core.converter.impl.pnfd.parser;
import java.util.Collections;
@@ -50,9 +49,7 @@ public class PnfdNodeTemplateBlockParser extends AbstractPnfdBlockParser {
if (MapUtils.isEmpty(nodeTemplateMap)) {
return Collections.emptySet();
}
-
- return nodeTemplateMap.entrySet().stream()
- .filter(mapEntry -> PnfdQueryExecutor.find(conversionQuery, mapEntry.getValue()))
+ return nodeTemplateMap.entrySet().stream().filter(mapEntry -> PnfdQueryExecutor.find(conversionQuery, mapEntry.getValue()))
.map(stringObjectEntry -> {
final Map<String, Object> map = new HashMap<>();
map.put(stringObjectEntry.getKey(), stringObjectEntry.getValue());
@@ -62,8 +59,8 @@ public class PnfdNodeTemplateBlockParser extends AbstractPnfdBlockParser {
@Override
protected Optional<Map<String, Object>> buildParsedBlock(final Map<String, Object> attributeQuery,
- final Map<String, Object> fromNodeTemplateAttributeMap,
- final ConversionDefinition conversionDefinition) {
+ final Map<String, Object> fromNodeTemplateAttributeMap,
+ final ConversionDefinition conversionDefinition) {
//cannot query for more than one attribute
if (attributeQuery.keySet().size() > 1) {
return Optional.empty();
@@ -74,9 +71,7 @@ public class PnfdNodeTemplateBlockParser extends AbstractPnfdBlockParser {
if (queryValue == null) {
PnfdConversionStrategy pnfdConversionStrategy = conversionDefinition.getPnfdConversionStrategy();
if (isGetInputFunction(attributeValueToConvert)) {
- inputNameToConvertMap.put(extractObjectValue(attributeValueToConvert)
- , conversionDefinition.getToGetInput()
- );
+ inputNameToConvertMap.put(extractObjectValue(attributeValueToConvert), conversionDefinition.getToGetInput());
pnfdConversionStrategy = new CopyConversionStrategy();
}
final Map<String, Object> parsedNodeTemplate = new HashMap<>();
@@ -84,18 +79,15 @@ public class PnfdNodeTemplateBlockParser extends AbstractPnfdBlockParser {
if (convertedAttribute.isPresent()) {
parsedNodeTemplate.put(conversionDefinition.getToAttributeName(), convertedAttribute.get());
}
-
return parsedNodeTemplate.isEmpty() ? Optional.empty() : Optional.of(parsedNodeTemplate);
} else {
if (!(queryValue instanceof Map) || !(attributeValueToConvert instanceof Map)) {
return Optional.empty();
}
final Map<String, Object> parsedNodeTemplate = new HashMap<>();
- final Optional<Map<String, Object>> builtNodeTemplate = buildParsedBlock(
- (Map<String, Object>) queryValue,
+ final Optional<Map<String, Object>> builtNodeTemplate = buildParsedBlock((Map<String, Object>) queryValue,
(Map<String, Object>) attributeValueToConvert, conversionDefinition);
builtNodeTemplate.ifPresent(builtNodeTemplate1 -> parsedNodeTemplate.put(attribute, builtNodeTemplate1));
-
return parsedNodeTemplate.isEmpty() ? Optional.empty() : Optional.of(parsedNodeTemplate);
}
}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/PnfdNodeTypeBlockParser.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/PnfdNodeTypeBlockParser.java
index 386bbfb558..e77200a906 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/PnfdNodeTypeBlockParser.java
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/PnfdNodeTypeBlockParser.java
@@ -16,7 +16,6 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.core.converter.impl.pnfd.parser;
import static org.openecomp.sdc.be.utils.TypeUtils.ToscaTagNamesEnum.DERIVED_FROM;
@@ -46,17 +45,12 @@ public class PnfdNodeTypeBlockParser extends AbstractPnfdBlockParser {
if (customNodeTypeMap.isEmpty()) {
return Collections.emptySet();
}
-
- final String nodeNamePrefix =
- transformation.getPropertyValue(TransformationPropertyType.NODE_NAME_PREFIX, String.class)
- .orElse("");
-
- return customNodeTypeMap.entrySet().parallelStream()
- .map(nodeEntry -> {
- final Map<String, Object> map = new HashMap<>();
- map.put(nodeNamePrefix.concat(nodeEntry.getKey()), nodeEntry.getValue());
- return map;
- }).collect(Collectors.toSet());
+ final String nodeNamePrefix = transformation.getPropertyValue(TransformationPropertyType.NODE_NAME_PREFIX, String.class).orElse("");
+ return customNodeTypeMap.entrySet().parallelStream().map(nodeEntry -> {
+ final Map<String, Object> map = new HashMap<>();
+ map.put(nodeNamePrefix.concat(nodeEntry.getKey()), nodeEntry.getValue());
+ return map;
+ }).collect(Collectors.toSet());
}
@Override
@@ -74,8 +68,7 @@ public class PnfdNodeTypeBlockParser extends AbstractPnfdBlockParser {
if (queryValue == null) {
PnfdConversionStrategy pnfdConversionStrategy = conversionDefinition.getPnfdConversionStrategy();
final Optional convertedAttribute = pnfdConversionStrategy
- .convert(DERIVED_FROM.getElementName()
- .equalsIgnoreCase(attribute) ? attributeValueToBeConverted : attributeValueToConvert);
+ .convert(DERIVED_FROM.getElementName().equalsIgnoreCase(attribute) ? attributeValueToBeConverted : attributeValueToConvert);
if (convertedAttribute.isPresent()) {
parsedNodeTemplate.put(conversionDefinition.getToAttributeName(), convertedAttribute.get());
}
@@ -90,5 +83,4 @@ public class PnfdNodeTypeBlockParser extends AbstractPnfdBlockParser {
DataModelUtil.addNodeType(templateTo, blockName, nodeTypeYamlParser);
}
}
-
}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/TransformationYamlParser.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/TransformationYamlParser.java
index 92e1d8f392..210ffc6b5b 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/TransformationYamlParser.java
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/parser/TransformationYamlParser.java
@@ -16,7 +16,6 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.core.converter.impl.pnfd.parser;
import static org.openecomp.core.converter.pnfd.model.PnfTransformationToken.CONVERSIONS;
@@ -59,14 +58,13 @@ public class TransformationYamlParser {
private static final Logger LOGGER = LoggerFactory.getLogger(TransformationYamlParser.class);
private TransformationYamlParser() {
-
}
/**
* Parses the given YAML object to a {@link Transformation} instance.
- * @param transformationYaml the YAML object representing a transformation
- * @return
- * A new instance of {@link Transformation}.
+ *
+ * @param transformationYaml the YAML object representing a transformation
+ * @return A new instance of {@link Transformation}.
*/
public static Optional<Transformation> parse(final Map<String, Object> transformationYaml) {
final Transformation transformation = new Transformation();
@@ -77,7 +75,6 @@ public class TransformationYamlParser {
transformation.setName(name.orElse(null));
transformation.setDescription(parseStringAttribute(DESCRIPTION.getName(), transformationYaml).orElse(null));
transformation.setPropertySet(readProperties(transformationYaml));
-
final String block = parseStringAttribute(TRANSFORMATION_FOR.getName(), transformationYaml).orElse(null);
final Optional<TransformationBlock> transformationBlockOptional = TransformationBlock.parse(block);
if (transformationBlockOptional.isPresent()) {
@@ -85,14 +82,11 @@ public class TransformationYamlParser {
transformation.setBlock(transformationBlock);
parseTransformationBlock(transformationBlock, transformation, transformationYaml);
} else {
- LOGGER.warn("Invalid '{}' value in transformation '{}'", TRANSFORMATION_FOR.getName(),
- transformationYaml.toString());
+ LOGGER.warn("Invalid '{}' value in transformation '{}'", TRANSFORMATION_FOR.getName(), transformationYaml.toString());
}
-
if (transformation.isValid()) {
return Optional.of(transformation);
}
-
return Optional.empty();
}
@@ -101,14 +95,10 @@ public class TransformationYamlParser {
if (MapUtils.isEmpty(propertyMap)) {
return Collections.emptySet();
}
-
final Set<TransformationProperty> propertySet = new HashSet<>();
-
propertyMap.forEach((key, value) -> {
- final TransformationPropertyType transformationPropertyType = TransformationPropertyType.parse(key)
- .orElse(null);
-
- if(transformationPropertyType != null) {
+ final TransformationPropertyType transformationPropertyType = TransformationPropertyType.parse(key).orElse(null);
+ if (transformationPropertyType != null) {
if (value instanceof String) {
propertySet.add(new TransformationProperty<>(transformationPropertyType, (String) value));
} else if (value instanceof Boolean) {
@@ -120,72 +110,57 @@ public class TransformationYamlParser {
}
}
});
-
return propertySet;
}
- private static void parseTransformationBlock(final TransformationBlock transformationBlock,
- final Transformation transformationReference,
+ private static void parseTransformationBlock(final TransformationBlock transformationBlock, final Transformation transformationReference,
final Map<String, Object> transformationYaml) {
if (transformationBlock == TransformationBlock.CUSTOM_NODE_TYPE) {
parseCustomNodeTypeBlock(transformationReference, transformationYaml);
return;
}
-
- ConversionQueryYamlParser.parse(transformationYaml.get(QUERY.getName()))
- .ifPresent(transformationReference::setConversionQuery);
-
+ ConversionQueryYamlParser.parse(transformationYaml.get(QUERY.getName())).ifPresent(transformationReference::setConversionQuery);
transformationReference.setConversionDefinitionList(parseConversions(transformationYaml));
}
- private static void parseCustomNodeTypeBlock(final Transformation transformationReference,
- final Map<String, Object> transformationYaml) {
+ private static void parseCustomNodeTypeBlock(final Transformation transformationReference, final Map<String, Object> transformationYaml) {
final Object fromAttribute = transformationYaml.get(FROM.getName());
if (!(fromAttribute instanceof String)) {
return;
}
final String from = parseStringAttribute(FROM.getName(), transformationYaml).orElse(null);
-
final Object toAttribute = transformationYaml.get(TO.getName());
if (!(toAttribute instanceof String)) {
return;
}
final String to = parseStringAttribute(TO.getName(), transformationYaml).orElse(null);
-
final HashMap<String, String> transformationQuery = new HashMap<>();
transformationQuery.put(ToscaTagNamesEnum.DERIVED_FROM.getElementName(), from);
transformationReference.setConversionQuery(new ConversionQuery(transformationQuery));
-
final List<ConversionDefinition> conversionDefinitionList = new ArrayList<>();
final HashMap<String, String> conversionDefinitionQuery = new HashMap<>();
conversionDefinitionQuery.put(ToscaTagNamesEnum.TYPE.getElementName(), null);
- ConversionDefinition conversionDefinition = new ConversionDefinition(new ConversionQuery(conversionDefinitionQuery)
- , ToscaTagNamesEnum.TYPE.getElementName(), new ReplaceConversionStrategy(from, to));
+ ConversionDefinition conversionDefinition = new ConversionDefinition(new ConversionQuery(conversionDefinitionQuery),
+ ToscaTagNamesEnum.TYPE.getElementName(), new ReplaceConversionStrategy(from, to));
conversionDefinitionList.add(conversionDefinition);
transformationReference.setConversionDefinitionList(conversionDefinitionList);
}
private static List<ConversionDefinition> parseConversions(final Map<String, Object> conversionYaml) {
final List<Object> conversionList = (List<Object>) conversionYaml.get(CONVERSIONS.getName());
-
if (CollectionUtils.isEmpty(conversionList)) {
return Collections.emptyList();
}
-
- return conversionList.stream()
- .map(conversion -> ConversionDefinitionYamlParser.parse((Map<String, Object>) conversion).orElse(null))
- .filter(Objects::nonNull)
- .collect(Collectors.toList());
+ return conversionList.stream().map(conversion -> ConversionDefinitionYamlParser.parse((Map<String, Object>) conversion).orElse(null))
+ .filter(Objects::nonNull).collect(Collectors.toList());
}
private static Optional<String> parseStringAttribute(final String attribute, final Map<String, Object> transformationYaml) {
try {
return Optional.of((String) transformationYaml.get(attribute));
} catch (final Exception e) {
- LOGGER.warn("Could not parse the String '{}' in transformation '{}'",
- attribute, transformationYaml.toString(), e);
+ LOGGER.warn("Could not parse the String '{}' in transformation '{}'", attribute, transformationYaml.toString(), e);
return Optional.empty();
}
}
-
}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/strategy/CopyConversionStrategy.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/strategy/CopyConversionStrategy.java
index c379dfa85c..762e997e01 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/strategy/CopyConversionStrategy.java
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/strategy/CopyConversionStrategy.java
@@ -16,13 +16,12 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.core.converter.impl.pnfd.strategy;
import java.util.HashMap;
import java.util.Optional;
-import org.openecomp.core.converter.pnfd.strategy.AbstractPnfdConversionStrategy;
import org.openecomp.core.converter.pnfd.model.ConversionStrategyType;
+import org.openecomp.core.converter.pnfd.strategy.AbstractPnfdConversionStrategy;
public class CopyConversionStrategy extends AbstractPnfdConversionStrategy<Object, Object> {
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/strategy/ReplaceConversionStrategy.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/strategy/ReplaceConversionStrategy.java
index 3bde6326b7..83f860b089 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/strategy/ReplaceConversionStrategy.java
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/strategy/ReplaceConversionStrategy.java
@@ -16,13 +16,12 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.core.converter.impl.pnfd.strategy;
import java.util.HashMap;
import java.util.Optional;
-import org.openecomp.core.converter.pnfd.strategy.AbstractPnfdConversionStrategy;
import org.openecomp.core.converter.pnfd.model.ConversionStrategyType;
+import org.openecomp.core.converter.pnfd.strategy.AbstractPnfdConversionStrategy;
public class ReplaceConversionStrategy extends AbstractPnfdConversionStrategy<Object, Object> {
@@ -35,5 +34,4 @@ public class ReplaceConversionStrategy extends AbstractPnfdConversionStrategy<Ob
public Optional<Object> convert(final Object originalValue) {
return Optional.ofNullable(conversionMap.get(originalValue));
}
-
}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/strategy/ReplaceInListConversionStrategy.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/strategy/ReplaceInListConversionStrategy.java
index 9984a8708d..de3b8ff8cb 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/strategy/ReplaceInListConversionStrategy.java
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/converter/impl/pnfd/strategy/ReplaceInListConversionStrategy.java
@@ -16,7 +16,6 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.core.converter.impl.pnfd.strategy;
import java.util.HashMap;
@@ -26,9 +25,9 @@ import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors;
-import org.openecomp.core.converter.pnfd.strategy.AbstractPnfdConversionStrategy;
import org.openecomp.core.converter.pnfd.model.ConversionStrategyType;
import org.openecomp.core.converter.pnfd.model.PnfTransformationToken;
+import org.openecomp.core.converter.pnfd.strategy.AbstractPnfdConversionStrategy;
public class ReplaceInListConversionStrategy extends AbstractPnfdConversionStrategy<List<Object>, List<Object>> {
@@ -37,11 +36,8 @@ public class ReplaceInListConversionStrategy extends AbstractPnfdConversionStrat
public ReplaceInListConversionStrategy(final List<Map<String, Object>> descriptorList) {
super(ConversionStrategyType.REPLACE_IN_LIST, new HashMap<>());
replaceInListConversionStrategyMap = new LinkedHashMap<>();
- descriptorList
- .forEach(stringObjectMap -> replaceInListConversionStrategyMap.put(stringObjectMap.get(
- PnfTransformationToken.FROM.getName())
- , stringObjectMap.get(PnfTransformationToken.TO.getName()))
- );
+ descriptorList.forEach(stringObjectMap -> replaceInListConversionStrategyMap
+ .put(stringObjectMap.get(PnfTransformationToken.FROM.getName()), stringObjectMap.get(PnfTransformationToken.TO.getName())));
}
@Override
@@ -49,12 +45,8 @@ public class ReplaceInListConversionStrategy extends AbstractPnfdConversionStrat
if (originalValue == null || originalValue.isEmpty()) {
return Optional.empty();
}
-
- final List<Object> convertedList = originalValue.stream()
- .map(replaceInListConversionStrategyMap::get)
- .filter(Objects::nonNull)
+ final List<Object> convertedList = originalValue.stream().map(replaceInListConversionStrategyMap::get).filter(Objects::nonNull)
.collect(Collectors.toList());
-
return convertedList.isEmpty() ? Optional.empty() : Optional.of(convertedList);
}
}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/AbstractToscaConverter.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/AbstractToscaConverter.java
index 7168192526..1be85a5759 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/AbstractToscaConverter.java
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/AbstractToscaConverter.java
@@ -19,20 +19,20 @@
* * ============LICENSE_END=========================================================
*
*/
-
package org.openecomp.core.impl;
-import static org.openecomp.core.converter.datatypes.Constants.ONAP_INDEX;
import static org.openecomp.core.converter.datatypes.Constants.DEFINITIONS_DIR;
import static org.openecomp.core.converter.datatypes.Constants.GLOBAL_ST_NAME;
import static org.openecomp.core.converter.datatypes.Constants.GLOBAL_SUBSTITUTION;
import static org.openecomp.core.converter.datatypes.Constants.MAIN_ST_NAME;
+import static org.openecomp.core.converter.datatypes.Constants.ONAP_INDEX;
import static org.openecomp.core.converter.datatypes.Constants.OPENECOMP_HEAT_INDEX;
import static org.openecomp.core.impl.GlobalSubstitutionServiceTemplate.GLOBAL_SUBSTITUTION_SERVICE_FILE_NAME;
import static org.openecomp.core.impl.GlobalSubstitutionServiceTemplate.HEAT_INDEX_IMPORT_FILE;
import static org.openecomp.core.impl.GlobalSubstitutionServiceTemplate.ONAP_INDEX_IMPORT_FILE;
import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_ORIG_PATH_FILE_NAME;
import static org.openecomp.sdc.tosca.csar.ToscaMetadataFileInfo.TOSCA_META_PATH_FILE_NAME;
+
import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
@@ -66,10 +66,10 @@ import org.slf4j.LoggerFactory;
import org.yaml.snakeyaml.error.YAMLException;
public abstract class AbstractToscaConverter implements ToscaConverter {
+
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractToscaConverter.class);
- public abstract void convertTopologyTemplate(@NotNull ServiceTemplate serviceTemplate,
- ServiceTemplateReaderService readerService);
+ public abstract void convertTopologyTemplate(@NotNull ServiceTemplate serviceTemplate, ServiceTemplateReaderService readerService);
protected void handleMetadataFile(Map<String, byte[]> csarFiles) {
byte[] bytes = csarFiles.remove(TOSCA_META_PATH_FILE_NAME);
@@ -78,8 +78,7 @@ public abstract class AbstractToscaConverter implements ToscaConverter {
}
}
- protected void handleDefinitionTemplate(String key, Map<String, byte[]> csarFiles,
- GlobalSubstitutionServiceTemplate gsst) {
+ protected void handleDefinitionTemplate(String key, Map<String, byte[]> csarFiles, GlobalSubstitutionServiceTemplate gsst) {
try {
ServiceTemplateReaderService readerService = new ServiceTemplateReaderServiceImpl(csarFiles.get(key));
Object nodeTypes = readerService.getNodeTypes();
@@ -89,9 +88,9 @@ public abstract class AbstractToscaConverter implements ToscaConverter {
}
gsst.appendDataTypes((Map) readerService.getDataTypes());
} catch (YAMLException ye) {
- throw new CoreException(new ErrorCode.ErrorCodeBuilder()
- .withMessage("Invalid YAML content in file " + key)
- .withCategory(ErrorCategory.APPLICATION).build(), ye);
+ throw new CoreException(
+ new ErrorCode.ErrorCodeBuilder().withMessage("Invalid YAML content in file " + key).withCategory(ErrorCategory.APPLICATION).build(),
+ ye);
}
}
@@ -100,52 +99,39 @@ public abstract class AbstractToscaConverter implements ToscaConverter {
if (artifactIndex < 0) {
return fileName;
}
-
- int artifactDirectoryIndex =
- artifactIndex + CsarFileTypes.Artifacts.name().length() + 1;
+ int artifactDirectoryIndex = artifactIndex + CsarFileTypes.Artifacts.name().length() + 1;
return fileName.substring(artifactDirectoryIndex);
}
- protected void updateToscaServiceModel(ToscaServiceModel toscaServiceModel,
- Map<String, ServiceTemplate> serviceTemplates,
+ protected void updateToscaServiceModel(ToscaServiceModel toscaServiceModel, Map<String, ServiceTemplate> serviceTemplates,
FileContentHandler externalFilesHandler,
- GlobalSubstitutionServiceTemplate globalSubstitutionServiceTemplate,
- Map<String, byte[]> csarFiles, String entryDefinitionServiceTemplateName) {
- Collection<ServiceTemplate> globalServiceTemplates =
- GlobalTypesGenerator.getGlobalTypesServiceTemplate(OnboardingTypesEnum.CSAR).values();
+ GlobalSubstitutionServiceTemplate globalSubstitutionServiceTemplate, Map<String, byte[]> csarFiles,
+ String entryDefinitionServiceTemplateName) {
+ Collection<ServiceTemplate> globalServiceTemplates = GlobalTypesGenerator.getGlobalTypesServiceTemplate(OnboardingTypesEnum.CSAR).values();
addGlobalServiceTemplates(globalServiceTemplates, serviceTemplates);
toscaServiceModel.setServiceTemplates(serviceTemplates);
toscaServiceModel.setEntryDefinitionServiceTemplate(entryDefinitionServiceTemplateName);
- externalFilesHandler.addFile(TOSCA_META_ORIG_PATH_FILE_NAME,
- csarFiles.get(TOSCA_META_ORIG_PATH_FILE_NAME));
+ externalFilesHandler.addFile(TOSCA_META_ORIG_PATH_FILE_NAME, csarFiles.get(TOSCA_META_ORIG_PATH_FILE_NAME));
toscaServiceModel.setArtifactFiles(externalFilesHandler);
-
if (MapUtils.isNotEmpty(globalSubstitutionServiceTemplate.getNode_types())) {
- serviceTemplates
- .put(GLOBAL_SUBSTITUTION_SERVICE_FILE_NAME, globalSubstitutionServiceTemplate);
+ serviceTemplates.put(GLOBAL_SUBSTITUTION_SERVICE_FILE_NAME, globalSubstitutionServiceTemplate);
}
}
- private void addGlobalServiceTemplates(Collection<ServiceTemplate> globalServiceTemplates,
- Map<String, ServiceTemplate> serviceTemplates) {
+ private void addGlobalServiceTemplates(Collection<ServiceTemplate> globalServiceTemplates, Map<String, ServiceTemplate> serviceTemplates) {
for (ServiceTemplate serviceTemplate : globalServiceTemplates) {
serviceTemplates.put(ToscaUtil.getServiceTemplateFileName(serviceTemplate), serviceTemplate);
}
}
- protected void handleServiceTemplate(String serviceTemplateName,
- String fileName, Map<String, byte[]> csarFiles,
+ protected void handleServiceTemplate(String serviceTemplateName, String fileName, Map<String, byte[]> csarFiles,
Map<String, ServiceTemplate> serviceTemplates) {
final byte[] inputServiceTemplate = getServiceTemplateFromCsar(fileName, csarFiles);
Optional<ServiceTemplate> serviceTemplate = convertServiceTemplate(fileName, inputServiceTemplate);
- serviceTemplate.ifPresent(
- serviceTemplateValue -> addServiceTemplate(serviceTemplateName, serviceTemplateValue,
- serviceTemplates));
+ serviceTemplate.ifPresent(serviceTemplateValue -> addServiceTemplate(serviceTemplateName, serviceTemplateValue, serviceTemplates));
}
- private void addServiceTemplate(String serviceTemplateName,
- ServiceTemplate serviceTemplate,
- Map<String, ServiceTemplate> serviceTemplates) {
+ private void addServiceTemplate(String serviceTemplateName, ServiceTemplate serviceTemplate, Map<String, ServiceTemplate> serviceTemplates) {
serviceTemplates.put(serviceTemplateName, serviceTemplate);
}
@@ -153,12 +139,10 @@ public abstract class AbstractToscaConverter implements ToscaConverter {
return csarFiles.get(fileName);
}
- private Optional<ServiceTemplate> convertServiceTemplate(String serviceTemplateName,
- byte[] fileContent) {
+ private Optional<ServiceTemplate> convertServiceTemplate(String serviceTemplateName, byte[] fileContent) {
ServiceTemplate serviceTemplate = new ServiceTemplate();
try {
- ServiceTemplateReaderService readerService =
- new ServiceTemplateReaderServiceImpl(fileContent);
+ ServiceTemplateReaderService readerService = new ServiceTemplateReaderServiceImpl(fileContent);
convertMetadata(serviceTemplateName, serviceTemplate, readerService);
convertToscaVersion(serviceTemplate, readerService);
convertImports(serviceTemplate);
@@ -166,17 +150,13 @@ public abstract class AbstractToscaConverter implements ToscaConverter {
convertDataTypes(serviceTemplate, readerService);
convertTopologyTemplate(serviceTemplate, readerService);
} catch (YAMLException ye) {
- throw new CoreException(new ErrorCode.ErrorCodeBuilder()
- .withMessage("Invalid YAML content in file" + serviceTemplateName)
- .withCategory(ErrorCategory.APPLICATION).build(), ye);
+ throw new CoreException(new ErrorCode.ErrorCodeBuilder().withMessage("Invalid YAML content in file" + serviceTemplateName)
+ .withCategory(ErrorCategory.APPLICATION).build(), ye);
}
-
-
return Optional.of(serviceTemplate);
}
- private void convertToscaVersion(ServiceTemplate serviceTemplate,
- ServiceTemplateReaderService readerService) {
+ private void convertToscaVersion(ServiceTemplate serviceTemplate, ServiceTemplateReaderService readerService) {
Object toscaVersion = readerService.getToscaVersion();
serviceTemplate.setTosca_definitions_version((String) toscaVersion);
}
@@ -194,26 +174,20 @@ public abstract class AbstractToscaConverter implements ToscaConverter {
Import anImport = new Import();
anImport.setFile(fileName);
importMap.put(key, anImport);
-
return importMap;
}
- private void convertMetadata(String serviceTemplateName,
- ServiceTemplate serviceTemplate,
- ServiceTemplateReaderService readerService) {
+ private void convertMetadata(String serviceTemplateName, ServiceTemplate serviceTemplate, ServiceTemplateReaderService readerService) {
Map<String, Object> metadataToConvert = (Map<String, Object>) readerService.getMetadata();
Map<String, String> finalMetadata = new HashMap<>();
-
if (MapUtils.isNotEmpty(metadataToConvert)) {
for (Map.Entry<String, Object> metadataEntry : metadataToConvert.entrySet()) {
- if (Objects.isNull(metadataEntry.getValue()) ||
- !(metadataEntry.getValue() instanceof String)) {
+ if (Objects.isNull(metadataEntry.getValue()) || !(metadataEntry.getValue() instanceof String)) {
continue;
}
finalMetadata.put(metadataEntry.getKey(), (String) metadataEntry.getValue());
}
}
-
finalMetadata.put("template_name", getTemplateNameFromStName(serviceTemplateName));
serviceTemplate.setMetadata(finalMetadata);
}
@@ -223,27 +197,18 @@ public abstract class AbstractToscaConverter implements ToscaConverter {
if (MapUtils.isEmpty(nodeTypes)) {
return;
}
-
for (Map.Entry<String, Object> nodeTypeEntry : nodeTypes.entrySet()) {
- Optional<NodeType> nodeType = ToscaConverterUtil
- .createObjectFromClass(nodeTypeEntry.getKey(), nodeTypeEntry.getValue(),
- NodeType.class);
-
- nodeType.ifPresent(nodeTypeValue -> DataModelUtil
- .addNodeType(serviceTemplate, nodeTypeEntry.getKey(), nodeTypeValue));
+ Optional<NodeType> nodeType = ToscaConverterUtil.createObjectFromClass(nodeTypeEntry.getKey(), nodeTypeEntry.getValue(), NodeType.class);
+ nodeType.ifPresent(nodeTypeValue -> DataModelUtil.addNodeType(serviceTemplate, nodeTypeEntry.getKey(), nodeTypeValue));
}
}
- protected void convertDataTypes(final ServiceTemplate serviceTemplate,
- final ServiceTemplateReaderService readerService) {
+ protected void convertDataTypes(final ServiceTemplate serviceTemplate, final ServiceTemplateReaderService readerService) {
try {
final Map<String, Object> dataTypes = readerService.getDataTypes();
for (final Map.Entry<String, Object> entry : dataTypes.entrySet()) {
- final Optional<DataType> dataType =
- ToscaConverterUtil.createObjectFromClass(entry.getKey(), entry.getValue(), DataType.class);
-
- dataType.ifPresent(
- nodeTypeValue -> DataModelUtil.addDataType(serviceTemplate, entry.getKey(), nodeTypeValue));
+ final Optional<DataType> dataType = ToscaConverterUtil.createObjectFromClass(entry.getKey(), entry.getValue(), DataType.class);
+ dataType.ifPresent(nodeTypeValue -> DataModelUtil.addDataType(serviceTemplate, entry.getKey(), nodeTypeValue));
}
} catch (final Exception ex) {
LOGGER.error("Unable to process data types: ", ex);
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/AbstractToscaSolConverter.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/AbstractToscaSolConverter.java
index ee669244ce..fb170e3ece 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/AbstractToscaSolConverter.java
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/AbstractToscaSolConverter.java
@@ -19,7 +19,6 @@
* * ============LICENSE_END=========================================================
*
*/
-
package org.openecomp.core.impl;
import static org.openecomp.core.converter.datatypes.Constants.GLOBAL_ST_NAME;
@@ -40,7 +39,6 @@ import org.openecomp.sdc.tosca.csar.OnboardingToscaMetadata;
import org.openecomp.sdc.tosca.csar.ToscaMetadata;
import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
-
public abstract class AbstractToscaSolConverter extends AbstractToscaConverter {
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractToscaSolConverter.class);
@@ -75,21 +73,19 @@ public abstract class AbstractToscaSolConverter extends AbstractToscaConverter {
if (isGlobalServiceTemplate(fileEntry.getKey())) {
handleServiceTemplate(GLOBAL_ST_NAME, fileEntry.getKey(), csarFiles, serviceTemplates);
} else {
- artifacts.addFile(
- getConcreteArtifactFileName(fileEntry.getKey()), fileEntry.getValue());
+ artifacts.addFile(getConcreteArtifactFileName(fileEntry.getKey()), fileEntry.getValue());
}
}
}
}
- private void handleImportDefinitions(final String fileName, final Map<String, byte[]> csarFiles
- , final GlobalSubstitutionServiceTemplate gsst) {
+ private void handleImportDefinitions(final String fileName, final Map<String, byte[]> csarFiles, final GlobalSubstitutionServiceTemplate gsst) {
final ToscaDefinitionImportHandler toscaDefinitionImportHandler = new ToscaDefinitionImportHandler(csarFiles, fileName);
if (toscaDefinitionImportHandler.hasError()) {
throw new InvalidToscaDefinitionImportException(toscaDefinitionImportHandler.getErrors());
}
- final Map<String, ServiceTemplateReaderService> handledImportDefinitionFileMap =
- toscaDefinitionImportHandler.getHandledImportDefinitionFileMap();
+ final Map<String, ServiceTemplateReaderService> handledImportDefinitionFileMap = toscaDefinitionImportHandler
+ .getHandledImportDefinitionFileMap();
handledDefinitionFilesList.addAll(handledImportDefinitionFileMap.keySet());
for (final String file : handledDefinitionFilesList) {
handleDefinitionTemplate(file, csarFiles, gsst);
@@ -98,8 +94,8 @@ public abstract class AbstractToscaSolConverter extends AbstractToscaConverter {
private String getMainServiceDefinitionFileName(FileContentHandler contentHandler) throws IOException {
try {
- ToscaMetadata toscaMetadata = OnboardingToscaMetadata.parseToscaMetadataFile(
- contentHandler.getFileContentAsStream(TOSCA_META_PATH_FILE_NAME));
+ ToscaMetadata toscaMetadata = OnboardingToscaMetadata
+ .parseToscaMetadataFile(contentHandler.getFileContentAsStream(TOSCA_META_PATH_FILE_NAME));
return toscaMetadata.getMetaEntries().get(ENTRY_DEFINITIONS.getName());
} catch (IOException e) {
LOGGER.error(e.getMessage(), e);
@@ -113,5 +109,4 @@ public abstract class AbstractToscaSolConverter extends AbstractToscaConverter {
}
return path;
}
-
-} \ No newline at end of file
+}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/GlobalSubstitutionServiceTemplate.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/GlobalSubstitutionServiceTemplate.java
index 98d8d23751..4907451a06 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/GlobalSubstitutionServiceTemplate.java
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/GlobalSubstitutionServiceTemplate.java
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.core.impl;
import static org.openecomp.core.converter.datatypes.Constants.ONAP_INDEX;
@@ -35,15 +34,14 @@ import org.openecomp.sdc.translator.services.heattotosca.globaltypes.GlobalTypes
public class GlobalSubstitutionServiceTemplate extends ServiceTemplate {
- public static final String GLOBAL_SUBSTITUTION_SERVICE_FILE_NAME =
- "GlobalSubstitutionTypesServiceTemplate.yaml";
+ public static final String GLOBAL_SUBSTITUTION_SERVICE_FILE_NAME = "GlobalSubstitutionTypesServiceTemplate.yaml";
public static final String TEMPLATE_NAME_PROPERTY = "template_name";
public static final String DEFINITION_VERSION = "tosca_simple_yaml_1_0_0";
public static final String HEAT_INDEX = "openecomp_heat_index";
public static final String HEAT_INDEX_IMPORT_FILE = "openecomp-heat/_index.yml";
public static final String ONAP_INDEX_IMPORT_FILE = "onap/_index.yml";
-
// transient needed to avoid being parsed as a YAML String. Used parser is reading fields instead of getters,
+
// although it ignores static or transient fields.
private final transient Map<String, ServiceTemplate> globalServiceTemplates;
private final transient Map<String, DataType> globalDataTypeMap;
@@ -51,12 +49,11 @@ public class GlobalSubstitutionServiceTemplate extends ServiceTemplate {
public GlobalSubstitutionServiceTemplate() {
super();
init();
- globalServiceTemplates =
- GlobalTypesGenerator.getGlobalTypesServiceTemplate(OnboardingTypesEnum.CSAR);
+ globalServiceTemplates = GlobalTypesGenerator.getGlobalTypesServiceTemplate(OnboardingTypesEnum.CSAR);
globalDataTypeMap = loadGlobalDataTypes();
}
- public void init() {
+ public void init() {
writeDefinitionSection();
writeMetadataSection();
writeImportsSection();
@@ -73,12 +70,10 @@ public class GlobalSubstitutionServiceTemplate extends ServiceTemplate {
if (MapUtils.isEmpty(dataTypeMap)) {
return;
}
- dataTypeMap.entrySet().stream()
- .filter(dataTypeEntry -> !isGlobalDataType(dataTypeEntry.getKey()))
- .forEach(dataTypeEntry -> {
- final Optional<DataType> dataType = parseDataTypeToYamlObject(dataTypeEntry);
- dataType.ifPresent(dataType1 -> getData_types().put(dataTypeEntry.getKey(), dataType1));
- });
+ dataTypeMap.entrySet().stream().filter(dataTypeEntry -> !isGlobalDataType(dataTypeEntry.getKey())).forEach(dataTypeEntry -> {
+ final Optional<DataType> dataType = parseDataTypeToYamlObject(dataTypeEntry);
+ dataType.ifPresent(dataType1 -> getData_types().put(dataTypeEntry.getKey(), dataType1));
+ });
}
private void writeImportsSection() {
@@ -94,7 +89,6 @@ public class GlobalSubstitutionServiceTemplate extends ServiceTemplate {
stringImportMap.put(ONAP_INDEX, onapDefinitionsImport);
}
-
private void writeMetadataSection() {
Map<String, String> metadata = new HashMap<>();
metadata.put(TEMPLATE_NAME_PROPERTY, "GlobalSubstitutionTypes");
@@ -105,22 +99,18 @@ public class GlobalSubstitutionServiceTemplate extends ServiceTemplate {
setTosca_definitions_version(DEFINITION_VERSION);
}
- private Optional<Map<String, NodeType>> findNonGlobalTypesNodes(final Map<String, NodeType> nodes){
+ private Optional<Map<String, NodeType>> findNonGlobalTypesNodes(final Map<String, NodeType> nodes) {
final Map<String, NodeType> globalNodeTypes = getAllGlobalNodeTypes();
if (MapUtils.isEmpty(globalNodeTypes)) {
return Optional.of(nodes);
}
-
final Map<String, NodeType> nodeTypesToAdd = new HashMap<>();
-
- for(Map.Entry<String, NodeType> nodeTypeEntry : nodes.entrySet()){
- if(!globalNodeTypes.containsKey(nodeTypeEntry.getKey())){
+ for (Map.Entry<String, NodeType> nodeTypeEntry : nodes.entrySet()) {
+ if (!globalNodeTypes.containsKey(nodeTypeEntry.getKey())) {
Optional<NodeType> nodeType = parseNodeTypeToYamlObject(nodeTypeEntry);
- nodeType
- .ifPresent(nodeTypeValue -> nodeTypesToAdd.put(nodeTypeEntry.getKey(), nodeTypeValue));
+ nodeType.ifPresent(nodeTypeValue -> nodeTypesToAdd.put(nodeTypeEntry.getKey(), nodeTypeValue));
}
}
-
return Optional.of(nodeTypesToAdd);
}
@@ -128,37 +118,30 @@ public class GlobalSubstitutionServiceTemplate extends ServiceTemplate {
if (MapUtils.isEmpty(globalDataTypeMap)) {
return false;
}
-
return globalDataTypeMap.containsKey(dataType);
}
private Optional<NodeType> parseNodeTypeToYamlObject(final Entry<String, NodeType> nodeTypeEntry) {
- return ToscaConverterUtil
- .createObjectFromClass(nodeTypeEntry.getKey(), nodeTypeEntry.getValue(), NodeType.class);
+ return ToscaConverterUtil.createObjectFromClass(nodeTypeEntry.getKey(), nodeTypeEntry.getValue(), NodeType.class);
}
private Optional<DataType> parseDataTypeToYamlObject(final Entry<String, DataType> dataTypeEntry) {
- return ToscaConverterUtil
- .createObjectFromClass(dataTypeEntry.getKey(), dataTypeEntry.getValue(), DataType.class);
+ return ToscaConverterUtil.createObjectFromClass(dataTypeEntry.getKey(), dataTypeEntry.getValue(), DataType.class);
}
private Map<String, DataType> loadGlobalDataTypes() {
- return globalServiceTemplates.values().stream()
- .map(ServiceTemplate::getData_types)
- .filter(MapUtils::isNotEmpty)
+ return globalServiceTemplates.values().stream().map(ServiceTemplate::getData_types).filter(MapUtils::isNotEmpty)
.flatMap(stringDataTypeMap -> stringDataTypeMap.entrySet().stream())
.collect(Collectors.toMap(Entry::getKey, Entry::getValue, (dataType, dataType2) -> dataType));
}
- private Map<String, NodeType> getAllGlobalNodeTypes(){
+ private Map<String, NodeType> getAllGlobalNodeTypes() {
Map<String, NodeType> globalNodeTypes = new HashMap<>();
-
- for(Map.Entry<String, ServiceTemplate> serviceTemplateEntry : globalServiceTemplates.entrySet()){
- if(isNodesServiceTemplate(serviceTemplateEntry.getKey())){
+ for (Map.Entry<String, ServiceTemplate> serviceTemplateEntry : globalServiceTemplates.entrySet()) {
+ if (isNodesServiceTemplate(serviceTemplateEntry.getKey())) {
globalNodeTypes.putAll(serviceTemplateEntry.getValue().getNode_types());
}
}
-
return globalNodeTypes;
}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/InvalidToscaDefinitionImportException.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/InvalidToscaDefinitionImportException.java
index ac2e5eccc2..0c683fbf85 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/InvalidToscaDefinitionImportException.java
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/InvalidToscaDefinitionImportException.java
@@ -16,7 +16,6 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.core.impl;
import java.util.List;
@@ -33,15 +32,15 @@ public class InvalidToscaDefinitionImportException extends RuntimeException {
/**
* Builds the exception message based on the provided validation error list.
- * @param validationErrorList The error list
+ *
+ * @param validationErrorList The error list
*/
public InvalidToscaDefinitionImportException(final List<ErrorMessage> validationErrorList) {
final StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("The provided package is invalid as it contains descriptors import errors:\n");
if (CollectionUtils.isNotEmpty(validationErrorList)) {
final StringJoiner joiner = new StringJoiner(";\n");
- validationErrorList.forEach(
- errorMessage -> joiner.add(String.format("%s: %s", errorMessage.getLevel(), errorMessage.getMessage())));
+ validationErrorList.forEach(errorMessage -> joiner.add(String.format("%s: %s", errorMessage.getLevel(), errorMessage.getMessage())));
message = stringBuilder.append(joiner.toString()).toString();
} else {
message = stringBuilder.toString();
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaConverterImpl.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaConverterImpl.java
index 6f50205f44..1d109bb457 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaConverterImpl.java
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaConverterImpl.java
@@ -13,58 +13,51 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.core.impl;
+import static org.openecomp.core.converter.datatypes.Constants.GLOBAL_ST_NAME;
+import static org.openecomp.core.converter.datatypes.Constants.MAIN_ST_NAME;
+
+import java.util.HashMap;
+import java.util.Map;
import org.onap.sdc.tosca.datatypes.model.ServiceTemplate;
import org.openecomp.core.converter.ServiceTemplateReaderService;
import org.openecomp.core.converter.datatypes.CsarFileTypes;
import org.openecomp.core.utilities.file.FileContentHandler;
import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
-import java.util.HashMap;
-import java.util.Map;
-
-import static org.openecomp.core.converter.datatypes.Constants.GLOBAL_ST_NAME;
-import static org.openecomp.core.converter.datatypes.Constants.MAIN_ST_NAME;
-
public class ToscaConverterImpl extends AbstractToscaConverter {
- @Override
- public ToscaServiceModel convert(FileContentHandler fileContentHandler) {
- Map<String, byte[]> csarFiles = new HashMap<>(fileContentHandler.getFiles());
- ToscaServiceModel toscaServiceModel = new ToscaServiceModel();
- Map<String, ServiceTemplate> serviceTemplates = new HashMap<>();
- FileContentHandler artifacts = new FileContentHandler();
- GlobalSubstitutionServiceTemplate gsst = new GlobalSubstitutionServiceTemplate();
- csarFiles.putAll(fileContentHandler.getFiles());
- for (Map.Entry<String, byte[]> fileEntry : csarFiles.entrySet()) {
- CsarFileTypes fileType = getFileType(fileEntry.getKey());
- switch (fileType) {
- case mainServiceTemplate:
- handleServiceTemplate(MAIN_ST_NAME, fileEntry.getKey(), csarFiles, serviceTemplates);
- break;
-
- case globalServiceTemplate:
- handleServiceTemplate(GLOBAL_ST_NAME, fileEntry.getKey(), csarFiles, serviceTemplates);
- break;
-
- case externalFile:
- artifacts.addFile(
- getConcreteArtifactFileName(fileEntry.getKey()), fileEntry.getValue());
- break;
-
- case definitionsFile:
- handleDefinitionTemplate(fileEntry.getKey(), csarFiles, gsst);
- break;
-
- default:
- break;
- }
- }
- handleMetadataFile(csarFiles);
- updateToscaServiceModel(toscaServiceModel, serviceTemplates, artifacts, gsst, csarFiles, MAIN_ST_NAME);
- return toscaServiceModel;
+ @Override
+ public ToscaServiceModel convert(FileContentHandler fileContentHandler) {
+ Map<String, byte[]> csarFiles = new HashMap<>(fileContentHandler.getFiles());
+ ToscaServiceModel toscaServiceModel = new ToscaServiceModel();
+ Map<String, ServiceTemplate> serviceTemplates = new HashMap<>();
+ FileContentHandler artifacts = new FileContentHandler();
+ GlobalSubstitutionServiceTemplate gsst = new GlobalSubstitutionServiceTemplate();
+ csarFiles.putAll(fileContentHandler.getFiles());
+ for (Map.Entry<String, byte[]> fileEntry : csarFiles.entrySet()) {
+ CsarFileTypes fileType = getFileType(fileEntry.getKey());
+ switch (fileType) {
+ case mainServiceTemplate:
+ handleServiceTemplate(MAIN_ST_NAME, fileEntry.getKey(), csarFiles, serviceTemplates);
+ break;
+ case globalServiceTemplate:
+ handleServiceTemplate(GLOBAL_ST_NAME, fileEntry.getKey(), csarFiles, serviceTemplates);
+ break;
+ case externalFile:
+ artifacts.addFile(getConcreteArtifactFileName(fileEntry.getKey()), fileEntry.getValue());
+ break;
+ case definitionsFile:
+ handleDefinitionTemplate(fileEntry.getKey(), csarFiles, gsst);
+ break;
+ default:
+ break;
+ }
+ }
+ handleMetadataFile(csarFiles);
+ updateToscaServiceModel(toscaServiceModel, serviceTemplates, artifacts, gsst, csarFiles, MAIN_ST_NAME);
+ return toscaServiceModel;
}
@Override
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaConverterUtil.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaConverterUtil.java
index a77c150a91..ffb953c89e 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaConverterUtil.java
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaConverterUtil.java
@@ -13,65 +13,56 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.core.impl;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.Set;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
import org.apache.commons.collections4.CollectionUtils;
import org.openecomp.core.converter.errors.CreateToscaObjectErrorBuilder;
import org.openecomp.sdc.common.errors.CoreException;
import org.openecomp.sdc.common.utils.CommonUtil;
-import java.util.*;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
public class ToscaConverterUtil {
- private static final String DEFAULT = "default";
- private static final String DEFAULT_CAPITAL = "Default";
- private static final Set<String> DEFAULT_VALUE_KEYS;
+ private static final String DEFAULT = "default";
+ private static final String DEFAULT_CAPITAL = "Default";
+ private static final Set<String> DEFAULT_VALUE_KEYS;
- static {
- DEFAULT_VALUE_KEYS =
- Stream.of(DEFAULT, DEFAULT_CAPITAL).collect(Collectors.toSet());
- }
-
- private ToscaConverterUtil() {
- // static utility methods only, prevent instantiation
- }
-
- static <T> Optional<T> createObjectFromClass(String objectId,
- Object objectCandidate,
- Class<T> classToCreate) {
- try {
- return CommonUtil.createObjectUsingSetters(objectCandidate, classToCreate);
- } catch (Exception ex) {
- throw new CoreException(
- new CreateToscaObjectErrorBuilder(classToCreate.getSimpleName(), objectId)
- .build(), ex);
+ static {
+ DEFAULT_VALUE_KEYS = Stream.of(DEFAULT, DEFAULT_CAPITAL).collect(Collectors.toSet());
}
- }
-
- static Optional<Object> getDefaultValue(Object entryValue,
- Object objectToAssignDefaultValue) {
- if (!(entryValue instanceof Map)
- || Objects.isNull(objectToAssignDefaultValue)) {
- return Optional.empty();
+ private ToscaConverterUtil() {
+ // static utility methods only, prevent instantiation
}
- return Optional.ofNullable(getDefaultParameterValue((Map<String, Object>) entryValue));
- }
-
- private static Object getDefaultParameterValue(Map<String, Object> entryValue) {
- Object defaultValue = null;
- Set<String> keys = new HashSet<>(entryValue.keySet());
- keys.retainAll(DEFAULT_VALUE_KEYS);
+ static <T> Optional<T> createObjectFromClass(String objectId, Object objectCandidate, Class<T> classToCreate) {
+ try {
+ return CommonUtil.createObjectUsingSetters(objectCandidate, classToCreate);
+ } catch (Exception ex) {
+ throw new CoreException(new CreateToscaObjectErrorBuilder(classToCreate.getSimpleName(), objectId).build(), ex);
+ }
+ }
- if (CollectionUtils.isNotEmpty(keys)) {
- defaultValue = entryValue.get(keys.iterator().next());
+ static Optional<Object> getDefaultValue(Object entryValue, Object objectToAssignDefaultValue) {
+ if (!(entryValue instanceof Map) || Objects.isNull(objectToAssignDefaultValue)) {
+ return Optional.empty();
+ }
+ return Optional.ofNullable(getDefaultParameterValue((Map<String, Object>) entryValue));
}
- return defaultValue;
- }
+ private static Object getDefaultParameterValue(Map<String, Object> entryValue) {
+ Object defaultValue = null;
+ Set<String> keys = new HashSet<>(entryValue.keySet());
+ keys.retainAll(DEFAULT_VALUE_KEYS);
+ if (CollectionUtils.isNotEmpty(keys)) {
+ defaultValue = entryValue.get(keys.iterator().next());
+ }
+ return defaultValue;
+ }
}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaDefinitionImportHandler.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaDefinitionImportHandler.java
index 661cadc738..a48fb36374 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaDefinitionImportHandler.java
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaDefinitionImportHandler.java
@@ -16,7 +16,6 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.core.impl;
import static org.openecomp.sdc.tosca.csar.CSARConstants.NON_FILE_IMPORT_ATTRIBUTES;
@@ -46,9 +45,7 @@ import org.slf4j.LoggerFactory;
public class ToscaDefinitionImportHandler {
private static final Logger LOGGER = LoggerFactory.getLogger(ToscaDefinitionImportHandler.class);
-
private final Map<String, byte[]> fileMap;
-
/**
* Stores all processed files during the import handling
*/
@@ -59,17 +56,17 @@ public class ToscaDefinitionImportHandler {
/**
* Reads the provided package structure starting from a main definition yaml file.
- * @param fileStructureMap The package structure with file path and respective file byte
- * @param mainDefinitionFilePath The main descriptor yaml file to start the reading
+ *
+ * @param fileStructureMap The package structure with file path and respective file byte
+ * @param mainDefinitionFilePath The main descriptor yaml file to start the reading
*/
- public ToscaDefinitionImportHandler(final Map<String, byte[]> fileStructureMap,
- final String mainDefinitionFilePath) {
+ public ToscaDefinitionImportHandler(final Map<String, byte[]> fileStructureMap, final String mainDefinitionFilePath) {
this.fileMap = fileStructureMap;
readImportsFromMainDefinition(mainDefinitionFilePath);
}
private void readImportsFromMainDefinition(final String mainDefinitionFilePath) {
- if(!checkMainDefinitionExists(mainDefinitionFilePath)) {
+ if (!checkMainDefinitionExists(mainDefinitionFilePath)) {
return;
}
final ServiceTemplateReaderService readerService = parseToServiceTemplate(mainDefinitionFilePath).orElse(null);
@@ -90,19 +87,16 @@ public class ToscaDefinitionImportHandler {
return Optional.of(new ServiceTemplateReaderServiceImpl(fileMap.get(definitionFile)));
} catch (final Exception ex) {
LOGGER.debug("Could not parse '{}' to a ServiceTemplateReader", definitionFile, ex);
- reportError(ErrorLevel.ERROR,
- String.format(Messages.INVALID_YAML_FORMAT.getErrorMessage(), ex.getMessage()));
+ reportError(ErrorLevel.ERROR, String.format(Messages.INVALID_YAML_FORMAT.getErrorMessage(), ex.getMessage()));
}
-
return Optional.empty();
}
/**
- * Reads and validates the descriptor imports recursively.
- * Starts from the provided descriptor and goes until the end of the import tree.
+ * Reads and validates the descriptor imports recursively. Starts from the provided descriptor and goes until the end of the import tree.
* Processes each file just once.
*
- * @param fileName the descriptor file path
+ * @param fileName the descriptor file path
*/
private void handleImports(final String fileName) {
currentFile = fileName;
@@ -113,14 +107,11 @@ public class ToscaDefinitionImportHandler {
if (readerService == null) {
return;
}
-
handledImportDefinitionFileMap.put(fileName, readerService);
final List<Object> imports = readerService.getImports();
final List<String> extractImportFiles = extractFileImports(imports);
- extractImportFiles.stream()
- .map(importedFile -> resolveImportPath(FilenameUtils.getPath(fileName), importedFile))
- .filter(resolvedPath -> !handledImportDefinitionFileMap.containsKey(resolvedPath))
- .forEach(this::handleImports);
+ extractImportFiles.stream().map(importedFile -> resolveImportPath(FilenameUtils.getPath(fileName), importedFile))
+ .filter(resolvedPath -> !handledImportDefinitionFileMap.containsKey(resolvedPath)).forEach(this::handleImports);
}
/**
@@ -133,22 +124,19 @@ public class ToscaDefinitionImportHandler {
* - yetAnotherDescriptor:
* yetAnotherDescriptor: ../Definitions/yetAnotherDescriptor.yaml
* </pre>
- * @param imports the import statements
- * @return
- * The list of import file paths found
+ *
+ * @param imports the import statements
+ * @return The list of import file paths found
*/
private List<String> extractFileImports(final List<Object> imports) {
final List<String> importedFileList = new ArrayList<>();
imports.forEach(importObject -> importedFileList.addAll(readImportStatement(importObject)));
-
return importedFileList;
}
/**
- * Reads an import statement which can be a value, a [key:value] or a [key:[key:value]].
- * Ignores entries which contains the same keys as
- * {@link org.openecomp.sdc.tosca.csar.CSARConstants#NON_FILE_IMPORT_ATTRIBUTES}.
- * Reports invalid import statements.
+ * Reads an import statement which can be a value, a [key:value] or a [key:[key:value]]. Ignores entries which contains the same keys as {@link
+ * org.openecomp.sdc.tosca.csar.CSARConstants#NON_FILE_IMPORT_ATTRIBUTES}. Reports invalid import statements.
* <pre>
* example of yaml imports statements:
* - /Artifacts/anImportedDescriptor.yaml
@@ -156,9 +144,9 @@ public class ToscaDefinitionImportHandler {
* - yetAnotherDescriptor:
* yetAnotherDescriptor: ../Definitions/yetAnotherDescriptor.yaml
* </pre>
- * @param importObject the object representing the yaml import statement
- * @return
- * The list of import file paths found
+ *
+ * @param importObject the object representing the yaml import statement
+ * @return The list of import file paths found
*/
private List<String> readImportStatement(final Object importObject) {
final List<String> importedFileList = new ArrayList<>();
@@ -172,43 +160,34 @@ public class ToscaDefinitionImportHandler {
}
}
} else {
- reportError(ErrorLevel.ERROR,
- String.format(Messages.INVALID_IMPORT_STATEMENT.getErrorMessage(), currentFile, importObject));
+ reportError(ErrorLevel.ERROR, String.format(Messages.INVALID_IMPORT_STATEMENT.getErrorMessage(), currentFile, importObject));
}
-
return importedFileList;
}
/**
* Given a directory path, resolves the import path.
- * @param directoryPath A directory path to resolve the import path
- * @param importPath An import statement path
- * @return
- * The resolved path of the import, using as base the directory path
+ *
+ * @param directoryPath A directory path to resolve the import path
+ * @param importPath An import statement path
+ * @return The resolved path of the import, using as base the directory path
*/
private String resolveImportPath(final String directoryPath, final String importPath) {
final String fixedParentDir;
if (StringUtils.isEmpty(directoryPath)) {
fixedParentDir = "/";
} else {
- fixedParentDir = String.format("%s%s%s",
- directoryPath.startsWith("/") ? "" : "/"
- , directoryPath
- , directoryPath.endsWith("/") ? "" : "/");
+ fixedParentDir = String.format("%s%s%s", directoryPath.startsWith("/") ? "" : "/", directoryPath, directoryPath.endsWith("/") ? "" : "/");
}
-
final URI parentDirUri = URI.create(fixedParentDir);
-
String resolvedImportPath = parentDirUri.resolve(importPath).toString();
if (resolvedImportPath.contains("../")) {
- reportError(ErrorLevel.ERROR,
- Messages.INVALID_IMPORT_STATEMENT.formatMessage(currentFile, importPath));
+ reportError(ErrorLevel.ERROR, Messages.INVALID_IMPORT_STATEMENT.formatMessage(currentFile, importPath));
return null;
}
if (resolvedImportPath.startsWith("/")) {
resolvedImportPath = resolvedImportPath.substring(1);
}
-
return resolvedImportPath;
}
@@ -221,28 +200,25 @@ public class ToscaDefinitionImportHandler {
}
/**
- * Checks if the given file path exists inside the file structure.
- * Reports an error if the file was not found.
+ * Checks if the given file path exists inside the file structure. Reports an error if the file was not found.
*
- * @param filePath file path to check inside the file structure
- * @param errorMsg the error message to report
- * @return
- * {@code true} if the file exists, {@code false} otherwise
+ * @param filePath file path to check inside the file structure
+ * @param errorMsg the error message to report
+ * @return {@code true} if the file exists, {@code false} otherwise
*/
private boolean checkFileExists(final String filePath, final String errorMsg) {
if (!fileMap.containsKey(filePath)) {
reportError(ErrorLevel.ERROR, errorMsg);
return false;
}
-
return true;
}
/**
* Adds an error to the validation error list.
*
- * @param errorLevel the error level
- * @param errorMessage the error message
+ * @param errorLevel the error level
+ * @param errorMessage the error message
*/
private void reportError(final ErrorLevel errorLevel, final String errorMessage) {
validationErrorList.add(new ErrorMessage(errorLevel, errorMessage));
@@ -250,8 +226,8 @@ public class ToscaDefinitionImportHandler {
/**
* Gets the list of errors.
- * @return
- * The import validation errors detected
+ *
+ * @return The import validation errors detected
*/
public List<ErrorMessage> getErrors() {
return validationErrorList;
@@ -259,8 +235,8 @@ public class ToscaDefinitionImportHandler {
/**
* Checks if the handler detected a import error.
- * @return
- * {@code true} if the handler detected any error, {@code false} otherwise.
+ *
+ * @return {@code true} if the handler detected any error, {@code false} otherwise.
*/
public boolean hasError() {
return !validationErrorList.isEmpty();
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaSolConverterVnf.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaSolConverterVnf.java
index 7d2a38f4f0..e43ed5383a 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaSolConverterVnf.java
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaSolConverterVnf.java
@@ -19,7 +19,6 @@
* * ============LICENSE_END=========================================================
*
*/
-
package org.openecomp.core.impl;
import org.onap.sdc.tosca.datatypes.model.ServiceTemplate;
@@ -31,5 +30,4 @@ public class ToscaSolConverterVnf extends AbstractToscaSolConverter {
public void convertTopologyTemplate(ServiceTemplate serviceTemplate, ServiceTemplateReaderService readerService) {
new VnfTopologyTemplateConverter().convertTopologyTemplate(serviceTemplate, readerService);
}
-
}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaSolModelDrivenConverterPnf.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaSolModelDrivenConverterPnf.java
index b861980f24..425c57aeb9 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaSolModelDrivenConverterPnf.java
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaSolModelDrivenConverterPnf.java
@@ -16,7 +16,6 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.core.impl;
import org.onap.sdc.tosca.datatypes.model.ServiceTemplate;
@@ -29,22 +28,19 @@ public class ToscaSolModelDrivenConverterPnf extends AbstractToscaSolConverter {
/**
* Calls the model driven engine to parse the onboarding PNF descriptor
+ *
* @param serviceTemplate
* @param readerService
*/
@Override
- public void convertTopologyTemplate(final ServiceTemplate serviceTemplate,
- final ServiceTemplateReaderService readerService) {
- final PnfdTransformationEngine pnfdTransformationEngine =
- new PnfdNodeTemplateTransformationEngine(readerService, serviceTemplate);
+ public void convertTopologyTemplate(final ServiceTemplate serviceTemplate, final ServiceTemplateReaderService readerService) {
+ final PnfdTransformationEngine pnfdTransformationEngine = new PnfdNodeTemplateTransformationEngine(readerService, serviceTemplate);
pnfdTransformationEngine.transform();
}
@Override
- protected void convertNodeTypes(final ServiceTemplate serviceTemplate,
- final ServiceTemplateReaderService readerService) {
- final PnfdTransformationEngine pnfdTransformationEngine =
- new PnfdNodeTypeTransformationEngine(readerService, serviceTemplate);
+ protected void convertNodeTypes(final ServiceTemplate serviceTemplate, final ServiceTemplateReaderService readerService) {
+ final PnfdTransformationEngine pnfdTransformationEngine = new PnfdNodeTypeTransformationEngine(readerService, serviceTemplate);
pnfdTransformationEngine.transform();
}
-} \ No newline at end of file
+}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/VnfTopologyTemplateConverter.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/VnfTopologyTemplateConverter.java
index dd7e11ab2b..ec7e493464 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/VnfTopologyTemplateConverter.java
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/VnfTopologyTemplateConverter.java
@@ -19,9 +19,20 @@
* * ============LICENSE_END=========================================================
*
*/
-
package org.openecomp.core.impl;
+import static org.openecomp.core.converter.datatypes.Constants.CAPABILITIES;
+import static org.openecomp.core.converter.datatypes.Constants.INPUTS;
+import static org.openecomp.core.converter.datatypes.Constants.NODE_FILTER;
+import static org.openecomp.core.converter.datatypes.Constants.NODE_TYPE;
+import static org.openecomp.core.converter.datatypes.Constants.OUTPUTS;
+import static org.openecomp.core.converter.datatypes.Constants.REQUIREMENTS;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
import org.apache.commons.collections.MapUtils;
import org.onap.sdc.tosca.datatypes.model.ArtifactDefinition;
import org.onap.sdc.tosca.datatypes.model.CapabilityAssignment;
@@ -39,19 +50,6 @@ import org.openecomp.core.converter.errors.SubstitutionMappingsConverterErrorBui
import org.openecomp.sdc.common.errors.CoreException;
import org.openecomp.sdc.tosca.services.DataModelUtil;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Optional;
-
-import static org.openecomp.core.converter.datatypes.Constants.CAPABILITIES;
-import static org.openecomp.core.converter.datatypes.Constants.INPUTS;
-import static org.openecomp.core.converter.datatypes.Constants.NODE_FILTER;
-import static org.openecomp.core.converter.datatypes.Constants.NODE_TYPE;
-import static org.openecomp.core.converter.datatypes.Constants.OUTPUTS;
-import static org.openecomp.core.converter.datatypes.Constants.REQUIREMENTS;
-
public class VnfTopologyTemplateConverter {
public void convertTopologyTemplate(ServiceTemplate serviceTemplate, ServiceTemplateReaderService readerService) {
@@ -72,28 +70,23 @@ public class VnfTopologyTemplateConverter {
addInputsOrOutputsToServiceTemplate(serviceTemplate, outputs, Constants.OUTPUTS);
}
- private void addInputsOrOutputsToServiceTemplate(ServiceTemplate serviceTemplate, Map<String, Object> mapToConvert,
- String inputsOrOutputs) {
+ private void addInputsOrOutputsToServiceTemplate(ServiceTemplate serviceTemplate, Map<String, Object> mapToConvert, String inputsOrOutputs) {
if (MapUtils.isEmpty(mapToConvert)) {
return;
}
-
for (Map.Entry<String, Object> entry : mapToConvert.entrySet()) {
- Optional<ParameterDefinition> parameterDefinition = ToscaConverterUtil.createObjectFromClass(entry.getKey(),
- entry.getValue(), ParameterDefinition.class);
-
+ Optional<ParameterDefinition> parameterDefinition = ToscaConverterUtil
+ .createObjectFromClass(entry.getKey(), entry.getValue(), ParameterDefinition.class);
parameterDefinition.ifPresent(parameterDefinitionValue -> {
- Optional<Object> defaultValue =
- ToscaConverterUtil.getDefaultValue(entry.getValue(), parameterDefinition.get());
+ Optional<Object> defaultValue = ToscaConverterUtil.getDefaultValue(entry.getValue(), parameterDefinition.get());
defaultValue.ifPresent(parameterDefinitionValue::set_default);
- addToServiceTemplateAccordingToSection(serviceTemplate, inputsOrOutputs, entry.getKey(),
- parameterDefinition.get());
+ addToServiceTemplateAccordingToSection(serviceTemplate, inputsOrOutputs, entry.getKey(), parameterDefinition.get());
});
}
}
- private void addToServiceTemplateAccordingToSection(ServiceTemplate serviceTemplate, String inputsOrOutputs,
- String parameterId, ParameterDefinition parameterDefinition) {
+ private void addToServiceTemplateAccordingToSection(ServiceTemplate serviceTemplate, String inputsOrOutputs, String parameterId,
+ ParameterDefinition parameterDefinition) {
if (inputsOrOutputs.equals(INPUTS)) {
DataModelUtil.addInputParameterToTopologyTemplate(serviceTemplate, parameterId, parameterDefinition);
} else if (inputsOrOutputs.equals(OUTPUTS)) {
@@ -106,7 +99,6 @@ public class VnfTopologyTemplateConverter {
if (MapUtils.isEmpty(nodeTemplates)) {
return;
}
-
for (Map.Entry<String, Object> nodeTemplateEntry : nodeTemplates.entrySet()) {
NodeTemplate nodeTemplate = convertNodeTemplate(nodeTemplateEntry.getValue());
DataModelUtil.addNodeTemplate(serviceTemplate, nodeTemplateEntry.getKey(), nodeTemplate);
@@ -115,7 +107,6 @@ public class VnfTopologyTemplateConverter {
private NodeTemplate convertNodeTemplate(Object candidateNodeTemplate) {
NodeTemplate nodeTemplate = new NodeTemplate();
-
Map<String, Object> nodeTemplateAsMap = (Map<String, Object>) candidateNodeTemplate;
nodeTemplate.setArtifacts((Map<String, ArtifactDefinition>) nodeTemplateAsMap.get("artifacts"));
nodeTemplate.setAttributes((Map<String, Object>) nodeTemplateAsMap.get("attributes"));
@@ -128,7 +119,6 @@ public class VnfTopologyTemplateConverter {
nodeTemplate.setRequirements((List<Map<String, RequirementAssignment>>) nodeTemplateAsMap.get("requirements"));
nodeTemplate.setType((String) nodeTemplateAsMap.get("type"));
nodeTemplate.setCapabilities(convertCapabilities((Map<String, Object>) nodeTemplateAsMap.get("capabilities")));
-
return nodeTemplate;
}
@@ -136,23 +126,17 @@ public class VnfTopologyTemplateConverter {
if (MapUtils.isEmpty(capabilities)) {
return null;
}
-
Map<String, CapabilityAssignment> convertedCapabilities = new HashMap<>();
for (Map.Entry<String, Object> capabilityAssignmentEntry : capabilities.entrySet()) {
- Optional<CapabilityAssignment> capabilityAssignment = ToscaConverterUtil.createObjectFromClass(
- capabilityAssignmentEntry.getKey(), capabilityAssignmentEntry.getValue(),
- CapabilityAssignment.class);
-
- capabilityAssignment.ifPresent(capabilityAssignmentValue -> convertedCapabilities
- .put(capabilityAssignmentEntry.getKey(),
- capabilityAssignmentValue));
-
+ Optional<CapabilityAssignment> capabilityAssignment = ToscaConverterUtil
+ .createObjectFromClass(capabilityAssignmentEntry.getKey(), capabilityAssignmentEntry.getValue(), CapabilityAssignment.class);
+ capabilityAssignment
+ .ifPresent(capabilityAssignmentValue -> convertedCapabilities.put(capabilityAssignmentEntry.getKey(), capabilityAssignmentValue));
}
return convertedCapabilities;
}
- private void convertSubstitutionMappings(ServiceTemplate serviceTemplate,
- ServiceTemplateReaderService readerService) {
+ private void convertSubstitutionMappings(ServiceTemplate serviceTemplate, ServiceTemplateReaderService readerService) {
Map<String, Object> substitutionMappings = readerService.getSubstitutionMappings();
if (MapUtils.isEmpty(substitutionMappings)) {
return;
@@ -163,53 +147,41 @@ public class VnfTopologyTemplateConverter {
private SubstitutionMapping convertSubstitutionMappings(Map<String, Object> substitutionMappings) {
SubstitutionMapping substitutionMapping = new SubstitutionMapping();
-
substitutionMapping.setNode_type((String) substitutionMappings.get(NODE_TYPE));
- substitutionMapping.setCapabilities(
- convertSubstitutionMappingsSections(CAPABILITIES, substitutionMappings.get(CAPABILITIES)));
- substitutionMapping.setRequirements(
- convertSubstitutionMappingsSections(REQUIREMENTS, substitutionMappings.get(REQUIREMENTS)));
+ substitutionMapping.setCapabilities(convertSubstitutionMappingsSections(CAPABILITIES, substitutionMappings.get(CAPABILITIES)));
+ substitutionMapping.setRequirements(convertSubstitutionMappingsSections(REQUIREMENTS, substitutionMappings.get(REQUIREMENTS)));
substitutionMapping.setSubstitution_filter((NodeFilter) substitutionMappings.get(NODE_FILTER));
-
return substitutionMapping;
}
private Map<String, List<String>> convertSubstitutionMappingsSections(String sectionName, Object sectionToConvert) {
-
if (Objects.isNull(sectionToConvert)) {
return null;
}
-
if (!(sectionToConvert instanceof Map)) {
- throw new CoreException(new SubstitutionMappingsConverterErrorBuilder(sectionName,
- sectionToConvert.getClass().getSimpleName()).build());
+ throw new CoreException(new SubstitutionMappingsConverterErrorBuilder(sectionName, sectionToConvert.getClass().getSimpleName()).build());
}
-
return convertSection(sectionToConvert);
}
private Map<String, List<String>> convertSection(Object sectionToConvert) {
-
Map<String, Object> sectionAsMap = (Map<String, Object>) sectionToConvert;
Map<String, List<String>> convertedSection = new HashMap<>();
-
if (MapUtils.isEmpty(sectionAsMap)) {
return null;
}
-
for (Map.Entry<String, Object> entry : sectionAsMap.entrySet()) {
if (entry.getValue() instanceof List) {
convertedSection.put(entry.getKey(), (List<String>) entry.getValue());
}
}
-
return convertedSection;
}
private void convertPolicies(ServiceTemplate serviceTemplate, ServiceTemplateReaderService readerService) {
List<Object> policiesList = readerService.getPolicies();
- policiesList.forEach(policiesListItem -> ((Map<String, Object>) policiesListItem).forEach((key, value) ->
- DataModelUtil.addPolicyDefinition(serviceTemplate, key, convertPolicy(value))));
+ policiesList.forEach(policiesListItem -> ((Map<String, Object>) policiesListItem)
+ .forEach((key, value) -> DataModelUtil.addPolicyDefinition(serviceTemplate, key, convertPolicy(value))));
}
private PolicyDefinition convertPolicy(Object policyCandidate) {
@@ -221,7 +193,6 @@ public class VnfTopologyTemplateConverter {
policyDefinition.setProperties((Map<String, Object>) policy.get("properties"));
policyDefinition.setTargets((List<String>) policy.get("targets"));
policyDefinition.setTriggers((Map<String, Trigger>) policy.get("triggers"));
-
return policyDefinition;
}
}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/factory/ToscaConverterFactoryImpl.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/factory/ToscaConverterFactoryImpl.java
index d585868365..1e8a83e172 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/factory/ToscaConverterFactoryImpl.java
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/factory/ToscaConverterFactoryImpl.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.core.impl.factory;
import org.openecomp.core.converter.ToscaConverter;
@@ -25,8 +24,9 @@ import org.openecomp.core.converter.factory.ToscaConverterFactory;
import org.openecomp.core.impl.ToscaConverterImpl;
public class ToscaConverterFactoryImpl extends ToscaConverterFactory {
- @Override
- public ToscaConverter createInterface() {
- return new ToscaConverterImpl();
- }
+
+ @Override
+ public ToscaConverter createInterface() {
+ return new ToscaConverterImpl();
+ }
}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/services/ServiceTemplateReaderServiceImpl.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/services/ServiceTemplateReaderServiceImpl.java
index 9cd2d7ea07..421aeb60d2 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/services/ServiceTemplateReaderServiceImpl.java
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/services/ServiceTemplateReaderServiceImpl.java
@@ -17,15 +17,14 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.core.impl.services;
-import static org.openecomp.core.converter.datatypes.Constants.POLICIES;
import static org.openecomp.core.converter.datatypes.Constants.INPUTS;
import static org.openecomp.core.converter.datatypes.Constants.METADATA;
import static org.openecomp.core.converter.datatypes.Constants.NODE_TEMPLATES;
import static org.openecomp.core.converter.datatypes.Constants.NODE_TYPES;
import static org.openecomp.core.converter.datatypes.Constants.OUTPUTS;
+import static org.openecomp.core.converter.datatypes.Constants.POLICIES;
import static org.openecomp.core.converter.datatypes.Constants.SUBSTITUTION_MAPPINGS;
import static org.openecomp.core.converter.datatypes.Constants.TOPOLOGY_TEMPLATE;
import static org.openecomp.sdc.be.utils.TypeUtils.ToscaTagNamesEnum.DATA_TYPES;
@@ -63,8 +62,7 @@ public class ServiceTemplateReaderServiceImpl implements ServiceTemplateReaderSe
@Override
public List<Object> getPolicies() {
List<Object> policiesList = new ArrayList<>();
- if (Objects.nonNull(this.getTopologyTemplate()) && Objects.nonNull(
- ((Map<String, Object>) this.getTopologyTemplate()).get(POLICIES))) {
+ if (Objects.nonNull(this.getTopologyTemplate()) && Objects.nonNull(((Map<String, Object>) this.getTopologyTemplate()).get(POLICIES))) {
policiesList = (List<Object>) ((Map<String, Object>) this.getTopologyTemplate()).get(POLICIES);
}
return policiesList;
@@ -112,8 +110,7 @@ public class ServiceTemplateReaderServiceImpl implements ServiceTemplateReaderSe
@Override
public Map<String, Object> getSubstitutionMappings() {
return Objects.isNull(this.getTopologyTemplate()) ? new HashMap<>()
- : (Map<String, Object>) ((Map<String, Object>) this.getTopologyTemplate())
- .get(SUBSTITUTION_MAPPINGS);
+ : (Map<String, Object>) ((Map<String, Object>) this.getTopologyTemplate()).get(SUBSTITUTION_MAPPINGS);
}
@Override