Merge "Add the query to AAI for SI with customer info"
authorRob Daugherty <rd472p@att.com>
Thu, 13 Dec 2018 15:18:38 +0000 (15:18 +0000)
committerGerrit Code Review <gerrit@onap.org>
Thu, 13 Dec 2018 15:18:38 +0000 (15:18 +0000)
1  2 
bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java

@@@ -609,27 -609,16 +609,27 @@@ public class BBInputSetup implements Ja
                        vnf = createGenericVnf(lookupKeyMap, instanceName, platform, lineOfBusiness,
                                        resourceId, generatedVnfType, instanceParams);
                        serviceInstance.getVnfs().add(vnf);
 +                      mapVnfcCollectionInstanceGroup(vnf, modelInfo, service);
                }
                if(vnf != null) {
                        mapCatalogVnf(vnf, modelInfo, service);
 -                      mapVnfcCollectionInstanceGroup(vnf, modelInfo, service);
 -                      if (instanceGroupId != null && instanceGroupModelInfo != null) {
 +                      if (instanceGroupId != null && instanceGroupModelInfo != null
 +                                      && instanceGroupModelInfo.getModelType().equals(ModelType.networkInstanceGroup)
 +                                      && !instanceGroupInList(vnf, instanceGroupId)) {
                                mapNetworkCollectionInstanceGroup(vnf, instanceGroupId);
                        }
                }
        }
  
 +      protected boolean instanceGroupInList(GenericVnf vnf, String instanceGroupId) {
 +              for(InstanceGroup instanceGroup : vnf.getInstanceGroups()) {
 +                      if(instanceGroup.getId() != null && instanceGroup.getId().equalsIgnoreCase(instanceGroupId)) {
 +                              return true;
 +                      }
 +              }
 +              return false;
 +      }
 +
        protected void mapVnfcCollectionInstanceGroup(GenericVnf genericVnf, ModelInfo modelInfo, Service service) {
                VnfResourceCustomization vnfResourceCustomization = getVnfResourceCustomizationFromService(modelInfo, service);
                if(vnfResourceCustomization != null) {
                        String serviceInstanceId, boolean aLaCarte, String bbName) throws Exception {
                ServiceInstance serviceInstance = this.getServiceInstanceHelper(requestDetails, customer, project, owningEntity,
                                lookupKeyMap, serviceInstanceId, aLaCarte, service, bbName);
 -              org.onap.aai.domain.yang.ServiceInstance serviceInstanceAAI = this.bbInputSetupUtils
 -                              .getAAIServiceInstanceById(serviceInstanceId);
 +              org.onap.aai.domain.yang.ServiceInstance serviceInstanceAAI = null;
 +              if(customer != null && customer.getServiceSubscription() != null) {
 +                      serviceInstanceAAI = bbInputSetupUtils.getAAIServiceInstanceByIdAndCustomer(customer.getGlobalCustomerId(), 
 +                                      customer.getServiceSubscription().getServiceType(), serviceInstanceId);
 +              } else {
 +                      serviceInstanceAAI = bbInputSetupUtils.getAAIServiceInstanceById(serviceInstanceId);
 +              }
                if (serviceInstanceAAI != null
                                && !serviceInstanceAAI.getModelVersionId().equalsIgnoreCase(service.getModelUUID())) {
                        Service tempService = this.bbInputSetupUtils
                                        .getAAIServiceInstanceByName(requestDetails.getRequestInfo().getInstanceName(), customer);
                        }
                        if (serviceInstanceId != null && serviceInstanceAAI == null) {
-                               serviceInstanceAAI = bbInputSetupUtils.getAAIServiceInstanceById(serviceInstanceId);
+                               if(customer != null && customer.getServiceSubscription() != null) {
+                                       serviceInstanceAAI = bbInputSetupUtils.getAAIServiceInstanceByIdAndCustomer(customer.getGlobalCustomerId(), 
+                                                       customer.getServiceSubscription().getServiceType(), serviceInstanceId);
+                               } else {
+                                       serviceInstanceAAI = bbInputSetupUtils.getAAIServiceInstanceById(serviceInstanceId);
+                               }
                        }
                        if (serviceInstanceAAI != null) {
                                lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, serviceInstanceId);