summaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl')
-rw-r--r--openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/EnrichmentInfo.java11
-rw-r--r--openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/factory/EnricherHandlerFactory.java7
-rw-r--r--openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/EnricherHandlerFactoryImpl.java6
-rw-r--r--openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/EnricherHandlerImpl.java11
-rw-r--r--openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/external/artifact/ExternalArtifactEnricher.java69
-rw-r--r--openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/external/artifact/MonitoringMibEnricher.java377
-rw-r--r--openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/external/artifact/ProcessArtifactEnricher.java153
-rw-r--r--openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/external/artifact/VspInformationArtifactEnricher.java102
-rw-r--r--openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/AbstractSubstituteToscaEnricher.java169
-rw-r--r--openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/ComponentQuestionnaireData.java155
-rw-r--r--openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/PortMirroringEnricher.java125
-rw-r--r--openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/ToscaEnricher.java75
-rw-r--r--openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/model/PortMirroringConnectionPointDescription.java154
-rw-r--r--openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/util/EnrichmentConstants.java23
-rw-r--r--openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/inter/Enricher.java8
-rw-r--r--openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/inter/EnricherHandler.java6
-rw-r--r--openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/inter/ExternalArtifactEnricherInterface.java17
17 files changed, 608 insertions, 860 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/EnrichmentInfo.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/EnrichmentInfo.java
index 8f3798f764..15d0e12d39 100644
--- a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/EnrichmentInfo.java
+++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/EnrichmentInfo.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,17 +17,16 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.enrichment;
-import org.openecomp.core.enrichment.types.EntityInfo;
-import org.openecomp.sdc.versioning.dao.types.Version;
-
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import org.openecomp.core.enrichment.types.EntityInfo;
+import org.openecomp.sdc.versioning.dao.types.Version;
public class EnrichmentInfo {
+
Map<String, List<Object>> additionalInfo = new HashMap<>();
Map<String, EntityInfo> entitiesInfo = new HashMap<>();
String key;
diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/factory/EnricherHandlerFactory.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/factory/EnricherHandlerFactory.java
index 1167a6df9a..2c05055a90 100644
--- a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/factory/EnricherHandlerFactory.java
+++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/factory/EnricherHandlerFactory.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,15 +17,12 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.enrichment.factory;
-
import org.openecomp.core.factory.api.AbstractComponentFactory;
import org.openecomp.core.factory.api.AbstractFactory;
import org.openecomp.sdc.enrichment.inter.EnricherHandler;
-
public abstract class EnricherHandlerFactory extends AbstractComponentFactory<EnricherHandler> {
public static EnricherHandlerFactory getInstance() {
diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/EnricherHandlerFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/EnricherHandlerFactoryImpl.java
index 9898ef678a..197256ecb5 100644
--- a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/EnricherHandlerFactoryImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/EnricherHandlerFactoryImpl.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,10 +17,8 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.enrichment.impl;
-
import org.openecomp.sdc.enrichment.factory.EnricherHandlerFactory;
import org.openecomp.sdc.enrichment.inter.EnricherHandler;
diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/EnricherHandlerImpl.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/EnricherHandlerImpl.java
index c9d89ee38f..08e61ed3cf 100644
--- a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/EnricherHandlerImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/EnricherHandlerImpl.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,9 +17,10 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.enrichment.impl;
+import java.util.ArrayList;
+import java.util.List;
import org.openecomp.sdc.enrichment.impl.external.artifact.ExternalArtifactEnricher;
import org.openecomp.sdc.enrichment.impl.tosca.ToscaEnricher;
import org.openecomp.sdc.enrichment.inter.Enricher;
@@ -27,9 +28,6 @@ import org.openecomp.sdc.enrichment.inter.EnricherHandler;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
-import java.util.ArrayList;
-import java.util.List;
-
public class EnricherHandlerImpl implements EnricherHandler {
private static Logger logger = (Logger) LoggerFactory.getLogger(EnricherHandlerImpl.class);
@@ -41,5 +39,4 @@ public class EnricherHandlerImpl implements EnricherHandler {
enricherList.add(new ExternalArtifactEnricher());
return enricherList;
}
-
}
diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/external/artifact/ExternalArtifactEnricher.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/external/artifact/ExternalArtifactEnricher.java
index 49ba6148c0..faa377c4d3 100644
--- a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/external/artifact/ExternalArtifactEnricher.java
+++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/external/artifact/ExternalArtifactEnricher.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,9 +17,13 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.enrichment.impl.external.artifact;
+import java.lang.reflect.Constructor;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import org.openecomp.core.utilities.file.FileUtils;
import org.openecomp.core.utilities.json.JsonUtil;
import org.openecomp.sdc.datatypes.error.ErrorMessage;
@@ -27,41 +31,30 @@ import org.openecomp.sdc.enrichment.inter.Enricher;
import org.openecomp.sdc.enrichment.inter.ExternalArtifactEnricherInterface;
import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
-import java.lang.reflect.Constructor;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
public class ExternalArtifactEnricher extends Enricher {
- private static final String EXTERNAL_ARTIFACT_ENRICH_CONF_FILE = "ExternalArtifactConfiguration"
- + ".json";
- private static Collection<String> implementingClasses =
- getExternalArtifactEnrichedImplClassesList();
-
- private static Collection<String> getExternalArtifactEnrichedImplClassesList() {
- @SuppressWarnings("unchecked")
- Map<String, String> confFileAsMap = FileUtils.readViaInputStream(EXTERNAL_ARTIFACT_ENRICH_CONF_FILE,
- stream -> JsonUtil.json2Object(stream, Map.class));
-
- return confFileAsMap.values();
- }
-
- @Override
- public Map<String, List<ErrorMessage>> enrich() throws Exception{
- Map<String, List<ErrorMessage>> errors = new HashMap<>();
-
- for (String implementingClassName : implementingClasses) {
- ExternalArtifactEnricherInterface externalArtifactEnricherInstance = getExternalArtifactEnricherInstance(implementingClassName);
- errors.putAll(externalArtifactEnricherInstance.enrich(this.data, (ToscaServiceModel) this.model));
- }
- return errors;
- }
- private ExternalArtifactEnricherInterface getExternalArtifactEnricherInstance(
- String implementingClassName) throws Exception {
- Class<?> clazz = Class.forName(implementingClassName);
- Constructor<?> constructor = clazz.getConstructor();
- return (ExternalArtifactEnricherInterface) constructor.newInstance();
- }
+ private static final String EXTERNAL_ARTIFACT_ENRICH_CONF_FILE = "ExternalArtifactConfiguration" + ".json";
+ private static Collection<String> implementingClasses = getExternalArtifactEnrichedImplClassesList();
+
+ private static Collection<String> getExternalArtifactEnrichedImplClassesList() {
+ @SuppressWarnings("unchecked") Map<String, String> confFileAsMap = FileUtils
+ .readViaInputStream(EXTERNAL_ARTIFACT_ENRICH_CONF_FILE, stream -> JsonUtil.json2Object(stream, Map.class));
+ return confFileAsMap.values();
+ }
+
+ @Override
+ public Map<String, List<ErrorMessage>> enrich() throws Exception {
+ Map<String, List<ErrorMessage>> errors = new HashMap<>();
+ for (String implementingClassName : implementingClasses) {
+ ExternalArtifactEnricherInterface externalArtifactEnricherInstance = getExternalArtifactEnricherInstance(implementingClassName);
+ errors.putAll(externalArtifactEnricherInstance.enrich(this.data, (ToscaServiceModel) this.model));
+ }
+ return errors;
+ }
+
+ private ExternalArtifactEnricherInterface getExternalArtifactEnricherInstance(String implementingClassName) throws Exception {
+ Class<?> clazz = Class.forName(implementingClassName);
+ Constructor<?> constructor = clazz.getConstructor();
+ return (ExternalArtifactEnricherInterface) constructor.newInstance();
+ }
}
diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/external/artifact/MonitoringMibEnricher.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/external/artifact/MonitoringMibEnricher.java
index 34954bdbbb..06a5b3a2c2 100644
--- a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/external/artifact/MonitoringMibEnricher.java
+++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/external/artifact/MonitoringMibEnricher.java
@@ -12,8 +12,7 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
-*/
-
+ */
package org.openecomp.sdc.enrichment.impl.external.artifact;
import static org.openecomp.sdc.tosca.services.ToscaConstants.SERVICE_TEMPLATE_FILTER_PROPERTY_NAME;
@@ -61,251 +60,187 @@ import org.openecomp.sdc.versioning.dao.types.Version;
public class MonitoringMibEnricher implements ExternalArtifactEnricherInterface {
- private EnrichedServiceModelDao enrichedServiceModelDao;
- private ComponentDao componentDao;
- private ComponentArtifactDao componentArtifactDao;
- private static final String COMPONENT_PREFIX = "org.openecomp.resource.vfc.";
-
- private final Logger log = LoggerFactory.getLogger(this.getClass().getName());
-
- /**
- * Enrich map.
- *
- * @param enrichmentInfo the enrichmentInfo
- * @return the map
- */
- @Override
- public Map<String, List<ErrorMessage>> enrich(EnrichmentInfo enrichmentInfo,
- ToscaServiceModel serviceModel) {
-
- Map<String, List<ErrorMessage>> errors = new HashMap<>();
- String vspId = enrichmentInfo.getKey();
- Version version = enrichmentInfo.getVersion();
-
- Collection<ComponentEntity> components =
- getComponentDao().list(new ComponentEntity(vspId, version, null));
- components
- .forEach(componentEntry -> errors.putAll(enrichComponent(vspId, version, componentEntry,
- serviceModel)));
-
- return errors;
- }
-
- private Map<String, List<ErrorMessage>> enrichComponent(String vspId,
- Version version,
- ComponentEntity component,
- ToscaServiceModel serviceModel) {
- Set<String> abstractNodeTypes =
- extractAbstractTypesFromSameTypeFromServiceModel(component, serviceModel);
- return enrichComponent(vspId, version, component, abstractNodeTypes);
- }
-
- private Set<String> extractAbstractTypesFromSameTypeFromServiceModel(ComponentEntity component,
- ToscaServiceModel serviceModel) {
- Set<String> abstractNodeTypes = new HashSet<>();
- Map<String, ServiceTemplate> serviceTemplates = serviceModel.getServiceTemplates();
- String typeToCheck =
- getComponentVfcTypeToCheck(component.getComponentCompositionData().getName());
-
- for (ServiceTemplate serviceTemplate : serviceTemplates.values()) {
- collectAllAbstractNodeTypesPointingToType(
- typeToCheck, serviceTemplate, serviceTemplates, abstractNodeTypes);
+ private static final String COMPONENT_PREFIX = "org.openecomp.resource.vfc.";
+ private final Logger log = LoggerFactory.getLogger(this.getClass().getName());
+ private EnrichedServiceModelDao enrichedServiceModelDao;
+ private ComponentDao componentDao;
+ private ComponentArtifactDao componentArtifactDao;
+
+ /**
+ * Enrich map.
+ *
+ * @param enrichmentInfo the enrichmentInfo
+ * @return the map
+ */
+ @Override
+ public Map<String, List<ErrorMessage>> enrich(EnrichmentInfo enrichmentInfo, ToscaServiceModel serviceModel) {
+ Map<String, List<ErrorMessage>> errors = new HashMap<>();
+ String vspId = enrichmentInfo.getKey();
+ Version version = enrichmentInfo.getVersion();
+ Collection<ComponentEntity> components = getComponentDao().list(new ComponentEntity(vspId, version, null));
+ components.forEach(componentEntry -> errors.putAll(enrichComponent(vspId, version, componentEntry, serviceModel)));
+ return errors;
}
- return abstractNodeTypes;
- }
-
- private String getComponentVfcTypeToCheck(String type) {
- return Objects.isNull(type) ? ""
- : type.replace(COMPONENT_PREFIX, COMPONENT_PREFIX + "compute.");
- }
-
- private void collectAllAbstractNodeTypesPointingToType(String typeToCheck,
- ServiceTemplate serviceTemplate,
- Map<String, ServiceTemplate> serviceTemplates,
- Set<String> abstractNodeTypes) {
- Map<String, NodeTemplate> nodeTemplates =
- DataModelUtil.getNodeTemplates(serviceTemplate);
-
- for (Map.Entry<String, NodeTemplate> nodeTemplateEntry : nodeTemplates.entrySet()) {
- handleNodeTemplate(nodeTemplateEntry.getValue(), typeToCheck,
- serviceTemplates, abstractNodeTypes);
+ private Map<String, List<ErrorMessage>> enrichComponent(String vspId, Version version, ComponentEntity component,
+ ToscaServiceModel serviceModel) {
+ Set<String> abstractNodeTypes = extractAbstractTypesFromSameTypeFromServiceModel(component, serviceModel);
+ return enrichComponent(vspId, version, component, abstractNodeTypes);
}
- }
- private void handleNodeTemplate(NodeTemplate nodeTemplate,
- String typeToCheck,
- Map<String, ServiceTemplate> serviceTemplates,
- Set<String> abstractNodeTypes) {
- List<String> directives = DataModelUtil.getDirectives(nodeTemplate);
- if (directives.contains(Directive.SUBSTITUTABLE.getDisplayName())) {
- handleSubstitutionServiceTemplate(typeToCheck, nodeTemplate, serviceTemplates,
- abstractNodeTypes);
+ private Set<String> extractAbstractTypesFromSameTypeFromServiceModel(ComponentEntity component, ToscaServiceModel serviceModel) {
+ Set<String> abstractNodeTypes = new HashSet<>();
+ Map<String, ServiceTemplate> serviceTemplates = serviceModel.getServiceTemplates();
+ String typeToCheck = getComponentVfcTypeToCheck(component.getComponentCompositionData().getName());
+ for (ServiceTemplate serviceTemplate : serviceTemplates.values()) {
+ collectAllAbstractNodeTypesPointingToType(typeToCheck, serviceTemplate, serviceTemplates, abstractNodeTypes);
+ }
+ return abstractNodeTypes;
}
- }
- private void handleSubstitutionServiceTemplate(String typeToCheck,
- NodeTemplate nodeTemplate,
- Map<String, ServiceTemplate> serviceTemplates,
- Set<String> abstractNodeTypes) {
- Object serviceTemplateFilter =
- DataModelUtil.getPropertyValue(nodeTemplate, SERVICE_TEMPLATE_FILTER_PROPERTY_NAME);
- if (Objects.nonNull(serviceTemplateFilter) && serviceTemplateFilter instanceof Map) {
- String substituteServiceTemplateName =
- (String) ((Map<String, Object>) serviceTemplateFilter)
- .get(SUBSTITUTE_SERVICE_TEMPLATE_PROPERTY_NAME);
- ServiceTemplate substituteServiceTemplate =
- serviceTemplates.get(substituteServiceTemplateName);
- if (doesNodeTypeExistInSubServiceTemplate(typeToCheck, substituteServiceTemplate)) {
- abstractNodeTypes.add(nodeTemplate.getType());
- }
+ private String getComponentVfcTypeToCheck(String type) {
+ return Objects.isNull(type) ? "" : type.replace(COMPONENT_PREFIX, COMPONENT_PREFIX + "compute.");
}
- }
-
- private boolean doesNodeTypeExistInSubServiceTemplate(String nodeTypeId,
- ServiceTemplate substituteServiceTemplate) {
- return Objects
- .nonNull(DataModelUtil.getNodeType(substituteServiceTemplate, nodeTypeId));
- }
-
- Map<String, List<ErrorMessage>> enrichComponent(String vspId,
- Version version,
- ComponentEntity componentEntry,
- Set<String> abstractNodeTypes) {
- Map<String, List<ErrorMessage>> errors = new HashMap<>();
- List<ComponentMonitoringUploadInfo> componentMonitoringUploadInfoList =
- extractComponentMibInfo(vspId, version, componentEntry, abstractNodeTypes);
-
- componentMonitoringUploadInfoList.forEach(
- componentUploadInfo -> enrichComponentMib(vspId, version, componentUploadInfo, errors));
- return errors;
- }
-
- private List<ComponentMonitoringUploadInfo> extractComponentMibInfo(String vspId, Version version,
- ComponentEntity componentEntity,
- Set<String> abstractNodeTypes) {
- String componentId = componentEntity.getId();
- ComponentMonitoringUploadEntity entity = new ComponentMonitoringUploadEntity();
-
- entity.setVspId(vspId);
- entity.setVersion(version);
- entity.setComponentId(componentId);
- List<ComponentMonitoringUploadInfo> componentMonitoringUploadInfoList = new ArrayList<>();
-
- abstractNodeTypes.forEach(unifiedComponentNodeType -> componentMonitoringUploadInfoList
- .add(updComponentMibInfoByType(unifiedComponentNodeType, entity)));
- return componentMonitoringUploadInfoList;
- }
+ private void collectAllAbstractNodeTypesPointingToType(String typeToCheck, ServiceTemplate serviceTemplate,
+ Map<String, ServiceTemplate> serviceTemplates, Set<String> abstractNodeTypes) {
+ Map<String, NodeTemplate> nodeTemplates = DataModelUtil.getNodeTemplates(serviceTemplate);
+ for (Map.Entry<String, NodeTemplate> nodeTemplateEntry : nodeTemplates.entrySet()) {
+ handleNodeTemplate(nodeTemplateEntry.getValue(), typeToCheck, serviceTemplates, abstractNodeTypes);
+ }
+ }
- private ComponentMonitoringUploadInfo updComponentMibInfoByType(String componentName,
- ComponentMonitoringUploadEntity componentMonitoringUploadEntity) {
- ComponentMonitoringUploadInfo componentMonitoringUploadInfo =
- new ComponentMonitoringUploadInfo();
+ private void handleNodeTemplate(NodeTemplate nodeTemplate, String typeToCheck, Map<String, ServiceTemplate> serviceTemplates,
+ Set<String> abstractNodeTypes) {
+ List<String> directives = DataModelUtil.getDirectives(nodeTemplate);
+ if (directives.contains(Directive.SUBSTITUTABLE.getDisplayName())) {
+ handleSubstitutionServiceTemplate(typeToCheck, nodeTemplate, serviceTemplates, abstractNodeTypes);
+ }
+ }
- for (MonitoringUploadType type : MonitoringUploadType.values()) {
- componentMonitoringUploadEntity.setType(type);
- Optional<ComponentMonitoringUploadEntity> artifact =
- getComponentArtifactDao().getByType(componentMonitoringUploadEntity);
+ private void handleSubstitutionServiceTemplate(String typeToCheck, NodeTemplate nodeTemplate, Map<String, ServiceTemplate> serviceTemplates,
+ Set<String> abstractNodeTypes) {
+ Object serviceTemplateFilter = DataModelUtil.getPropertyValue(nodeTemplate, SERVICE_TEMPLATE_FILTER_PROPERTY_NAME);
+ if (Objects.nonNull(serviceTemplateFilter) && serviceTemplateFilter instanceof Map) {
+ String substituteServiceTemplateName = (String) ((Map<String, Object>) serviceTemplateFilter)
+ .get(SUBSTITUTE_SERVICE_TEMPLATE_PROPERTY_NAME);
+ ServiceTemplate substituteServiceTemplate = serviceTemplates.get(substituteServiceTemplateName);
+ if (doesNodeTypeExistInSubServiceTemplate(typeToCheck, substituteServiceTemplate)) {
+ abstractNodeTypes.add(nodeTemplate.getType());
+ }
+ }
+ }
- if (!artifact.isPresent()) {
- continue;
- }
- ComponentMonitoringUploadEntity mibArtifact = artifact.get();
- updateComponentMonitoringUploadInfoWithMib(getArtifactPath(type, componentName), type,
- mibArtifact,
- componentMonitoringUploadInfo);
+ private boolean doesNodeTypeExistInSubServiceTemplate(String nodeTypeId, ServiceTemplate substituteServiceTemplate) {
+ return Objects.nonNull(DataModelUtil.getNodeType(substituteServiceTemplate, nodeTypeId));
}
- return componentMonitoringUploadInfo;
- }
- private String getArtifactPath(MonitoringUploadType type, String unifiedComponentNodeType) {
- return unifiedComponentNodeType + File.separator + ArtifactCategory.DEPLOYMENT.getDisplayName()
- + File.separator + type.name();
- }
+ Map<String, List<ErrorMessage>> enrichComponent(String vspId, Version version, ComponentEntity componentEntry, Set<String> abstractNodeTypes) {
+ Map<String, List<ErrorMessage>> errors = new HashMap<>();
+ List<ComponentMonitoringUploadInfo> componentMonitoringUploadInfoList = extractComponentMibInfo(vspId, version, componentEntry,
+ abstractNodeTypes);
+ componentMonitoringUploadInfoList.forEach(componentUploadInfo -> enrichComponentMib(vspId, version, componentUploadInfo, errors));
+ return errors;
+ }
- private void updateComponentMonitoringUploadInfoWithMib(String path,
- MonitoringUploadType type,
- ComponentMonitoringUploadEntity mibArtifact,
- ComponentMonitoringUploadInfo componentMonitoringUploadInfo) {
- MonitoringArtifactInfo monitoringArtifactInfo = new MonitoringArtifactInfo();
- monitoringArtifactInfo.setName(path);
- monitoringArtifactInfo.setContent(mibArtifact.getArtifact().array());
- componentMonitoringUploadInfo.setMonitoringArtifactFile(type, monitoringArtifactInfo);
- }
+ private List<ComponentMonitoringUploadInfo> extractComponentMibInfo(String vspId, Version version, ComponentEntity componentEntity,
+ Set<String> abstractNodeTypes) {
+ String componentId = componentEntity.getId();
+ ComponentMonitoringUploadEntity entity = new ComponentMonitoringUploadEntity();
+ entity.setVspId(vspId);
+ entity.setVersion(version);
+ entity.setComponentId(componentId);
+ List<ComponentMonitoringUploadInfo> componentMonitoringUploadInfoList = new ArrayList<>();
+ abstractNodeTypes
+ .forEach(unifiedComponentNodeType -> componentMonitoringUploadInfoList.add(updComponentMibInfoByType(unifiedComponentNodeType, entity)));
+ return componentMonitoringUploadInfoList;
+ }
- private void enrichComponentMib(String vspId,
- Version version,
- ComponentMonitoringUploadInfo componentUploadInfo,
- Map<String, List<ErrorMessage>> errors) {
- ServiceArtifact mibServiceArtifact = new ServiceArtifact();
- mibServiceArtifact.setVspId(vspId);
- mibServiceArtifact.setVersion(version);
- enrichMibFiles(mibServiceArtifact, componentUploadInfo, errors);
- }
+ private ComponentMonitoringUploadInfo updComponentMibInfoByType(String componentName,
+ ComponentMonitoringUploadEntity componentMonitoringUploadEntity) {
+ ComponentMonitoringUploadInfo componentMonitoringUploadInfo = new ComponentMonitoringUploadInfo();
+ for (MonitoringUploadType type : MonitoringUploadType.values()) {
+ componentMonitoringUploadEntity.setType(type);
+ Optional<ComponentMonitoringUploadEntity> artifact = getComponentArtifactDao().getByType(componentMonitoringUploadEntity);
+ if (!artifact.isPresent()) {
+ continue;
+ }
+ ComponentMonitoringUploadEntity mibArtifact = artifact.get();
+ updateComponentMonitoringUploadInfoWithMib(getArtifactPath(type, componentName), type, mibArtifact, componentMonitoringUploadInfo);
+ }
+ return componentMonitoringUploadInfo;
+ }
- private void enrichMibFiles(ServiceArtifact monitoringArtifact,
- ComponentMonitoringUploadInfo componentMonitoringUploadInfo,
- Map<String, List<ErrorMessage>> errors) {
- if (componentMonitoringUploadInfo == null) {
- return;
+ private String getArtifactPath(MonitoringUploadType type, String unifiedComponentNodeType) {
+ return unifiedComponentNodeType + File.separator + ArtifactCategory.DEPLOYMENT.getDisplayName() + File.separator + type.name();
}
- enrichMibByType(componentMonitoringUploadInfo.getSnmpTrap(), MonitoringUploadType.SNMP_TRAP,
- monitoringArtifact,
- errors);
- enrichMibByType(componentMonitoringUploadInfo.getSnmpPoll(), MonitoringUploadType.SNMP_POLL,
- monitoringArtifact,
- errors);
- enrichMibByType(componentMonitoringUploadInfo.getVesEvent(), MonitoringUploadType.VES_EVENTS,
- monitoringArtifact,
- errors);
- }
- private void enrichMibByType(MonitoringArtifactInfo monitoringArtifactInfo,
- MonitoringUploadType type,
- ServiceArtifact mibServiceArtifact,
- Map<String, List<ErrorMessage>> errors) {
- if (monitoringArtifactInfo == null) {
- return;
+ private void updateComponentMonitoringUploadInfoWithMib(String path, MonitoringUploadType type, ComponentMonitoringUploadEntity mibArtifact,
+ ComponentMonitoringUploadInfo componentMonitoringUploadInfo) {
+ MonitoringArtifactInfo monitoringArtifactInfo = new MonitoringArtifactInfo();
+ monitoringArtifactInfo.setName(path);
+ monitoringArtifactInfo.setContent(mibArtifact.getArtifact().array());
+ componentMonitoringUploadInfo.setMonitoringArtifactFile(type, monitoringArtifactInfo);
}
- FileContentHandler mibs;
- try {
- mibs = FileUtils
- .getFileContentMapFromZip(FileUtils.toByteArray(monitoringArtifactInfo.getContent()));
- } catch (ZipException ex) {
- log.error("Failed to get file content map from zip ", ex);
- ErrorMessage.ErrorMessageUtil
- .addMessage(mibServiceArtifact.getName() + "." + type.name(), errors)
- .add(new ErrorMessage(ErrorLevel.ERROR, Messages.INVALID_ZIP_FILE.getErrorMessage()));
- return;
+
+ private void enrichComponentMib(String vspId, Version version, ComponentMonitoringUploadInfo componentUploadInfo,
+ Map<String, List<ErrorMessage>> errors) {
+ ServiceArtifact mibServiceArtifact = new ServiceArtifact();
+ mibServiceArtifact.setVspId(vspId);
+ mibServiceArtifact.setVersion(version);
+ enrichMibFiles(mibServiceArtifact, componentUploadInfo, errors);
}
- Set<String> fileList = mibs.getFileList();
- for (String fileName : fileList) {
- mibServiceArtifact.setContentData(mibs.getFileContent(fileName));
- mibServiceArtifact.setName(monitoringArtifactInfo.getName() + File.separator + fileName);
- getEnrichedServiceModelDao().storeExternalArtifact(mibServiceArtifact);
+
+ private void enrichMibFiles(ServiceArtifact monitoringArtifact, ComponentMonitoringUploadInfo componentMonitoringUploadInfo,
+ Map<String, List<ErrorMessage>> errors) {
+ if (componentMonitoringUploadInfo == null) {
+ return;
+ }
+ enrichMibByType(componentMonitoringUploadInfo.getSnmpTrap(), MonitoringUploadType.SNMP_TRAP, monitoringArtifact, errors);
+ enrichMibByType(componentMonitoringUploadInfo.getSnmpPoll(), MonitoringUploadType.SNMP_POLL, monitoringArtifact, errors);
+ enrichMibByType(componentMonitoringUploadInfo.getVesEvent(), MonitoringUploadType.VES_EVENTS, monitoringArtifact, errors);
}
- }
- private EnrichedServiceModelDao getEnrichedServiceModelDao() {
- if (enrichedServiceModelDao == null) {
- enrichedServiceModelDao = EnrichedServiceModelDaoFactory.getInstance().createInterface();
+ private void enrichMibByType(MonitoringArtifactInfo monitoringArtifactInfo, MonitoringUploadType type, ServiceArtifact mibServiceArtifact,
+ Map<String, List<ErrorMessage>> errors) {
+ if (monitoringArtifactInfo == null) {
+ return;
+ }
+ FileContentHandler mibs;
+ try {
+ mibs = FileUtils.getFileContentMapFromZip(FileUtils.toByteArray(monitoringArtifactInfo.getContent()));
+ } catch (ZipException ex) {
+ log.error("Failed to get file content map from zip ", ex);
+ ErrorMessage.ErrorMessageUtil.addMessage(mibServiceArtifact.getName() + "." + type.name(), errors)
+ .add(new ErrorMessage(ErrorLevel.ERROR, Messages.INVALID_ZIP_FILE.getErrorMessage()));
+ return;
+ }
+ Set<String> fileList = mibs.getFileList();
+ for (String fileName : fileList) {
+ mibServiceArtifact.setContentData(mibs.getFileContent(fileName));
+ mibServiceArtifact.setName(monitoringArtifactInfo.getName() + File.separator + fileName);
+ getEnrichedServiceModelDao().storeExternalArtifact(mibServiceArtifact);
+ }
}
- return enrichedServiceModelDao;
- }
- private ComponentDao getComponentDao() {
- if (componentDao == null) {
- componentDao = ComponentDaoFactory.getInstance().createInterface();
+ private EnrichedServiceModelDao getEnrichedServiceModelDao() {
+ if (enrichedServiceModelDao == null) {
+ enrichedServiceModelDao = EnrichedServiceModelDaoFactory.getInstance().createInterface();
+ }
+ return enrichedServiceModelDao;
}
- return componentDao;
- }
- private ComponentArtifactDao getComponentArtifactDao() {
- if (componentArtifactDao == null) {
- componentArtifactDao = MonitoringUploadDaoFactory.getInstance().createInterface();
+ private ComponentDao getComponentDao() {
+ if (componentDao == null) {
+ componentDao = ComponentDaoFactory.getInstance().createInterface();
+ }
+ return componentDao;
}
- return componentArtifactDao;
- }
+ private ComponentArtifactDao getComponentArtifactDao() {
+ if (componentArtifactDao == null) {
+ componentArtifactDao = MonitoringUploadDaoFactory.getInstance().createInterface();
+ }
+ return componentArtifactDao;
+ }
}
diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/external/artifact/ProcessArtifactEnricher.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/external/artifact/ProcessArtifactEnricher.java
index bade8ec66b..dd64bfb137 100644
--- a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/external/artifact/ProcessArtifactEnricher.java
+++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/external/artifact/ProcessArtifactEnricher.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,9 +17,14 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.enrichment.impl.external.artifact;
+import java.io.File;
+import java.io.IOException;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import org.openecomp.core.enrichment.types.ArtifactCategory;
import org.openecomp.core.enrichment.types.ComponentProcessInfo;
import org.openecomp.core.model.dao.EnrichedServiceModelDao;
@@ -39,99 +44,75 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessType;
import org.openecomp.sdc.versioning.dao.types.Version;
-import java.io.File;
-import java.io.IOException;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
public class ProcessArtifactEnricher implements ExternalArtifactEnricherInterface {
- private ComponentDao componentDao;
- private ProcessDao processDao;
- private EnrichedServiceModelDao enrichedServiceModelDao;
-
- @Override
- public Map<String, List<ErrorMessage>> enrich(EnrichmentInfo enrichmentInfo,
- ToscaServiceModel serviceModel) throws IOException {
- Map<String, List<ErrorMessage>> errors = new HashMap<>();
- String vspId = enrichmentInfo.getKey();
- Version version = enrichmentInfo.getVersion();
-
- Collection<ComponentEntity> components =
- getComponentDao().list(new ComponentEntity(vspId, version, null));
- components.forEach(componentEntry -> errors.putAll(enrichComponent(componentEntry,
- vspId, version)));
-
- return errors;
- }
-
- Map<String, List<ErrorMessage>> enrichComponent(ComponentEntity componentEntry, String vspId,
- Version version) {
- Map<String, List<ErrorMessage>> errors = new HashMap<>();
- enrichComponentProcessArtifact(componentEntry, vspId, version, errors);
- return errors;
- }
-
- void enrichComponentProcessArtifact(ComponentEntity componentEntity,
- String vspId, Version version,
- Map<String, List<ErrorMessage>> errors) {
- String componentId = componentEntity.getId();
- ProcessEntity processEntity = new ProcessEntity(vspId, version, componentId, null);
- final Collection<ProcessEntity> processes = getProcessDao().list(processEntity);
-
- processes.forEach(entity -> {
- ProcessEntity artifactEntity = new ProcessEntity(vspId, version,
- componentId, entity.getId());
-
- ProcessEntity artifactProcessEntity = getProcessDao().getArtifact(artifactEntity);
- if (artifactProcessEntity != null && ProcessType.Lifecycle_Operations.equals(
- artifactProcessEntity.getType())
- && artifactProcessEntity.getArtifactName() != null ) {
- String componentName = componentEntity.getComponentCompositionData().getName();
- String path = componentName + File.separator
- + ArtifactCategory.DEPLOYMENT.getDisplayName() + File.separator
- + "Lifecycle Operations" + File.separator + artifactProcessEntity.getArtifactName();
+ private ComponentDao componentDao;
+ private ProcessDao processDao;
+ private EnrichedServiceModelDao enrichedServiceModelDao;
+
+ @Override
+ public Map<String, List<ErrorMessage>> enrich(EnrichmentInfo enrichmentInfo, ToscaServiceModel serviceModel) throws IOException {
+ Map<String, List<ErrorMessage>> errors = new HashMap<>();
+ String vspId = enrichmentInfo.getKey();
+ Version version = enrichmentInfo.getVersion();
+ Collection<ComponentEntity> components = getComponentDao().list(new ComponentEntity(vspId, version, null));
+ components.forEach(componentEntry -> errors.putAll(enrichComponent(componentEntry, vspId, version)));
+ return errors;
+ }
- ComponentProcessInfo componentProcessInfo = new ComponentProcessInfo();
- componentProcessInfo.setName(path);
- componentProcessInfo.setContent(artifactProcessEntity.getArtifact().array());
+ Map<String, List<ErrorMessage>> enrichComponent(ComponentEntity componentEntry, String vspId, Version version) {
+ Map<String, List<ErrorMessage>> errors = new HashMap<>();
+ enrichComponentProcessArtifact(componentEntry, vspId, version, errors);
+ return errors;
+ }
- ServiceArtifact processServiceArtifact = new ServiceArtifact();
- processServiceArtifact.setVspId(vspId);
- processServiceArtifact.setVersion(version);
- enrichServiceArtifact(componentProcessInfo, processServiceArtifact);
- }
+ void enrichComponentProcessArtifact(ComponentEntity componentEntity, String vspId, Version version, Map<String, List<ErrorMessage>> errors) {
+ String componentId = componentEntity.getId();
+ ProcessEntity processEntity = new ProcessEntity(vspId, version, componentId, null);
+ final Collection<ProcessEntity> processes = getProcessDao().list(processEntity);
+ processes.forEach(entity -> {
+ ProcessEntity artifactEntity = new ProcessEntity(vspId, version, componentId, entity.getId());
+ ProcessEntity artifactProcessEntity = getProcessDao().getArtifact(artifactEntity);
+ if (artifactProcessEntity != null && ProcessType.Lifecycle_Operations.equals(artifactProcessEntity.getType())
+ && artifactProcessEntity.getArtifactName() != null) {
+ String componentName = componentEntity.getComponentCompositionData().getName();
+ String path = componentName + File.separator + ArtifactCategory.DEPLOYMENT.getDisplayName() + File.separator + "Lifecycle Operations"
+ + File.separator + artifactProcessEntity.getArtifactName();
+ ComponentProcessInfo componentProcessInfo = new ComponentProcessInfo();
+ componentProcessInfo.setName(path);
+ componentProcessInfo.setContent(artifactProcessEntity.getArtifact().array());
+ ServiceArtifact processServiceArtifact = new ServiceArtifact();
+ processServiceArtifact.setVspId(vspId);
+ processServiceArtifact.setVersion(version);
+ enrichServiceArtifact(componentProcessInfo, processServiceArtifact);
+ }
});
- }
-
- void enrichServiceArtifact(ComponentProcessInfo componentProcessInfo,
- ServiceArtifact processServiceArtifact) {
- processServiceArtifact.setName(componentProcessInfo.getName());
- processServiceArtifact.setContentData(FileUtils.toByteArray(componentProcessInfo.getContent()));
- getEnrichedServiceModelDao().storeExternalArtifact(processServiceArtifact);
- }
+ }
- private ComponentDao getComponentDao() {
- if (componentDao == null) {
- componentDao = ComponentDaoFactory.getInstance().createInterface();
+ void enrichServiceArtifact(ComponentProcessInfo componentProcessInfo, ServiceArtifact processServiceArtifact) {
+ processServiceArtifact.setName(componentProcessInfo.getName());
+ processServiceArtifact.setContentData(FileUtils.toByteArray(componentProcessInfo.getContent()));
+ getEnrichedServiceModelDao().storeExternalArtifact(processServiceArtifact);
}
- return componentDao;
- }
- private ProcessDao getProcessDao() {
- if (processDao == null) {
- processDao = ProcessDaoFactory.getInstance().createInterface();
+ private ComponentDao getComponentDao() {
+ if (componentDao == null) {
+ componentDao = ComponentDaoFactory.getInstance().createInterface();
+ }
+ return componentDao;
}
- return processDao;
- }
- private EnrichedServiceModelDao getEnrichedServiceModelDao() {
+ private ProcessDao getProcessDao() {
+ if (processDao == null) {
+ processDao = ProcessDaoFactory.getInstance().createInterface();
+ }
+ return processDao;
+ }
- if (enrichedServiceModelDao == null) {
- enrichedServiceModelDao = EnrichedServiceModelDaoFactory.getInstance().createInterface();
+ private EnrichedServiceModelDao getEnrichedServiceModelDao() {
+ if (enrichedServiceModelDao == null) {
+ enrichedServiceModelDao = EnrichedServiceModelDaoFactory.getInstance().createInterface();
+ }
+ return enrichedServiceModelDao;
}
- return enrichedServiceModelDao;
- }
}
diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/external/artifact/VspInformationArtifactEnricher.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/external/artifact/VspInformationArtifactEnricher.java
index 8f3c57f432..6be1b5f2cd 100644
--- a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/external/artifact/VspInformationArtifactEnricher.java
+++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/external/artifact/VspInformationArtifactEnricher.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,10 +17,16 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.enrichment.impl.external.artifact;
-
+import java.io.File;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
import org.openecomp.core.enrichment.types.ArtifactCategory;
import org.openecomp.core.enrichment.types.InformationArtifactFolderNames;
import org.openecomp.core.model.dao.EnrichedServiceModelDao;
@@ -39,70 +45,46 @@ import org.openecomp.sdc.vendorsoftwareproduct.factory.InformationArtifactGenera
import org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.InformationArtifactGenerator;
import org.openecomp.sdc.versioning.dao.types.Version;
-import java.io.File;
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.util.*;
-
/**
* Created by Talio on 11/24/2016
*/
public class VspInformationArtifactEnricher implements ExternalArtifactEnricherInterface {
- private static InformationArtifactGenerator informationArtifactGenerator =
- InformationArtifactGeneratorFactory.getInstance().createInterface();
- private EnrichedServiceModelDao enrichedServiceModelDao =
- EnrichedServiceModelDaoFactory.getInstance().createInterface();
- private VendorSoftwareProductInfoDao vspInfoDao = VendorSoftwareProductInfoDaoFactory
- .getInstance().createInterface();
-
- public VspInformationArtifactEnricher() {
- }
- public Map<String, List<ErrorMessage>> enrich(EnrichmentInfo enrichmentInfo,
- ToscaServiceModel serviceModel)
- throws IOException {
+ private static InformationArtifactGenerator informationArtifactGenerator = InformationArtifactGeneratorFactory.getInstance().createInterface();
+ private EnrichedServiceModelDao enrichedServiceModelDao = EnrichedServiceModelDaoFactory.getInstance().createInterface();
+ private VendorSoftwareProductInfoDao vspInfoDao = VendorSoftwareProductInfoDaoFactory.getInstance().createInterface();
- String vspId = enrichmentInfo.getKey();
- Version version = enrichmentInfo.getVersion();
- return enrichInformationArtifact(vspId, version);
- }
-
- private Map<String, List<ErrorMessage>> enrichInformationArtifact(String vspId, Version version)
- throws IOException {
- Map<String, List<ErrorMessage>> errors = new HashMap<>();
- ByteBuffer infoArtifactByteBuffer = ByteBuffer.wrap(informationArtifactGenerator.generate(
- vspId, version).getBytes());
-
- if (Objects.isNull(infoArtifactByteBuffer)) {
- List<ErrorMessage> errorList = new ArrayList<>();
- errorList.add(new ErrorMessage(ErrorLevel.ERROR, String.format(
- "Cannot enrich information artifact for vendor software product with id %s and version %s",
- vspId, version.toString())));
- return errors;
+ public VspInformationArtifactEnricher() {
}
- enrichInformationArtifact(vspId, version, infoArtifactByteBuffer);
- return errors;
- }
-
- private void enrichInformationArtifact(String vspId, Version version,
- ByteBuffer infoArtifactByteBuffer) {
- ServiceArtifact infoArtifactServiceArtifact = new ServiceArtifact();
-
- String vspName = vspInfoDao.get(new VspDetails(vspId, version)).getName();
-
- infoArtifactServiceArtifact.setVspId(vspId);
- infoArtifactServiceArtifact.setVersion(version);
- infoArtifactServiceArtifact
- .setName(ArtifactCategory.INFORMATIONAL.getDisplayName() + File.separator
- + InformationArtifactFolderNames.Guide + File.separator + String.format(
- VendorSoftwareProductConstants
- .INFORMATION_ARTIFACT_NAME,
- vspName));
- infoArtifactServiceArtifact.setContentData(infoArtifactByteBuffer.array());
-
- enrichedServiceModelDao.storeExternalArtifact(infoArtifactServiceArtifact);
+ public Map<String, List<ErrorMessage>> enrich(EnrichmentInfo enrichmentInfo, ToscaServiceModel serviceModel) throws IOException {
+ String vspId = enrichmentInfo.getKey();
+ Version version = enrichmentInfo.getVersion();
+ return enrichInformationArtifact(vspId, version);
+ }
- }
+ private Map<String, List<ErrorMessage>> enrichInformationArtifact(String vspId, Version version) throws IOException {
+ Map<String, List<ErrorMessage>> errors = new HashMap<>();
+ ByteBuffer infoArtifactByteBuffer = ByteBuffer.wrap(informationArtifactGenerator.generate(vspId, version).getBytes());
+ if (Objects.isNull(infoArtifactByteBuffer)) {
+ List<ErrorMessage> errorList = new ArrayList<>();
+ errorList.add(new ErrorMessage(ErrorLevel.ERROR, String
+ .format("Cannot enrich information artifact for vendor software product with id %s and version %s", vspId, version.toString())));
+ return errors;
+ }
+ enrichInformationArtifact(vspId, version, infoArtifactByteBuffer);
+ return errors;
+ }
+ private void enrichInformationArtifact(String vspId, Version version, ByteBuffer infoArtifactByteBuffer) {
+ ServiceArtifact infoArtifactServiceArtifact = new ServiceArtifact();
+ String vspName = vspInfoDao.get(new VspDetails(vspId, version)).getName();
+ infoArtifactServiceArtifact.setVspId(vspId);
+ infoArtifactServiceArtifact.setVersion(version);
+ infoArtifactServiceArtifact.setName(
+ ArtifactCategory.INFORMATIONAL.getDisplayName() + File.separator + InformationArtifactFolderNames.Guide + File.separator + String
+ .format(VendorSoftwareProductConstants.INFORMATION_ARTIFACT_NAME, vspName));
+ infoArtifactServiceArtifact.setContentData(infoArtifactByteBuffer.array());
+ enrichedServiceModelDao.storeExternalArtifact(infoArtifactServiceArtifact);
+ }
}
diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/AbstractSubstituteToscaEnricher.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/AbstractSubstituteToscaEnricher.java
index a6bb9323ee..7148d1b3d9 100644
--- a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/AbstractSubstituteToscaEnricher.java
+++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/AbstractSubstituteToscaEnricher.java
@@ -13,9 +13,29 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.sdc.enrichment.impl.tosca;
+import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.HIGH_AVAIL_MODE;
+import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.MANDATORY;
+import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.MAX_INSTANCES;
+import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.MIN_INSTANCES;
+import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.NFC_FUNCTION;
+import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.NFC_NAMING_CODE;
+import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.VFC_CODE;
+import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.VM_TYPE_TAG;
+import static org.openecomp.sdc.tosca.datatypes.ToscaCapabilityType.NATIVE_NODE;
+import static org.openecomp.sdc.tosca.datatypes.ToscaNodeType.MULTIDEPLOYMENTFLAVOR_NODE_TYPE;
+import static org.openecomp.sdc.tosca.datatypes.ToscaNodeType.VFC_ABSTRACT_SUBSTITUTE;
+import static org.openecomp.sdc.tosca.datatypes.ToscaRelationshipType.NATIVE_DEPENDS_ON;
+import static org.openecomp.sdc.tosca.services.ToscaConstants.SERVICE_TEMPLATE_FILTER_PROPERTY_NAME;
+import static org.openecomp.sdc.translator.services.heattotosca.Constants.VNF_NODE_TEMPLATE_ID_SUFFIX;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.onap.sdc.tosca.datatypes.model.NodeTemplate;
@@ -33,98 +53,51 @@ import org.openecomp.sdc.tosca.services.ToscaConstants;
import org.openecomp.sdc.tosca.services.impl.ToscaAnalyzerServiceImpl;
import org.openecomp.sdc.versioning.dao.types.Version;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Optional;
-
-import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.HIGH_AVAIL_MODE;
-import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.MANDATORY;
-import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.MAX_INSTANCES;
-import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.MIN_INSTANCES;
-import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.NFC_FUNCTION;
-import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.NFC_NAMING_CODE;
-import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.VFC_CODE;
-import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.VM_TYPE_TAG;
-import static org.openecomp.sdc.tosca.datatypes.ToscaCapabilityType.NATIVE_NODE;
-import static org.openecomp.sdc.tosca.datatypes.ToscaNodeType.MULTIDEPLOYMENTFLAVOR_NODE_TYPE;
-import static org.openecomp.sdc.tosca.datatypes.ToscaNodeType.VFC_ABSTRACT_SUBSTITUTE;
-import static org.openecomp.sdc.tosca.datatypes.ToscaRelationshipType.NATIVE_DEPENDS_ON;
-import static org.openecomp.sdc.tosca.services.ToscaConstants.SERVICE_TEMPLATE_FILTER_PROPERTY_NAME;
-import static org.openecomp.sdc.translator.services.heattotosca.Constants.VNF_NODE_TEMPLATE_ID_SUFFIX;
-
public class AbstractSubstituteToscaEnricher {
private ToscaAnalyzerService toscaAnalyzerService;
private ComponentQuestionnaireData componentQuestionnaireData;
-
public Map<String, List<ErrorMessage>> enrich(ToscaServiceModel toscaModel, String vspId, Version version) {
componentQuestionnaireData = getComponentQuestionnaireData();
toscaAnalyzerService = new ToscaAnalyzerServiceImpl();
-
- Map<String, Map<String, Object>> componentProperties =
- componentQuestionnaireData.getPropertiesfromCompQuestionnaire(vspId, version);
-
+ Map<String, Map<String, Object>> componentProperties = componentQuestionnaireData.getPropertiesfromCompQuestionnaire(vspId, version);
final Map<String, List<String>> sourceToTargetDependencies = componentQuestionnaireData
- .populateDependencies(vspId, version,
- componentQuestionnaireData
- .getSourceToTargetComponent());
+ .populateDependencies(vspId, version, componentQuestionnaireData.getSourceToTargetComponent());
Map<String, List<ErrorMessage>> errors = new HashMap<>();
-
- final ServiceTemplate serviceTemplate =
- toscaModel.getServiceTemplates().get(toscaModel.getEntryDefinitionServiceTemplate());
-
+ final ServiceTemplate serviceTemplate = toscaModel.getServiceTemplates().get(toscaModel.getEntryDefinitionServiceTemplate());
if (serviceTemplate == null) {
return errors;
}
-
final TopologyTemplate topologyTemplate = serviceTemplate.getTopology_template();
if (topologyTemplate == null) {
return errors;
}
-
final Map<String, NodeTemplate> nodeTemplates = serviceTemplate.getTopology_template().getNode_templates();
if (nodeTemplates == null) {
return errors;
}
-
- final Map<String, List<String>> componentDisplayNameToNodeTemplateIds =
- populateAllNodeTemplateIdForComponent(nodeTemplates, serviceTemplate, toscaModel);
-
+ final Map<String, List<String>> componentDisplayNameToNodeTemplateIds = populateAllNodeTemplateIdForComponent(nodeTemplates, serviceTemplate,
+ toscaModel);
nodeTemplates.keySet().forEach(nodeTemplateId -> {
- final NodeTemplate nodeTemplate =
- toscaAnalyzerService.getNodeTemplateById(serviceTemplate, nodeTemplateId).orElse(null);
-
- if (nodeTemplate != null && toscaAnalyzerService.isTypeOf(nodeTemplate, VFC_ABSTRACT_SUBSTITUTE,
- serviceTemplate, toscaModel)) {
-
+ final NodeTemplate nodeTemplate = toscaAnalyzerService.getNodeTemplateById(serviceTemplate, nodeTemplateId).orElse(null);
+ if (nodeTemplate != null && toscaAnalyzerService.isTypeOf(nodeTemplate, VFC_ABSTRACT_SUBSTITUTE, serviceTemplate, toscaModel)) {
String componentDisplayName = getComponentDisplayName(nodeTemplateId, nodeTemplate);
-
enrichProperties(nodeTemplate, componentDisplayName, componentProperties);
-
- enrichRequirements(sourceToTargetDependencies, componentDisplayName, nodeTemplate,
- componentDisplayNameToNodeTemplateIds, serviceTemplate, toscaModel);
+ enrichRequirements(sourceToTargetDependencies, componentDisplayName, nodeTemplate, componentDisplayNameToNodeTemplateIds,
+ serviceTemplate, toscaModel);
}
});
return errors;
}
- private void enrichProperties(NodeTemplate nodeTemplate, String componentDisplayName,
- Map<String, Map<String, Object>> componentProperties) {
+ private void enrichProperties(NodeTemplate nodeTemplate, String componentDisplayName, Map<String, Map<String, Object>> componentProperties) {
setProperty(nodeTemplate, VM_TYPE_TAG, componentDisplayName);
-
if (componentProperties != null && componentProperties.containsKey(componentDisplayName)) {
- final String mandatory =
- getValueFromQuestionnaireDetails(componentProperties, componentDisplayName, MANDATORY);
-
+ final String mandatory = getValueFromQuestionnaireDetails(componentProperties, componentDisplayName, MANDATORY);
boolean isServiceTemplateFilterNotExists = false;
if (!StringUtils.isEmpty(mandatory)) {
- Map<String, Object> innerProps = (Map<String, Object>) nodeTemplate.getProperties()
- .get(SERVICE_TEMPLATE_FILTER_PROPERTY_NAME);
-
+ Map<String, Object> innerProps = (Map<String, Object>) nodeTemplate.getProperties().get(SERVICE_TEMPLATE_FILTER_PROPERTY_NAME);
if (innerProps == null) {
innerProps = new HashMap<>();
isServiceTemplateFilterNotExists = true;
@@ -133,55 +106,31 @@ public class AbstractSubstituteToscaEnricher {
if (mandatoryValue.isPresent()) {
innerProps.put(MANDATORY, mandatoryValue.get());
}
-
if (isServiceTemplateFilterNotExists) {
nodeTemplate.getProperties().put(SERVICE_TEMPLATE_FILTER_PROPERTY_NAME, innerProps);
}
}
-
- setProperty(nodeTemplate, HIGH_AVAIL_MODE,
- getValueFromQuestionnaireDetails(componentProperties, componentDisplayName,
- HIGH_AVAIL_MODE));
-
- setProperty(nodeTemplate, NFC_NAMING_CODE,
- getValueFromQuestionnaireDetails(componentProperties, componentDisplayName,
- NFC_NAMING_CODE));
-
- setProperty(nodeTemplate, VFC_CODE,
- getValueFromQuestionnaireDetails(componentProperties, componentDisplayName, VFC_CODE));
-
- setProperty(nodeTemplate, NFC_FUNCTION,
- getValueFromQuestionnaireDetails(componentProperties, componentDisplayName, NFC_FUNCTION));
-
+ setProperty(nodeTemplate, HIGH_AVAIL_MODE, getValueFromQuestionnaireDetails(componentProperties, componentDisplayName, HIGH_AVAIL_MODE));
+ setProperty(nodeTemplate, NFC_NAMING_CODE, getValueFromQuestionnaireDetails(componentProperties, componentDisplayName, NFC_NAMING_CODE));
+ setProperty(nodeTemplate, VFC_CODE, getValueFromQuestionnaireDetails(componentProperties, componentDisplayName, VFC_CODE));
+ setProperty(nodeTemplate, NFC_FUNCTION, getValueFromQuestionnaireDetails(componentProperties, componentDisplayName, NFC_FUNCTION));
if (componentProperties.get(componentDisplayName).get(MIN_INSTANCES) != null) {
- nodeTemplate.getProperties().put(MIN_INSTANCES,
- componentProperties.get(componentDisplayName).get(MIN_INSTANCES));
+ nodeTemplate.getProperties().put(MIN_INSTANCES, componentProperties.get(componentDisplayName).get(MIN_INSTANCES));
}
-
if (componentProperties.get(componentDisplayName).get(MAX_INSTANCES) != null) {
- nodeTemplate.getProperties().put(MAX_INSTANCES,
- componentProperties.get(componentDisplayName).get(MAX_INSTANCES));
+ nodeTemplate.getProperties().put(MAX_INSTANCES, componentProperties.get(componentDisplayName).get(MAX_INSTANCES));
}
}
}
- private Map<String, List<String>> populateAllNodeTemplateIdForComponent(Map<String, NodeTemplate> nodeTemplates,
- ServiceTemplate serviceTemplate,
- ToscaServiceModel toscaModel) {
-
-
+ private Map<String, List<String>> populateAllNodeTemplateIdForComponent(Map<String, NodeTemplate> nodeTemplates, ServiceTemplate serviceTemplate,
+ ToscaServiceModel toscaModel) {
Map<String, List<String>> componentDisplayNameToNodeTempalteIds = new HashMap<>();
-
//set dependency target
nodeTemplates.keySet().forEach(nodeTemplateId -> {
- final NodeTemplate nodeTemplate =
- toscaAnalyzerService.getNodeTemplateById(serviceTemplate, nodeTemplateId).orElse(null);
-
- if (nodeTemplate != null &&
- toscaAnalyzerService.isTypeOf(nodeTemplate, VFC_ABSTRACT_SUBSTITUTE, serviceTemplate, toscaModel)) {
-
+ final NodeTemplate nodeTemplate = toscaAnalyzerService.getNodeTemplateById(serviceTemplate, nodeTemplateId).orElse(null);
+ if (nodeTemplate != null && toscaAnalyzerService.isTypeOf(nodeTemplate, VFC_ABSTRACT_SUBSTITUTE, serviceTemplate, toscaModel)) {
String componentDisplayName = getComponentDisplayName(nodeTemplateId, nodeTemplate);
-
if (componentDisplayNameToNodeTempalteIds.containsKey(componentDisplayName)) {
componentDisplayNameToNodeTempalteIds.get(componentDisplayName).add(nodeTemplateId);
} else {
@@ -189,49 +138,42 @@ public class AbstractSubstituteToscaEnricher {
nodeTemplateIds.add(nodeTemplateId);
componentDisplayNameToNodeTempalteIds.put(componentDisplayName, nodeTemplateIds);
}
-
}
});
-
return componentDisplayNameToNodeTempalteIds;
}
- private void enrichRequirements(Map<String, List<String>> sourceToTargetDependencies, String componentDisplayName,
- NodeTemplate nodeTemplate,
- Map<String, List<String>> componentDisplayNameToNodeTempalteIds,
- ServiceTemplate serviceTemplate, ToscaServiceModel toscaServiceModel) {
+ private void enrichRequirements(Map<String, List<String>> sourceToTargetDependencies, String componentDisplayName, NodeTemplate nodeTemplate,
+ Map<String, List<String>> componentDisplayNameToNodeTempalteIds, ServiceTemplate serviceTemplate,
+ ToscaServiceModel toscaServiceModel) {
final List<String> targets = sourceToTargetDependencies.get(componentDisplayName);
if (CollectionUtils.isEmpty(targets)) {
return;
}
-
for (String target : targets) {
List<String> targetNodeTemplateIds = componentDisplayNameToNodeTempalteIds.get(target);
if (CollectionUtils.isEmpty(targetNodeTemplateIds)) {
continue;
}
for (String targetNodeTemplateId : targetNodeTemplateIds) {
- Optional<String> dependencyRequirementKey =
- getDependencyRequirementKey(serviceTemplate, componentDisplayName, nodeTemplate,
- toscaServiceModel);
+ Optional<String> dependencyRequirementKey = getDependencyRequirementKey(serviceTemplate, componentDisplayName, nodeTemplate,
+ toscaServiceModel);
if (dependencyRequirementKey.isPresent()) {
RequirementAssignment requirementAssignment = new RequirementAssignment();
requirementAssignment.setCapability(NATIVE_NODE);
requirementAssignment.setRelationship(NATIVE_DEPENDS_ON);
requirementAssignment.setNode(targetNodeTemplateId);
- DataModelUtil.addRequirementAssignment(nodeTemplate, dependencyRequirementKey.get(),
- requirementAssignment);
+ DataModelUtil.addRequirementAssignment(nodeTemplate, dependencyRequirementKey.get(), requirementAssignment);
}
}
}
}
- private Optional<String> getDependencyRequirementKey(ServiceTemplate serviceTemplate, String componentDisplayName,
- NodeTemplate nodeTemplate,
- ToscaServiceModel toscaServiceModel) {
+ private Optional<String> getDependencyRequirementKey(ServiceTemplate serviceTemplate, String componentDisplayName, NodeTemplate nodeTemplate,
+ ToscaServiceModel toscaServiceModel) {
String nodeType = nodeTemplate.getType();
- NodeType flatNodeType = (NodeType) toscaAnalyzerService.getFlatEntity(ToscaElementTypes.NODE_TYPE, nodeType,
- serviceTemplate, toscaServiceModel).getFlatEntity();
+ NodeType flatNodeType = (NodeType) toscaAnalyzerService
+ .getFlatEntity(ToscaElementTypes.NODE_TYPE, nodeType, serviceTemplate, toscaServiceModel).getFlatEntity();
List<Map<String, RequirementDefinition>> flatNodeTypeRequirements = flatNodeType.getRequirements();
if (Objects.isNull(flatNodeTypeRequirements)) {
return Optional.empty();
@@ -259,14 +201,15 @@ public class AbstractSubstituteToscaEnricher {
return componentDisplayName;
}
- private String getValueFromQuestionnaireDetails(Map<String, Map<String, Object>> componentTypetoParams,
- String componentDisplayName, String propertyName) {
+ private String getValueFromQuestionnaireDetails(Map<String, Map<String, Object>> componentTypetoParams, String componentDisplayName,
+ String propertyName) {
return (String) componentTypetoParams.get(componentDisplayName).get(propertyName);
}
private void setProperty(NodeTemplate nodeTemplate, String key, String value) {
if (!StringUtils.isEmpty(value)) {
//YamlUtil throws IllegalStateException("duplicate key: " + key) if key is already present.
+
// So first removing and then populating same key with new updated value
nodeTemplate.getProperties().remove(key);
nodeTemplate.getProperties().put(key, value);
diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/ComponentQuestionnaireData.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/ComponentQuestionnaireData.java
index 4b9ed4f45e..db6f37ad85 100644
--- a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/ComponentQuestionnaireData.java
+++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/ComponentQuestionnaireData.java
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.sdc.enrichment.impl.tosca;
import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.HIGH_AVAIL_MODE;
@@ -39,105 +38,73 @@ import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentData;
import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.ComponentQuestionnaire;
import org.openecomp.sdc.versioning.dao.types.Version;
-
public class ComponentQuestionnaireData {
- ComponentDao componentDao = ComponentDaoFactory.getInstance().createInterface();
- ComponentDependencyModelDao componentDependencyModelDao =
- ComponentDependencyModelDaoFactory.getInstance().createInterface();
-
- private Map<String, String> sourceToTargetComponent;
-
- public Map<String, String> getSourceToTargetComponent() {
- return sourceToTargetComponent;
- }
-
- public void setSourceToTargetComponent(Map<String, String> sourceToTargetComponent) {
- this.sourceToTargetComponent = sourceToTargetComponent;
- }
-
- public Map<String, Map<String, Object>> getPropertiesfromCompQuestionnaire(String key,
- Version version) {
- Map<String, Map<String, Object>> componentProperties = new HashMap<>();
-
- final Collection<ComponentEntity> componentEntities =
- componentDao.listCompositionAndQuestionnaire(key, version);
-
- Map<String, String> sourceToTarget = new HashMap<>();
-
- for (ComponentEntity component : componentEntities) {
- Map<String, Object> questionnaireParams = new HashMap<>();
-
- final ComponentQuestionnaire componentQuestionnaire =
- JsonUtil.json2Object(component.getQuestionnaireData(), ComponentQuestionnaire.class);
-
- final ComponentData componentData =
- JsonUtil.json2Object(component.getCompositionData(), ComponentData.class);
-
- sourceToTarget.put(component.getId(), componentData.getDisplayName());
-
- String nfcNamingCode = componentQuestionnaire.getGeneral().getNfcNamingCode();
- questionnaireParams.put(NFC_NAMING_CODE, nfcNamingCode);
+ ComponentDao componentDao = ComponentDaoFactory.getInstance().createInterface();
+ ComponentDependencyModelDao componentDependencyModelDao = ComponentDependencyModelDaoFactory.getInstance().createInterface();
+ private Map<String, String> sourceToTargetComponent;
- String vfcDescription = componentQuestionnaire.getGeneral().getNfcFunction();
- questionnaireParams.put(EnrichmentConstants.NFC_FUNCTION, vfcDescription);
-
-
- if (componentQuestionnaire.getHighAvailabilityAndLoadBalancing() != null) {
- String mandatory = componentQuestionnaire.getHighAvailabilityAndLoadBalancing()
- .getIsComponentMandatory();
- questionnaireParams.put(MANDATORY, mandatory);
-
- String mode = componentQuestionnaire.getHighAvailabilityAndLoadBalancing()
- .getHighAvailabilityMode();
-
- questionnaireParams.put(HIGH_AVAIL_MODE, mode);
- }
-
- final Integer maxVms =
- componentQuestionnaire.getCompute() != null ? (componentQuestionnaire.getCompute()
- .getNumOfVMs() != null ? componentQuestionnaire.getCompute().getNumOfVMs()
- .getMaximum() : null) : null;
-
- final Integer minVms =
- componentQuestionnaire.getCompute() != null ? (componentQuestionnaire.getCompute()
- .getNumOfVMs() != null ? componentQuestionnaire.getCompute().getNumOfVMs()
- .getMinimum() : null) : null;
-
- questionnaireParams.put(MIN_INSTANCES, minVms != null && minVms == 0 ? null : minVms);
- questionnaireParams.put(MAX_INSTANCES, maxVms != null && maxVms == 0 ? null : maxVms);
-
- if (!questionnaireParams.isEmpty()) {
- componentProperties.put(JsonUtil.json2Object(component.getCompositionData(),
- ComponentData.class).getDisplayName(), questionnaireParams);
- }
+ public Map<String, String> getSourceToTargetComponent() {
+ return sourceToTargetComponent;
}
- setSourceToTargetComponent(sourceToTarget);
-
- return componentProperties;
- }
-
- public Map<String, List<String>> populateDependencies(String vspId, Version version, Map<String,
- String> componentNameData) {
- Collection<ComponentDependencyModelEntity> componentDependencies =
- componentDependencyModelDao.list(new ComponentDependencyModelEntity(vspId, version, null));
-
- Map<String, List<String>> dependencies = new HashMap<>();
- List<String> targetComponents;
- for (ComponentDependencyModelEntity dependency : componentDependencies) {
- String sourceComponentName = componentNameData.get(dependency.getSourceComponentId());
- String targetComponentName = componentNameData.get(dependency.getTargetComponentId());
- if (!dependencies.containsKey(sourceComponentName)) {
- targetComponents = new ArrayList<>();
- } else {
- targetComponents = dependencies.get(sourceComponentName);
- }
- targetComponents.add(targetComponentName);
- dependencies.put(sourceComponentName, targetComponents);
+ public void setSourceToTargetComponent(Map<String, String> sourceToTargetComponent) {
+ this.sourceToTargetComponent = sourceToTargetComponent;
}
- return dependencies;
- }
+ public Map<String, Map<String, Object>> getPropertiesfromCompQuestionnaire(String key, Version version) {
+ Map<String, Map<String, Object>> componentProperties = new HashMap<>();
+ final Collection<ComponentEntity> componentEntities = componentDao.listCompositionAndQuestionnaire(key, version);
+ Map<String, String> sourceToTarget = new HashMap<>();
+ for (ComponentEntity component : componentEntities) {
+ Map<String, Object> questionnaireParams = new HashMap<>();
+ final ComponentQuestionnaire componentQuestionnaire = JsonUtil
+ .json2Object(component.getQuestionnaireData(), ComponentQuestionnaire.class);
+ final ComponentData componentData = JsonUtil.json2Object(component.getCompositionData(), ComponentData.class);
+ sourceToTarget.put(component.getId(), componentData.getDisplayName());
+ String nfcNamingCode = componentQuestionnaire.getGeneral().getNfcNamingCode();
+ questionnaireParams.put(NFC_NAMING_CODE, nfcNamingCode);
+ String vfcDescription = componentQuestionnaire.getGeneral().getNfcFunction();
+ questionnaireParams.put(EnrichmentConstants.NFC_FUNCTION, vfcDescription);
+ if (componentQuestionnaire.getHighAvailabilityAndLoadBalancing() != null) {
+ String mandatory = componentQuestionnaire.getHighAvailabilityAndLoadBalancing().getIsComponentMandatory();
+ questionnaireParams.put(MANDATORY, mandatory);
+ String mode = componentQuestionnaire.getHighAvailabilityAndLoadBalancing().getHighAvailabilityMode();
+ questionnaireParams.put(HIGH_AVAIL_MODE, mode);
+ }
+ final Integer maxVms =
+ componentQuestionnaire.getCompute() != null ? (componentQuestionnaire.getCompute().getNumOfVMs() != null ? componentQuestionnaire
+ .getCompute().getNumOfVMs().getMaximum() : null) : null;
+ final Integer minVms =
+ componentQuestionnaire.getCompute() != null ? (componentQuestionnaire.getCompute().getNumOfVMs() != null ? componentQuestionnaire
+ .getCompute().getNumOfVMs().getMinimum() : null) : null;
+ questionnaireParams.put(MIN_INSTANCES, minVms != null && minVms == 0 ? null : minVms);
+ questionnaireParams.put(MAX_INSTANCES, maxVms != null && maxVms == 0 ? null : maxVms);
+ if (!questionnaireParams.isEmpty()) {
+ componentProperties
+ .put(JsonUtil.json2Object(component.getCompositionData(), ComponentData.class).getDisplayName(), questionnaireParams);
+ }
+ }
+ setSourceToTargetComponent(sourceToTarget);
+ return componentProperties;
+ }
+ public Map<String, List<String>> populateDependencies(String vspId, Version version, Map<String, String> componentNameData) {
+ Collection<ComponentDependencyModelEntity> componentDependencies = componentDependencyModelDao
+ .list(new ComponentDependencyModelEntity(vspId, version, null));
+ Map<String, List<String>> dependencies = new HashMap<>();
+ List<String> targetComponents;
+ for (ComponentDependencyModelEntity dependency : componentDependencies) {
+ String sourceComponentName = componentNameData.get(dependency.getSourceComponentId());
+ String targetComponentName = componentNameData.get(dependency.getTargetComponentId());
+ if (!dependencies.containsKey(sourceComponentName)) {
+ targetComponents = new ArrayList<>();
+ } else {
+ targetComponents = dependencies.get(sourceComponentName);
+ }
+ targetComponents.add(targetComponentName);
+ dependencies.put(sourceComponentName, targetComponents);
+ }
+ return dependencies;
+ }
}
diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/PortMirroringEnricher.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/PortMirroringEnricher.java
index 266d1346e4..b2d1a218f4 100644
--- a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/PortMirroringEnricher.java
+++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/PortMirroringEnricher.java
@@ -13,11 +13,23 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.sdc.enrichment.impl.tosca;
+import static org.openecomp.sdc.tosca.services.DataModelUtil.getClonedObject;
+import static org.openecomp.sdc.tosca.services.ToscaConstants.PORT_MIRRORING_CAPABILITY_CP_PROPERTY_NAME;
+import static org.openecomp.sdc.tosca.services.ToscaConstants.PORT_MIRRORING_CAPABILITY_ID;
+
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.Set;
+import java.util.stream.Collectors;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
import org.onap.sdc.tosca.datatypes.model.Import;
@@ -35,32 +47,24 @@ import org.openecomp.sdc.tosca.services.ToscaUtil;
import org.openecomp.sdc.translator.services.heattotosca.HeatToToscaUtil;
import org.openecomp.sdc.translator.services.heattotosca.globaltypes.GlobalTypesGenerator;
-import java.util.*;
-import java.util.stream.Collectors;
-
-import static org.openecomp.sdc.tosca.services.DataModelUtil.getClonedObject;
-import static org.openecomp.sdc.tosca.services.ToscaConstants.PORT_MIRRORING_CAPABILITY_CP_PROPERTY_NAME;
-import static org.openecomp.sdc.tosca.services.ToscaConstants.PORT_MIRRORING_CAPABILITY_ID;
-
public class PortMirroringEnricher {
+
private static final String ABSTRACT_LINK_REQUIREMENT_ID_PREFIX = ToscaConstants.LINK_REQUIREMENT_ID + "_";
private static final int ABSTRACT_LINK_REQUIREMENT_ID_PREFIX_LENGTH = ABSTRACT_LINK_REQUIREMENT_ID_PREFIX.length();
- private static final Map<String, String> nodeTypeExternalNodeType = initializeNodeTypeExternalNodeType();
+ private static final Map<String, String> nodeTypeExternalNodeType = initializeNodeTypeExternalNodeType();
//Map of service template file name and map of all port node template ids, node template
private final Map<String, Map<String, NodeTemplate>> portNodeTemplates = new HashMap<>();
//Map of service template file name and map of external port node template ids, node template
private final Map<String, Map<String, NodeTemplate>> externalPortNodeTemplates = new HashMap<>();
//Map of substitution service template name and the list of ports with link requirement from the abstract
private final Map<String, List<String>> portNodeTemplateIdsFromAbstract = new HashMap<>();
- private final Map<String, ServiceTemplate> globalTypesServiceTemplate =
- GlobalTypesGenerator.getGlobalTypesServiceTemplate(OnboardingTypesEnum.ZIP);
+ private final Map<String, ServiceTemplate> globalTypesServiceTemplate = GlobalTypesGenerator
+ .getGlobalTypesServiceTemplate(OnboardingTypesEnum.ZIP);
- private static ImmutableMap<String,String> initializeNodeTypeExternalNodeType() {
- return ImmutableMap.<String, String>builder()
- .put(ToscaNodeType.CONTRAIL_PORT, ToscaNodeType.EXTERNAL_CONTRAIL_PORT)
- .put(ToscaNodeType.CONTRAILV2_VIRTUAL_MACHINE_INTERFACE, ToscaNodeType.EXTERNAL_VMI_PORT)
- .put(ToscaNodeType.NEUTRON_PORT, ToscaNodeType.EXTERNAL_NEUTRON_PORT)
- .build();
+ private static ImmutableMap<String, String> initializeNodeTypeExternalNodeType() {
+ return ImmutableMap.<String, String>builder().put(ToscaNodeType.CONTRAIL_PORT, ToscaNodeType.EXTERNAL_CONTRAIL_PORT)
+ .put(ToscaNodeType.CONTRAILV2_VIRTUAL_MACHINE_INTERFACE, ToscaNodeType.EXTERNAL_VMI_PORT)
+ .put(ToscaNodeType.NEUTRON_PORT, ToscaNodeType.EXTERNAL_NEUTRON_PORT).build();
}
/**
@@ -73,11 +77,10 @@ public class PortMirroringEnricher {
Map<String, List<ErrorMessage>> errors = new HashMap<>();
Map<String, ServiceTemplate> serviceTemplates = toscaServiceModel.getServiceTemplates();
serviceTemplates.entrySet().stream()
- //Skipping the service templates which do not contain topology template
- .filter(serviceTemplateEntry -> serviceTemplateEntry.getValue().getTopology_template() != null)
- .forEach(serviceTemplateEntry ->
- //Collect all the ports across all the service templates
- collectPorts(serviceTemplateEntry.getValue()));
+ //Skipping the service templates which do not contain topology template
+ .filter(serviceTemplateEntry -> serviceTemplateEntry.getValue().getTopology_template() != null).forEach(serviceTemplateEntry ->
+ //Collect all the ports across all the service templates
+ collectPorts(serviceTemplateEntry.getValue()));
//Collect External ports from the list of all ports collected above
filterExternalPorts();
//Handle external port changes
@@ -91,13 +94,10 @@ public class PortMirroringEnricher {
return;
}
//Get all concrete port node templates from the service template
- Map<String, NodeTemplate> serviceTemplatePortNodeTemplates = nodeTemplates.entrySet().stream()
- .filter(nodeTemplateEntry -> (Objects.nonNull(nodeTemplateEntry.getValue()))
- && (isPortNodeTemplate(nodeTemplateEntry.getValue().getType())))
- .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
-
- portNodeTemplates.put(ToscaUtil.getServiceTemplateFileName(serviceTemplate),
- serviceTemplatePortNodeTemplates);
+ Map<String, NodeTemplate> serviceTemplatePortNodeTemplates = nodeTemplates.entrySet().stream().filter(
+ nodeTemplateEntry -> (Objects.nonNull(nodeTemplateEntry.getValue())) && (isPortNodeTemplate(nodeTemplateEntry.getValue().getType())))
+ .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
+ portNodeTemplates.put(ToscaUtil.getServiceTemplateFileName(serviceTemplate), serviceTemplatePortNodeTemplates);
//Get all linked internal ports from abstract node template link requirements
collectLinkedInternalPorts(nodeTemplates);
}
@@ -112,22 +112,19 @@ public class PortMirroringEnricher {
}
}
- private void handleSubstitutableNodeTemplate(List<String> abstractLinkedPortNodeTemplates,
- NodeTemplate nodeTemplate) {
+ private void handleSubstitutableNodeTemplate(List<String> abstractLinkedPortNodeTemplates, NodeTemplate nodeTemplate) {
List<Map<String, RequirementAssignment>> requirements = nodeTemplate.getRequirements();
if (Objects.isNull(requirements)) {
return;
}
- requirements
- .forEach(requirement -> addInternalPortToAbstractNode(requirement, abstractLinkedPortNodeTemplates));
+ requirements.forEach(requirement -> addInternalPortToAbstractNode(requirement, abstractLinkedPortNodeTemplates));
if (CollectionUtils.isNotEmpty(abstractLinkedPortNodeTemplates)) {
//Populate a map of the substitution service templates and list of internal ports
addCollectedPortsToAbstractServiceTemplatePortMap(nodeTemplate, abstractLinkedPortNodeTemplates);
}
}
- private void addInternalPortToAbstractNode(Map<String, RequirementAssignment> requirement,
- List<String> abstractLinkedPortNodeTemplates) {
+ private void addInternalPortToAbstractNode(Map<String, RequirementAssignment> requirement, List<String> abstractLinkedPortNodeTemplates) {
String requirementId = requirement.keySet().iterator().next();
if (requirementId.startsWith(ABSTRACT_LINK_REQUIREMENT_ID_PREFIX)) {
//Collect port node template ids from the link requirement ids in the abstract node template
@@ -135,16 +132,13 @@ public class PortMirroringEnricher {
}
}
- private void addCollectedPortsToAbstractServiceTemplatePortMap(NodeTemplate nodeTemplate,
- List<String> abstractLinkedPortNodeTemplates) {
+ private void addCollectedPortsToAbstractServiceTemplatePortMap(NodeTemplate nodeTemplate, List<String> abstractLinkedPortNodeTemplates) {
String substitutionServiceTemplateName;
if (Objects.isNull(nodeTemplate.getProperties())) {
return;
}
- Map serviceTemplateFilter = (Map<String, Object>) nodeTemplate.getProperties()
- .get(ToscaConstants.SERVICE_TEMPLATE_FILTER_PROPERTY_NAME);
- substitutionServiceTemplateName = (String)
- serviceTemplateFilter.get(ToscaConstants.SUBSTITUTE_SERVICE_TEMPLATE_PROPERTY_NAME);
+ Map serviceTemplateFilter = (Map<String, Object>) nodeTemplate.getProperties().get(ToscaConstants.SERVICE_TEMPLATE_FILTER_PROPERTY_NAME);
+ substitutionServiceTemplateName = (String) serviceTemplateFilter.get(ToscaConstants.SUBSTITUTE_SERVICE_TEMPLATE_PROPERTY_NAME);
if (Objects.isNull(substitutionServiceTemplateName)) {
return;
}
@@ -194,8 +188,7 @@ public class PortMirroringEnricher {
}
}
- private void handleExternalPortNodeTemplates(ServiceTemplate serviceTemplate,
- Map<String, NodeTemplate> externalPortNodeTemplates) {
+ private void handleExternalPortNodeTemplates(ServiceTemplate serviceTemplate, Map<String, NodeTemplate> externalPortNodeTemplates) {
for (Map.Entry<String, NodeTemplate> externalNodeTemplate : externalPortNodeTemplates.entrySet()) {
updateExternalPortNodeTemplate(externalNodeTemplate.getValue());
if (Objects.nonNull(DataModelUtil.getSubstitutionMappings(serviceTemplate))) {
@@ -205,14 +198,12 @@ public class PortMirroringEnricher {
}
}
- private void addPortMirroringSubstitutionMappingCapability(ServiceTemplate serviceTemplate,
- String externalPortNodeTemplateId) {
+ private void addPortMirroringSubstitutionMappingCapability(ServiceTemplate serviceTemplate, String externalPortNodeTemplateId) {
List<String> portMirroringCapability = new LinkedList<>();
portMirroringCapability.add(externalPortNodeTemplateId);
portMirroringCapability.add(PORT_MIRRORING_CAPABILITY_ID);
String substitutionMappingCapabilityId = PORT_MIRRORING_CAPABILITY_ID + "_" + externalPortNodeTemplateId;
- DataModelUtil.addSubstitutionMappingCapability(serviceTemplate,
- substitutionMappingCapabilityId, portMirroringCapability);
+ DataModelUtil.addSubstitutionMappingCapability(serviceTemplate, substitutionMappingCapabilityId, portMirroringCapability);
}
private void addPortMirroringCapability(NodeTemplate portNodeTemplate) {
@@ -226,17 +217,14 @@ public class PortMirroringEnricher {
}
if (!connectionPoint.isEmpty()) {
portMirroringCapabilityProperties.put(PORT_MIRRORING_CAPABILITY_CP_PROPERTY_NAME, connectionPoint);
- DataModelUtil.addNodeTemplateCapability(portNodeTemplate,
- PORT_MIRRORING_CAPABILITY_ID, portMirroringCapabilityProperties, null);
+ DataModelUtil.addNodeTemplateCapability(portNodeTemplate, PORT_MIRRORING_CAPABILITY_ID, portMirroringCapabilityProperties, null);
}
}
- private void setConnectionPointNfcType(NodeTemplate portNodeTemplate,
- PortMirroringConnectionPointDescription connectionPoint) {
+ private void setConnectionPointNfcType(NodeTemplate portNodeTemplate, PortMirroringConnectionPointDescription connectionPoint) {
//Get NFC_Type from the binding requirement node
- Optional<List<RequirementAssignment>> requirementAssignment =
- DataModelUtil.getRequirementAssignment(portNodeTemplate.getRequirements(), ToscaConstants
- .BINDING_REQUIREMENT_ID);
+ Optional<List<RequirementAssignment>> requirementAssignment = DataModelUtil
+ .getRequirementAssignment(portNodeTemplate.getRequirements(), ToscaConstants.BINDING_REQUIREMENT_ID);
if (requirementAssignment.isPresent()) {
RequirementAssignment bindingRequirementAssignment = requirementAssignment.get().get(0);
String node = bindingRequirementAssignment.getNode();
@@ -244,10 +232,8 @@ public class PortMirroringEnricher {
}
}
- private void setConnectionPointNetworkRole(NodeTemplate portNodeTemplate,
- PortMirroringConnectionPointDescription connectionPoint) {
- Object networkRolePropertyValue =
- portNodeTemplate.getProperties().get(ToscaConstants.PORT_NETWORK_ROLE_PROPERTY_NAME);
+ private void setConnectionPointNetworkRole(NodeTemplate portNodeTemplate, PortMirroringConnectionPointDescription connectionPoint) {
+ Object networkRolePropertyValue = portNodeTemplate.getProperties().get(ToscaConstants.PORT_NETWORK_ROLE_PROPERTY_NAME);
if (Objects.nonNull(networkRolePropertyValue)) {
Object portMirroringNetworkRolePropertyVal = getClonedObject(networkRolePropertyValue);
connectionPoint.setNetwork_role(portMirroringNetworkRolePropertyVal);
@@ -257,9 +243,8 @@ public class PortMirroringEnricher {
private void addGlobalTypeImport(ServiceTemplate serviceTemplate) {
List<Map<String, Import>> imports = serviceTemplate.getImports();
Map<String, Import> openecompIndexImport = new HashMap<>();
- openecompIndexImport.put("openecomp_index",
- HeatToToscaUtil.createServiceTemplateImport(globalTypesServiceTemplate
- .get("openecomp/_index.yml")));
+ openecompIndexImport
+ .put("openecomp_index", HeatToToscaUtil.createServiceTemplateImport(globalTypesServiceTemplate.get("openecomp/_index.yml")));
imports.add(openecompIndexImport);
}
@@ -270,26 +255,22 @@ public class PortMirroringEnricher {
}
private Set<String> getPortNodeTypes() {
- return ImmutableSet.of(ToscaNodeType.NEUTRON_PORT,
- ToscaNodeType.CONTRAILV2_VIRTUAL_MACHINE_INTERFACE, ToscaNodeType.CONTRAIL_PORT);
+ return ImmutableSet.of(ToscaNodeType.NEUTRON_PORT, ToscaNodeType.CONTRAILV2_VIRTUAL_MACHINE_INTERFACE, ToscaNodeType.CONTRAIL_PORT);
}
private boolean isSubstitutableNodeTemplate(NodeTemplate nodeTemplate) {
- return Objects.nonNull(nodeTemplate.getDirectives())
- && nodeTemplate.getDirectives()
- .contains(ToscaConstants.NODE_TEMPLATE_DIRECTIVE_SUBSTITUTABLE);
+ return Objects.nonNull(nodeTemplate.getDirectives()) && nodeTemplate.getDirectives()
+ .contains(ToscaConstants.NODE_TEMPLATE_DIRECTIVE_SUBSTITUTABLE);
}
- private boolean isInternalPort(String serviceTemplateFileName, String nodeTemplateId,
- NodeTemplate nodeTemplate) {
- return isAbstractInternalPort(serviceTemplateFileName, nodeTemplateId)
- || isConcreteInternalPort(nodeTemplate);
+ private boolean isInternalPort(String serviceTemplateFileName, String nodeTemplateId, NodeTemplate nodeTemplate) {
+ return isAbstractInternalPort(serviceTemplateFileName, nodeTemplateId) || isConcreteInternalPort(nodeTemplate);
}
private boolean isAbstractInternalPort(String serviceTemplateFileName, String nodeTemplateId) {
//Check if port corresponds to an abstract internal port
- return portNodeTemplateIdsFromAbstract.containsKey(serviceTemplateFileName)
- && portNodeTemplateIdsFromAbstract.get(serviceTemplateFileName).contains(nodeTemplateId);
+ return portNodeTemplateIdsFromAbstract.containsKey(serviceTemplateFileName) && portNodeTemplateIdsFromAbstract.get(serviceTemplateFileName)
+ .contains(nodeTemplateId);
}
private boolean isConcreteInternalPort(NodeTemplate nodeTemplate) {
diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/ToscaEnricher.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/ToscaEnricher.java
index 26c1be9938..ee459afa0d 100644
--- a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/ToscaEnricher.java
+++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/ToscaEnricher.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,57 +17,48 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.enrichment.impl.tosca;
-import org.openecomp.sdc.datatypes.error.ErrorLevel;
-import org.openecomp.sdc.datatypes.error.ErrorMessage;
-import org.openecomp.sdc.enrichment.inter.Enricher;
-import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
-
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import org.openecomp.sdc.datatypes.error.ErrorLevel;
+import org.openecomp.sdc.datatypes.error.ErrorMessage;
+import org.openecomp.sdc.enrichment.inter.Enricher;
+import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
public class ToscaEnricher extends Enricher {
- @Override
- public Map<String, List<ErrorMessage>> enrich() {
- Map<String, List<ErrorMessage>> errors = new HashMap<>();
- errors.putAll(enrichAbstractSubstitute());
- errors.putAll(enrichPortMirroring());
-
- return errors;
- }
- private Map<String, List<ErrorMessage>> enrichAbstractSubstitute() {
- Map<String, List<ErrorMessage>> enrichErrors = new HashMap<>();
-
- ToscaServiceModel toscaModel = (ToscaServiceModel) model;
- AbstractSubstituteToscaEnricher abstractSubstituteToscaEnricher =
- new AbstractSubstituteToscaEnricher();
-
- try {
- enrichErrors = abstractSubstituteToscaEnricher.enrich(toscaModel, data.getKey(),
- data.getVersion());
- }catch (Exception e){
- enrichErrors.put("Tosca Enrich", Arrays.asList(new ErrorMessage(ErrorLevel.ERROR, e
- .getMessage())));
+ @Override
+ public Map<String, List<ErrorMessage>> enrich() {
+ Map<String, List<ErrorMessage>> errors = new HashMap<>();
+ errors.putAll(enrichAbstractSubstitute());
+ errors.putAll(enrichPortMirroring());
+ return errors;
}
- return enrichErrors;
- }
- private Map<String, List<ErrorMessage>> enrichPortMirroring() {
- Map<String, List<ErrorMessage>> enrichErrors = new HashMap<>();
- ToscaServiceModel toscaModel = (ToscaServiceModel) model;
- PortMirroringEnricher portMirroringEnricher = new PortMirroringEnricher();
+ private Map<String, List<ErrorMessage>> enrichAbstractSubstitute() {
+ Map<String, List<ErrorMessage>> enrichErrors = new HashMap<>();
+ ToscaServiceModel toscaModel = (ToscaServiceModel) model;
+ AbstractSubstituteToscaEnricher abstractSubstituteToscaEnricher = new AbstractSubstituteToscaEnricher();
+ try {
+ enrichErrors = abstractSubstituteToscaEnricher.enrich(toscaModel, data.getKey(), data.getVersion());
+ } catch (Exception e) {
+ enrichErrors.put("Tosca Enrich", Arrays.asList(new ErrorMessage(ErrorLevel.ERROR, e.getMessage())));
+ }
+ return enrichErrors;
+ }
- try {
- enrichErrors = portMirroringEnricher.enrich(toscaModel);
- }catch (Exception e){
- enrichErrors.put("Tosca Enrich", Arrays.asList(new ErrorMessage(ErrorLevel.ERROR, e
- .getMessage())));
+ private Map<String, List<ErrorMessage>> enrichPortMirroring() {
+ Map<String, List<ErrorMessage>> enrichErrors = new HashMap<>();
+ ToscaServiceModel toscaModel = (ToscaServiceModel) model;
+ PortMirroringEnricher portMirroringEnricher = new PortMirroringEnricher();
+ try {
+ enrichErrors = portMirroringEnricher.enrich(toscaModel);
+ } catch (Exception e) {
+ enrichErrors.put("Tosca Enrich", Arrays.asList(new ErrorMessage(ErrorLevel.ERROR, e.getMessage())));
+ }
+ return enrichErrors;
}
- return enrichErrors;
- }
}
diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/model/PortMirroringConnectionPointDescription.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/model/PortMirroringConnectionPointDescription.java
index 9654ba5130..64d90262da 100644
--- a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/model/PortMirroringConnectionPointDescription.java
+++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/model/PortMirroringConnectionPointDescription.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,87 +17,83 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.enrichment.impl.tosca.model;
import java.util.Objects;
@SuppressWarnings("CheckStyle")
public class PortMirroringConnectionPointDescription {
- private String nf_type;
- private String nfc_type;
- private String nf_naming_code;
- private String nfc_naming_code;
-
- //Keeping below attributes as objects to accomodate for tosca functions for property
- // values like get_input, get_attribute
- private Object network_role;
- private Object pps_capacity;
-
- public PortMirroringConnectionPointDescription() {
- //Populating empty strings as default values to be populated in tosca
- nf_type = "";
- nfc_type = "";
- nf_naming_code = "";
- nfc_naming_code = "";
- network_role = "";
- pps_capacity = "";
- }
-
- public String getNf_type() {
- return nf_type;
- }
-
- public void setNf_type(String nf_type) {
- this.nf_type = nf_type;
- }
-
- public String getNfc_type() {
- return nfc_type;
- }
-
- public void setNfc_type(String nfc_type) {
- this.nfc_type = nfc_type;
- }
-
- public String getNf_naming_code() {
- return nf_naming_code;
- }
-
- public void setNf_naming_code(String nf_naming_code) {
- this.nf_naming_code = nf_naming_code;
- }
-
- public String getNfc_naming_code() {
- return nfc_naming_code;
- }
-
- public void setNfc_naming_code(String nfc_naming_code) {
- this.nfc_naming_code = nfc_naming_code;
- }
-
- public Object getNetwork_role() {
- return network_role;
- }
-
- public void setNetwork_role(Object network_role) {
- this.network_role = network_role;
- }
-
- public Object getPps_capacity() {
- return pps_capacity;
- }
-
- public void setPps_capacity(String pps_capacity) {
- this.pps_capacity = pps_capacity;
- }
-
- public boolean isEmpty() {
- return Objects.isNull(nf_type)
- && Objects.isNull(nfc_type)
- && Objects.isNull(nf_naming_code)
- && Objects.isNull(nfc_naming_code)
- && Objects.isNull(network_role)
- && Objects.isNull(pps_capacity);
- }
+
+ private String nf_type;
+ private String nfc_type;
+ private String nf_naming_code;
+ private String nfc_naming_code;
+ //Keeping below attributes as objects to accomodate for tosca functions for property
+
+ // values like get_input, get_attribute
+ private Object network_role;
+ private Object pps_capacity;
+
+ public PortMirroringConnectionPointDescription() {
+ //Populating empty strings as default values to be populated in tosca
+ nf_type = "";
+ nfc_type = "";
+ nf_naming_code = "";
+ nfc_naming_code = "";
+ network_role = "";
+ pps_capacity = "";
+ }
+
+ public String getNf_type() {
+ return nf_type;
+ }
+
+ public void setNf_type(String nf_type) {
+ this.nf_type = nf_type;
+ }
+
+ public String getNfc_type() {
+ return nfc_type;
+ }
+
+ public void setNfc_type(String nfc_type) {
+ this.nfc_type = nfc_type;
+ }
+
+ public String getNf_naming_code() {
+ return nf_naming_code;
+ }
+
+ public void setNf_naming_code(String nf_naming_code) {
+ this.nf_naming_code = nf_naming_code;
+ }
+
+ public String getNfc_naming_code() {
+ return nfc_naming_code;
+ }
+
+ public void setNfc_naming_code(String nfc_naming_code) {
+ this.nfc_naming_code = nfc_naming_code;
+ }
+
+ public Object getNetwork_role() {
+ return network_role;
+ }
+
+ public void setNetwork_role(Object network_role) {
+ this.network_role = network_role;
+ }
+
+ public Object getPps_capacity() {
+ return pps_capacity;
+ }
+
+ public void setPps_capacity(String pps_capacity) {
+ this.pps_capacity = pps_capacity;
+ }
+
+ public boolean isEmpty() {
+ return Objects.isNull(nf_type) && Objects.isNull(nfc_type) && Objects.isNull(nf_naming_code) && Objects.isNull(nfc_naming_code) && Objects
+ .isNull(network_role) && Objects.isNull(pps_capacity);
+ }
}
diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/util/EnrichmentConstants.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/util/EnrichmentConstants.java
index 18d28afb07..2f83b573e1 100644
--- a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/util/EnrichmentConstants.java
+++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/util/EnrichmentConstants.java
@@ -13,22 +13,19 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.sdc.enrichment.impl.util;
public class EnrichmentConstants {
- public static final String NFC_NAMING_CODE = "nfc_naming_code";
- public static final String MANDATORY = "mandatory";
- public static final String HIGH_AVAIL_MODE = "high_availablity";
- public static final String MIN_INSTANCES = "min_instances";
- public static final String MAX_INSTANCES = "max_instances";
- public static final String VM_TYPE_TAG = "vm_type_tag";
- public static final String VFC_CODE = "nfc_code";
- public static final String NFC_FUNCTION = "nfc_function";
-
- private EnrichmentConstants() {
-
- }
+ public static final String NFC_NAMING_CODE = "nfc_naming_code";
+ public static final String MANDATORY = "mandatory";
+ public static final String HIGH_AVAIL_MODE = "high_availablity";
+ public static final String MIN_INSTANCES = "min_instances";
+ public static final String MAX_INSTANCES = "max_instances";
+ public static final String VM_TYPE_TAG = "vm_type_tag";
+ public static final String VFC_CODE = "nfc_code";
+ public static final String NFC_FUNCTION = "nfc_function";
+ private EnrichmentConstants() {
+ }
}
diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/inter/Enricher.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/inter/Enricher.java
index cc3a0d5186..f331da7863 100644
--- a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/inter/Enricher.java
+++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/inter/Enricher.java
@@ -17,22 +17,18 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.enrichment.inter;
-
+import java.util.List;
+import java.util.Map;
import lombok.Setter;
import org.openecomp.sdc.datatypes.error.ErrorMessage;
import org.openecomp.sdc.datatypes.model.AsdcModel;
import org.openecomp.sdc.enrichment.EnrichmentInfo;
-import java.util.List;
-import java.util.Map;
-
@Setter
public abstract class Enricher {
-
protected EnrichmentInfo data;
protected AsdcModel model;
diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/inter/EnricherHandler.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/inter/EnricherHandler.java
index f0ffa0b1ad..cff0293a5a 100644
--- a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/inter/EnricherHandler.java
+++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/inter/EnricherHandler.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.sdc.enrichment.inter;
import java.util.List;
@@ -25,5 +24,4 @@ import java.util.List;
public interface EnricherHandler {
List<Enricher> getEnrichers();
-
}
diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/inter/ExternalArtifactEnricherInterface.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/inter/ExternalArtifactEnricherInterface.java
index dd1f13d034..8d77317a31 100644
--- a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/inter/ExternalArtifactEnricherInterface.java
+++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/inter/ExternalArtifactEnricherInterface.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,22 +17,19 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.enrichment.inter;
-
-import org.openecomp.sdc.datatypes.error.ErrorMessage;
-import org.openecomp.sdc.enrichment.EnrichmentInfo;
-import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
-
import java.io.IOException;
import java.util.List;
import java.util.Map;
+import org.openecomp.sdc.datatypes.error.ErrorMessage;
+import org.openecomp.sdc.enrichment.EnrichmentInfo;
+import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
/**
* Created by Talio on 11/24/2016.
*/
public interface ExternalArtifactEnricherInterface {
- Map<String, List<ErrorMessage>> enrich(EnrichmentInfo enrichmentInfo,
- ToscaServiceModel serviceModel) throws IOException;
+
+ Map<String, List<ErrorMessage>> enrich(EnrichmentInfo enrichmentInfo, ToscaServiceModel serviceModel) throws IOException;
}