summaryrefslogtreecommitdiffstats
path: root/catalog-be/src
diff options
context:
space:
mode:
authorTal Gitelman <tg851x@intl.att.com>2017-11-13 18:47:15 +0200
committerTal Gitelman <tg851x@intl.att.com>2017-11-13 18:47:15 +0200
commit17482a68a5bb27239b360612ca27fe207e0db513 (patch)
tree3cb98eb2734e57561efae31eca41b639fd39d539 /catalog-be/src
parentea70a785c6c041c192a18906485d1e7f2de4e963 (diff)
Bug fix
Change-Id: I202efb7bacb903ca63193b4814fba366e96591b4 Issue-ID: SDC-533 Signed-off-by: Tal Gitelman <tg851x@intl.att.com>
Diffstat (limited to 'catalog-be/src')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java28
1 files changed, 25 insertions, 3 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
index e65c4b5001..1f29eb2113 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
@@ -938,12 +938,12 @@ public class ToscaExportHandler {
if(CollectionUtils.isEmpty(filteredRelations)){
result = true;
} else {
- result = !filteredRelations.stream().filter(rel -> !addRequirement(componentInstance, originComponent, component.getComponentInstances(), rel, toscaRequirements)).findFirst().isPresent();
+ result = !filteredRelations.stream().filter(rel -> !addRequirement(component,componentInstance, originComponent, component.getComponentInstances(), rel, toscaRequirements)).findFirst().isPresent();
}
return result;
}
- private boolean addRequirement(ComponentInstance fromInstance, Component originComponent, List<ComponentInstance> instancesList, RequirementCapabilityRelDef rel, List<Map<String, ToscaTemplateRequirement>> toscaRequirements){
+ private boolean addRequirement(Component component,ComponentInstance fromInstance, Component originComponent, List<ComponentInstance> instancesList, RequirementCapabilityRelDef rel, List<Map<String, ToscaTemplateRequirement>> toscaRequirements){
boolean result = true;
Map<String,Component> originComponents = new HashMap<>();
@@ -962,7 +962,13 @@ public class ToscaExportHandler {
result = false;
}
if(result){
- reqOpt = findRequirement(reqMap, reqAndRelationshipPair.getRequirementUid());
+
+ if(component.getComponentType().equals(ComponentTypeEnum.SERVICE)) {
+ reqOpt = findRequirement(reqMap, reqAndRelationshipPair);
+ }
+ else {
+ reqOpt = findRequirement(reqMap, reqAndRelationshipPair.getRequirementUid());
+ }
if(!reqOpt.isPresent()){
log.debug("Failed to find a requirement with uniqueId {} on a component with uniqueId {}", reqAndRelationshipPair.getRequirementUid(), originComponent.getUniqueId());
result = false;
@@ -1020,7 +1026,23 @@ public class ToscaExportHandler {
}
return Optional.empty();
}
+
+ private Optional<RequirementDefinition> findRequirement(Map<String, List<RequirementDefinition>> reqMap, RequirementAndRelationshipPair reqAndRelationshipPair) {
+ for(List<RequirementDefinition> reqList: reqMap.values()){
+ Optional<RequirementDefinition> reqOpt = reqList.stream().filter(r ->
+ isRequirmentBelongTo(reqAndRelationshipPair, r))
+ .findFirst();
+ if(reqOpt.isPresent()){
+ return reqOpt;
+ }
+ }
+ return Optional.empty();
+ }
+ private boolean isRequirmentBelongTo(RequirementAndRelationshipPair reqAndRelationshipPair, RequirementDefinition r) {
+ return StringUtils.isNotEmpty(r.getOwnerId()) && r.getOwnerId().equals(reqAndRelationshipPair.getRequirementOwnerId())
+ && StringUtils.isNotEmpty(r.getName()) && r.getName().equals(reqAndRelationshipPair.getRequirement());
+ }
private Either<SubstitutionMapping, ToscaError> convertCapabilities(Component component, SubstitutionMapping substitutionMappings) {