Respect owning-entity-id when searching instances by Subscriber
[vid.git] / vid-app-common / src / main / java / org / onap / vid / model / ServiceInstanceSearchResult.java
index abf60d6..f750279 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * VID
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * 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.
 
 package org.onap.vid.model;
 
-public class ServiceInstanceSearchResult {
+import com.fasterxml.jackson.annotation.JsonProperty;
+import org.apache.commons.lang3.StringUtils;
+import org.onap.vid.roles.WithPermissionPropertiesOwningEntity;
+import org.onap.vid.roles.WithPermissionPropertiesSubscriberAndServiceType;
+
+public class ServiceInstanceSearchResult
+       implements WithPermissionPropertiesSubscriberAndServiceType, WithPermissionPropertiesOwningEntity {
+
+       private final String SUBSCRIBER_ID_FRONTEND_ALIAS = "globalCustomerId";
 
        private String serviceInstanceId;
 
-       private String globalCustomerId;
+       private String subscriberId;
 
        private String serviceType;
 
@@ -36,21 +44,24 @@ public class ServiceInstanceSearchResult {
 
        private String aaiModelVersionId;
 
+       private String owningEntityId;
+
        private boolean isPermitted;
 
        public ServiceInstanceSearchResult(){
-
        }
-       public ServiceInstanceSearchResult(String serviceInstanceId, String globalCustomerId, String serviceType,
-                                                                          String serviceInstanceName, String subscriberName, String aaiModelInvariantId,
-                                                                          String aaiModelVersionId, boolean isPermitted) {
+       
+       public ServiceInstanceSearchResult(String serviceInstanceId, String subscriberId, String serviceType,
+               String serviceInstanceName, String subscriberName, String aaiModelInvariantId,
+               String aaiModelVersionId, String owningEntityId, boolean isPermitted) {
                this.serviceInstanceId = serviceInstanceId;
-               this.globalCustomerId = globalCustomerId;
+               this.subscriberId = subscriberId;
                this.serviceType = serviceType;
                this.serviceInstanceName = serviceInstanceName;
                this.subscriberName = subscriberName;
                this.aaiModelInvariantId = aaiModelInvariantId;
                this.aaiModelVersionId = aaiModelVersionId;
+               this.owningEntityId = owningEntityId;
                this.isPermitted = isPermitted;
        }
 
@@ -62,14 +73,17 @@ public class ServiceInstanceSearchResult {
                this.serviceInstanceId = serviceInstanceId;
        }
 
-       public String getGlobalCustomerId() {
-               return globalCustomerId;
+       @Override
+       @JsonProperty(SUBSCRIBER_ID_FRONTEND_ALIAS)
+       public String getSubscriberId() {
+               return subscriberId;
        }
 
-       public void setGlobalCustomerId(String globalCustomerId) {
-               this.globalCustomerId = globalCustomerId;
+       public void setSubscriberId(String subscriberId) {
+               this.subscriberId = subscriberId;
        }
 
+       @Override
        public String getServiceType() {
                return serviceType;
        }
@@ -110,6 +124,15 @@ public class ServiceInstanceSearchResult {
                this.aaiModelVersionId = aaiModelVersionId;
        }
 
+       @Override
+       public String getOwningEntityId() {
+               return owningEntityId;
+       }
+
+       public void setOwningEntityId(String owningEntityId) {
+               this.owningEntityId = owningEntityId;
+       }
+
        public boolean getIsPermitted() {
                return isPermitted;
        }
@@ -119,21 +142,21 @@ public class ServiceInstanceSearchResult {
        }
 
        @Override
-       public boolean equals(Object other){
-               if (other instanceof ServiceInstanceSearchResult) {
-                       ServiceInstanceSearchResult serviceInstanceSearchResultOther = (ServiceInstanceSearchResult) other;
-                       if (this.getServiceInstanceId().equals(serviceInstanceSearchResultOther.getServiceInstanceId())) {
-                               return true;
-                       }
+       public boolean equals(Object o{
+               if (this == o) {
+                       return true;
+               }
+               if (o == null || getClass() != o.getClass()) {
+                       return false;
                }
-               return false;
 
+               ServiceInstanceSearchResult that = (ServiceInstanceSearchResult) o;
+
+               return StringUtils.equals(serviceInstanceId, that.serviceInstanceId);
        }
 
        @Override
        public int hashCode() {
-               int result = 17;
-               result = 31 * result + serviceInstanceId.hashCode();
-               return result;
+               return serviceInstanceId != null ? serviceInstanceId.hashCode() : 0;
        }
-}
\ No newline at end of file
+}