summaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java
diff options
context:
space:
mode:
authorAviZi <avi.ziv@amdocs.com>2017-06-09 02:39:56 +0300
committerAviZi <avi.ziv@amdocs.com>2017-06-09 02:39:56 +0300
commit280f8015d06af1f41a3ef12e8300801c7a5e0d54 (patch)
tree9c1d3978c04cd28068f02073038c936bb49ca9e0 /openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java
parentfd3821dad11780d33c5373d74c957c442489945e (diff)
[SDC-29] Amdocs OnBoard 1707 initial commit.
Change-Id: Ie4d12a3f574008b792899b368a0902a8b46b5370 Signed-off-by: AviZi <avi.ziv@amdocs.com>
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java')
-rw-r--r--openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/EnrichmentInfo.java64
-rw-r--r--openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/factory/EnricherHandlerFactory.java8
-rw-r--r--openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/EnricherHandlerFactoryImpl.java8
-rw-r--r--openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/EnricherHandlerImpl.java62
-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.java100
-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.java236
-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.java144
-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.java134
-rw-r--r--openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/AbstractSubstituteToscaEnricher.java243
-rw-r--r--openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/CeilometerEnricher.java112
-rw-r--r--openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/ComponentInfo.java47
-rw-r--r--openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/ComponentQuestionnaireData.java123
-rw-r--r--openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/ToscaEnricher.java42
-rw-r--r--openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/util/EnrichmentConstants.java12
-rw-r--r--openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/inter/Enricher.java19
-rw-r--r--openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/inter/EnricherHandler.java14
-rw-r--r--openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/inter/ExternalArtifactEnricherInterface.java (renamed from openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/SnmpEnricher.java)18
17 files changed, 1014 insertions, 372 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 17c4091a28..8f3798f764 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
@@ -28,36 +28,36 @@ import java.util.List;
import java.util.Map;
public class EnrichmentInfo {
- Map<String, List<Object>> additionalInfo = new HashMap<>();
- Map<String, EntityInfo> entityInfo = new HashMap<>(); //componentName,EntityInfo
- String key;
- Version version;
-
- public Map<String, List<Object>> getAdditionalInfo() {
- return additionalInfo;
- }
-
- public Map<String, EntityInfo> getEntityInfo() {
- return entityInfo;
- }
-
- public void addEntityInfo(String type, EntityInfo entityInfo) {
- this.entityInfo.put(type, entityInfo);
- }
-
- public String getKey() {
- return key;
- }
-
- public void setKey(String key) {
- this.key = key;
- }
-
- public Version getVersion() {
- return version;
- }
-
- public void setVersion(Version version) {
- this.version = version;
- }
+ Map<String, List<Object>> additionalInfo = new HashMap<>();
+ Map<String, EntityInfo> entitiesInfo = new HashMap<>();
+ String key;
+ Version version;
+
+ public Map<String, List<Object>> getAdditionalInfo() {
+ return additionalInfo;
+ }
+
+ public Map<String, EntityInfo> getEntityInfo() {
+ return entitiesInfo;
+ }
+
+ public void addEntityInfo(String entityKey, EntityInfo entityInfo) {
+ this.entitiesInfo.put(entityKey, entityInfo);
+ }
+
+ public String getKey() {
+ return key;
+ }
+
+ public void setKey(String key) {
+ this.key = key;
+ }
+
+ public Version getVersion() {
+ return version;
+ }
+
+ public void setVersion(Version version) {
+ this.version = version;
+ }
}
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 47821f6670..1167a6df9a 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
@@ -20,13 +20,15 @@
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() {
- return AbstractFactory.getInstance(EnricherHandlerFactory.class);
- }
+ public static EnricherHandlerFactory getInstance() {
+ return AbstractFactory.getInstance(EnricherHandlerFactory.class);
+ }
}
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 00f5c91661..9898ef678a 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
@@ -26,8 +26,8 @@ import org.openecomp.sdc.enrichment.inter.EnricherHandler;
public class EnricherHandlerFactoryImpl extends EnricherHandlerFactory {
- @Override
- public EnricherHandler createInterface() {
- return new EnricherHandlerImpl();
- }
+ @Override
+ public EnricherHandler createInterface() {
+ return new EnricherHandlerImpl();
+ }
}
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 e2e5b47d2a..a5eeece2b3 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
@@ -20,70 +20,26 @@
package org.openecomp.sdc.enrichment.impl;
-import org.openecomp.core.enrichment.types.EntityInfo;
-import org.openecomp.sdc.datatypes.error.ErrorMessage;
-import org.openecomp.sdc.datatypes.model.AsdcModel;
-import org.openecomp.sdc.enrichment.EnrichmentInfo;
+import org.openecomp.sdc.logging.api.Logger;
+import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.enrichment.impl.external.artifact.ExternalArtifactEnricher;
import org.openecomp.sdc.enrichment.impl.tosca.ToscaEnricher;
import org.openecomp.sdc.enrichment.inter.Enricher;
import org.openecomp.sdc.enrichment.inter.EnricherHandler;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
-/**
- * The type Enricher handler.
- */
public class EnricherHandlerImpl implements EnricherHandler {
- private static Logger logger = LoggerFactory.getLogger(EnricherHandlerImpl.class);
- private EnrichmentInfo input;
- private AsdcModel model;
-
- @Override
- public List<Enricher> getEnrichers() {
- List<Enricher> enricherList = new ArrayList<>();
- enricherList.add(new ToscaEnricher());
- enricherList.add(new ExternalArtifactEnricher());
- return enricherList;
- }
+ private static Logger logger = (Logger) LoggerFactory.getLogger(EnricherHandlerImpl.class);
- @Override
- public Map<String, List<ErrorMessage>> enrich() {
- Map<String, List<ErrorMessage>> errors = new HashMap<>();
- Map<String, List<ErrorMessage>> enricherResponse;
- for (Enricher enricher : getEnrichers()) {
- enricher.setInput(this.input);
- enricher.setModel(this.model);
- enricherResponse = enricher.enrich();
- errors.putAll(enricherResponse);
+ @Override
+ public List<Enricher> getEnrichers() {
+ List<Enricher> enricherList = new ArrayList<>();
+ enricherList.add(new ToscaEnricher());
+ enricherList.add(new ExternalArtifactEnricher());
+ return enricherList;
}
- return errors;
- }
-
- /**
- * Adds additional input.
- *
- * @param key key
- * @param input input
- */
- public void addAdditionalInput(String key, Object input) {
- if (!this.input.getAdditionalInfo().containsKey(key)) {
- this.input.getAdditionalInfo().put(key, new ArrayList<>());
- }
- this.input.getAdditionalInfo().get(key).add(input);
- }
-
- public void addEntityInfo(String entityId, EntityInfo entityInfo) {
- this.input.getEntityInfo().put(entityId, entityInfo);
- }
- public void setModel(AsdcModel model) {
- this.model = model;
- }
}
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 a276cfba7d..3c27a0fac8 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
@@ -20,87 +20,65 @@
package org.openecomp.sdc.enrichment.impl.external.artifact;
-import org.openecomp.core.enrichment.types.ComponentArtifactType;
-import org.openecomp.core.enrichment.types.MibInfo;
-import org.openecomp.core.model.dao.EnrichedServiceModelDao;
-import org.openecomp.core.model.dao.EnrichedServiceModelDaoFactory;
-import org.openecomp.core.model.types.ServiceArtifact;
-import org.openecomp.core.utilities.file.FileContentHandler;
import org.openecomp.core.utilities.file.FileUtils;
-import org.openecomp.core.validation.errors.Messages;
-import org.openecomp.sdc.datatypes.error.ErrorLevel;
+import org.openecomp.core.utilities.json.JsonUtil;
+import org.openecomp.sdc.common.utils.CommonUtil;
import org.openecomp.sdc.datatypes.error.ErrorMessage;
-import org.openecomp.sdc.enrichment.impl.tosca.ComponentInfo;
import org.openecomp.sdc.enrichment.inter.Enricher;
-import org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.sdc.enrichment.inter.ExternalArtifactEnricherInterface;
+import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
-import java.io.File;
-import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.Constructor;
+import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.Set;
public class ExternalArtifactEnricher extends Enricher {
+ private MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
+ private static String EXTERNAL_ARTIFACT_ENRICH_CONF_FILE = "ExternalArtifactConfiguration.json";
+ private static final String EXTERNAL_ARTIFACT_ENRICH_ERROR = "ERROR_CREATING_EXTERNAL_ARTIFACTS";
+ private static final String EXTERNAL_ARTIFACT_ENRICH_ERROR_MSG =
+ "An Error has occured during enrichment of external artifacts ";
+ private static Collection<String> implementingClasses =
+ getExternalArtifactEnrichedImplClassesList();
- private static EnrichedServiceModelDao enrichedServiceModelDao =
- EnrichedServiceModelDaoFactory.getInstance().createInterface();
+ private static Collection<String> getExternalArtifactEnrichedImplClassesList() {
+ InputStream externalArtifactEnrichConfigurationJson =
+ FileUtils.getFileInputStream(EXTERNAL_ARTIFACT_ENRICH_CONF_FILE);
+ @SuppressWarnings("unchecked")
+ Map<String, String> confFileAsMap =
+ JsonUtil.json2Object(externalArtifactEnrichConfigurationJson, Map.class);
+ return confFileAsMap.values();
+ }
@Override
public Map<String, List<ErrorMessage>> enrich() {
- Map<String, List<ErrorMessage>> errors = new HashMap<>();
- input.getEntityInfo().entrySet().stream().forEach(
- entry -> enrichComponentMib(entry.getKey(), (ComponentInfo) entry.getValue(), errors));
-
- return errors;
- }
+ mdcDataDebugMessage.debugEntryMessage(null, null);
+ Map<String, List<ErrorMessage>> errors = new HashMap<>();
- private void enrichComponentMib(String componentName, ComponentInfo componentInfo,
- Map<String, List<ErrorMessage>> errors) {
-
- String vspId = input.getKey();
- Version version = input.getVersion();
- ServiceArtifact mibServiceArtifact = new ServiceArtifact();
- mibServiceArtifact.setVspId(vspId);
- mibServiceArtifact.setVersion(version);
- enrichMibFiles(mibServiceArtifact, componentInfo, errors);
- }
+ try {
+ for (String implementingClassName : implementingClasses) {
+ ExternalArtifactEnricherInterface externalArtifactEnricherInstance = getExternalArtifactEnricherInstance(implementingClassName);
+ externalArtifactEnricherInstance.enrich(this.data);
+ }
+ } catch (Exception e) {
+ e.printStackTrace(); //// FIXME: 29-Nov-16
+ }
- private void enrichMibFiles(ServiceArtifact mibServiceArtifact, ComponentInfo componentInfo,
- Map<String, List<ErrorMessage>> errors) {
- if (componentInfo.getMibInfo() == null) {
- return;
- }
- enrichMibByType(componentInfo.getMibInfo().getSnmpTrap(), ComponentArtifactType.SNMP_TRAP,
- mibServiceArtifact, errors);
- enrichMibByType(componentInfo.getMibInfo().getSnmpPoll(), ComponentArtifactType.SNMP_POLL,
- mibServiceArtifact, errors);
+ mdcDataDebugMessage.debugExitMessage(null, null);
+ return errors;
}
- private void enrichMibByType(MibInfo mibInfo, ComponentArtifactType type,
- ServiceArtifact mibServiceArtifact,
- Map<String, List<ErrorMessage>> errors) {
- if (mibInfo == null) {
- return;
- }
- FileContentHandler mibs;
- try {
- mibs = FileUtils.getFileContentMapFromZip(FileUtils.toByteArray(mibInfo.getContent()));
- } catch (IOException ioException) {
- 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(FileUtils.toByteArray(mibs.getFileContent(fileName)));
- mibServiceArtifact.setName(mibInfo.getName() + File.separator + fileName);
- enrichedServiceModelDao.storeExternalArtifact(mibServiceArtifact);
- }
+ 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
new file mode 100644
index 0000000000..3920cc28af
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/external/artifact/MonitoringMibEnricher.java
@@ -0,0 +1,236 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.enrichment.impl.external.artifact;
+
+import org.openecomp.core.enrichment.types.ArtifactCategory;
+import org.openecomp.core.enrichment.types.ArtifactType;
+import org.openecomp.core.enrichment.types.ComponentMibInfo;
+import org.openecomp.core.enrichment.types.MibInfo;
+import org.openecomp.core.model.dao.EnrichedServiceModelDao;
+import org.openecomp.core.model.dao.EnrichedServiceModelDaoFactory;
+import org.openecomp.core.model.types.ServiceArtifact;
+import org.openecomp.core.utilities.file.FileContentHandler;
+import org.openecomp.core.utilities.file.FileUtils;
+import org.openecomp.sdc.common.errors.Messages;
+import org.openecomp.sdc.datatypes.error.ErrorLevel;
+import org.openecomp.sdc.datatypes.error.ErrorMessage;
+import org.openecomp.sdc.enrichment.EnrichmentInfo;
+import org.openecomp.sdc.enrichment.inter.ExternalArtifactEnricherInterface;
+import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.MibDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.MibDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.MibEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
+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;
+import java.util.Optional;
+import java.util.Set;
+
+public class MonitoringMibEnricher implements ExternalArtifactEnricherInterface {
+
+ private EnrichedServiceModelDao enrichedServiceModelDao;
+ private ComponentDao componentDao;
+ private MibDao mibDao;
+ private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
+
+ /**
+ * Enrich map.
+ *
+ * @param enrichmentInfo the enrichmentInfo
+ * @return the map
+ */
+ public Map<String, List<ErrorMessage>> enrich(EnrichmentInfo enrichmentInfo) {
+
+ 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) {
+
+
+ mdcDataDebugMessage.debugEntryMessage(null, null);
+
+ Map<String, List<ErrorMessage>> errors = new HashMap<>();
+ ComponentMibInfo componentMibInfo =
+ extractComponentMibInfo(componentEntry, vspId, version, errors);
+ enrichComponentMib(componentMibInfo, vspId, version, errors);
+
+ mdcDataDebugMessage.debugExitMessage(null, null);
+ return errors;
+ }
+
+ ComponentMibInfo extractComponentMibInfo(ComponentEntity componentEntity, String vspId,
+ Version version,
+ Map<String, List<ErrorMessage>> errors) {
+
+
+ mdcDataDebugMessage.debugEntryMessage(null, null);
+
+ String componentId = componentEntity.getId();
+ MibEntity entity = new MibEntity();
+
+ entity.setVspId(vspId);
+ entity.setVersion(version);
+ entity.setComponentId(componentId);
+ String componentName = componentEntity.getComponentCompositionData().getName();
+ ComponentMibInfo componentMibInfo = new ComponentMibInfo();
+ updComponentMibInfoByType(componentName, ArtifactType.SNMP_POLL, entity, componentMibInfo,
+ errors);
+ updComponentMibInfoByType(componentName, ArtifactType.SNMP_TRAP, entity, componentMibInfo,
+ errors);
+
+ mdcDataDebugMessage.debugExitMessage(null, null);
+ return componentMibInfo;
+ }
+
+ void updComponentMibInfoByType(String componentName, ArtifactType type,
+ MibEntity mibEntity,
+ ComponentMibInfo componentMibInfo,
+ Map<String, List<ErrorMessage>> errors) {
+
+
+ mdcDataDebugMessage.debugEntryMessage(null, null);
+
+ String path;
+ mibEntity.setType(type);
+ Optional<MibEntity> artifact =
+ getMibDao().getByType(mibEntity);
+
+ if (!artifact.isPresent()) {
+ return;
+ }
+ path = componentName + File.separator + ArtifactCategory.DEPLOYMENT.getDisplayName()
+ + File.separator + type.name();
+ MibInfo mibInfo = new MibInfo();
+ mibInfo.setName(path);
+ mibInfo.setContent(artifact.get().getArtifact().array());
+ switch (type) {
+ case SNMP_POLL:
+ componentMibInfo.setSnmpPoll(mibInfo);
+ break;
+ case SNMP_TRAP:
+ componentMibInfo.setSnmpTrap(mibInfo);
+ break;
+ default:
+ break;
+ }
+
+ mdcDataDebugMessage.debugExitMessage(null, null);
+ }
+
+ void enrichComponentMib(ComponentMibInfo componentMibInfo, String vspId, Version version,
+ Map<String, List<ErrorMessage>> errors) {
+
+
+ mdcDataDebugMessage.debugEntryMessage(null, null);
+
+ ServiceArtifact mibServiceArtifact = new ServiceArtifact();
+ mibServiceArtifact.setVspId(vspId);
+ mibServiceArtifact.setVersion(version);
+ enrichMibFiles(mibServiceArtifact, componentMibInfo, errors);
+
+ mdcDataDebugMessage.debugExitMessage(null, null);
+ }
+
+ void enrichMibFiles(ServiceArtifact mibServiceArtifact, ComponentMibInfo componentMibInfo,
+ Map<String, List<ErrorMessage>> errors) {
+
+
+ mdcDataDebugMessage.debugEntryMessage(null, null);
+
+ if (componentMibInfo == null) {
+ return;
+ }
+ enrichMibByType(componentMibInfo.getSnmpTrap(), ArtifactType.SNMP_TRAP, mibServiceArtifact,
+ errors);
+ enrichMibByType(componentMibInfo.getSnmpPoll(), ArtifactType.SNMP_POLL, mibServiceArtifact,
+ errors);
+
+ mdcDataDebugMessage.debugExitMessage(null, null);
+ }
+
+ void enrichMibByType(MibInfo mibInfo, ArtifactType type, ServiceArtifact mibServiceArtifact,
+ Map<String, List<ErrorMessage>> errors) {
+
+
+ mdcDataDebugMessage.debugEntryMessage(null, null);
+
+ if (mibInfo == null) {
+ return;
+ }
+ FileContentHandler mibs;
+ try {
+ mibs = FileUtils.getFileContentMapFromZip(FileUtils.toByteArray(mibInfo.getContent()));
+ } catch (IOException ioException) {
+ 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(FileUtils.toByteArray(mibs.getFileContent(fileName)));
+ mibServiceArtifact.setName(mibInfo.getName() + File.separator + fileName);
+ getEnrichedServiceModelDao().storeExternalArtifact(mibServiceArtifact);
+ }
+
+ mdcDataDebugMessage.debugExitMessage(null, null);
+ }
+
+ private EnrichedServiceModelDao getEnrichedServiceModelDao() {
+ if (enrichedServiceModelDao == null) {
+ enrichedServiceModelDao = EnrichedServiceModelDaoFactory.getInstance().createInterface();
+ }
+ return enrichedServiceModelDao;
+ }
+
+ private ComponentDao getComponentDao() {
+ if (componentDao == null) {
+ componentDao = ComponentDaoFactory.getInstance().createInterface();
+ }
+ return componentDao;
+ }
+
+ private MibDao getMibDao() {
+ if (mibDao == null) {
+ mibDao = MibDaoFactory.getInstance().createInterface();
+ }
+ return mibDao;
+ }
+
+}
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
new file mode 100644
index 0000000000..b4a2815d69
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/external/artifact/ProcessArtifactEnricher.java
@@ -0,0 +1,144 @@
+package org.openecomp.sdc.enrichment.impl.external.artifact;
+
+import org.openecomp.core.enrichment.types.ArtifactCategory;
+import org.openecomp.core.enrichment.types.ComponentProcessInfo;
+import org.openecomp.core.model.dao.EnrichedServiceModelDao;
+import org.openecomp.core.model.dao.EnrichedServiceModelDaoFactory;
+import org.openecomp.core.model.types.ServiceArtifact;
+import org.openecomp.core.utilities.file.FileUtils;
+import org.openecomp.sdc.datatypes.error.ErrorMessage;
+import org.openecomp.sdc.enrichment.EnrichmentInfo;
+import org.openecomp.sdc.enrichment.inter.ExternalArtifactEnricherInterface;
+import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ProcessDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ProcessDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
+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 VendorSoftwareProductDao vendorSoftwareProductDao;
+ //private ProcessArtifactDao processArtifactDao;
+ private ProcessDao processDao;
+ private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
+ private EnrichedServiceModelDao enrichedServiceModelDao;
+
+ @Override
+ public Map<String, List<ErrorMessage>> enrich(EnrichmentInfo enrichmentInfo) throws IOException {
+ Map<String, List<ErrorMessage>> errors = new HashMap<>();
+ String vspId = enrichmentInfo.getKey();
+ Version version = enrichmentInfo.getVersion();
+
+ Collection<ComponentEntity> components =
+ getVendorSoftwareProductDao().listComponents(vspId, version);
+ components.stream()
+ .forEach(componentEntry -> errors.putAll(enrichComponent(componentEntry,
+ vspId, version)));
+
+ return errors;
+ }
+
+ Map<String, List<ErrorMessage>> enrichComponent(ComponentEntity componentEntry, String vspId,
+ Version version) {
+ mdcDataDebugMessage.debugEntryMessage("LifeCycleOperationArtifactEnricher vspId ",
+ vspId);
+
+ Map<String, List<ErrorMessage>> errors = new HashMap<>();
+ enrichComponentProcessArtifact(componentEntry, vspId, version, errors);
+
+ mdcDataDebugMessage.debugExitMessage("LifeCycleOperationArtifactEnricher vspId ",
+ vspId);
+ return errors;
+ }
+
+ void enrichComponentProcessArtifact(ComponentEntity componentEntity,
+ String vspId, Version version,
+ Map<String, List<ErrorMessage>> errors) {
+
+
+ mdcDataDebugMessage.debugEntryMessage(null, null);
+
+ String componentId = componentEntity.getId();
+ ProcessEntity processEntity = new ProcessEntity(vspId, version, componentId, null);
+ final Collection<ProcessEntity> processes = getProcessDao().list(processEntity);
+
+ /*processes.stream()
+ .filter(entity -> entity.getType().equals(ProcessType.Lifecycle_Operations))
+ .forEach(entity -> {
+ ProcessArtifactEntity artifactEntity = new ProcessArtifactEntity(vspId, version,
+ componentId, entity.getId());*/
+
+ processes.stream()
+ .filter(entity -> entity.getType().equals(ProcessType.Lifecycle_Operations))
+ .forEach(entity -> {
+ ProcessEntity artifactEntity = new ProcessEntity(vspId, version,
+ componentId, entity.getId());
+
+ ProcessEntity artifactProcessEntity = getProcessDao().get(artifactEntity);
+ //ProcessArtifactEntity artifact = getProcessArtifactDao().get(artifactEntity);
+ if (artifactProcessEntity != 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, errors);
+ }
+ });
+
+ mdcDataDebugMessage.debugExitMessage(null, null);
+ }
+
+ void enrichServiceArtifact(ComponentProcessInfo componentProcessInfo,
+ ServiceArtifact processServiceArtifact,
+ Map<String, List<ErrorMessage>> errors) {
+
+
+ mdcDataDebugMessage.debugEntryMessage(null, null);
+
+ processServiceArtifact.setName(componentProcessInfo.getName());
+ processServiceArtifact.setContentData(FileUtils.toByteArray(componentProcessInfo.getContent()));
+ getEnrichedServiceModelDao().storeExternalArtifact(processServiceArtifact);
+ mdcDataDebugMessage.debugExitMessage(null, null);
+ }
+
+ private VendorSoftwareProductDao getVendorSoftwareProductDao() {
+ if (vendorSoftwareProductDao == null) {
+ vendorSoftwareProductDao = VendorSoftwareProductDaoFactory.getInstance().createInterface();
+ }
+ return vendorSoftwareProductDao;
+ }
+
+ private ProcessDao getProcessDao() {
+ if (processDao == null) {
+ processDao = ProcessDaoFactory.getInstance().createInterface();
+ }
+ return processDao;
+ }
+
+ private EnrichedServiceModelDao getEnrichedServiceModelDao() {
+
+ if (enrichedServiceModelDao == null) {
+ enrichedServiceModelDao = EnrichedServiceModelDaoFactory.getInstance().createInterface();
+ }
+ 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
new file mode 100644
index 0000000000..b7da22bdfb
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/external/artifact/VspInformationArtifactEnricher.java
@@ -0,0 +1,134 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.enrichment.impl.external.artifact;
+
+
+import org.openecomp.core.enrichment.types.ArtifactCategory;
+import org.openecomp.core.enrichment.types.InformationArtifactFolderNames;
+import org.openecomp.core.model.dao.EnrichedServiceModelDao;
+import org.openecomp.core.model.dao.EnrichedServiceModelDaoFactory;
+import org.openecomp.core.model.types.ServiceArtifact;
+import org.openecomp.sdc.datatypes.error.ErrorLevel;
+import org.openecomp.sdc.datatypes.error.ErrorMessage;
+import org.openecomp.sdc.enrichment.EnrichmentInfo;
+import org.openecomp.sdc.enrichment.inter.ExternalArtifactEnricherInterface;
+import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
+import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
+import org.openecomp.sdc.vendorsoftwareproduct.factory.InformationArtifactGeneratorFactory;
+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.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+
+/**
+ * Created by Talio on 11/24/2016
+ */
+public class VspInformationArtifactEnricher implements ExternalArtifactEnricherInterface {
+ private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
+ private static InformationArtifactGenerator informationArtifactGenerator =
+ InformationArtifactGeneratorFactory.getInstance().createInterface();
+ private EnrichedServiceModelDao enrichedServiceModelDao =
+ EnrichedServiceModelDaoFactory.getInstance().createInterface();
+ private VendorSoftwareProductInfoDao vspInfoDao = VendorSoftwareProductInfoDaoFactory
+ .getInstance().createInterface();
+ private OrchestrationTemplateDao orchestrationTemplateDataDao =
+ OrchestrationTemplateDaoFactory.getInstance().createInterface();
+
+ public VspInformationArtifactEnricher() {
+ }
+
+ public Map<String, List<ErrorMessage>> enrich(EnrichmentInfo enrichmentInfo)
+ throws IOException {
+
+ String vspId = enrichmentInfo.getKey();
+ Version version = enrichmentInfo.getVersion();
+ Map<String, List<ErrorMessage>> errors = enrichInformationArtifact(vspId, version);
+
+ return errors;
+ }
+
+ private Map<String, List<ErrorMessage>> enrichInformationArtifact(String vspId, Version version)
+ throws IOException {
+
+
+ mdcDataDebugMessage.debugEntryMessage(null, null);
+
+ 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())));
+ //TODO: add error to map (what is the key?)
+
+ mdcDataDebugMessage.debugExitMessage(null, null);
+ return errors;
+ }
+
+ enrichInformationArtifact(vspId, version, infoArtifactByteBuffer);
+
+ mdcDataDebugMessage.debugExitMessage(null, null);
+ return errors;
+ }
+
+ private void enrichInformationArtifact(String vspId, Version version,
+ ByteBuffer infoArtifactByteBuffer) {
+ ServiceArtifact infoArtifactServiceArtifact = new ServiceArtifact();
+
+ VspDetails vspDetails = getVspDetails(vspId, version);
+
+ String vspName = vspDetails.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 VspDetails getVspDetails(String vspId,Version version){
+ VspDetails vspDetails = vspInfoDao.get(new VspDetails(vspId,version));
+ vspDetails.setValidationData(orchestrationTemplateDataDao.getValidationData(vspId,version));
+ return vspDetails;
+ }
+}
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
new file mode 100644
index 0000000000..d75c83f24c
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/AbstractSubstituteToscaEnricher.java
@@ -0,0 +1,243 @@
+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.VFC_NAMING_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.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.ABSTRACT_NODE_TEMPLATE_ID_PREFIX;
+
+import org.apache.commons.lang3.StringUtils;
+import org.openecomp.sdc.datatypes.error.ErrorMessage;
+import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
+import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
+import org.openecomp.sdc.tosca.datatypes.model.NodeTemplate;
+import org.openecomp.sdc.tosca.datatypes.model.RequirementAssignment;
+import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate;
+import org.openecomp.sdc.tosca.services.ToscaAnalyzerService;
+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.Optional;
+
+public class AbstractSubstituteToscaEnricher {
+ private ToscaAnalyzerService toscaAnalyzerService ;
+ private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
+ private ComponentQuestionnaireData componentQuestionnaireData;
+
+
+ public Map<String,List<ErrorMessage>> enrich(ToscaServiceModel toscaModel, String vspId, Version
+ version) {
+
+ mdcDataDebugMessage.debugEntryMessage(vspId, version.toString());
+
+ componentQuestionnaireData = getComponentQuestionnaireData();
+ toscaAnalyzerService = new ToscaAnalyzerServiceImpl();
+
+ Map<String, Map<String, Object>> componentProperties =
+ componentQuestionnaireData.getPropertiesfromCompQuestionnaire(vspId, version);
+
+ final Map<String, List<String>> sourceToTargetDependencies =
+ componentQuestionnaireData.populateDependencies(vspId, version,
+ componentQuestionnaireData.getSourceToTargetComponent());
+
+ Map<String, List<ErrorMessage>> errors = new HashMap<>();
+
+ final ServiceTemplate serviceTemplate = toscaModel.getServiceTemplates()
+ .get(toscaModel.getEntryDefinitionServiceTemplate());
+
+ if (serviceTemplate == null) return errors;
+
+ final Map<String, NodeTemplate> node_templates =
+ serviceTemplate.getTopology_template().getNode_templates();
+
+ final Map<String, List<String>> componentDisplayNameToNodeTempalteIds =
+ populateAllNodeTemplateIdForComponent(node_templates, serviceTemplate, toscaModel);
+
+ node_templates.keySet()
+ .stream()
+ .forEach(nodeTemplateId -> {
+ final Optional<NodeTemplate> nodeTemplateById =
+ toscaAnalyzerService.getNodeTemplateById(serviceTemplate, nodeTemplateId);
+ final NodeTemplate nodeTemplate =
+ nodeTemplateById.isPresent() ? nodeTemplateById.get() : null;
+
+ if (toscaAnalyzerService.isTypeOf(nodeTemplate, VFC_ABSTRACT_SUBSTITUTE, serviceTemplate,
+ toscaModel)) {
+
+ String componentDisplayName = getComponentDisplayName(nodeTemplateId);
+
+ setProperty(nodeTemplate, VM_TYPE_TAG, componentDisplayName);
+
+ if (componentProperties != null && componentProperties.containsKey
+ (componentDisplayName)) {
+ final String mandatory =
+ getValueFromQuestionnaireDetails(componentProperties, componentDisplayName,
+ MANDATORY);
+
+ boolean isServiceTemplateFilterNotExists = false;
+ if (!StringUtils.isEmpty(mandatory)) {
+ Map innerProps = (Map<String, Object>) nodeTemplate.getProperties()
+ .get(SERVICE_TEMPLATE_FILTER_PROPERTY_NAME);
+
+ if (innerProps == null) {
+ innerProps = new HashMap<String, Object>();
+ isServiceTemplateFilterNotExists = true;
+ }
+
+ innerProps.put(MANDATORY, getValue(mandatory));
+
+ if(isServiceTemplateFilterNotExists)
+ nodeTemplate.getProperties().put(SERVICE_TEMPLATE_FILTER_PROPERTY_NAME,
+ innerProps);
+ }
+
+ setProperty(nodeTemplate, HIGH_AVAIL_MODE, getValueFromQuestionnaireDetails
+ (componentProperties, componentDisplayName, HIGH_AVAIL_MODE));
+
+ setProperty(nodeTemplate, VFC_NAMING_CODE, getValueFromQuestionnaireDetails
+ (componentProperties, componentDisplayName, VFC_NAMING_CODE));
+
+
+ if(componentProperties.get(componentDisplayName).get(MIN_INSTANCES) != null) {
+ 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));
+ }
+ }
+
+ enrichRequirements(sourceToTargetDependencies, componentDisplayName, nodeTemplate,
+ componentDisplayNameToNodeTempalteIds);
+ }
+ });
+
+ mdcDataDebugMessage.debugExitMessage(vspId, version.toString());
+ return errors;
+ }
+
+ private Map<String,List<String>> populateAllNodeTemplateIdForComponent(Map<String,
+ NodeTemplate> node_templates, ServiceTemplate serviceTemplate, ToscaServiceModel
+ toscaModel) {
+
+
+ Map<String,List<String>> componentDisplayNameToNodeTempalteIds = new HashMap<String,
+ List<String>>();
+
+ //set dependency target
+ node_templates.keySet()
+ .stream()
+ .forEach(nodeTemplateId -> {
+
+ final Optional<NodeTemplate> nodeTemplateById =
+ toscaAnalyzerService.getNodeTemplateById(serviceTemplate, nodeTemplateId);
+ final NodeTemplate nodeTemplate =
+ nodeTemplateById.isPresent() ? nodeTemplateById.get() : null;
+
+ if (toscaAnalyzerService.isTypeOf(nodeTemplate, VFC_ABSTRACT_SUBSTITUTE, serviceTemplate,
+ toscaModel)) {
+
+ String componentDisplayName = getComponentDisplayName(nodeTemplateId);
+
+ if (componentDisplayNameToNodeTempalteIds.containsKey(componentDisplayName)) {
+ componentDisplayNameToNodeTempalteIds.get(componentDisplayName).add(nodeTemplateId);
+ } else {
+ List<String> nodeTemplateIds = new ArrayList<String>();
+ 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) {
+ List<Map<String, RequirementAssignment>> requirements =
+ nodeTemplate.getRequirements();
+
+ if(requirements == null) {
+ requirements = new ArrayList<Map<String, RequirementAssignment>>();
+ }
+
+ final List<String> targets = sourceToTargetDependencies.get(componentDisplayName);
+ if(targets != null) {
+ for (String target : targets) {
+ List<String> targetNodeTemplateIds = componentDisplayNameToNodeTempalteIds.get(target);
+ if(targetNodeTemplateIds != null) {
+ for (String targetNodeTemplateId : targetNodeTemplateIds) {
+ Map<String, RequirementAssignment> requirement = new HashMap<String,
+ RequirementAssignment>();
+ RequirementAssignment requirementAssignment = new RequirementAssignment();
+ requirementAssignment.setCapability(NATIVE_NODE);
+ requirementAssignment.setRelationship(NATIVE_DEPENDS_ON);
+ requirementAssignment.setNode(targetNodeTemplateId);
+ requirement.put("dependency", requirementAssignment);
+ requirements.add(requirement);
+ }
+ }
+ }
+ }
+
+ if (!requirements.isEmpty())
+ nodeTemplate.setRequirements(requirements);
+ }
+
+ private String getComponentDisplayName(String nodeTemplateId ) {
+ String componentDisplayName = null;
+ if (nodeTemplateId.contains(ABSTRACT_NODE_TEMPLATE_ID_PREFIX)) {
+ String removedPrefix = nodeTemplateId.split(ABSTRACT_NODE_TEMPLATE_ID_PREFIX)[1];
+ final String[] removedSuffix = removedPrefix.split("_\\d");
+ componentDisplayName = removedSuffix[0];
+ }
+ return componentDisplayName;
+ }
+
+ 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);
+ }
+ }
+
+ private Boolean getValue(String value) {
+ String returnValue = null;
+ switch (value) {
+ case "YES" :
+ return true;
+ case "NO" :
+ return false;
+ default: return null;
+ }
+ }
+
+ private ComponentQuestionnaireData getComponentQuestionnaireData() {
+ if (componentQuestionnaireData == null) {
+ componentQuestionnaireData = new ComponentQuestionnaireData();
+ }
+ return componentQuestionnaireData;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/CeilometerEnricher.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/CeilometerEnricher.java
deleted file mode 100644
index eb79787b59..0000000000
--- a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/CeilometerEnricher.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.enrichment.impl.tosca;
-
-import org.apache.commons.collections4.MapUtils;
-import org.openecomp.core.enrichment.types.CeilometerInfo;
-import org.openecomp.sdc.datatypes.error.ErrorMessage;
-import org.openecomp.sdc.enrichment.EnrichmentInfo;
-import org.openecomp.sdc.tosca.datatypes.ToscaCapabilityType;
-import org.openecomp.sdc.tosca.datatypes.ToscaElementTypes;
-import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
-import org.openecomp.sdc.tosca.datatypes.model.CapabilityDefinition;
-import org.openecomp.sdc.tosca.datatypes.model.CapabilityType;
-import org.openecomp.sdc.tosca.datatypes.model.NodeType;
-import org.openecomp.sdc.tosca.services.ToscaAnalyzerService;
-import org.openecomp.sdc.tosca.services.ToscaUtil;
-import org.openecomp.sdc.tosca.services.impl.ToscaAnalyzerServiceImpl;
-import org.openecomp.sdc.translator.services.heattotosca.globaltypes.CommonGlobalTypes;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-public class CeilometerEnricher {
- /**
- * Enrich map.
- *
- * @param toscaModel the tosca model
- * @param modelNodeType the model node type
- * @param input the input
- * @return the map
- */
- public static Map<String, List<ErrorMessage>> enrich(ToscaServiceModel toscaModel,
- Map<String, List<NodeType>> modelNodeType,
- EnrichmentInfo input) {
- Map<String, List<ErrorMessage>> errors = new HashMap<>();
- input.getEntityInfo().entrySet().stream().forEach(
- entry -> enrichNodeType(toscaModel, (ComponentInfo) entry.getValue(),
- modelNodeType.get(entry.getKey())));
-
- return errors;
- }
-
- private static void enrichNodeType(ToscaServiceModel toscaModel, ComponentInfo componentInfo,
- List<NodeType> nodeTypes) {
-
- for (CeilometerInfo ceilometerInfo : componentInfo.getCeilometerInfo()
- .getCeilometerInfoList()) {
- String capabilityId = ceilometerInfo.getName();
-
- Map<String, Object> properties = getCeilometerProperties(ceilometerInfo);
-
- //CapabilityType capabilityType = CommonGlobalTypes.createServiceTemplate()
- // .getCapability_types().
- // get(ToscaCapabilityType.METRIC_CEILOMETER.getDisplayName());
- //CapabilityType metricCapabilityType = CommonGlobalTypes.createServiceTemplate().
- // getCapability_types().get(ToscaCapabilityType.METRIC.getDisplayName());
- ToscaAnalyzerService toscaAnalyzerService = new ToscaAnalyzerServiceImpl();
- CapabilityType capabilityType = (CapabilityType) toscaAnalyzerService
- .getFlatEntity(ToscaElementTypes.CAPABILITY_TYPE,
- ToscaCapabilityType.METRIC_CEILOMETER.getDisplayName(),
- CommonGlobalTypes.createServiceTemplate(), toscaModel);
-
-
- nodeTypes.stream().forEach(nodeType ->
- addCapability(nodeType, capabilityId, ToscaUtil
- .convertTypeToDefinition(ToscaCapabilityType.METRIC_CEILOMETER.getDisplayName(),
- capabilityType, properties, ceilometerInfo.getDescription())));
- }
- }
-
- private static Map<String, Object> getCeilometerProperties(CeilometerInfo ceilometerInfo) {
- Map<String, Object> properties = new HashMap<>();
- properties.put("name", ceilometerInfo.getName());
- properties.put("type", ceilometerInfo.getType());
- properties.put("unit", ceilometerInfo.getUnit());
- if (ceilometerInfo.getCategory() != null) {
- properties.put("category", ceilometerInfo.getCategory());
- }
- return properties;
- }
-
- private static void addCapability(NodeType nodeType, String capabilityId,
- CapabilityDefinition capabilityDefinition) {
- if (MapUtils.isEmpty(nodeType.getCapabilities())) {
- nodeType.setCapabilities(new HashMap<>());
- }
- //clean unnecessary info
- capabilityDefinition.setAttributes(null);
- capabilityDefinition.setOccurrences(null);
-
- nodeType.getCapabilities().put(capabilityId, capabilityDefinition);
- }
-}
diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/ComponentInfo.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/ComponentInfo.java
deleted file mode 100644
index 0a1f3d36ff..0000000000
--- a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/ComponentInfo.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.enrichment.impl.tosca;
-
-import org.openecomp.core.enrichment.types.ComponentCeilometerInfo;
-import org.openecomp.core.enrichment.types.ComponentMibInfo;
-import org.openecomp.core.enrichment.types.EntityInfo;
-
-public class ComponentInfo implements EntityInfo {
-
- private ComponentCeilometerInfo ceilometerInfo;
- private ComponentMibInfo mibInfo;
-
- public ComponentCeilometerInfo getCeilometerInfo() {
- return ceilometerInfo;
- }
-
- public void setCeilometerInfo(ComponentCeilometerInfo ceilometerInfo) {
- this.ceilometerInfo = ceilometerInfo;
- }
-
- public ComponentMibInfo getMibInfo() {
- return mibInfo;
- }
-
- public void setMibInfo(ComponentMibInfo mibInfo) {
- this.mibInfo = mibInfo;
- }
-}
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
new file mode 100644
index 0000000000..7457c36701
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/ComponentQuestionnaireData.java
@@ -0,0 +1,123 @@
+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.VFC_NAMING_CODE;
+
+import org.openecomp.core.utilities.json.JsonUtil;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDependencyModelDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDependencyModelDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentDependencyModelEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
+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;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+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<String, Map<String,Object>>();
+
+ ComponentEntity entity = new ComponentEntity(key, version, null);
+ final Collection<ComponentEntity> componentEntities =
+ componentDao.listCompositionAndQuestionnaire(key, version);
+
+ Map<String,String> sourceToTarget = new HashMap<String, String>();
+
+ for (ComponentEntity component : componentEntities) {
+ Map<String, Object> questionnaireParams = new HashMap<String, Object>();
+
+ 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 vfc_code = componentData != null ? componentData.getVfcCode() : null;
+ questionnaireParams.put(VFC_NAMING_CODE, vfc_code);
+
+ 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>> sourceToTargetComponent = new HashMap<String, List<String>>();
+ List<String> targetComponents = null;
+ for (ComponentDependencyModelEntity dependency : componentDependencies) {
+ String sourceComponentName = componentNameData.get(dependency.getSourceComponentId());
+ String targetComponentName = componentNameData.get(dependency.getTargetComponentId());
+ if (!sourceToTargetComponent.containsKey(sourceComponentName)) {
+ targetComponents = new ArrayList<String>();
+ } else {
+ targetComponents = sourceToTargetComponent.get(sourceComponentName);
+ }
+ targetComponents.add(targetComponentName);
+ sourceToTargetComponent.put(sourceComponentName, targetComponents);
+ }
+
+ return sourceToTargetComponent;
+ }
+
+}
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 2c0f03480f..854d84ad84 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
@@ -20,11 +20,11 @@
package org.openecomp.sdc.enrichment.impl.tosca;
+import org.openecomp.sdc.common.utils.CommonUtil;
import org.openecomp.sdc.datatypes.error.ErrorMessage;
import org.openecomp.sdc.enrichment.inter.Enricher;
+import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
-import org.openecomp.sdc.tosca.datatypes.model.NodeType;
-import org.openecomp.sdc.tosca.services.ToscaUtil;
import java.util.HashMap;
import java.util.List;
@@ -32,42 +32,28 @@ import java.util.Map;
public class ToscaEnricher extends Enricher {
- Map<String, List<NodeType>> componentTypNodeTypeMap;
+ private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
@Override
public Map<String, List<ErrorMessage>> enrich() {
Map<String, List<ErrorMessage>> errors = new HashMap<>();
- Map<String, List<ErrorMessage>> enrichResponse;
- enrichResponse = enrichCilometer();
- errors.putAll(enrichResponse);
- enrichResponse = enrichSnmp();
- errors.putAll(enrichResponse);
-
+ errors.putAll(enrichAbstractSubstitute());
return errors;
}
- private Map<String, List<ErrorMessage>> enrichCilometer() {
- Map<String, List<ErrorMessage>> enrichResponse;
-
- ToscaServiceModel toscaModel = (ToscaServiceModel) model;
-
- componentTypNodeTypeMap =
- ToscaUtil.normalizeComponentNameNodeType(toscaModel, input.getEntityInfo().keySet());
-
- enrichResponse = CeilometerEnricher.enrich(toscaModel, componentTypNodeTypeMap, this.input);
+ private Map<String, List<ErrorMessage>> enrichAbstractSubstitute() {
+ mdcDataDebugMessage.debugEntryMessage(null, null);
- return enrichResponse;
- }
+ Map<String, List<ErrorMessage>> enrichErrors;
+ ToscaServiceModel toscaModel = (ToscaServiceModel) model;
+ AbstractSubstituteToscaEnricher abstractSubstituteToscaEnricher =
+ new AbstractSubstituteToscaEnricher();
+ enrichErrors = abstractSubstituteToscaEnricher.enrich(toscaModel, data.getKey(),
+ data.getVersion());
- private Map<String, List<ErrorMessage>> enrichSnmp() {
- Map<String, List<ErrorMessage>> enrichResponse;
-
- enrichResponse = SnmpEnricher.enrich(componentTypNodeTypeMap, this.input);
-
- return enrichResponse;
+ mdcDataDebugMessage.debugExitMessage(null, null);
+ return enrichErrors;
}
-
-
}
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
new file mode 100644
index 0000000000..e803d14b35
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/util/EnrichmentConstants.java
@@ -0,0 +1,12 @@
+package org.openecomp.sdc.enrichment.impl.util;
+
+public class EnrichmentConstants {
+
+ public static final String VFC_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";
+
+}
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 1d6867d1f3..ed606f8746 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
@@ -20,6 +20,7 @@
package org.openecomp.sdc.enrichment.inter;
+
import org.openecomp.sdc.datatypes.error.ErrorMessage;
import org.openecomp.sdc.datatypes.model.AsdcModel;
import org.openecomp.sdc.enrichment.EnrichmentInfo;
@@ -30,16 +31,16 @@ import java.util.Map;
public abstract class Enricher {
- protected EnrichmentInfo input;
- protected AsdcModel model;
+ protected EnrichmentInfo data;
+ protected AsdcModel model;
- public void setInput(EnrichmentInfo input) {
- this.input = input;
- }
+ public void setData(EnrichmentInfo data) {
+ this.data = data;
+ }
- public void setModel(AsdcModel model) {
- this.model = model;
- }
+ public void setModel(AsdcModel model) {
+ this.model = model;
+ }
- public abstract Map<String, List<ErrorMessage>> enrich();
+ public abstract Map<String, List<ErrorMessage>> enrich();
}
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 717bbc8313..f0ffa0b1ad 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
@@ -20,22 +20,10 @@
package org.openecomp.sdc.enrichment.inter;
-import org.openecomp.sdc.datatypes.error.ErrorMessage;
-import org.openecomp.sdc.datatypes.model.AsdcModel;
-
import java.util.List;
-import java.util.Map;
public interface EnricherHandler {
-
- List<Enricher> getEnrichers();
-
- Map<String, List<ErrorMessage>> enrich();
-
- void addAdditionalInput(String key, Object input);
-
- void setModel(AsdcModel model);
-
+ List<Enricher> getEnrichers();
}
diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/SnmpEnricher.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/inter/ExternalArtifactEnricherInterface.java
index 42cbcdd50b..49b424ef05 100644
--- a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/SnmpEnricher.java
+++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/inter/ExternalArtifactEnricherInterface.java
@@ -18,21 +18,19 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.sdc.enrichment.impl.tosca;
+package org.openecomp.sdc.enrichment.inter;
-import org.openecomp.sdc.datatypes.error.ErrorMessage;
+import org.openecomp.sdc.datatypes.error.ErrorMessage;
import org.openecomp.sdc.enrichment.EnrichmentInfo;
-import org.openecomp.sdc.tosca.datatypes.model.NodeType;
-import java.util.HashMap;
+import java.io.IOException;
import java.util.List;
import java.util.Map;
-public class SnmpEnricher {
- public static Map<String, List<ErrorMessage>> enrich(Map<String, List<NodeType>> modelNodeType,
- EnrichmentInfo input) {
- return new HashMap<>();
-
- }
+/**
+ * Created by Talio on 11/24/2016.
+ */
+public interface ExternalArtifactEnricherInterface {
+ public Map<String, List<ErrorMessage>> enrich(EnrichmentInfo enrichmentInfo) throws IOException;
}