AAI Query optimization for VID 26/124426/2
authorPATTANAYAK, SAUMYA SWARUP (sp931a) <sp931a@att.com>
Wed, 22 Sep 2021 14:22:53 +0000 (10:22 -0400)
committerPATTANAYAK, SAUMYA SWARUP (sp931a) <sp931a@att.com>
Wed, 29 Sep 2021 14:28:22 +0000 (10:28 -0400)
Issue-ID: VID-986
Change-Id: Ia3e012c41df4e9049ce9a1ae56ec83b276e11611
Signed-off-by: PATTANAYAK, SAUMYA SWARUP (sp931a) <sp931a@att.com>
22 files changed:
vid-app-common/src/main/java/org/onap/vid/aai/AaiClient.java
vid-app-common/src/main/java/org/onap/vid/aai/AaiClientInterface.java
vid-app-common/src/main/java/org/onap/vid/aai/Customer.java [new file with mode: 0644]
vid-app-common/src/main/java/org/onap/vid/aai/CustomerRelatedNodes.java [new file with mode: 0644]
vid-app-common/src/main/java/org/onap/vid/aai/CustomerServiceSubscription.java [new file with mode: 0644]
vid-app-common/src/main/java/org/onap/vid/aai/CustomerSpecificServiceInstance.java [new file with mode: 0644]
vid-app-common/src/main/java/org/onap/vid/aai/DSLQuerySimpleResponse.java [new file with mode: 0644]
vid-app-common/src/main/java/org/onap/vid/aai/ServiceInstanceResponseBySubscriber.java [new file with mode: 0644]
vid-app-common/src/main/java/org/onap/vid/aai/ServiceSubscriptionRelatedNodes.java [new file with mode: 0644]
vid-app-common/src/main/java/org/onap/vid/aai/model/ViewEditSIResult.java [new file with mode: 0644]
vid-app-common/src/main/java/org/onap/vid/controller/AaiController.java
vid-app-common/src/main/java/org/onap/vid/services/AaiService.java
vid-app-common/src/main/java/org/onap/vid/services/AaiServiceImpl.java
vid-app-common/src/main/webapp/app/vid/scripts/constants/componentConstants.js
vid-app-common/src/main/webapp/app/vid/scripts/controller/aaiSubscriberController.js
vid-app-common/src/main/webapp/app/vid/scripts/controller/aaiSubscriberController.test.js
vid-app-common/src/main/webapp/app/vid/scripts/services/aaiService.js
vid-app-common/src/test/java/org/onap/vid/aai/AaiClientTest.java
vid-app-common/src/test/resources/payload_jsons/service-instance-by-subscriberid.json [new file with mode: 0644]
vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetServiceInstanceBySubscriberIdAndServiceTypeAndSIID.java [new file with mode: 0644]
vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIServiceInstanceDSLPut.java [new file with mode: 0644]
vid-automation/src/test/java/org/onap/vid/api/AaiApiTest.java

index 00137b6..d37adba 100644 (file)
@@ -109,7 +109,7 @@ public class AaiClient implements AaiClientInterface {
     private static final String BUSINESS_CUSTOMER = "/business/customers/customer/";
     private static final String SERVICE_INSTANCE = "/service-instances/service-instance/";
     private static final String BUSINESS_CUSTOMERS_CUSTOMER = "business/customers/customer/";
-
+    private static final String QUERY_FORMAT_RESOURCE_DSL = "dsl?format=resource&nodesOnly=true&depth=0&as-tree=true";
     protected String fromAppId = "VidAaiController";
 
     private PortDetailsTranslator portDetailsTranslator;
@@ -918,6 +918,39 @@ public class AaiClient implements AaiClientInterface {
         }
     }
 
+    @Override
+    public AaiResponse<DSLQuerySimpleResponse> getServiceInstanceBySubscriberIdAndInstanceIdentifier(String globalCustomerId, String identifierType, String serviceIdentifier) {
+        ResponseWithRequestInfo response;
+        String payload = getDSLQueryPayloadByServiceIdentifier(globalCustomerId,identifierType,serviceIdentifier);
+//        Response resp = doAaiPut(QUERY_FORMAT_RESOURCE_DSL, payload, false);
+//        resp.bufferEntity();
+//        String rawPayload = resp.readEntity(String.class);
+//        AaiResponse<DSLQuerySimpleResponse> aaiResponse = processAaiResponse(resp, DSLQuerySimpleResponse.class, rawPayload);
+
+        response = doAaiPut(QUERY_FORMAT_RESOURCE_DSL, payload, false, false);
+        AaiResponseWithRequestInfo<DSLQuerySimpleResponse> aaiResponse = processAaiResponse(response, DSLQuerySimpleResponse.class, false);
+        verifyAaiResponseValidityOrThrowExc(aaiResponse, aaiResponse.getAaiResponse().getHttpCode());
+        return aaiResponse.getAaiResponse();
+    }
+
+    private String getDSLQueryPayloadByServiceIdentifier(String globalCustomerId, String identifierType, String serviceIdentifier) {
+        String query = null;
+        String payLoad = null;
+        if(globalCustomerId != null && identifierType != null && serviceIdentifier != null) {
+            if(identifierType.equalsIgnoreCase("Service Instance Id")) {
+                query = "customer*('global-customer-id','"+globalCustomerId+"')>" +
+                    "service-subscription>service-instance*('service-instance-id','"+serviceIdentifier+"')";
+                payLoad = "{\"dsl\":\"" + query + "\"}";
+            } else {
+                query = "customer*('global-customer-id','"+globalCustomerId+"')>" +
+                    "service-subscription>service-instance*('service-instance-name','"+serviceIdentifier+"')";
+                payLoad = "{\"dsl\":\"" + query + "\"}";
+            }
+
+        }
+        return payLoad;
+    }
+
     @Override
     public void resetCache(String cacheName) {
         cacheProvider.resetCache(cacheName);
index c322afa..a1edc8d 100644 (file)
@@ -108,4 +108,6 @@ public interface AaiClientInterface extends ProbeInterface {
     Map<String, Properties> getCloudRegionAndTenantByVnfId(String vnfId);
 
     AaiResponse<AaiGetVnfResponse> getVnfsByParamsForChangeManagement(String subscriberId, String serviceType, String nfRole, String cloudRegion);
+
+    AaiResponse getServiceInstanceBySubscriberIdAndInstanceIdentifier(String globalCustomerId, String identifierType, String serviceIdentifier);
 }
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/Customer.java b/vid-app-common/src/main/java/org/onap/vid/aai/Customer.java
new file mode 100644 (file)
index 0000000..a28b3c3
--- /dev/null
@@ -0,0 +1,84 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 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.onap.vid.aai;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import java.util.List;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class Customer {
+       
+    @JsonProperty("global-customer-id")
+    public String globalCustomerId;
+
+    @JsonProperty("subscriber-name")
+    public String subscriberName;
+
+    public String getGlobalCustomerId() {
+        return globalCustomerId;
+    }
+
+    public void setGlobalCustomerId(String globalCustomerId) {
+        this.globalCustomerId = globalCustomerId;
+    }
+
+    public String getSubscriberName() {
+        return subscriberName;
+    }
+
+    public void setSubscriberName(String subscriberName) {
+        this.subscriberName = subscriberName;
+    }
+
+    public String getSubscriberType() {
+        return subscriberType;
+    }
+
+    public void setSubscriberType(String subscriberType) {
+        this.subscriberType = subscriberType;
+    }
+
+    public String getResourceVersion() {
+        return resourceVersion;
+    }
+
+    public void setResourceVersion(String resourceVersion) {
+        this.resourceVersion = resourceVersion;
+    }
+
+    public List<CustomerRelatedNodes> getCustomerRelatedNodes() {
+        return customerRelatedNodes;
+    }
+
+    public void setCustomerRelatedNodes(List<CustomerRelatedNodes> customerRelatedNodes) {
+        this.customerRelatedNodes = customerRelatedNodes;
+    }
+
+    @JsonProperty("subscriber-type")
+    public String subscriberType;
+
+    @JsonProperty("resource-version")
+    public String resourceVersion;
+
+    @JsonProperty("related-nodes")
+    public List<CustomerRelatedNodes> customerRelatedNodes;
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/CustomerRelatedNodes.java b/vid-app-common/src/main/java/org/onap/vid/aai/CustomerRelatedNodes.java
new file mode 100644 (file)
index 0000000..7637e31
--- /dev/null
@@ -0,0 +1,40 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 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.onap.vid.aai;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class CustomerRelatedNodes {
+
+    public CustomerServiceSubscription getCustomerServiceSubscription() {
+        return customerServiceSubscription;
+    }
+
+    public void setCustomerServiceSubscription(CustomerServiceSubscription customerServiceSubscription) {
+        this.customerServiceSubscription = customerServiceSubscription;
+    }
+
+    @JsonProperty("service-subscription")
+    public CustomerServiceSubscription customerServiceSubscription;
+
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/CustomerServiceSubscription.java b/vid-app-common/src/main/java/org/onap/vid/aai/CustomerServiceSubscription.java
new file mode 100644 (file)
index 0000000..9b94cf6
--- /dev/null
@@ -0,0 +1,62 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 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.onap.vid.aai;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import java.util.List;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class CustomerServiceSubscription {
+
+    @JsonProperty("service-type")
+    public String serviceType;
+
+    public String getServiceType() {
+        return serviceType;
+    }
+
+    public void setServiceType(String serviceType) {
+        this.serviceType = serviceType;
+    }
+
+    public String getResourceVersion() {
+        return resourceVersion;
+    }
+
+    public void setResourceVersion(String resourceVersion) {
+        this.resourceVersion = resourceVersion;
+    }
+
+    public List<ServiceSubscriptionRelatedNodes> getServiceSubscriptionRelatedNodes() {
+        return serviceSubscriptionRelatedNodes;
+    }
+
+    public void setServiceSubscriptionRelatedNodes(List<ServiceSubscriptionRelatedNodes> serviceSubscriptionRelatedNodes) {
+        this.serviceSubscriptionRelatedNodes = serviceSubscriptionRelatedNodes;
+    }
+
+    @JsonProperty("resource-version")
+    public String resourceVersion;
+
+    @JsonProperty("related-nodes")
+    public List<ServiceSubscriptionRelatedNodes> serviceSubscriptionRelatedNodes;
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/CustomerSpecificServiceInstance.java b/vid-app-common/src/main/java/org/onap/vid/aai/CustomerSpecificServiceInstance.java
new file mode 100644 (file)
index 0000000..ef6f498
--- /dev/null
@@ -0,0 +1,150 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 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.onap.vid.aai;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class CustomerSpecificServiceInstance {
+       
+       @JsonProperty("service-instance-id")
+       public String serviceInstanceId;
+
+       @JsonProperty("service-instance-name")
+       public String serviceInstanceName;
+
+       @JsonProperty("orchestration-status")
+       public String orchestrationStatus;
+
+       @JsonProperty("model-invariant-id")
+       public String modelInvariantId;
+
+       @JsonProperty("model-version-id")
+       public String modelVersionId;
+
+       public String getServiceInstanceId() {
+               return serviceInstanceId;
+       }
+
+       public void setServiceInstanceId(String serviceInstanceId) {
+               this.serviceInstanceId = serviceInstanceId;
+       }
+
+       public String getServiceInstanceName() {
+               return serviceInstanceName;
+       }
+
+       public void setServiceInstanceName(String serviceInstanceName) {
+               this.serviceInstanceName = serviceInstanceName;
+       }
+
+       public String getOrchestrationStatus() {
+               return orchestrationStatus;
+       }
+
+       public void setOrchestrationStatus(String orchestrationStatus) {
+               this.orchestrationStatus = orchestrationStatus;
+       }
+
+       public String getModelInvariantId() {
+               return modelInvariantId;
+       }
+
+       public void setModelInvariantId(String modelInvariantId) {
+               this.modelInvariantId = modelInvariantId;
+       }
+
+       public String getModelVersionId() {
+               return modelVersionId;
+       }
+
+       public void setModelVersionId(String modelVersionId) {
+               this.modelVersionId = modelVersionId;
+       }
+
+       public String getSelfLink() {
+               return selfLink;
+       }
+
+       public void setSelfLink(String selfLink) {
+               this.selfLink = selfLink;
+       }
+
+       public String getServiceRole() {
+               return serviceRole;
+       }
+
+       public void setServiceRole(String serviceRole) {
+               this.serviceRole = serviceRole;
+       }
+
+       public String getServiceType() {
+               return serviceType;
+       }
+
+       public void setServiceType(String serviceType) {
+               this.serviceType = serviceType;
+       }
+
+       public String getEnvironmentContext() {
+               return environmentContext;
+       }
+
+       public void setEnvironmentContext(String environmentContext) {
+               this.environmentContext = environmentContext;
+       }
+
+       public String getWorkloadContext() {
+               return workloadContext;
+       }
+
+       public void setWorkloadContext(String workloadContext) {
+               this.workloadContext = workloadContext;
+       }
+
+       public String getResourceVersion() {
+               return resourceVersion;
+       }
+
+       public void setResourceVersion(String resourceVersion) {
+               this.resourceVersion = resourceVersion;
+       }
+
+       @JsonProperty("selflink")
+       public String selfLink;
+
+       @JsonProperty("service-role")
+       public String serviceRole;
+
+       @JsonProperty("service-type")
+       public String serviceType;
+
+       @JsonProperty("environment-context")
+       public String environmentContext;
+
+       @JsonProperty("workload-context")
+       public String workloadContext;
+
+       @JsonProperty("resource-version")
+       public String resourceVersion;
+
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/DSLQuerySimpleResponse.java b/vid-app-common/src/main/java/org/onap/vid/aai/DSLQuerySimpleResponse.java
new file mode 100644 (file)
index 0000000..e151ffd
--- /dev/null
@@ -0,0 +1,45 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 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.onap.vid.aai;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import java.util.List;
+
+//@JsonInclude(JsonInclude.Include.NON_NULL)
+//@JsonPropertyOrder({
+//        "results"
+//})
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class DSLQuerySimpleResponse {
+
+    private final List<ServiceInstanceResponseBySubscriber> results;
+
+    public DSLQuerySimpleResponse(@JsonProperty("results") List<ServiceInstanceResponseBySubscriber> results) {
+        this.results = results;
+    }
+
+    public List<ServiceInstanceResponseBySubscriber> getResults() {
+        return results;
+    }
+
+
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/ServiceInstanceResponseBySubscriber.java b/vid-app-common/src/main/java/org/onap/vid/aai/ServiceInstanceResponseBySubscriber.java
new file mode 100644 (file)
index 0000000..3c4071e
--- /dev/null
@@ -0,0 +1,43 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 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.onap.vid.aai;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+//@JsonInclude(JsonInclude.Include.NON_NULL)
+//@JsonPropertyOrder({
+//        "results"
+//})
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class ServiceInstanceResponseBySubscriber {
+
+    public Customer getCustomer() {
+        return customer;
+    }
+
+    public void setCustomer(Customer customer) {
+        this.customer = customer;
+    }
+
+    @JsonProperty("customer")
+    public Customer customer;
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/ServiceSubscriptionRelatedNodes.java b/vid-app-common/src/main/java/org/onap/vid/aai/ServiceSubscriptionRelatedNodes.java
new file mode 100644 (file)
index 0000000..a991b98
--- /dev/null
@@ -0,0 +1,39 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 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.onap.vid.aai;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class ServiceSubscriptionRelatedNodes {
+
+    public CustomerSpecificServiceInstance getServiceInstance() {
+        return serviceInstance;
+    }
+
+    public void setServiceInstance(CustomerSpecificServiceInstance serviceInstance) {
+        this.serviceInstance = serviceInstance;
+    }
+
+    @JsonProperty("service-instance")
+    public CustomerSpecificServiceInstance serviceInstance;
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/model/ViewEditSIResult.java b/vid-app-common/src/main/java/org/onap/vid/aai/model/ViewEditSIResult.java
new file mode 100644 (file)
index 0000000..f06cd91
--- /dev/null
@@ -0,0 +1,94 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 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.onap.vid.aai.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class ViewEditSIResult {
+
+    private String serviceInstanceId;
+
+    public String getServiceInstanceId() {
+        return serviceInstanceId;
+    }
+
+    @JsonProperty("serviceInstanceId")
+    public void setServiceInstanceId(String serviceInstanceId) {
+        this.serviceInstanceId = serviceInstanceId;
+    }
+
+    public String getServiceInstanceName() {
+        return serviceInstanceName;
+    }
+
+    @JsonProperty("serviceInstanceName")
+    public void setServiceInstanceName(String serviceInstanceName) {
+        this.serviceInstanceName = serviceInstanceName;
+    }
+
+    public String getModelVersionId() {
+        return modelVersionId;
+    }
+
+    @JsonProperty("modelVersionId")
+    public void setModelVersionId(String modelVersionId) {
+        this.modelVersionId = modelVersionId;
+    }
+
+    public String getModelInvariantId() {
+        return modelInvariantId;
+    }
+    @JsonProperty("modelInvariantId")
+    public void setModelInvariantId(String modelInvariantId) {
+        this.modelInvariantId = modelInvariantId;
+    }
+
+    public String getOrchestrationStatus() {
+        return orchestrationStatus;
+    }
+    @JsonProperty("orchestrationStatus")
+    public void setOrchestrationStatus(String orchestrationStatus) {
+        this.orchestrationStatus = orchestrationStatus;
+    }
+
+    public String getSubscriberName() {
+        return subscriberName;
+    }
+    @JsonProperty("subscriberName")
+    public void setSubscriberName(String subscriberName) {
+        this.subscriberName = subscriberName;
+    }
+
+    private String serviceInstanceName;
+    private String modelVersionId;
+    private String modelInvariantId;
+    private String orchestrationStatus;
+    private String subscriberName;
+
+
+
+
+
+
+
+}
index a9ce40b..e4fbeca 100644 (file)
@@ -27,6 +27,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
 import java.io.IOException;
 import java.util.List;
 import java.util.Map;
+import java.util.Optional;
 import java.util.UUID;
 import java.util.stream.Collectors;
 import javax.servlet.http.HttpServletRequest;
@@ -68,6 +69,16 @@ import org.springframework.web.servlet.HandlerMapping;
 import org.springframework.web.servlet.ModelAndView;
 import org.togglz.core.manager.FeatureManager;
 
+import org.json.JSONException;
+import org.json.JSONObject;
+import org.json.simple.JSONArray;
+import org.json.simple.parser.JSONParser;
+import org.json.simple.parser.ParseException;
+import org.onap.vid.aai.CustomerSpecificServiceInstance;
+import org.onap.vid.aai.DSLQuerySimpleResponse;
+import org.onap.vid.aai.model.ServiceRelationships;
+import org.onap.vid.aai.model.ViewEditSIResult;
+
 
 @RestController
 public class AaiController extends RestrictedBaseController {
@@ -268,14 +279,27 @@ public class AaiController extends RestrictedBaseController {
     public ResponseEntity<String> SearchServiceInstances(HttpServletRequest request,
         @RequestParam(value = "subscriberId", required = false) String subscriberId,
         @RequestParam(value = "serviceInstanceIdentifier", required = false) String instanceIdentifier,
+        @RequestParam(value = "serviceInstanceIdentifierType", required = false) String instanceIdentifierType,
         @RequestParam(value = "project", required = false) List<String> projects,
         @RequestParam(value = "owningEntity", required = false) List<String> owningEntities) throws IOException {
         ResponseEntity responseEntity;
 
         RoleValidator roleValidator = roleProvider.getUserRolesValidator(request);
 
-        AaiResponse<ServiceInstancesSearchResults> searchResult = aaiService
-            .getServiceInstanceSearchResults(subscriberId, instanceIdentifier, roleValidator, owningEntities, projects);
+        AaiResponse<ServiceInstancesSearchResults> searchResult = null;
+
+        if( instanceIdentifier != null && isValidInstanceIdentifierType(instanceIdentifierType)) {
+            LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== search_service_instances search by subscriberId "
+                + " instanceIdentifier and instanceIdentifierType start");
+            searchResult = aaiService
+                .getServiceInstanceSearchResultsByIdentifierType(subscriberId, instanceIdentifier,
+                    instanceIdentifierType, roleValidator, owningEntities, projects);
+        } else {
+            LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== search_service_instances search by subscriberId "
+                + "instanceIdentifier instanceIdentifier and instanceIdentifierType start");
+            searchResult = aaiService
+                .getServiceInstanceSearchResults(subscriberId, instanceIdentifier, roleValidator, owningEntities, projects);
+        }
 
         String httpMessage = searchResult.getT() != null ?
             objectMapper.writeValueAsString(searchResult.getT()) :
@@ -291,6 +315,85 @@ public class AaiController extends RestrictedBaseController {
         return responseEntity;
     }
 
+    @RequestMapping(value = {
+        "/aai_get_service_instance_by_id_and_type/{globalCustomerId}/{serviceInstanceIdentifier}/{serviceIdentifierType}/{subscriberName}",
+        "/aai_get_service_instance_by_id_and_type/{globalCustomerId}/{serviceInstanceIdentifier}/{serviceIdentifierType}"},
+        method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
+    public ResponseEntity<String> doGetServiceInstanceByIdAndType(
+        @PathVariable("globalCustomerId") String globalCustomerId,
+        @PathVariable("serviceInstanceIdentifier") String serviceInstanceIdentifier,
+        @PathVariable("serviceIdentifierType") String serviceIdentifierType,
+        @PathVariable("subscriberName") java.util.Optional<String> subscriberName) throws IOException {
+
+        AaiResponse aaiResponse = null;
+        String orchStatus = null;
+        String siid, siName, modelVerId, modelInvId = null;
+        String errorMessage = null;
+        int statusCode = -1;
+        ViewEditSIResult viewEditSIResult = new ViewEditSIResult();
+        if(!subscriberName.equals(Optional.empty()) && serviceInstanceIdentifier != null) {
+            LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + ".aai_get_service_instance_by_id_and_type. "
+                + "Search node query to get Service Type: "+serviceInstanceIdentifier);
+            ResponseEntity entity = convertResponseToResponseEntity(doAaiGet(
+                "search/nodes-query?search-node-type=service-instance&filter=service-instance-id:EQUALS:"
+                    + serviceInstanceIdentifier, false));
+            JSONParser jsonParser = new JSONParser();
+            try {
+                if(entity != null) {
+                    org.json.simple.JSONObject jsonObject = (org.json.simple.JSONObject) jsonParser.parse(
+                                                                                            entity.getBody().toString());
+                    JSONArray jSONArray = (JSONArray)jsonObject.get("result-data");
+                    org.json.simple.JSONObject jSONObject = (org.json.simple.JSONObject)jSONArray.get(0);
+                    String resourceLink = jSONObject.get("resource-link").toString();
+                    String serviceType = resourceLink.split("/")[9];
+                    aaiResponse = aaiService.getServiceInstanceBySubscriberIdAndSIID(globalCustomerId,serviceType,
+                                                                                            serviceInstanceIdentifier);
+                    if(aaiResponse != null && aaiResponse.getT() != null) {
+                        viewEditSIResult.setOrchestrationStatus(((ServiceRelationships) aaiResponse.getT()).orchestrationStatus);
+                        viewEditSIResult.setServiceInstanceId(((ServiceRelationships) aaiResponse.getT()).serviceInstanceId);
+                        viewEditSIResult.setServiceInstanceName(((ServiceRelationships) aaiResponse.getT()).serviceInstanceName);
+                        viewEditSIResult.setModelVersionId(((ServiceRelationships) aaiResponse.getT()).modelVersionId);
+                        viewEditSIResult.setModelInvariantId(((ServiceRelationships) aaiResponse.getT()).modelInvariantId);
+                        viewEditSIResult.setSubscriberName(subscriberName.get());
+                    } else {
+                        LOGGER.info(EELFLoggerDelegate.errorLogger, "<== " + ".aai_get_service_instance_by_id_and_type. No response for getServiceInstanceBySubscriberIdAndSIID: "+serviceInstanceIdentifier);
+                        errorMessage = aaiResponse.getErrorMessage();
+                    }
+                    statusCode = aaiResponse.getHttpCode();
+                } else {
+                    LOGGER.info(EELFLoggerDelegate.errorLogger, "<== " + ".aai_get_service_instance_by_id_and_type. No response for nodes-query for siid: "+serviceInstanceIdentifier);
+                    statusCode = entity.getStatusCode().value();
+                    errorMessage = aaiResponse.getErrorMessage();
+                }
+            } catch (Exception e) {
+                LOGGER.info(EELFLoggerDelegate.errorLogger, "<== " + ".aai_get_service_instance_by_id_and_type" + e.toString());
+                LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + ".aai_get_service_instance_by_id_and_type" + e.toString());
+            }
+        } else {
+            LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + ".aai_get_service_instance_by_id_and_type. Use DSL query to get SI details."+serviceInstanceIdentifier);
+            aaiResponse = aaiService
+                .getServiceInstanceBySubscriberIdAndInstanceIdentifier(globalCustomerId, serviceIdentifierType, serviceInstanceIdentifier);
+            if(aaiResponse != null && aaiResponse.getT() != null) {
+                CustomerSpecificServiceInstance siData = ((DSLQuerySimpleResponse)aaiResponse.getT()).getResults().get(0).getCustomer().
+                    customerRelatedNodes.get(0).getCustomerServiceSubscription().
+                    getServiceSubscriptionRelatedNodes().get(0).getServiceInstance();
+                viewEditSIResult.setOrchestrationStatus(siData.getOrchestrationStatus());
+                viewEditSIResult.setServiceInstanceId(siData.serviceInstanceId);
+                viewEditSIResult.setServiceInstanceName(siData.serviceInstanceName);
+                viewEditSIResult.setModelVersionId(siData.modelVersionId);
+                viewEditSIResult.setModelInvariantId(siData.modelInvariantId);
+                viewEditSIResult.setSubscriberName(((DSLQuerySimpleResponse)aaiResponse.getT()).getResults().get(0).getCustomer().subscriberName);
+            } else {
+                LOGGER.info(EELFLoggerDelegate.errorLogger, "<== " + ".aai_get_service_instance_by_id_and_type. No result for DSL query :"+serviceInstanceIdentifier);
+                errorMessage = aaiResponse.getErrorMessage();
+            }
+            statusCode = aaiResponse.getHttpCode();
+        }
+        String httpMessage = viewEditSIResult != null ? objectMapper.writeValueAsString(viewEditSIResult) : errorMessage;
+        return new ResponseEntity<>(httpMessage,HttpStatus.valueOf(statusCode));
+    }
+
+
     @RequestMapping(value = "/aai_sub_viewedit/{namedQueryId}/{globalCustomerId}/{serviceType}/{serviceInstance}", method = RequestMethod.GET)
     public ResponseEntity<String> viewEditGetComponentList(
         @PathVariable("namedQueryId") String namedQueryId,
@@ -577,4 +680,9 @@ public class AaiController extends RestrictedBaseController {
             return null;
         }
     }
+    private boolean isValidInstanceIdentifierType(String instanceIdentifierType) {
+        return instanceIdentifierType != null
+            && (    instanceIdentifierType.equalsIgnoreCase("Service Instance Id") ||
+            instanceIdentifierType.equalsIgnoreCase("Service Instance Name"));
+    }
 }
index bc26b5e..7be2dd2 100644 (file)
@@ -102,4 +102,8 @@ public interface AaiService {
     List<Network> getL3NetworksByCloudRegion(String cloudRegionId, String tenantId, String networkRole);
 
     ModelVer getNewestModelVersionByInvariantId(String modelInvariantId);
+
+    AaiResponse getServiceInstanceBySubscriberIdAndInstanceIdentifier(String globalCustomerId, String identifierType, String serviceIdentifier);
+    AaiResponse getServiceInstanceSearchResultsByIdentifierType(String subscriberId, String instanceIdentifier, String instanceIdentifierType, RoleValidator roleValidator, List<String> owningEntities, List<String> projects);
+    AaiResponse getServiceInstanceBySubscriberIdAndSIID(String globalCustomerId, String serviceType, String serviceId);
 }
index 1e79ab4..21e5409 100644 (file)
@@ -48,8 +48,12 @@ import org.onap.vid.aai.AaiClientInterface;
 import org.onap.vid.aai.AaiGetVnfResponse;
 import org.onap.vid.aai.AaiResponse;
 import org.onap.vid.aai.AaiResponseTranslator;
+import org.onap.vid.aai.Customer;
+import org.onap.vid.aai.CustomerSpecificServiceInstance;
+import org.onap.vid.aai.DSLQuerySimpleResponse;
 import org.onap.vid.aai.ExceptionWithRequestInfo;
 import org.onap.vid.aai.ServiceInstance;
+import org.onap.vid.aai.ServiceInstanceResponseBySubscriber;
 import org.onap.vid.aai.ServiceInstancesSearchResults;
 import org.onap.vid.aai.ServiceSubscription;
 import org.onap.vid.aai.ServiceSubscriptions;
@@ -750,4 +754,94 @@ public class AaiServiceImpl implements AaiService {
     public ModelVer getNewestModelVersionByInvariantId(String modelInvariantId){
         return aaiClient.getLatestVersionByInvariantId(modelInvariantId);
     }
+
+    @Override
+    public AaiResponse getServiceInstanceBySubscriberIdAndInstanceIdentifier(String globalCustomerId, String identifierType, String serviceIdentifier) {
+        return aaiClient.getServiceInstanceBySubscriberIdAndInstanceIdentifier(globalCustomerId,identifierType,serviceIdentifier);
+    }
+
+    @Override
+    public AaiResponse getServiceInstanceSearchResultsByIdentifierType(String subscriberId, String instanceIdentifier,
+        String instanceIdentifierType,
+        RoleValidator roleValidator,
+        List<String> owningEntities, List<String> projects) {
+        List<List<ServiceInstanceSearchResult>> resultList = new ArrayList<>();
+        ServiceInstancesSearchResults serviceInstancesSearchResults = new ServiceInstancesSearchResults();
+
+        if (subscriberId != null && instanceIdentifier != null && isValidInstanceIdentifierType(instanceIdentifierType)) {
+            resultList.add(getServicesBySubscriberAndServiceInstance(subscriberId, instanceIdentifier, instanceIdentifierType, roleValidator));
+        }
+        if (owningEntities != null) {
+            resultList.add(getServicesByOwningEntityId(owningEntities, roleValidator));
+        }
+        if (projects != null) {
+            resultList.add(getServicesByProjectNames(projects, roleValidator));
+        }
+        if (!resultList.isEmpty()) {
+            serviceInstancesSearchResults.serviceInstances = Intersection.of(resultList);
+        }
+
+        return new AaiResponse<>(serviceInstancesSearchResults, null, HttpStatus.SC_OK);
+    }
+
+    private boolean isValidInstanceIdentifierType(String instanceIdentifierType) {
+        return instanceIdentifierType != null
+            && (    instanceIdentifierType.equalsIgnoreCase("Service Instance Id") ||
+            instanceIdentifierType.equalsIgnoreCase("Service Instance Name"));
+    }
+    private List<ServiceInstanceSearchResult> getServicesBySubscriberAndServiceInstance(String subscriberId,
+        String instanceIdentifier,
+        String instanceIdentifierType,
+        RoleValidator roleValidator) {
+        LOGGER.info("Starting getServicesBySubscriberAndServiceInstance subscriberId : {}, " +
+                "instanceIdentifier : {}, instanceIdentifierType: {} ",
+            subscriberId,instanceIdentifier, instanceIdentifierType);
+        ArrayList<ServiceInstanceSearchResult> results = new ArrayList<>();
+        if( instanceIdentifier == null || instanceIdentifierType == null) {
+            return results;
+        }
+        ServiceInstanceResponseBySubscriber serviceInstanceResponseBySubscriber = null;
+        Customer customer = null;
+        CustomerSpecificServiceInstance serviceInstance = null;
+        String subscriberName,serviceType,serviceInstanceId, serviceInstanceName,modelInvariantId,modelVersionId= null;
+        ServiceInstanceSearchResult serviceInstanceSearchResult = null;
+
+        AaiResponse<DSLQuerySimpleResponse> aaiResponse =
+            aaiClient.getServiceInstanceBySubscriberIdAndInstanceIdentifier(subscriberId,instanceIdentifierType,
+                instanceIdentifier);
+        if( aaiResponse != null && aaiResponse.getT() !=null && aaiResponse.getT().getResults() != null){
+            serviceInstanceResponseBySubscriber = aaiResponse.getT().getResults().get(0);
+            customer = serviceInstanceResponseBySubscriber.getCustomer();
+            serviceInstance = customer.getCustomerRelatedNodes().get(0).getCustomerServiceSubscription().
+                getServiceSubscriptionRelatedNodes().get(0).getServiceInstance();
+            subscriberName = customer.getSubscriberName();
+            serviceType = customer.getCustomerRelatedNodes().get(0).getCustomerServiceSubscription().getServiceType();
+            serviceInstanceId = serviceInstance.getServiceInstanceId();
+            serviceInstanceName = serviceInstance.getServiceInstanceName();
+            modelInvariantId = serviceInstance.getModelInvariantId();
+            modelVersionId = serviceInstance.getModelVersionId();
+
+            serviceInstanceSearchResult =
+                new ServiceInstanceSearchResult(serviceInstanceId, subscriberId, serviceType,
+                    serviceInstanceName, subscriberName, modelInvariantId,
+                    modelVersionId, null, false);
+            serviceInstanceSearchResult.setIsPermitted(roleValidator.isServicePermitted(serviceInstanceSearchResult));
+
+            LOGGER.info("Result from AAI, getServicesBySubscriberAndServiceInstance serviceType : {}, " +
+                    "serviceInstanceId : {}, serviceInstanceName: {} , modelInvariantId : {}, " +
+                    "modelVersionId :{}, permission :{}",
+                serviceType, serviceInstanceId, serviceInstanceName, modelInvariantId,
+                modelVersionId, serviceInstanceSearchResult.getIsPermitted());
+            results.add(serviceInstanceSearchResult);
+        } else {
+            LOGGER.error("Inside getServicesBySubscriberAndServiceInstance response NULL");
+        }
+
+        return results;
+    }
+
+    @Override
+    public AaiResponse getServiceInstanceBySubscriberIdAndSIID(String globalCustomerId, String serviceType, String serviceId) {
+        return aaiClient.getServiceInstance(globalCustomerId, serviceType, serviceId);
+    }
 }
index 337ad46..366f057 100755 (executable)
@@ -113,6 +113,9 @@ appDS2
     VPN_ID_1: "1a2b3c4d5e6f",
 
     // PATHS
+    //2011 AAI query optimization work
+    AAI_SUB_DETAILS_SERVICE_INSTANCE_PATH: "aai_get_service_instance_by_id_and_type/",
+    SELECTED_SERVICE_INSTANCE_TYPE_SUB_PATH: "serviceInstanceIdentifierType=",
     CHANGE_MANAGEMENT_OPERATION_NO_SCHEDULER: "change-management/workflow/@vnfName",
     GET_WORKFLOW: "change-management/get_vnf_workflow_relation",
     GET_SO_WORKFLOWS: "workflows-management/workflows",
index 2701e3e..2f07652 100755 (executable)
@@ -522,7 +522,7 @@ appDS2.controller("aaiSubscriberController", ["COMPONENT", "FIELD", "PARAMETER",
             var deferred = $q.defer();\r
             AaiService.searchServiceInstances(\r
                 '?subscriberId=' + $location.search().subscriberId +\r
-                '&serviceInstanceIdentifier=' + $location.search().serviceInstanceId)\r
+                '&serviceInstanceIdentifier=' + $location.search().serviceInstanceId + '&serviceInstanceIdentifierType=Service Instance Id')\r
                 .then(function (response) {\r
                     if (response.displayData && response.displayData.length) {\r
                         var first = response.displayData[0];\r
@@ -589,7 +589,14 @@ appDS2.controller("aaiSubscriberController", ["COMPONENT", "FIELD", "PARAMETER",
                     $scope.hasFabricConfigurations = !UtilityService.isObjectEmpty($scope.service.model.fabricConfigurations);\r
                     return AaiService.runNamedQuery($scope.namedQueryId, $scope.globalCustomerId, $scope.serviceType, $scope.serviceInstanceId,\r
                         function (response) { //success\r
-                            $scope.handleInitialResponseInventoryItems(response);\r
+                            try {\r
+                                $log.debug("Getting inventory reponse items from Named Query with AAI query optimization - Before ");\r
+                                $scope.handleInitialResponseInventoryItemsOptimized(response);\r
+                                $log.debug("Getting inventory reponse items from Named Query with AAI query optimization - After ");\r
+                            }catch (error) {\r
+                                $log.error("Exception: Fallback to original method of getting subscriber name and SI orch status.");\r
+                                $scope.handleInitialResponseInventoryItems(response);\r
+                            }\r
                             $scope.setProgress(100); // done\r
                             $scope.status = FIELD.STATUS.DONE;\r
                             $scope.isSpinnerVisible = false;\r
@@ -630,7 +637,7 @@ appDS2.controller("aaiSubscriberController", ["COMPONENT", "FIELD", "PARAMETER",
                 return $q.resolve($scope.modelVersionIdForServiceInstance.aaiModelVersionId);\r
             } else {\r
                 $scope.status = FIELD.STATUS.FETCHING_SERVICE_INST_DATA + $scope.serviceInstanceId;\r
-                return AaiService.getModelVersionId(instance.globalCustomerId, instance.serviceInstanceId)\r
+                return AaiService.getModelVersionId(instance.globalCustomerId, instance.serviceInstanceId, 'Service Instance Id')\r
                     .then(function (aaiModelVersionId) {\r
                         $scope.modelVersionIdForServiceInstance = {\r
                             globalCustomerId: instance.globalCustomerId,\r
@@ -827,6 +834,298 @@ appDS2.controller("aaiSubscriberController", ["COMPONENT", "FIELD", "PARAMETER",
             return _.includes(vfModuleStatusHasAllowedResume, vfModuleStatus) && !$scope.isActivateDeactivateEnabled("activate");\r
         };\r
 \r
+        $scope.handleInitialResponseInventoryItemsOptimized = function (response) {\r
+\r
+            $scope.inventoryResponseItemList = response.data[FIELD.ID.INVENTORY_RESPONSE_ITEM]; // get data from json\r
+            $log.debug($scope.inventoryResponseItemList);\r
+\r
+            $scope.displayData = [];\r
+            $scope.vnfs = [];\r
+\r
+            $scope.counter = 100;\r
+\r
+            $scope.subscriberName = $location.search().subscriberName;\r
+\r
+            $scope.allConfigurationsAssigned = true;\r
+            // look up the subscriber name and service orchestration status from A&AI here...\r
+            AaiService.getSubscriberNameAndServiceInstanceInfo( $scope.globalCustomerId,\r
+                $scope.serviceInstanceId,\r
+                'Service Instance Id',$scope.subscriberName, function (response) {\r
+                    $scope.subscriberName = response['subscriberName'];\r
+                    DataService.setSubscriberName($scope.subscriberName);\r
+                    $scope.serviceOrchestrationStatus = response['orchestrationStatus'];\r
+                    if ($scope.serviceOrchestrationStatus.toLowerCase() !== FIELD.STATUS.ASSIGNED.toLowerCase()) {\r
+                        $scope.allConfigurationsAssigned = false;\r
+                    }\r
+                    angular.forEach($scope.inventoryResponseItemList, function (inventoryResponseItem, key) {\r
+\r
+                        $scope.inventoryResponseItem = inventoryResponseItem;\r
+\r
+                        $scope.service.instance = {\r
+                            "name": $scope.inventoryResponseItem[FIELD.ID.SERVICE_INSTANCE][FIELD.ID.SERVICE_INSTANCE_NAME],\r
+                            "serviceInstanceId": $scope.serviceInstanceId,\r
+                            "serviceType": $scope.serviceType,\r
+                            "globalCustomerId": $scope.globalCustomerId,\r
+                            "subscriberName": $scope.subscriberName,\r
+                            "id": $scope.serviceInstanceId,\r
+                            "inputs": {\r
+                                "a": {\r
+                                    "type": PARAMETER.STRING,\r
+                                    "description": FIELD.PROMPT.VAR_DESCRIPTION_A,\r
+                                    "default": FIELD.PROMPT.DEFAULT_A\r
+                                },\r
+                                "b": {\r
+                                    "type": PARAMETER.STRING,\r
+                                    "description": FIELD.PROMPT.VAR_DESCRIPTION_B,\r
+                                    "default": FIELD.PROMPT.DEFAULT_B\r
+                                }\r
+                            },\r
+                            "object": $scope.inventoryResponseItem[FIELD.ID.SERVICE_INSTANCE],\r
+                            "vnfs": [],\r
+                            "networks": [],\r
+                            "configurations": []\r
+                        };\r
+\r
+                        var portMirroringConfigurationIds = [];\r
+                        if (inventoryResponseItem[FIELD.ID.INVENTORY_RESPONSE_ITEMS] != null) {\r
+\r
+                            angular.forEach(inventoryResponseItem[FIELD.ID.INVENTORY_RESPONSE_ITEMS][FIELD.ID.INVENTORY_RESPONSE_ITEM], function (subInventoryResponseItem, key) {\r
+                                // i expect to find vnfs now\r
+\r
+                                if (subInventoryResponseItem[FIELD.ID.L3_NETWORK] != null) {\r
+                                    var l3NetworkObject = subInventoryResponseItem[FIELD.ID.L3_NETWORK];\r
+                                    var l3Network = {\r
+                                        "id": $scope.counter++,\r
+                                        "name": l3NetworkObject[FIELD.ID.NETWORK_NAME],\r
+                                        "itemType": FIELD.ID.L3_NETWORK,\r
+                                        "nodeId": l3NetworkObject[FIELD.ID.NETWORK_ID],\r
+                                        "nodeType": l3NetworkObject[FIELD.ID.NETWORK_TYPE],\r
+                                        "nodeStatus": l3NetworkObject[FIELD.ID.ORCHESTRATION_STATUS],\r
+                                        "object": l3NetworkObject,\r
+                                        "nodes": [],\r
+                                        "subnets": [],\r
+                                        "vlans": []\r
+                                    };\r
+                                    if (subInventoryResponseItem[FIELD.ID.INVENTORY_RESPONSE_ITEMS] != null) {\r
+                                        //console.log ("subInventoryResponseItem[FIELD.ID.INVENTORY_RESPONSE_ITEMS]=");\r
+                                        //console.log (JSON.stringify (subInventoryResponseItem[FIELD.ID.INVENTORY_RESPONSE_ITEMS], null, 4 ));\r
+                                        angular.forEach(subInventoryResponseItem[FIELD.ID.INVENTORY_RESPONSE_ITEMS][FIELD.ID.INVENTORY_RESPONSE_ITEM], function (subSubInventoryResponseItem, key) {\r
+                                            //console.log (JSON.stringify (subSubInventoryResponseItem, null, 4 ));\r
+                                            var subnet = {};\r
+                                            var subnetObject;\r
+                                            if (subSubInventoryResponseItem[FIELD.ID.SUB_NET] != null) {\r
+                                                subnetObject = subSubInventoryResponseItem[FIELD.ID.SUB_NET];\r
+                                                subnet = {\r
+                                                    "subnet-id": subnetObject[FIELD.ID.SUBNET_ID],\r
+                                                    "subnet-name": subnetObject[FIELD.ID.SUBNET_NAME],\r
+                                                    "gateway-address": subnetObject[FIELD.ID.GATEWAY_ADDRESS],\r
+                                                    "network-start-address": subnetObject[FIELD.ID.NETWORK_START_ADDRESS],\r
+                                                    "cidr-mask": subnetObject[FIELD.ID.CIDR_MASK]\r
+                                                };\r
+                                                l3Network.subnets.push(subnet);\r
+                                            }\r
+                                        });\r
+                                    }\r
+\r
+\r
+                                    var networkObj = _.find(serviceNetworkVlans, { 'networkId': l3Network.nodeId});\r
+                                    if (networkObj !== undefined && networkObj.vlans !== undefined) {\r
+                                        l3Network["vlans"] = networkObj.vlans;\r
+                                    }\r
+                                    $scope.service.instance[FIELD.ID.NETWORKS].push(l3Network);\r
+                                }\r
+\r
+                                if (subInventoryResponseItem[FIELD.ID.GENERIC_VNF] != null) {\r
+                                    var genericVnfObject = subInventoryResponseItem[FIELD.ID.GENERIC_VNF];\r
+\r
+                                    var genericVnf = {\r
+                                        "name": genericVnfObject[FIELD.ID.VNF_NAME],\r
+                                        "id": $scope.counter++,\r
+                                        "itemType": COMPONENT.VNF,\r
+                                        "nodeType": genericVnfObject[FIELD.ID.VNF_TYPE],\r
+                                        "nodeId": genericVnfObject[FIELD.ID.VNF_ID],\r
+                                        "nodeStatus": genericVnfObject[FIELD.ID.ORCHESTRATION_STATUS],\r
+                                        "modelVersionId" : genericVnfObject[FIELD.ID.MODEL_VERSION_ID],\r
+                                        "object": genericVnfObject,\r
+                                        "vfModules": [],\r
+                                        "volumeGroups": [],\r
+                                        "instanceGroups": [],\r
+                                        "availableVolumeGroups": [],\r
+                                        "networks": []\r
+                                    };\r
+\r
+                                    var vnfNetworkObj = _.find(vnfNetworksAndVlans, { 'vnfId': genericVnf.nodeId});\r
+                                    if (vnfNetworkObj !== undefined && vnfNetworkObj.networks !== undefined) {\r
+                                        genericVnf["networks"] = vnfNetworkObj.networks;\r
+                                    }\r
+\r
+                                    $scope.service.instance[FIELD.ID.VNFS].push(genericVnf);\r
+                                    getRelatedInstanceGroupsByVnfId(genericVnf);\r
+\r
+\r
+\r
+                                    // look for volume-groups\r
+                                    if (subInventoryResponseItem[FIELD.ID.INVENTORY_RESPONSE_ITEMS] != null) {\r
+                                        angular.forEach(subInventoryResponseItem[FIELD.ID.INVENTORY_RESPONSE_ITEMS][FIELD.ID.INVENTORY_RESPONSE_ITEM], function (vfmodules, key) {\r
+\r
+                                            if (vfmodules[FIELD.ID.VOLUME_GROUP] != null) {\r
+                                                var volumeGroupObject = vfmodules[FIELD.ID.VOLUME_GROUP];\r
+                                                var volumeGroup = {\r
+                                                    "id": $scope.counter++,\r
+                                                    "name": volumeGroupObject[FIELD.ID.VOLUME_GROUP_NAME],\r
+                                                    "itemType": FIELD.ID.VOLUME_GROUP,\r
+                                                    "nodeId": volumeGroupObject[FIELD.ID.VOLUME_GROUP_ID],\r
+                                                    "nodeType": volumeGroupObject[FIELD.ID.VNF_TYPE],\r
+                                                    "nodeStatus": volumeGroupObject[FIELD.ID.ORCHESTRATION_STATUS],\r
+                                                    "object": volumeGroupObject,\r
+                                                    "nodes": []\r
+                                                };\r
+                                                genericVnf[FIELD.ID.VOLUMEGROUPS].push(volumeGroup);\r
+                                                genericVnf[FIELD.ID.AVAILABLEVOLUMEGROUPS].push(volumeGroup);\r
+                                            }\r
+                                        });\r
+                                    }\r
+                                    // now we've loaded up the availableVolumeGroups, we can use it\r
+                                    if (subInventoryResponseItem[FIELD.ID.INVENTORY_RESPONSE_ITEMS] != null) {\r
+                                        angular.forEach(subInventoryResponseItem[FIELD.ID.INVENTORY_RESPONSE_ITEMS][FIELD.ID.INVENTORY_RESPONSE_ITEM], function (vfmodules, key) {\r
+\r
+                                            if (vfmodules[FIELD.ID.VF_MODULE] != null) {\r
+                                                var vfModuleObject = vfmodules[FIELD.ID.VF_MODULE];\r
+                                                var vfModule = {\r
+                                                    "id": $scope.counter++,\r
+                                                    "name": vfModuleObject[FIELD.ID.VF_MODULE_NAME],\r
+                                                    "itemType": FIELD.ID.VF_MODULE,\r
+                                                    "nodeType": FIELD.ID.VF_MODULE,\r
+                                                    "nodeStatus": vfModuleObject[FIELD.ID.ORCHESTRATION_STATUS],\r
+                                                    "volumeGroups": [],\r
+                                                    "object": vfModuleObject,\r
+                                                    "networks": []\r
+                                                };\r
+                                                genericVnf[FIELD.ID.VF_MODULES].push(vfModule);\r
+                                                if (vfmodules[FIELD.ID.INVENTORY_RESPONSE_ITEMS] != null) {\r
+                                                    angular.forEach(vfmodules[FIELD.ID.INVENTORY_RESPONSE_ITEMS][FIELD.ID.INVENTORY_RESPONSE_ITEM], function (networks, key) {\r
+                                                        if (networks[FIELD.ID.L3_NETWORK] != null) {\r
+                                                            var l3NetworkObject = networks[FIELD.ID.L3_NETWORK];\r
+                                                            var l3Network = {\r
+                                                                "id": $scope.counter++,\r
+                                                                "name": l3NetworkObject[FIELD.ID.NETWORK_NAME],\r
+                                                                "itemType": FIELD.ID.L3_NETWORK,\r
+                                                                "nodeId": l3NetworkObject[FIELD.ID.NETWORK_ID],\r
+                                                                "nodeType": l3NetworkObject[FIELD.ID.NETWORK_TYPE],\r
+                                                                "nodeStatus": l3NetworkObject[FIELD.ID.ORCHESTRATION_STATUS],\r
+                                                                "object": l3NetworkObject,\r
+                                                                "nodes": []\r
+                                                            };\r
+                                                            vfModule[FIELD.ID.NETWORKS].push(l3Network);\r
+                                                        }\r
+                                                        if (networks[FIELD.ID.VOLUME_GROUP] != null) {\r
+                                                            var volumeGroupObject = networks[FIELD.ID.VOLUME_GROUP];\r
+\r
+                                                            var volumeGroup = {\r
+                                                                "id": $scope.counter++,\r
+                                                                "name": volumeGroupObject[FIELD.ID.VOLUME_GROUP_NAME],\r
+                                                                "itemType": FIELD.ID.VOLUME_GROUP,\r
+                                                                "nodeId": volumeGroupObject[FIELD.ID.VOLUME_GROUP_ID],\r
+                                                                "nodeType": volumeGroupObject[FIELD.ID.VNF_TYPE],\r
+                                                                "nodeStatus": volumeGroupObject[FIELD.ID.ORCHESTRATION_STATUS],\r
+                                                                "object": volumeGroupObject,\r
+                                                                "nodes": []\r
+                                                            };\r
+                                                            var tmpVolGroup = [];\r
+\r
+                                                            angular.forEach(genericVnf[FIELD.ID.AVAILABLEVOLUMEGROUPS], function (avgroup, key) {\r
+                                                                if (avgroup.name != volumeGroup.name) {\r
+                                                                    tmpVolGroup.push(avgroup);\r
+                                                                }\r
+                                                            });\r
+\r
+                                                            genericVnf[FIELD.ID.AVAILABLEVOLUMEGROUPS] = tmpVolGroup;\r
+\r
+                                                            vfModule[FIELD.ID.VOLUMEGROUPS].push(volumeGroup);\r
+                                                        }\r
+\r
+                                                    });\r
+                                                }\r
+                                            }\r
+                                        });\r
+                                    }\r
+                                }\r
+\r
+\r
+                                if (subInventoryResponseItem[FIELD.ID.GENERIC_CONFIGURATION] != null) {\r
+                                    var configObject = subInventoryResponseItem[FIELD.ID.GENERIC_CONFIGURATION];\r
+                                    var config = {\r
+                                        "id": $scope.counter++,\r
+                                        "name": configObject[FIELD.ID.CONFIGURATION_NAME],\r
+                                        "itemType": FIELD.ID.CONFIGURATION,\r
+                                        "nodeId": configObject[FIELD.ID.CONFIGURATION_ID],\r
+                                        "nodeType": configObject[FIELD.ID.CONFIGURATION_TYPE],\r
+                                        "nodeStatus": configObject[FIELD.ID.ORCHESTRATION_STATUS],\r
+                                        "modelInvariantId": configObject[FIELD.ID.MODEL_INVAR_ID],\r
+                                        "modelVersionId": configObject[FIELD.ID.MODEL_VERSION_ID],\r
+                                        "modelCustomizationId": configObject[FIELD.ID.MODEL_CUSTOMIZATION_ID],\r
+                                        "object": configObject,\r
+                                        "ports": [],\r
+                                        "configData" : null\r
+                                    };\r
+                                    if( !$scope.hasFabricConfigurations ) {\r
+                                        portMirroringConfigurationIds.push(configObject[FIELD.ID.CONFIGURATION_ID]);\r
+                                        $scope.service.instance[FIELD.ID.CONFIGURATIONS].push(config);\r
+                                    } else {\r
+                                        if (config.nodeStatus.toLowerCase() !== FIELD.STATUS.ASSIGNED.toLowerCase()) {\r
+                                            $scope.allConfigurationsAssigned = false;\r
+                                            if ($scope.isActivateFabricConfiguration()) {\r
+                                                $scope.errorMsg = "Activate fabric configuration button is not available as some of the configuration objects are not in Assigned status. Check MSO logs for the reasons for this abnormal case.";\r
+                                            }\r
+                                        }\r
+                                    }\r
+                                }\r
+\r
+                            });\r
+\r
+                            AaiService.getPortMirroringData(portMirroringConfigurationIds).then(function(result){\r
+                                angular.forEach($scope.service.instance[FIELD.ID.CONFIGURATIONS], function(config){\r
+                                    config['configData'] = result.data[config['nodeId']];\r
+\r
+                                    if (config.configData && config.configData.errorDescription) {\r
+                                        $scope.errorMsg = ($scope.errorMsg ? $scope.errorMsg + "\n" : "") +\r
+                                            "Cannot read cloud-region for configuration \"" + config.name + "\": " +\r
+                                            config.configData.errorDescription;\r
+                                    }\r
+                                });\r
+                            });\r
+\r
+                            AaiService.getPortMirroringSourcePorts(portMirroringConfigurationIds).then(function(result){\r
+                                angular.forEach($scope.service.instance[FIELD.ID.CONFIGURATIONS], function(config){\r
+                                    angular.forEach(result.data[config['nodeId']], function(port){\r
+                                        if (port.errorDescription) {\r
+                                            $scope.errorMsg = ($scope.errorMsg ? $scope.errorMsg + "\n" : "") +\r
+                                                "Cannot read a source port for configuration \"" + config.name + "\": " +\r
+                                                port.errorDescription;\r
+                                        } else {\r
+                                            config.ports.push({\r
+                                                "portId": port[FIELD.ID.PORT_ID],\r
+                                                "portName": port[FIELD.ID.PORT_NAME],\r
+                                                "portStatus": port[FIELD.ID.PORT_MIRRORED] === true ? FIELD.STATUS.AAI_ENABLED : FIELD.STATUS.AAI_DISABLED\r
+                                            });\r
+                                        }\r
+                                    });\r
+                                });\r
+                            });\r
+\r
+                        }\r
+                    });\r
+\r
+                    var aaiNetworkIds = _.map(serviceNetworkVlans, 'networkId');\r
+                    var serviceInstanceNetworkIds = _.map($scope.service.instance[FIELD.ID.NETWORKS], 'nodeId');\r
+                    var isContains = aaiNetworkIds.every(function(val) { return serviceInstanceNetworkIds.indexOf(val) >= 0; });\r
+                    if (aaiNetworkIds.length && !isContains)  {\r
+                        $log.error("vlansByNetworks contain network that not found in service instance", aaiNetworkIds, serviceInstanceNetworkIds);\r
+                    }\r
+\r
+                });\r
+        };\r
+\r
         $scope.handleInitialResponseInventoryItems = function (response) {\r
 \r
             $scope.inventoryResponseItemList = response.data[FIELD.ID.INVENTORY_RESPONSE_ITEM]; // get data from json\r
@@ -1521,12 +1820,13 @@ appDS2.controller("aaiSubscriberController", ["COMPONENT", "FIELD", "PARAMETER",
 \r
         $scope.serviceInstanceses = [{"sinstance": FIELD.NAME.SERVICE_INSTANCE_Id}, {"sinstance": FIELD.NAME.SERVICE_INSTANCE_NAME}];\r
 \r
-        function navigateToSearchResultsPage(globalCustomerId, selectedServiceInstance, selectedProjects, selectedOwningEntities) {\r
+        function navigateToSearchResultsPage(globalCustomerId, selectedServiceInstance, selectedProjects, selectedOwningEntities, selectedInstanceIdentifierType) {\r
             var projectQuery = AaiService.getMultipleValueParamQueryString(_.map(selectedProjects, 'id'), COMPONENT.PROJECT_SUB_PATH);\r
             var owningEntityQuery = AaiService.getMultipleValueParamQueryString(_.map(selectedOwningEntities, 'id'), COMPONENT.OWNING_ENTITY_SUB_PATH);\r
             var globalCustomerIdQuery = globalCustomerId ? COMPONENT.SELECTED_SUBSCRIBER_SUB_PATH + globalCustomerId : null;\r
             var serviceInstanceQuery = selectedServiceInstance ? COMPONENT.SELECTED_SERVICE_INSTANCE_SUB_PATH + selectedServiceInstance : null;\r
-            var query = AaiService.getJoinedQueryString([projectQuery, owningEntityQuery, globalCustomerIdQuery, serviceInstanceQuery]);\r
+            var serviceInstanceTypeQuery = selectedInstanceIdentifierType ? COMPONENT.SELECTED_SERVICE_INSTANCE_TYPE_SUB_PATH + selectedInstanceIdentifierType : null;\r
+            var query = AaiService.getJoinedQueryString([projectQuery, owningEntityQuery, globalCustomerIdQuery, serviceInstanceQuery, serviceInstanceTypeQuery]);\r
 \r
             window.location.href = COMPONENT.SELECTED_SERVICE_SUB_PATH + query;\r
         }\r
@@ -1542,7 +1842,7 @@ appDS2.controller("aaiSubscriberController", ["COMPONENT", "FIELD", "PARAMETER",
                             .getGlobalCustomerIdByInstanceIdentifier(selectedServiceInstance, selectedInstanceIdentifierType)\r
                             .then(handleCustomerIdResponse);\r
                     } else {\r
-                        navigateToSearchResultsPage(selectedCustomer, null, selectedProject, selectedOwningEntity);\r
+                        navigateToSearchResultsPage(selectedCustomer, null, selectedProject, selectedOwningEntity, selectedInstanceIdentifierType);\r
                     }\r
                 } else {\r
                     alert(FIELD.ERROR.SELECT);\r
@@ -1550,7 +1850,7 @@ appDS2.controller("aaiSubscriberController", ["COMPONENT", "FIELD", "PARAMETER",
 \r
                 function handleCustomerIdResponse(globalCustomerId) {\r
                     if (UtilityService.hasContents(globalCustomerId)) {\r
-                        navigateToSearchResultsPage(globalCustomerId, selectedServiceInstance, selectedProject, selectedOwningEntity);\r
+                        navigateToSearchResultsPage(globalCustomerId, selectedServiceInstance, selectedProject, selectedOwningEntity, selectedInstanceIdentifierType);\r
                     } else {\r
                         alert(FIELD.ERROR.SERVICE_INST_DNE);\r
                     }\r
index 03a2998..2478797 100644 (file)
@@ -691,6 +691,14 @@ describe('aaiSubscriberController testing', () => {
             });
         };
 
+        mockAaiService.getSubscriberNameAndServiceInstanceInfo = (customerId, serviceInstanceId, serviceIdentifierType, subscriberName, successFunction) => {
+            successFunction({"serviceInstanceId":"5d942bc7-3acf-4e35-836a-393619ebde66",
+                "serviceInstanceName":"dpa2actsf5001v_Port_Mirroring_dpa2a_SVC",
+                "modelVersionId":"a9088517-efe8-4bed-9c54-534462cb08c2",
+                "modelInvariantId":"0757d856-a9c6-450d-b494-e1c0a4aab76f",
+                "orchestrationStatus":"Active","subscriberName":"Mobility"});
+        };
+
         mock_.map = (serviceNetworkVlans, networkId) => {
             return ["aaiNetworkId1","aaiNetworkId2"];
         };
index cfab522..49245c5 100755 (executable)
@@ -125,7 +125,28 @@ var AaiService = function ($http, $log, PropertyService, UtilityService, COMPONE
             })["catch"]
             (UtilityService.runHttpErrorHandler);
         },
-
+        getSubscriberNameAndServiceInstanceInfo: function (subscriberUuid, serviceInstanceIdentifier,
+            serviceInstanceIdentifierType, subscriberName, successCallbackFunction ) {
+            $log.debug("AaiService:getSubscriberNameAndServiceInstanceInfo: subscriberUuid: " + subscriberUuid +
+                ",serviceInstanceIdentifier :"+serviceInstanceIdentifier +
+                " , serviceInstanceIdentifierType="+serviceInstanceIdentifierType +",subscriberName="+subscriberName);
+
+            if (UtilityService.hasContents(subscriberUuid) && UtilityService.hasContents(serviceInstanceIdentifier) &&
+                UtilityService.hasContents(serviceInstanceIdentifierType) ) {
+                $http.get(COMPONENT.AAI_SUB_DETAILS_SERVICE_INSTANCE_PATH +
+                    subscriberUuid + COMPONENT.FORWARD_SLASH + serviceInstanceIdentifier +  COMPONENT.FORWARD_SLASH +
+                    serviceInstanceIdentifierType + COMPONENT.FORWARD_SLASH + subscriberName + COMPONENT.ASSIGN + Math.random(),
+                    {
+                        timeout: PropertyService.getServerResponseTimeoutMsec()
+                    }).then(function (response) {
+                    var result = {};
+                    if (response.data) {
+                        result = response.data;
+                    }
+                    successCallbackFunction(result);
+                })["catch"]
+                (UtilityService.runHttpErrorHandler);
+            }},
         runNamedQuery: function (namedQueryId, globalCustomerId, serviceType, serviceInstanceId, successCallback, errorCallback) {
 
             var url = COMPONENT.AAI_SUB_VIEWEDIT_PATH +
@@ -209,11 +230,11 @@ var AaiService = function ($http, $log, PropertyService, UtilityService, COMPONE
 
         searchServiceInstances: searchServiceInstances,
 
-        getModelVersionId: function (subscriberId, instanceId) {
+        getModelVersionId: function (subscriberId, instanceId, identifierType) {
             var globalCustomerIdQuery = COMPONENT.SELECTED_SUBSCRIBER_SUB_PATH + subscriberId;
             var serviceInstanceQuery = COMPONENT.SELECTED_SERVICE_INSTANCE_SUB_PATH + instanceId;
-
-            var query = "?" + getJoinedQueryString([globalCustomerIdQuery, serviceInstanceQuery]);
+            var serviceIdentifierType = COMPONENT.SELECTED_SERVICE_INSTANCE_TYPE_SUB_PATH + identifierType;
+            var query = "?" + getJoinedQueryString([globalCustomerIdQuery, serviceInstanceQuery, serviceIdentifierType]);
 
             var deferred = $q.defer();
 
@@ -695,7 +716,7 @@ var AaiService = function ($http, $log, PropertyService, UtilityService, COMPONE
             $log.debug("AaiService:getSubscriberServiceTypes: subscriberUuid: " + subscriberUuid);
 
             if (UtilityService.hasContents(subscriberUuid)) {
-                $http.get(COMPONENT.AAI_SUB_DETAILS_PATH + subscriberUuid + COMPONENT.ASSIGN + Math.random())
+                $http.get(COMPONENT.AAI_SUB_DETAILS_PATH + subscriberUuid + COMPONENT.ASSIGN + Math.random()+ COMPONENT.AAI_OMIT_SERVICE_INSTANCES + true)
                     .success(function (response) {
                         if (response && [FIELD.ID.SERVICE_SUBSCRIPTIONS]) {
                             deferred.resolve({data: response[FIELD.ID.SERVICE_SUBSCRIPTIONS][FIELD.ID.SERVICE_SUBSCRIPTION]});
index 1a75c55..ecfe5a0 100644 (file)
@@ -148,6 +148,9 @@ public class AaiClientTest {
     private static String responseJsonNfRole = "/payload_jsons/changeManagement/vnfs-fromServiceInstance-filterNfRole.json";
     private static String responseJsonCloudRegion ="/payload_jsons/changeManagement/vnfs-fromServiceInstance-filterByCloudRegion.json";
 
+    private static String responseJsonDSLServiceInstance ="/payload_jsons/service-instance-by-subscriberid.json";
+    private static String dslQueryPayloadByServiceInstanceId = "{\"dsl\":\"customer*('global-customer-id','SOME_GLOBAL_CUST_ID')>service-subscription>service-instance*('service-instance-id','SOME_SERVICE_INSTANCE_ID')\"}";
+    private static String dslQueryPayloadByServiceInstanceName = "{\"dsl\":\"customer*('global-customer-id','SOME_GLOBAL_CUST_ID')>service-subscription>service-instance*('service-instance-name','SOME_SERVICE_INSTANCE_NAME')\"}";
 
     @DataProvider
     public static Object[][] aaiPutCustomQueryData() {
@@ -952,6 +955,54 @@ public class AaiClientTest {
         Mockito.verify(aaiClientMock).doAaiGet(argThat(s -> s.contains("customer/" + subscriberId + "?") && s.contains("depth=" + depth)),any(Boolean.class));
     }
 
+
+    @DataProvider
+    public static Object[][] aaiDSLPutServiceInstanceQueryData() {
+        return new Object[][] {
+            {"SOME_GLOBAL_CUST_ID", "Service Instance Id", "SOME_SERVICE_INSTANCE_ID",
+                dslQueryPayloadByServiceInstanceId, responseJsonDSLServiceInstance, "SOME_SERVICE_INSTANCE_ID", 200},
+            {"SOME_GLOBAL_CUST_ID", "Service Instance Name", "SOME_SERVICE_INSTANCE_NAME",
+                dslQueryPayloadByServiceInstanceName, responseJsonDSLServiceInstance, "SOME_SERVICE_INSTANCE_ID", 200},
+            {"SOME_GLOBAL_CUST_ID", "Service Instance Name", "SOME_SERVICE_INSTANCE_NAME",
+                dslQueryPayloadByServiceInstanceName, responseJsonDSLServiceInstance, "SOME_SERVICE_INSTANCE_ID",200},
+
+        };
+    }
+
+    @Test(dataProvider = "aaiDSLPutServiceInstanceQueryData")
+    public void testAaiDSLPutServiceInstanceQueryByParams(          String globalCustomerId,
+                                                                    String identifierType,
+                                                                    String identifier,
+                                                                    String expectedPayload,
+                                                                    String responseBody,
+                                                                    String expectedSiId,
+                                                                    int responseHttpCode) {
+
+        String queryFormat = "dsl?format=resource&nodesOnly=true&depth=0&as-tree=true";
+
+        final ResponseWithRequestInfo mockedResponseWithRequestInfo = mockedResponseWithRequestInfo(Response.Status.OK,
+            TestUtils.readFileAsString(responseBody),
+            "dsl?format=resource&nodesOnly=true&depth=0&as-tree=true&Mock=True",
+            HttpMethod.PUT);
+
+        when(aaiClientMock.doAaiPut(eq(queryFormat), anyString(), anyBoolean(), anyBoolean())).thenReturn(mockedResponseWithRequestInfo);
+        when(aaiClientMock.getServiceInstanceBySubscriberIdAndInstanceIdentifier(anyString(), anyString(), anyString())).thenCallRealMethod();
+
+        AaiResponse<DSLQuerySimpleResponse> response = aaiClientMock.getServiceInstanceBySubscriberIdAndInstanceIdentifier(globalCustomerId, identifierType, identifier);
+
+        verify(aaiClientMock).doAaiPut(eq(queryFormat), eq(expectedPayload), eq(false), eq(false));
+
+        assertEquals(response.getHttpCode(), responseHttpCode);
+        assertEquals(response.getT().getResults().get(0).getCustomer().getCustomerRelatedNodes().get(0).getCustomerServiceSubscription().
+            getServiceSubscriptionRelatedNodes().get(0).getServiceInstance().serviceInstanceId, expectedSiId);
+
+        assertEquals(response.getT().getResults().get(0).getCustomer().getSubscriberName(), "Mobility");
+
+        assertEquals(response.getT().getResults().get(0).getCustomer().getCustomerRelatedNodes().get(0).getCustomerServiceSubscription().
+            getServiceSubscriptionRelatedNodes().get(0).getServiceInstance().orchestrationStatus, "SOME_ORCH_STATUS");
+
+    }
+
     @Test
     public void testToModelVerStream() throws IOException {
 
diff --git a/vid-app-common/src/test/resources/payload_jsons/service-instance-by-subscriberid.json b/vid-app-common/src/test/resources/payload_jsons/service-instance-by-subscriberid.json
new file mode 100644 (file)
index 0000000..fbf8cb1
--- /dev/null
@@ -0,0 +1 @@
+{"results": [{"customer": {"global-customer-id": "SOME_GLOBAL_CUST_ID", "subscriber-name": "Mobility", "subscriber-type": "INFRA", "resource-version": "1602518417955", "related-nodes": [{"service-subscription": {"service-type": "VPMS", "resource-version": "1629183620246","related-nodes": [{"service-instance": {"service-instance-id": "SOME_SERVICE_INSTANCE_ID", "service-instance-name": "SOME_SERVICE_INSTANCE_NAME", "service-type": "PORT-MIRROR", "service-role": "VPROBE", "environment-context": "General_Revenue-Bearing", "workload-context": "Production", "model-invariant-id": "0757d856-a9c6-450d-b494-e1c0a4aab76f","model-version-id": "a9088517-efe8-4bed-9c54-534462cb08c2","resource-version": "1615330529236","selflink": "SOME_SELF_LINK","orchestration-status": "SOME_ORCH_STATUS" }}]}}]}}  ]}
\ No newline at end of file
diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetServiceInstanceBySubscriberIdAndServiceTypeAndSIID.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetServiceInstanceBySubscriberIdAndServiceTypeAndSIID.java
new file mode 100644 (file)
index 0000000..fe722ae
--- /dev/null
@@ -0,0 +1,230 @@
+package org.onap.simulator.presetGenerator.presets.aai;
+
+import org.onap.simulator.presetGenerator.presets.BasePresets.BaseAAIPreset;
+import org.springframework.http.HttpMethod;
+
+public class PresetAAIGetServiceInstanceBySubscriberIdAndServiceTypeAndSIID extends BaseAAIPreset {
+    private String subscriberId;
+
+    public String getSubscriberId() {
+        return subscriberId;
+    }
+
+    public String getServiceType() {
+        return serviceType;
+    }
+
+    public String getServiceInstanceId() {
+        return serviceInstanceId;
+    }
+
+    private String serviceType;
+    private String serviceInstanceId;
+
+    public PresetAAIGetServiceInstanceBySubscriberIdAndServiceTypeAndSIID(String subscriberId, String serviceType, String serviceInstanceId) {
+        this.subscriberId = subscriberId;
+        this.serviceType = serviceType;
+        this.serviceInstanceId = serviceInstanceId;
+    }
+
+//    @Override
+//    public Map<String, List> getQueryParams() {
+//        return ImmutableMap.of("depth",  Collections.singletonList("1"));
+//    }
+
+    @Override
+    public HttpMethod getReqMethod() {
+        return HttpMethod.GET;
+    }
+
+    @Override
+    public String getReqPath() {
+        return getRootPath() +
+                "/business/customers/customer/"+getSubscriberId()+
+                "/service-subscriptions/service-subscription/"+getServiceType()+
+                "/service-instances/service-instance/"+getServiceInstanceId();
+    }
+
+    @Override
+    public Object getResponseBody() {
+        return "{\n"
+            + " \"service-instance-id\": \"5d942bc7-3acf-4e35-836a-393619ebde66\","
+            + " \"service-instance-name\": \"dpa2actsf5001v_Port_Mirroring_dpa2a_SVC\","
+            + " \"model-invariant-id\": \"0757d856-a9c6-450d-b494-e1c0a4aab76f\","
+            + " \"model-version-id\": \"a9088517-efe8-4bed-9c54-534462cb08c2\","
+            + " \"resource-version\": \"1500789244673\","
+            + " \"orchestration-status\": \"Active\","
+            + " \"relationship-list\": {"
+            + "  \"relationship\": ["
+            + "    {"
+            + "      \"related-to\": \"generic-vnf\","
+            + "      \"related-link\": \"/aai/v11/network/generic-vnfs/generic-vnf/c015cc0f-0f37-4488-aabf-53795fd93cd3\","
+            + "      \"relationship-data\": ["
+            + "        {"
+            + "          \"relationship-key\": \"generic-vnf.vnf-id\","
+            + "          \"relationship-value\": \"c015cc0f-0f37-4488-aabf-53795fd93cd3\""
+            + "        }"
+            + "      ],"
+            + "      \"related-to-property\": ["
+            + "        {"
+            + "          \"property-key\": \"generic-vnf.vnf-name\","
+            + "          \"property-value\": \"fsd\""
+            + "        }"
+            + "      ]"
+            + "    },"
+            + "    {"
+            + "      \"related-to\": \"generic-vnf\","
+            + "      \"related-link\": \"/aai/v11/network/generic-vnfs/generic-vnf/0846287b-65bf-45a6-88f6-6a1af4149fac\","
+            + "      \"relationship-data\": ["
+            + "        {"
+            + "          \"relationship-key\": \"generic-vnf.vnf-id\","
+            + "          \"relationship-value\": \"0846287b-65bf-45a6-88f6-6a1af4149fac\""
+            + "        }"
+            + "      ],"
+            + "      \"related-to-property\": ["
+            + "        {"
+            + "          \"property-key\": \"generic-vnf.vnf-name\","
+            + "          \"property-value\": \"kjkjk\""
+            + "        }"
+            + "      ]"
+            + "    },"
+            + "    {"
+            + "      \"related-to\": \"generic-vnf\","
+            + "      \"related-link\": \"/aai/v11/network/generic-vnfs/generic-vnf/9908b762-136f-4b1f-8eb4-ef670ef58bb4\","
+            + "      \"relationship-data\": ["
+            + "        {"
+            + "          \"relationship-key\": \"generic-vnf.vnf-id\","
+            + "          \"relationship-value\": \"9908b762-136f-4b1f-8eb4-ef670ef58bb4\""
+            + "        }"
+            + "      ],"
+            + "      \"related-to-property\": ["
+            + "        {"
+            + "          \"property-key\": \"generic-vnf.vnf-name\","
+            + "          \"property-value\": \"uiui\""
+            + "        }"
+            + "      ]"
+            + "    },"
+            + "    {"
+            + "      \"related-to\": \"generic-vnf\","
+            + "      \"related-link\": \"/aai/v11/network/generic-vnfs/generic-vnf/543931f5-e50e-45a2-a69f-ab727e4c7f2f\","
+            + "      \"relationship-data\": ["
+            + "        {"
+            + "          \"relationship-key\": \"generic-vnf.vnf-id\","
+            + "          \"relationship-value\": \"543931f5-e50e-45a2-a69f-ab727e4c7f2f\""
+            + "        }"
+            + "      ],"
+            + "      \"related-to-property\": ["
+            + "        {"
+            + "          \"property-key\": \"generic-vnf.vnf-name\","
+            + "          \"property-value\": \"sdfsdfdsf\""
+            + "        }"
+            + "      ]"
+            + "    },"
+            + "    {"
+            + "      \"related-to\": \"generic-vnf\","
+            + "      \"related-link\": \"/aai/v11/network/generic-vnfs/generic-vnf/25e84884-22d5-44c9-8212-cb459f63e0ba\","
+            + "      \"relationship-data\": ["
+            + "        {"
+            + "          \"relationship-key\": \"generic-vnf.vnf-id\","
+            + "          \"relationship-value\": \"25e84884-22d5-44c9-8212-cb459f63e0ba\""
+            + "        }"
+            + "      ],"
+            + "      \"related-to-property\": ["
+            + "        {"
+            + "          \"property-key\": \"generic-vnf.vnf-name\","
+            + "          \"property-value\": \"sdada\""
+            + "        }"
+            + "      ]"
+            + "    },"
+            + "    {"
+            + "      \"related-to\": \"generic-vnf\","
+            + "      \"related-link\": \"/aai/v11/network/generic-vnfs/generic-vnf/013fb0ba-977b-496c-9faa-7f8e5f083eec\","
+            + "      \"relationship-data\": ["
+            + "        {"
+            + "          \"relationship-key\": \"generic-vnf.vnf-id\","
+            + "          \"relationship-value\": \"013fb0ba-977b-496c-9faa-7f8e5f083eec\""
+            + "        }"
+            + "      ],"
+            + "      \"related-to-property\": ["
+            + "        {"
+            + "          \"property-key\": \"generic-vnf.vnf-name\","
+            + "          \"property-value\": \"gvb\""
+            + "        }"
+            + "      ]"
+            + "    },"
+            + "    {"
+            + "      \"related-to\": \"generic-vnf\","
+            + "      \"related-link\": \"/aai/v11/network/generic-vnfs/generic-vnf/06914296-cb46-4b62-9453-329a706a6cbb\","
+            + "      \"relationship-data\": ["
+            + "        {"
+            + "          \"relationship-key\": \"generic-vnf.vnf-id\","
+            + "          \"relationship-value\": \"06914296-cb46-4b62-9453-329a706a6cbb\""
+            + "        }"
+            + "      ],"
+            + "      \"related-to-property\": ["
+            + "        {"
+            + "          \"property-key\": \"generic-vnf.vnf-name\","
+            + "          \"property-value\": \"lkllll\""
+            + "        }"
+            + "      ]"
+            + "    },"
+            + "    {"
+            + "      \"related-to\": \"generic-vnf\","
+            + "      \"related-link\": \"/aai/v11/network/generic-vnfs/generic-vnf/c55da606-cf38-42c7-bc3c-be8e23b19299\","
+            + "      \"relationship-data\": ["
+            + "        {"
+            + "          \"relationship-key\": \"generic-vnf.vnf-id\","
+            + "          \"relationship-value\": \"c55da606-cf38-42c7-bc3c-be8e23b19299\""
+            + "        }"
+            + "      ],"
+            + "      \"related-to-property\": ["
+            + "        {"
+            + "          \"property-key\": \"generic-vnf.vnf-name\","
+            + "          \"property-value\": \"ss\""
+            + "        }"
+            + "      ]"
+            + "    },"
+            + "    {"
+            + "      \"related-to\": \"generic-vnf\","
+            + "      \"related-link\": \"/aai/v11/network/generic-vnfs/generic-vnf/27cc0914-70be-453e-b552-3df6b1d6cda9\","
+            + "      \"relationship-data\": ["
+            + "        {"
+            + "          \"relationship-key\": \"generic-vnf.vnf-id\","
+            + "          \"relationship-value\": \"27cc0914-70be-453e-b552-3df6b1d6cda9\""
+            + "        }"
+            + "      ],"
+            + "      \"related-to-property\": ["
+            + "        {"
+            + "          \"property-key\": \"generic-vnf.vnf-name\","
+            + "          \"property-value\": \"yh\""
+            + "        }"
+            + "      ]"
+            + "    },"
+            + "    {"
+            + "      \"related-to\": \"logical-link\","
+            + "      \"related-link\": \"/aai/v11/network/logical-links/logical-link/tesai372ve2%3Aae10%7Ctesaaisdgrbclz1a1%3Apo100\","
+            + "      \"relationship-data\": ["
+            + "        {"
+            + "          \"relationship-key\": \"logical-link.link-name\","
+            + "          \"relationship-value\": \"tesai372ve2:ae10|tesaaisdgrbclz1a1:po100\""
+            + "        }"
+            + "      ]"
+            + "    },"
+            + "    {"
+            + "      \"related-to\": \"logical-link\","
+            + "      \"related-link\": \"/aai/v11/network/logical-links/logical-link/SANITY6758cce9%3ALAG1992%7CSANITY6785cce9%3ALAG1961\","
+            + "      \"relationship-data\": ["
+            + "        {"
+            + "          \"relationship-key\": \"logical-link.link-name\","
+            + "          \"relationship-value\": \"SANITY6758cce9:LAG1992|SANITY6785cce9:LAG1961\""
+            + "        }"
+            + "           ]"
+            + "         }"
+            + "       ]"
+            + "     }"
+            + "   }"
+            + " }";
+    }
+
+}
+
diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIServiceInstanceDSLPut.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIServiceInstanceDSLPut.java
new file mode 100644 (file)
index 0000000..3ab5a4b
--- /dev/null
@@ -0,0 +1,105 @@
+package org.onap.simulator.presetGenerator.presets.aai;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import org.onap.simulator.presetGenerator.presets.BasePresets.BaseAAIPreset;
+import org.springframework.http.HttpMethod;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+public class PresetAAIServiceInstanceDSLPut extends BaseAAIPreset {
+
+    public PresetAAIServiceInstanceDSLPut(String globalCustomerId, String serviceInstanceIdentifier, String instanceIdentifierType) {
+        this.serviceInstanceIdentifier = serviceInstanceIdentifier;
+        this.globalCustomerId = globalCustomerId;
+        this.instanceIdentifierType = instanceIdentifierType;
+    }
+
+    public String getInstanceIdentifierType() {
+        return instanceIdentifierType;
+    }
+
+    private final String instanceIdentifierType;
+    private final String globalCustomerId;
+
+    public String getGlobalCustomerId() {
+        return globalCustomerId;
+    }
+
+    public String getServiceInstanceIdentifier() {
+        return serviceInstanceIdentifier;
+    }
+
+    private final String serviceInstanceIdentifier;
+
+    @Override
+    public HttpMethod getReqMethod() {
+        return HttpMethod.PUT;
+    }
+
+    @Override
+    public String getReqPath() {
+        return getRootPath() + "/dsl";
+    }
+
+    @Override
+    public Map<String, List> getQueryParams() {
+        return ImmutableMap.of(
+            "format", Collections.singletonList("resource"),
+            "nodesOnly", Collections.singletonList("true"),
+            "depth", Collections.singletonList("0"),
+            "as-tree", Collections.singletonList("true")
+        );
+    }
+
+    @Override
+    public Object getRequestBody() {
+        String requestBody = null;
+        String query = null;
+        if(getInstanceIdentifierType().equals("Service Instance Id")) {
+            query = "customer*('global-customer-id','" + getGlobalCustomerId() + "')>" +
+                "service-subscription>service-instance*('service-instance-id','" + getServiceInstanceIdentifier() + "')";
+            requestBody = "{\"dsl\":\"" + query + "\"}";
+        } else {
+            query = "customer*('global-customer-id','" + getGlobalCustomerId() + "')>" +
+                "service-subscription>service-instance*('service-instance-name','" + getServiceInstanceIdentifier() + "')";
+            requestBody = "{\"dsl\":\"" + query + "\"}";
+        }
+        return requestBody;
+    }
+
+
+    @Override
+    public Object getResponseBody() {
+        return "{\"results\": [\n"
+            + "{\n"
+            + "\"customer\": {\n"
+            + "\"global-customer-id\": \"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\",\n"
+            + "\"subscriber-name\": \"Mobility\",\n"
+            + "\"subscriber-type\": \"INFRA\",\n"
+            + "\"resource-version\": \"1602518417955\",\n"
+            + "\"related-nodes\": [\n"
+            + "{\n"
+            + "\"service-subscription\": {\n"
+            + "\"service-type\": \"VPMS\",\n"
+            + "\"resource-version\": \"1629183620246\",\n"
+            + "\"related-nodes\": [\n"
+            + "{\n"
+            + "\"service-instance\": {\n"
+            + "\"service-instance-id\": \"5d942bc7-3acf-4e35-836a-393619ebde66\",\n"
+            + "\"service-instance-name\": \"dpa2actsf5001v_Port_Mirroring_dpa2a_SVC\",\n"
+            + "\"service-type\": \"PORT-MIRROR\",\n"
+            + "\"service-role\": \"VPROBE\",\n"
+            + "\"environment-context\": \"General_Revenue-Bearing\",\n"
+            + "\"workload-context\": \"Production\",\n"
+            + "\"model-invariant-id\": \"0757d856-a9c6-450d-b494-e1c0a4aab76f\",\n"
+            + "\"model-version-id\": \"a9088517-efe8-4bed-9c54-534462cb08c2\",\n"
+            + "\"resource-version\": \"1615330529236\",\n"
+            + "\"selflink\": \"SOME_SELF_LINK\",\n"
+            + "\"orchestration-status\": \"Active\"\n"
+            + "}}]}}]}}]}";
+
+    }
+}
index 958ba87..98c6daf 100644 (file)
@@ -40,6 +40,7 @@ import org.onap.simulator.presetGenerator.presets.BasePresets.BasePreset;
 import org.onap.simulator.presetGenerator.presets.aai.AAIBaseGetL3NetworksByCloudRegionPreset;
 import org.onap.simulator.presetGenerator.presets.aai.PresetAAIBadBodyForGetServicesGet;
 import org.onap.simulator.presetGenerator.presets.aai.PresetAAICloudRegionAndSourceFromConfigurationPut;
+import org.onap.simulator.presetGenerator.presets.aai.PresetAAIFilterServiceInstanceById;
 import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetCloudOwnersByCloudRegionId;
 import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetHomingForVfModule;
 import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetInstanceGroupsByCloudRegion;
@@ -54,9 +55,11 @@ import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetNetworkCollect
 import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetPortMirroringSourcePorts;
 import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetPortMirroringSourcePortsError;
 import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetRelatedInstanceGroupsByVnfId;
+import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetServiceInstanceBySubscriberIdAndServiceTypeAndSIID;
 import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetSubscribersGet;
 import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetVpnsByType;
 import org.onap.simulator.presetGenerator.presets.aai.PresetAAIModelVersionsByInvariantId;
+import org.onap.simulator.presetGenerator.presets.aai.PresetAAIServiceInstanceDSLPut;
 import org.onap.simulator.presetGenerator.presets.aai.PresetAAIStandardQueryGet;
 import org.onap.simulator.presetGenerator.presets.aai.PresetBaseAAICustomQuery;
 import org.onap.simulator.presetGenerator.presets.sdc.PresetSDCGetServiceMetadataGet;
@@ -93,6 +96,10 @@ public class AaiApiTest extends BaseApiAaiTest {
     public static final String OPERATIONAL_ENVIRONMENT_STATUS = "Activate";
     public static final String GET_INSTANCE_GROUPS_BY_CLOUDREGION_EXPECTED_RESPONSE = "{\"results\":[{\"instance-group\":{\"id\":\"AAI-12002-test3-vm230w\",\"description\":\"a9DEa0kpY\",\"instance-group-role\":\"JZmha7QSS4tJ\",\"model-invariant-id\":\"model-id3\",\"model-version-id\":\"a0efd5fc-f7be-4502-936a-a6c6392b958f\",\"instance-group-type\":\"type\",\"resource-version\":\"1520888659539\",\"instance-group-name\":\"wKmBXiO1xm8bK\",\"instance-group-function\":\"testfunction2\",\"relationship-list\":{\"relationship\":[{\"relationDataList\":[{\"relationship-key\":\"cloud-region.cloud-owner\",\"relationship-value\":\"AAI-12002-vm230w\"},{\"relationship-key\":\"cloud-region.cloud-region-id\",\"relationship-value\":\"AAI-region-vm230w\"}],\"relatedToPropertyList\":[{\"property-key\":\"cloud-region.owner-defined-type\",\"property-value\":null}],\"related-to\":\"cloud-region\",\"related-link\":\"/aai/v13/cloud-infrastructure/cloud-regions/cloud-region/AAI-12002-vm230w/AAI-region-vm230w\",\"relationship-label\":\"org.onap.relationships.inventory.Uses\",\"relationship-data\":[{\"relationship-key\":\"cloud-region.cloud-owner\",\"relationship-value\":\"AAI-12002-vm230w\"},{\"relationship-key\":\"cloud-region.cloud-region-id\",\"relationship-value\":\"AAI-region-vm230w\"}],\"related-to-property\":[{\"property-key\":\"cloud-region.owner-defined-type\",\"property-value\":null}]}]}}},{\"instance-group\":{\"id\":\"AAI-12002-test1-vm230w\",\"description\":\"a9DEa0kpY\",\"instance-group-role\":\"JZmha7QSS4tJ\",\"model-invariant-id\":\"model-id1\",\"model-version-id\":\"a0efd5fc-f7be-4502-936a-a6c6392b958f\",\"instance-group-type\":\"type\",\"resource-version\":\"1520886467989\",\"instance-group-name\":\"wKmBXiO1xm8bK\",\"instance-group-function\":\"testfunction2\",\"relationship-list\":{\"relationship\":[{\"relationDataList\":[{\"relationship-key\":\"cloud-region.cloud-owner\",\"relationship-value\":\"AAI-12002-vm230w\"},{\"relationship-key\":\"cloud-region.cloud-region-id\",\"relationship-value\":\"AAI-region-vm230w\"}],\"relatedToPropertyList\":[{\"property-key\":\"cloud-region.owner-defined-type\",\"property-value\":null}],\"related-to\":\"cloud-region\",\"related-link\":\"/aai/v13/cloud-infrastructure/cloud-regions/cloud-region/AAI-12002-vm230w/AAI-region-vm230w\",\"relationship-label\":\"org.onap.relationships.inventory.Uses\",\"relationship-data\":[{\"relationship-key\":\"cloud-region.cloud-owner\",\"relationship-value\":\"AAI-12002-vm230w\"},{\"relationship-key\":\"cloud-region.cloud-region-id\",\"relationship-value\":\"AAI-region-vm230w\"}],\"related-to-property\":[{\"property-key\":\"cloud-region.owner-defined-type\",\"property-value\":null}]}]}}},{\"instance-group\":{\"id\":\"AAI-12002-test2-vm230w\",\"description\":\"a9DEa0kpY\",\"instance-group-role\":\"JZmha7QSS4tJ\",\"model-invariant-id\":\"model-id2\",\"model-version-id\":\"version2\",\"instance-group-type\":\"type\",\"resource-version\":\"1520888629970\",\"instance-group-name\":\"wKmBXiO1xm8bK\",\"instance-group-function\":\"testfunction2\",\"relationship-list\":{\"relationship\":[{\"relationDataList\":[{\"relationship-key\":\"cloud-region.cloud-owner\",\"relationship-value\":\"AAI-12002-vm230w\"},{\"relationship-key\":\"cloud-region.cloud-region-id\",\"relationship-value\":\"AAI-region-vm230w\"}],\"relatedToPropertyList\":[{\"property-key\":\"cloud-region.owner-defined-type\",\"property-value\":null}],\"related-to\":\"cloud-region\",\"related-link\":\"/aai/v13/cloud-infrastructure/cloud-regions/cloud-region/AAI-12002-vm230w/AAI-region-vm230w\",\"relationship-label\":\"org.onap.relationships.inventory.Uses\",\"relationship-data\":[{\"relationship-key\":\"cloud-region.cloud-owner\",\"relationship-value\":\"AAI-12002-vm230w\"},{\"relationship-key\":\"cloud-region.cloud-region-id\",\"relationship-value\":\"AAI-region-vm230w\"}],\"related-to-property\":[{\"property-key\":\"cloud-region.owner-defined-type\",\"property-value\":null}]}]}}}]}\n";
     public static final String GET_NETWORK_COLLECTION_EXPECTED_RESPONSE = "{\"results\":{\"collection\":{\"collection-id\":\"collection-1-2018-rs804s\",\"model-invariant-id\":\"5761e0a7-defj777\",\"model-version-id\":\"5761e0a7-defj232\",\"collection-name\":\"collection-name\",\"collection-type\":\"L3-NETWORK\",\"collection-role\":\"SUB-INTERFACE\",\"collection-function\":\"collection-function\",\"collection-customization-id\":\"custom-unique-data-id\",\"relationship-list\":{\"relationship\":[{\"relationDataList\":[{\"relationship-key\":\"customer.global-customer-id\",\"relationship-value\":\"customer-1-2017-rs804s\"},{\"relationship-key\":\"service-subscription.service-type\",\"relationship-value\":\"service-value7-rs804s\"},{\"relationship-key\":\"service-instance.service-instance-id\",\"relationship-value\":\"2UJZZ01777-rs804s\"}],\"relatedToPropertyList\":[{\"property-key\":\"service-instance.service-instance-name\",\"property-value\":null}],\"related-to\":\"service-instance\",\"related-link\":\"/aai/v13/business/customers/customer/customer-1-2017-rs804s/service-subscriptions/service-subscription/service-value7-rs804s/service-instances/service-instance/2UJZZ01777-rs804s\",\"relationship-label\":\"org.onap.relationships.inventory.MemberOf\",\"relationship-data\":[{\"relationship-key\":\"customer.global-customer-id\",\"relationship-value\":\"customer-1-2017-rs804s\"},{\"relationship-key\":\"service-subscription.service-type\",\"relationship-value\":\"service-value7-rs804s\"},{\"relationship-key\":\"service-instance.service-instance-id\",\"relationship-value\":\"2UJZZ01777-rs804s\"}],\"related-to-property\":[{\"property-key\":\"service-instance.service-instance-name\",\"property-value\":null}]},{\"relationDataList\":[{\"relationship-key\":\"instance-group.id\",\"relationship-value\":\"instanceGroup-2018-rs804s\"}],\"relatedToPropertyList\":[{\"property-key\":\"instance-group.description\",\"property-value\":\"zr6h\"},{\"property-key\":\"instance-group.instance-group-name\",\"property-value\":\"wKmBXiO1xm8bK\"}],\"related-to\":\"instance-group\",\"related-link\":\"/aai/v13/network/instance-groups/instance-group/instanceGroup-2018-rs804s\",\"relationship-label\":\"org.onap.relationships.inventory.MemberOf\",\"relationship-data\":[{\"relationship-key\":\"instance-group.id\",\"relationship-value\":\"instanceGroup-2018-rs804s\"}],\"related-to-property\":[{\"property-key\":\"instance-group.description\",\"property-value\":\"zr6h\"},{\"property-key\":\"instance-group.instance-group-name\",\"property-value\":\"wKmBXiO1xm8bK\"}]}]},\"resource-version\":\"1521662811309\"},\"networks\":[{\"network-id\":\"l3network-id-rs804s\",\"network-name\":\"oam-net\",\"network-type\":\"Tenant_Layer_3\",\"network-role\":\"RosemaProtectedOam.OAM\",\"network-technology\":\"Contrail\",\"is-bound-to-vpn\":false,\"resource-version\":\"1521662814627\",\"orchestration-status\":\"Created\",\"is-provider-network\":false,\"is-shared-network\":false,\"is-external-network\":false,\"relationship-list\":{\"relationship\":[{\"relationDataList\":[{\"relationship-key\":\"instance-group.id\",\"relationship-value\":\"instanceGroup-2018-rs804s\"}],\"relatedToPropertyList\":[{\"property-key\":\"instance-group.description\",\"property-value\":\"zr6h\"},{\"property-key\":\"instance-group.instance-group-name\",\"property-value\":\"wKmBXiO1xm8bK\"}],\"related-to\":\"instance-group\",\"related-link\":\"/aai/v13/network/instance-groups/instance-group/instanceGroup-2018-rs804s\",\"relationship-label\":\"org.onap.relationships.inventory.MemberOf\",\"relationship-data\":[{\"relationship-key\":\"instance-group.id\",\"relationship-value\":\"instanceGroup-2018-rs804s\"}],\"related-to-property\":[{\"property-key\":\"instance-group.description\",\"property-value\":\"zr6h\"},{\"property-key\":\"instance-group.instance-group-name\",\"property-value\":\"wKmBXiO1xm8bK\"}]}]}},{\"network-id\":\"l3network-id-3-rs804s\",\"network-name\":\"oam-net\",\"network-type\":\"Tenant_Layer_3\",\"network-role\":\"RosemaProtectedOam.OAM\",\"network-technology\":\"Contrail\",\"is-bound-to-vpn\":false,\"resource-version\":\"1521662816043\",\"orchestration-status\":\"Created\",\"is-provider-network\":false,\"is-shared-network\":false,\"is-external-network\":false,\"relationship-list\":{\"relationship\":[{\"relationDataList\":[{\"relationship-key\":\"instance-group.id\",\"relationship-value\":\"instanceGroup-2018-rs804s\"}],\"relatedToPropertyList\":[{\"property-key\":\"instance-group.description\",\"property-value\":\"zr6h\"},{\"property-key\":\"instance-group.instance-group-name\",\"property-value\":\"wKmBXiO1xm8bK\"}],\"related-to\":\"instance-group\",\"related-link\":\"/aai/v13/network/instance-groups/instance-group/instanceGroup-2018-rs804s\",\"relationship-label\":\"org.onap.relationships.inventory.MemberOf\",\"relationship-data\":[{\"relationship-key\":\"instance-group.id\",\"relationship-value\":\"instanceGroup-2018-rs804s\"}],\"related-to-property\":[{\"property-key\":\"instance-group.description\",\"property-value\":\"zr6h\"},{\"property-key\":\"instance-group.instance-group-name\",\"property-value\":\"wKmBXiO1xm8bK\"}]}]}},{\"network-id\":\"l3network-id-2-rs804s\",\"network-name\":\"oam-net\",\"network-type\":\"Tenant_Layer_3\",\"network-role\":\"RosemaProtectedOam.OAM\",\"network-technology\":\"Contrail\",\"is-bound-to-vpn\":false,\"resource-version\":\"1521662815304\",\"orchestration-status\":\"Created\",\"is-provider-network\":false,\"is-shared-network\":false,\"is-external-network\":false,\"relationship-list\":{\"relationship\":[{\"relationDataList\":[{\"relationship-key\":\"instance-group.id\",\"relationship-value\":\"instanceGroup-2018-rs804s\"}],\"relatedToPropertyList\":[{\"property-key\":\"instance-group.description\",\"property-value\":\"zr6h\"},{\"property-key\":\"instance-group.instance-group-name\",\"property-value\":\"wKmBXiO1xm8bK\"}],\"related-to\":\"instance-group\",\"related-link\":\"/aai/v13/network/instance-groups/instance-group/instanceGroup-2018-rs804s\",\"relationship-label\":\"org.onap.relationships.inventory.MemberOf\",\"relationship-data\":[{\"relationship-key\":\"instance-group.id\",\"relationship-value\":\"instanceGroup-2018-rs804s\"}],\"related-to-property\":[{\"property-key\":\"instance-group.description\",\"property-value\":\"zr6h\"},{\"property-key\":\"instance-group.instance-group-name\",\"property-value\":\"wKmBXiO1xm8bK\"}]}]}}],\"service-instance\":{\"service-instance-id\":\"2UJZZ01777-rs804s\",\"resource-version\":\"1521662813382\",\"relationship-list\":{\"relationship\":[{\"relationDataList\":[{\"relationship-key\":\"collection.collection-id\",\"relationship-value\":\"collection-1-2018-rs804s\"}],\"relatedToPropertyList\":null,\"related-to\":\"collection\",\"related-link\":\"/aai/v13/network/collections/collection/collection-1-2018-rs804s\",\"relationship-label\":\"org.onap.relationships.inventory.MemberOf\",\"relationship-data\":[{\"relationship-key\":\"collection.collection-id\",\"relationship-value\":\"collection-1-2018-rs804s\"}],\"related-to-property\":null}]}},\"instance-group\":{\"id\":\"instanceGroup-2018-rs804s\",\"description\":\"zr6h\",\"instance-group-role\":\"JZmha7QSS4tJ\",\"model-invariant-id\":\"5761e0a7-defj777\",\"model-version-id\":\"5761e0a7-defj22\",\"instance-group-type\":\"7DDjOdNL\",\"resource-version\":\"1521662814023\",\"instance-group-name\":\"wKmBXiO1xm8bK\",\"instance-group-function\":\"testfunction2\",\"relationship-list\":{\"relationship\":[{\"relationDataList\":[{\"relationship-key\":\"l3-network.network-id\",\"relationship-value\":\"l3network-id-rs804s\"}],\"relatedToPropertyList\":[{\"property-key\":\"l3-network.network-name\",\"property-value\":\"oam-net\"}],\"related-to\":\"l3-network\",\"related-link\":\"/aai/v13/network/l3-networks/l3-network/l3network-id-rs804s\",\"relationship-label\":\"org.onap.relationships.inventory.MemberOf\",\"relationship-data\":[{\"relationship-key\":\"l3-network.network-id\",\"relationship-value\":\"l3network-id-rs804s\"}],\"related-to-property\":[{\"property-key\":\"l3-network.network-name\",\"property-value\":\"oam-net\"}]},{\"relationDataList\":[{\"relationship-key\":\"collection.collection-id\",\"relationship-value\":\"collection-1-2018-rs804s\"}],\"relatedToPropertyList\":null,\"related-to\":\"collection\",\"related-link\":\"/aai/v13/network/collections/collection/collection-1-2018-rs804s\",\"relationship-label\":\"org.onap.relationships.inventory.MemberOf\",\"relationship-data\":[{\"relationship-key\":\"collection.collection-id\",\"relationship-value\":\"collection-1-2018-rs804s\"}],\"related-to-property\":null},{\"relationDataList\":[{\"relationship-key\":\"l3-network.network-id\",\"relationship-value\":\"l3network-id-3-rs804s\"}],\"relatedToPropertyList\":[{\"property-key\":\"l3-network.network-name\",\"property-value\":\"oam-net\"}],\"related-to\":\"l3-network\",\"related-link\":\"/aai/v13/network/l3-networks/l3-network/l3network-id-3-rs804s\",\"relationship-label\":\"org.onap.relationships.inventory.MemberOf\",\"relationship-data\":[{\"relationship-key\":\"l3-network.network-id\",\"relationship-value\":\"l3network-id-3-rs804s\"}],\"related-to-property\":[{\"property-key\":\"l3-network.network-name\",\"property-value\":\"oam-net\"}]},{\"relationDataList\":[{\"relationship-key\":\"l3-network.network-id\",\"relationship-value\":\"l3network-id-2-rs804s\"}],\"relatedToPropertyList\":[{\"property-key\":\"l3-network.network-name\",\"property-value\":\"oam-net\"}],\"related-to\":\"l3-network\",\"related-link\":\"/aai/v13/network/l3-networks/l3-network/l3network-id-2-rs804s\",\"relationship-label\":\"org.onap.relationships.inventory.MemberOf\",\"relationship-data\":[{\"relationship-key\":\"l3-network.network-id\",\"relationship-value\":\"l3network-id-2-rs804s\"}],\"related-to-property\":[{\"property-key\":\"l3-network.network-name\",\"property-value\":\"oam-net\"}]}]}}}}\n";
+
+    public static final String GET_SERVICE_INSTANCE_BY_SUBSCRIBER_DSL_EXPECTED_RESPONSE = "{\"results\": [{\"customer\": {\"global-customer-id\": \"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\",\"subscriber-name\": \"Mobility\",\"subscriber-type\": \"INFRA\",\"resource-version\": \"1602518417955\",\"related-nodes\": [{\"service-subscription\": {\"service-type\": \"VPMS\",\"resource-version\": \"1629183620246\",\"related-nodes\": [{\"service-instance\": {\"service-instance-id\": \"5d942bc7-3acf-4e35-836a-393619ebde66\",\"service-instance-name\": \"dpa2actsf5001v_Port_Mirroring_dpa2a_SVC\",\"service-type\": \"PORT-MIRROR\",\"service-role\": \"VPROBE\",\"environment-context\": \"General_Revenue-Bearing\",\"workload-context\": \"Production\",\"model-invariant-id\": \"0757d856-a9c6-450d-b494-e1c0a4aab76f\",\"model-version-id\": \"a9088517-efe8-4bed-9c54-534462cb08c2\",\"resource-version\": \"1615330529236\",\"selflink\": \"SOME_SELF_LINK\",\"orchestration-status\": \"Active\"}}]}}]}}]}";
+    public static final String GET_SEARCH_SERVICE_INSTANCE_BY_SUBSCRIBER_DSL_EXPECTED_RESPONSE = "{\"service-instances\":[{\"serviceInstanceId\":\"5d942bc7-3acf-4e35-836a-393619ebde66\",\"serviceType\":\"VPMS\",\"serviceInstanceName\":\"dpa2actsf5001v_Port_Mirroring_dpa2a_SVC\",\"subscriberName\":\"Mobility\",\"aaiModelInvariantId\":\"0757d856-a9c6-450d-b494-e1c0a4aab76f\",\"aaiModelVersionId\":\"a9088517-efe8-4bed-9c54-534462cb08c2\",\"owningEntityId\":null,\"isPermitted\":false,\"globalCustomerId\":\"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\"}]}";
+
     public static final String GET_AAI_SERVIES_EXPECTED_RESULT = "{\n" +
             "  \"services\": [{\n" +
             "    \"uuid\": \"20c4431c-246d-11e7-93ae-92361f002671\",\n" +
@@ -958,4 +965,96 @@ public class AaiApiTest extends BaseApiAaiTest {
             throw e;
         }
     }
+
+    @Test
+    public void getServiceInstanceBySubscriberAndServiceIdentifierAndSubscriberName_dsl_givenValidAaiResponse() {
+        SimulatorApi.clearAll();
+        String globalCustomerId = "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb";
+        String serviceIdentifier = "5d942bc7-3acf-4e35-836a-393619ebde66";
+        String serviceIdentifierType = "Service Instance Id";
+        String serviceType = "TYLER SILVIA";
+        SimulatorApi.registerExpectationFromPreset(new PresetAAIServiceInstanceDSLPut(
+            globalCustomerId,serviceIdentifier,serviceIdentifierType), CLEAR_THEN_SET);
+        SimulatorApi.registerExpectationFromPreset(new PresetAAIFilterServiceInstanceById(
+            globalCustomerId,serviceType,serviceIdentifier), APPEND);
+        SimulatorApi.registerExpectationFromPreset(new PresetAAIGetServiceInstanceBySubscriberIdAndServiceTypeAndSIID(
+            globalCustomerId,serviceType,serviceIdentifier), APPEND);
+        final String response = restTemplate.getForObject(
+            uri + "/aai_get_service_instance_by_id_and_type"+ "/" + globalCustomerId + "/" + serviceIdentifier + "/" + serviceIdentifierType + "/Mobility" ,
+            String.class);
+        assertResponse(GET_SERVICE_INSTANCE_BY_SUBSCRIBER_DSL_EXPECTED_RESPONSE, response);
+    }
+
+    @Test
+    public void getServiceInstanceBySubscriberAndServiceIdentifierWithoutSubscriberName_dsl_givenValidAaiResponse() {
+        SimulatorApi.clearAll();
+        String globalCustomerId = "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb";
+        String serviceIdentifier = "5d942bc7-3acf-4e35-836a-393619ebde66";
+        String serviceIdentifierType = "Service Instance Id";
+        String serviceType = "TYLER SILVIA";
+        SimulatorApi.registerExpectationFromPreset(new PresetAAIServiceInstanceDSLPut(
+            globalCustomerId,serviceIdentifier,serviceIdentifierType), CLEAR_THEN_SET);
+        SimulatorApi.registerExpectationFromPreset(new PresetAAIFilterServiceInstanceById(
+            globalCustomerId,serviceType,serviceIdentifier), APPEND);
+        SimulatorApi.registerExpectationFromPreset(new PresetAAIGetServiceInstanceBySubscriberIdAndServiceTypeAndSIID(
+            globalCustomerId,serviceType,serviceIdentifier), APPEND);
+        final String response = restTemplate.getForObject(
+            uri + "/aai_get_service_instance_by_id_and_type"+ "/" + globalCustomerId + "/" + serviceIdentifier + "/" + serviceIdentifierType ,
+            String.class);
+        assertResponse(GET_SERVICE_INSTANCE_BY_SUBSCRIBER_DSL_EXPECTED_RESPONSE, response);
+    }
+
+    @Test
+    public void getServiceInstanceBySubscriberAndServiceIdentifierWithSubscriberName_dsl_givenValidAaiResponse() {
+        SimulatorApi.clearAll();
+        String globalCustomerId = "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb";
+        String serviceIdentifier = "5d942bc7-3acf-4e35-836a-393619ebde66";
+        String serviceIdentifierType = "Service Instance Id";
+        String serviceType = "TYLER SILVIA";
+        String subscriberName = "Mobility";
+        SimulatorApi.registerExpectationFromPreset(new PresetAAIServiceInstanceDSLPut(
+            globalCustomerId,serviceIdentifier,serviceIdentifierType), CLEAR_THEN_SET);
+        SimulatorApi.registerExpectationFromPreset(new PresetAAIFilterServiceInstanceById(
+            globalCustomerId,serviceType,serviceIdentifier), APPEND);
+        SimulatorApi.registerExpectationFromPreset(new PresetAAIGetServiceInstanceBySubscriberIdAndServiceTypeAndSIID(
+            globalCustomerId,serviceType,serviceIdentifier), APPEND);
+        final String response = restTemplate.getForObject(
+            uri + "/aai_get_service_instance_by_id_and_type"+ "/" + globalCustomerId + "/" + serviceIdentifier + "/" + serviceIdentifierType + "/" + subscriberName ,
+            String.class);
+        assertResponse(GET_SERVICE_INSTANCE_BY_SUBSCRIBER_DSL_EXPECTED_RESPONSE, response);
+    }
+
+    @Test
+    public void searchServiceInstanceByIdentifierType_id_dsl_givenValidAaiResponse() {
+        SimulatorApi.clearAll();
+        String globalCustomerId = "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb";
+        String serviceInstanceIdentifier = "5d942bc7-3acf-4e35-836a-393619ebde66";
+        String serviceInstanceIdentifierType = "Service Instance Id";
+
+        SimulatorApi.registerExpectationFromPreset(new PresetAAIServiceInstanceDSLPut(
+            globalCustomerId,serviceInstanceIdentifier,serviceInstanceIdentifierType), CLEAR_THEN_SET);
+        String path = "/search_service_instances?subscriberId="+globalCustomerId+
+            "&serviceInstanceIdentifier="+serviceInstanceIdentifier+
+            "&serviceInstanceIdentifierType="+serviceInstanceIdentifierType+"";
+        final String response = restTemplate.getForObject( uri + path, String.class);
+        assertResponse(GET_SEARCH_SERVICE_INSTANCE_BY_SUBSCRIBER_DSL_EXPECTED_RESPONSE, response);
+
+    }
+
+    @Test
+    public void searchServiceInstanceByIdentifierType_name_dsl_givenValidAaiResponse() {
+        SimulatorApi.clearAll();
+        String globalCustomerId = "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb";
+        String serviceInstanceIdentifierType = "Service Instance Name";
+        String serviceInstanceIdentifier = "dpa2actsf5001v_Port_Mirroring_dpa2a_SVC";
+
+        SimulatorApi.registerExpectationFromPreset(new PresetAAIServiceInstanceDSLPut(
+            globalCustomerId,serviceInstanceIdentifier,serviceInstanceIdentifierType), CLEAR_THEN_SET);
+        String path = "/search_service_instances?subscriberId="+globalCustomerId+
+            "&serviceInstanceIdentifier="+serviceInstanceIdentifier+
+            "&serviceInstanceIdentifierType="+serviceInstanceIdentifierType+"";
+        final String response = restTemplate.getForObject( uri + path, String.class);
+        assertResponse(GET_SEARCH_SERVICE_INSTANCE_BY_SUBSCRIBER_DSL_EXPECTED_RESPONSE, response);
+    }
+
 }