summaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java
diff options
context:
space:
mode:
authormojahidi <mojahidul.islam@amdocs.com>2017-12-28 18:33:00 +0530
committerAvi Gaffa <avi.gaffa@amdocs.com>2018-01-02 15:20:27 +0000
commit9d79007d2b36d5ae4a03581eeca1fcf6232b3b09 (patch)
tree0638ab46c050e901995e03dcefe5d4c0314ec95d /openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java
parentb38f18bb99a603012ec406053531c45fb4643d62 (diff)
fix MIB assignment
Assign mib file to all of the components from the same VFC type Change-Id: Ia6a1a5a08b7383ec64ace085193b0c8daa399c7f Issue-ID: SDC-811 Signed-off-by: talio <tali.orenbach@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/impl/external/artifact/ExternalArtifactEnricher.java10
-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.java17
-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.java9
-rw-r--r--openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/inter/ExternalArtifactEnricherInterface.java4
5 files changed, 176 insertions, 100 deletions
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 57c1d19f03..e55ad880e9 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
@@ -28,6 +28,7 @@ import org.openecomp.sdc.enrichment.inter.ExternalArtifactEnricherInterface;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
+import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
import java.lang.reflect.Constructor;
import java.util.Collection;
@@ -38,9 +39,6 @@ import java.util.Map;
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 Logger logger = LoggerFactory.getLogger(ExternalArtifactEnricher.class);
@@ -57,21 +55,21 @@ public class ExternalArtifactEnricher extends Enricher {
public Map<String, List<ErrorMessage>> enrich() {
- mdcDataDebugMessage.debugEntryMessage(null, null);
+ mdcDataDebugMessage.debugEntryMessage(null);
Map<String, List<ErrorMessage>> errors = new HashMap<>();
try {
for (String implementingClassName : implementingClasses) {
ExternalArtifactEnricherInterface externalArtifactEnricherInstance = getExternalArtifactEnricherInstance(implementingClassName);
- externalArtifactEnricherInstance.enrich(this.data);
+ externalArtifactEnricherInstance.enrich(this.data, (ToscaServiceModel) this.model);
}
} catch (Exception e) {
logger.debug("",e);
logger.error(e.getMessage());
}
- mdcDataDebugMessage.debugExitMessage(null, null);
+ mdcDataDebugMessage.debugExitMessage(null);
return errors;
}
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 ff0e9b4838..f15d83cd55 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
@@ -37,7 +37,10 @@ import org.openecomp.sdc.enrichment.inter.ExternalArtifactEnricherInterface;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
-import org.openecomp.sdc.tosca.datatypes.ToscaNodeType;
+import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
+import org.openecomp.sdc.tosca.datatypes.model.Directive;
+import org.openecomp.sdc.tosca.datatypes.model.NodeTemplate;
+import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate;
import org.openecomp.sdc.tosca.services.DataModelUtil;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentArtifactDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao;
@@ -49,28 +52,37 @@ import org.openecomp.sdc.versioning.dao.types.Version;
import java.io.File;
import java.io.IOException;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
import java.util.Optional;
import java.util.Set;
+import static org.openecomp.sdc.tosca.services.ToscaConstants.SERVICE_TEMPLATE_FILTER_PROPERTY_NAME;
+import static org.openecomp.sdc.tosca.services.ToscaConstants.SUBSTITUTE_SERVICE_TEMPLATE_PROPERTY_NAME;
+
public class MonitoringMibEnricher implements ExternalArtifactEnricherInterface {
private EnrichedServiceModelDao enrichedServiceModelDao;
private ComponentDao componentDao;
private ComponentArtifactDao componentArtifactDao;
private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
+ private static final String COMPONENT_PREFIX = "org.openecomp.resource.vfc.";
+
+ private final Logger LOG = LoggerFactory.getLogger(this.getClass().getName());
- private final Logger log = (Logger) LoggerFactory.getLogger(this.getClass().getName());
/**
* Enrich map.
*
* @param enrichmentInfo the enrichmentInfo
* @return the map
*/
- public Map<String, List<ErrorMessage>> enrich(EnrichmentInfo enrichmentInfo) {
+ public Map<String, List<ErrorMessage>> enrich(EnrichmentInfo enrichmentInfo,
+ ToscaServiceModel serviceModel) {
Map<String, List<ErrorMessage>> errors = new HashMap<>();
String vspId = enrichmentInfo.getKey();
@@ -79,33 +91,115 @@ public class MonitoringMibEnricher implements ExternalArtifactEnricherInterface
Collection<ComponentEntity> components =
getComponentDao().list(new ComponentEntity(vspId, version, null));
components
- .forEach(componentEntry -> errors.putAll(enrichComponent(componentEntry, vspId, version)));
+ .forEach(componentEntry -> errors.putAll(enrichComponent(vspId, version, componentEntry,
+ serviceModel)));
return errors;
}
- Map<String, List<ErrorMessage>> enrichComponent(ComponentEntity componentEntry, String vspId,
- Version version) {
+ 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);
+ }
+
+ 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 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 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 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) {
- mdcDataDebugMessage.debugEntryMessage(null, null);
+ mdcDataDebugMessage.debugEntryMessage(null);
Map<String, List<ErrorMessage>> errors = new HashMap<>();
- ComponentMonitoringUploadInfo componentMonitoringUploadInfo =
- extractComponentMibInfo(componentEntry, vspId, version, errors);
- enrichComponentMib(componentMonitoringUploadInfo, vspId, version, errors);
- mdcDataDebugMessage.debugExitMessage(null, null);
+ List<ComponentMonitoringUploadInfo> componentMonitoringUploadInfoList =
+ extractComponentMibInfo(vspId, version, componentEntry, abstractNodeTypes);
+
+ componentMonitoringUploadInfoList.forEach(
+ componentUploadInfo -> enrichComponentMib(vspId, version, componentUploadInfo, errors));
+
+ mdcDataDebugMessage.debugExitMessage(null);
return errors;
}
- private ComponentMonitoringUploadInfo extractComponentMibInfo(ComponentEntity componentEntity,
- String vspId,
- Version version,
- Map<String, List<ErrorMessage>> errors) {
+ private List<ComponentMonitoringUploadInfo> extractComponentMibInfo(String vspId, Version version,
+ ComponentEntity componentEntity,
+ Set<String> abstractNodeTypes) {
- mdcDataDebugMessage.debugEntryMessage(null, null);
+ mdcDataDebugMessage.debugEntryMessage(null);
String componentId = componentEntity.getId();
ComponentMonitoringUploadEntity entity = new ComponentMonitoringUploadEntity();
@@ -113,79 +207,70 @@ public class MonitoringMibEnricher implements ExternalArtifactEnricherInterface
entity.setVspId(vspId);
entity.setVersion(version);
entity.setComponentId(componentId);
- String componentName = componentEntity.getComponentCompositionData().getName();
- ComponentMonitoringUploadInfo componentMonitoringUploadInfo =
- new ComponentMonitoringUploadInfo();
- for (MonitoringUploadType monitoringUploadType : MonitoringUploadType.values()) {
- updComponentMibInfoByType(componentName, monitoringUploadType, entity,
- componentMonitoringUploadInfo,
- errors);
- }
-// updComponentMibInfoByType(componentName, MonitoringUploadType.SNMP_POLL, entity,
-// componentMonitoringUploadInfo,
-// errors);
-// updComponentMibInfoByType(componentName, MonitoringUploadType.SNMP_TRAP, entity,
-// componentMonitoringUploadInfo,
-// errors);
-
- mdcDataDebugMessage.debugExitMessage(null, null);
- return componentMonitoringUploadInfo;
+ List<ComponentMonitoringUploadInfo> componentMonitoringUploadInfoList = new ArrayList<>();
+
+ abstractNodeTypes.forEach(unifiedComponentNodeType -> componentMonitoringUploadInfoList
+ .add(updComponentMibInfoByType(unifiedComponentNodeType, entity)));
+
+ mdcDataDebugMessage.debugExitMessage(null);
+ return componentMonitoringUploadInfoList;
}
- private void updComponentMibInfoByType(String componentName, MonitoringUploadType type,
- ComponentMonitoringUploadEntity componentMonitoringUploadEntity,
- ComponentMonitoringUploadInfo componentMonitoringUploadInfo,
- Map<String, List<ErrorMessage>> errors) {
+ private ComponentMonitoringUploadInfo updComponentMibInfoByType(String componentName,
+ ComponentMonitoringUploadEntity componentMonitoringUploadEntity) {
- mdcDataDebugMessage.debugEntryMessage(null, null);
+ mdcDataDebugMessage.debugEntryMessage(null);
- String path;
- componentMonitoringUploadEntity.setType(type);
- Optional<ComponentMonitoringUploadEntity> artifact =
- getComponentArtifactDao().getByType(componentMonitoringUploadEntity);
+ ComponentMonitoringUploadInfo componentMonitoringUploadInfo =
+ new ComponentMonitoringUploadInfo();
- if (!artifact.isPresent()) {
- return;
+ 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);
}
- String unifiedComponentNodeType =
- ToscaNodeType.ABSTRACT_NODE_TYPE_PREFIX + DataModelUtil.getNamespaceSuffix(componentName);
- path = unifiedComponentNodeType + File.separator + ArtifactCategory.DEPLOYMENT.getDisplayName()
+
+ mdcDataDebugMessage.debugExitMessage(null);
+ return componentMonitoringUploadInfo;
+ }
+
+ private String getArtifactPath(MonitoringUploadType type, String unifiedComponentNodeType) {
+ return unifiedComponentNodeType + File.separator + ArtifactCategory.DEPLOYMENT.getDisplayName()
+ File.separator + type.name();
+ }
+
+ private void updateComponentMonitoringUploadInfoWithMib(String path,
+ MonitoringUploadType type,
+ ComponentMonitoringUploadEntity mibArtifact,
+ ComponentMonitoringUploadInfo componentMonitoringUploadInfo) {
MonitoringArtifactInfo monitoringArtifactInfo = new MonitoringArtifactInfo();
monitoringArtifactInfo.setName(path);
- monitoringArtifactInfo.setContent(artifact.get().getArtifact().array());
- switch (type) { //todo as part of ATTASDC-4503
- case SNMP_POLL:
- componentMonitoringUploadInfo.setSnmpPoll(monitoringArtifactInfo);
- break;
- case SNMP_TRAP:
- componentMonitoringUploadInfo.setSnmpTrap(monitoringArtifactInfo);
- break;
- case VES_EVENTS:
- componentMonitoringUploadInfo.setVesEvent(monitoringArtifactInfo);
- break;
- default:
- break;
- }
-
- mdcDataDebugMessage.debugExitMessage(null, null);
+ monitoringArtifactInfo.setContent(mibArtifact.getArtifact().array());
+ componentMonitoringUploadInfo.setMonitoringArtifactFile(type, monitoringArtifactInfo);
}
- private void enrichComponentMib(ComponentMonitoringUploadInfo componentMonitoringUploadInfo,
- String vspId,
+ private void enrichComponentMib(String vspId,
Version version,
+ ComponentMonitoringUploadInfo componentUploadInfo,
Map<String, List<ErrorMessage>> errors) {
-
-
- mdcDataDebugMessage.debugEntryMessage(null, null);
+ mdcDataDebugMessage.debugEntryMessage(null);
ServiceArtifact mibServiceArtifact = new ServiceArtifact();
mibServiceArtifact.setVspId(vspId);
mibServiceArtifact.setVersion(version);
- enrichMibFiles(mibServiceArtifact, componentMonitoringUploadInfo, errors);
+ enrichMibFiles(mibServiceArtifact, componentUploadInfo, errors);
+
- mdcDataDebugMessage.debugExitMessage(null, null);
+ mdcDataDebugMessage.debugExitMessage(null);
}
private void enrichMibFiles(ServiceArtifact monitoringArtifact,
@@ -193,12 +278,11 @@ public class MonitoringMibEnricher implements ExternalArtifactEnricherInterface
Map<String, List<ErrorMessage>> errors) {
- mdcDataDebugMessage.debugEntryMessage(null, null);
+ mdcDataDebugMessage.debugEntryMessage(null);
if (componentMonitoringUploadInfo == null) {
return;
}
- //todo fix as part of ATTASDC-4503
enrichMibByType(componentMonitoringUploadInfo.getSnmpTrap(), MonitoringUploadType.SNMP_TRAP,
monitoringArtifact,
errors);
@@ -209,7 +293,7 @@ public class MonitoringMibEnricher implements ExternalArtifactEnricherInterface
monitoringArtifact,
errors);
- mdcDataDebugMessage.debugExitMessage(null, null);
+ mdcDataDebugMessage.debugExitMessage(null);
}
private void enrichMibByType(MonitoringArtifactInfo monitoringArtifactInfo,
@@ -218,7 +302,7 @@ public class MonitoringMibEnricher implements ExternalArtifactEnricherInterface
Map<String, List<ErrorMessage>> errors) {
- mdcDataDebugMessage.debugEntryMessage(null, null);
+ mdcDataDebugMessage.debugEntryMessage(null);
if (monitoringArtifactInfo == null) {
return;
@@ -228,7 +312,7 @@ public class MonitoringMibEnricher implements ExternalArtifactEnricherInterface
mibs = FileUtils
.getFileContentMapFromZip(FileUtils.toByteArray(monitoringArtifactInfo.getContent()));
} catch (IOException ioException) {
- log.debug("",ioException);
+ LOG.debug("", ioException);
ErrorMessage.ErrorMessageUtil
.addMessage(mibServiceArtifact.getName() + "." + type.name(), errors)
.add(new ErrorMessage(ErrorLevel.ERROR, Messages.INVALID_ZIP_FILE.getErrorMessage()));
@@ -241,7 +325,7 @@ public class MonitoringMibEnricher implements ExternalArtifactEnricherInterface
getEnrichedServiceModelDao().storeExternalArtifact(mibServiceArtifact);
}
- mdcDataDebugMessage.debugExitMessage(null, null);
+ mdcDataDebugMessage.debugExitMessage(null);
}
private EnrichedServiceModelDao getEnrichedServiceModelDao() {
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 828de7244c..089cfe7a82 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
@@ -10,6 +10,7 @@ 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.tosca.datatypes.ToscaServiceModel;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ProcessDao;
@@ -29,13 +30,13 @@ import java.util.Map;
public class ProcessArtifactEnricher implements ExternalArtifactEnricherInterface {
private ComponentDao componentDao;
- //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 {
+ 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();
@@ -72,18 +73,11 @@ public class ProcessArtifactEnricher implements ExternalArtifactEnricherInterfac
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.forEach(entity -> {
ProcessEntity artifactEntity = new ProcessEntity(vspId, version,
componentId, entity.getId());
ProcessEntity artifactProcessEntity = getProcessDao().get(artifactEntity);
- //ProcessArtifactEntity artifact = getProcessArtifactDao().get(artifactEntity);
if (artifactProcessEntity != null && ProcessType.Lifecycle_Operations.equals(
artifactProcessEntity.getType())
&& artifactProcessEntity.getArtifactName() != null ) {
@@ -99,7 +93,7 @@ public class ProcessArtifactEnricher implements ExternalArtifactEnricherInterfac
ServiceArtifact processServiceArtifact = new ServiceArtifact();
processServiceArtifact.setVspId(vspId);
processServiceArtifact.setVersion(version);
- enrichServiceArtifact(componentProcessInfo, processServiceArtifact, errors);
+ enrichServiceArtifact(componentProcessInfo, processServiceArtifact);
}
});
@@ -107,8 +101,7 @@ public class ProcessArtifactEnricher implements ExternalArtifactEnricherInterfac
}
void enrichServiceArtifact(ComponentProcessInfo componentProcessInfo,
- ServiceArtifact processServiceArtifact,
- Map<String, List<ErrorMessage>> errors) {
+ ServiceArtifact processServiceArtifact) {
mdcDataDebugMessage.debugEntryMessage(null);
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 9e46a5c33d..3836796420 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
@@ -31,6 +31,7 @@ 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.tosca.datatypes.ToscaServiceModel;
import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDaoFactory;
@@ -63,14 +64,13 @@ public class VspInformationArtifactEnricher implements ExternalArtifactEnricherI
public VspInformationArtifactEnricher() {
}
- public Map<String, List<ErrorMessage>> enrich(EnrichmentInfo enrichmentInfo)
+ public Map<String, List<ErrorMessage>> enrich(EnrichmentInfo enrichmentInfo,
+ ToscaServiceModel serviceModel)
throws IOException {
String vspId = enrichmentInfo.getKey();
Version version = enrichmentInfo.getVersion();
- Map<String, List<ErrorMessage>> errors = enrichInformationArtifact(vspId, version);
-
- return errors;
+ return enrichInformationArtifact(vspId, version);
}
private Map<String, List<ErrorMessage>> enrichInformationArtifact(String vspId, Version version)
@@ -88,7 +88,6 @@ public class VspInformationArtifactEnricher implements ExternalArtifactEnricherI
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);
return errors;
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 bd250bb8f4..dd1f13d034 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
@@ -23,6 +23,7 @@ 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;
@@ -32,5 +33,6 @@ import java.util.Map;
* Created by Talio on 11/24/2016.
*/
public interface ExternalArtifactEnricherInterface {
- Map<String, List<ErrorMessage>> enrich(EnrichmentInfo enrichmentInfo) throws IOException;
+ Map<String, List<ErrorMessage>> enrich(EnrichmentInfo enrichmentInfo,
+ ToscaServiceModel serviceModel) throws IOException;
}