Merge "Add resourceSharingLevel to service metadata" into 20.3
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java
index a38ffe9..7a25989 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java
@@ -1309,6 +1309,7 @@
             verifyValuesAreIdentical(serviceUpdate.getUUID(), currentService.getUUID(), "uuid");
 
             validateAndUpdateServiceType(currentService, serviceUpdate);
+            validateAndUpdateResourceSharingLevel(currentService, serviceUpdate);
             validateAndUpdateServiceFunction(currentService, serviceUpdate);
 
             response = validateAndUpdateServiceRole(user, currentService, serviceUpdate, UPDATE_SERVICE_METADATA);
@@ -1461,6 +1462,14 @@
             currentService.setServiceType(updatedServiceType);
         }
     }
+    
+    private void validateAndUpdateResourceSharingLevel(Service currentService, Service updatedService) {
+        String updatedResourceSharingLevel = updatedService.getResourceSharingLevel();
+        String currentResourceSharingLevel = currentService.getResourceSharingLevel();
+        if (!currentResourceSharingLevel.equals(updatedResourceSharingLevel)) {
+            currentService.setResourceSharingLevel(updatedResourceSharingLevel);
+        }
+    }
 
     private void validateAndUpdateServiceFunction(Service currentService, Service updatedService) {
         String updatedServiceFunction = updatedService.getServiceFunction();
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
index d0c14f7..ef09e7c 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
@@ -457,6 +457,9 @@
                 toscaMetadata.setType(component.getComponentType().getValue());
                 toscaMetadata.setServiceType(service.getServiceType());
                 toscaMetadata.setServiceRole(service.getServiceRole());
+                if (StringUtils.isNotEmpty(service.getResourceSharingLevel())) {
+                    toscaMetadata.setResourceSharingLevel(service.getResourceSharingLevel());
+                }
                 toscaMetadata.setServiceFunction(service.getServiceFunction());
                 toscaMetadata.setEnvironmentContext(service.getEnvironmentContext());
                 resolveInstantiationTypeAndSetItToToscaMetaData(toscaMetadata, service);
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaMetadata.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaMetadata.java
index f496994..edfe7ab 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaMetadata.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaMetadata.java
@@ -35,6 +35,7 @@
     private String resourceVendorModelNumber;
     private String serviceType;
     private String serviceRole;
+    private String resourceSharingLevel;
     private String instantiationType;
     private String serviceEcompNaming;
     private String ecompGeneratedNaming;
@@ -148,6 +149,14 @@
     public void setServiceFunction(String serviceFunction) {
         this.serviceFunction = serviceFunction;
     }
+    
+    public String getResourceSharingLevel() {
+        return resourceSharingLevel;
+    }
+
+    public void setResourceSharingLevel(String resourceSharingLevel) {
+        this.resourceSharingLevel = resourceSharingLevel;
+    }
 
     public void setInstantiationType(String instantiationType) {
         this.instantiationType = instantiationType;
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/Service.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/Service.java
index 2e326ce..16cda9d 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/Service.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/Service.java
@@ -135,6 +135,14 @@
     public void setServiceRole(String serviceRole) {
         getServiceMetadataDefinition().setServiceRole(serviceRole);
     }
+    
+    public String getResourceSharingLevel() {
+        return getServiceMetadataDefinition().getResourceSharingLevel();
+    }
+
+    public void setResourceSharingLevel(String resourceSharingLevel) {
+        getServiceMetadataDefinition().setResourceSharingLevel(resourceSharingLevel);
+    }
 
     public String getInstantiationType() {
         return getServiceMetadataDefinition().getInstantiationType();
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/utils/ModelConverter.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/utils/ModelConverter.java
index 4d2480f..fce87b8 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/utils/ModelConverter.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/utils/ModelConverter.java
@@ -787,8 +787,12 @@
             } else {
                 service.setServiceRole("");
             }
-            if (((String) toscaElement.getMetadataValue(JsonPresentationFields.SERVICE_FUNCTION)) != null){
-                service.setServiceFunction((String) toscaElement.getMetadataValue(JsonPresentationFields.SERVICE_FUNCTION));
+            if (((String) toscaElement.getMetadataValue(JsonPresentationFields.RESOURCE_SHARING_LEVEL)) != null) {
+                service.setResourceSharingLevel((String) toscaElement.getMetadataValue(JsonPresentationFields.RESOURCE_SHARING_LEVEL));
+            } 
+            if (((String) toscaElement.getMetadataValue(JsonPresentationFields.SERVICE_FUNCTION)) != null) {
+                service.setServiceFunction(
+                    (String) toscaElement.getMetadataValue(JsonPresentationFields.SERVICE_FUNCTION));
             } else {
                 service.setServiceFunction("");
             }
@@ -1331,8 +1335,13 @@
             } else {
                 toscaElement.setMetadataValue(JsonPresentationFields.SERVICE_ROLE, "");
             }
-            if (((Service) component).getServiceFunction() != null){
-                toscaElement.setMetadataValue(JsonPresentationFields.SERVICE_FUNCTION, ((Service) component).getServiceFunction());
+            if (((Service) component).getResourceSharingLevel() != null) {
+                toscaElement
+                    .setMetadataValue(JsonPresentationFields.RESOURCE_SHARING_LEVEL, ((Service) component).getResourceSharingLevel());
+            }
+            if (((Service) component).getServiceFunction() != null) {
+                toscaElement.setMetadataValue(JsonPresentationFields.SERVICE_FUNCTION,
+                    ((Service) component).getServiceFunction());
             } else {
                 toscaElement.setMetadataValue(JsonPresentationFields.SERVICE_FUNCTION, "");
             }
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiServiceMetadata.java b/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiServiceMetadata.java
index e1fe587..8b3ee15 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiServiceMetadata.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiServiceMetadata.java
@@ -35,6 +35,7 @@
     private String namingPolicy;
     private String serviceType;
     private String serviceRole;
+    private String resourceSharingLevel;
     private String environmentContext;
     private String instantiationType;
     private String serviceFunction;
@@ -46,6 +47,7 @@
         this.namingPolicy = metadata.getNamingPolicy();
         this.serviceType = metadata.getServiceType();
         this.serviceRole = metadata.getServiceRole();
+        this.resourceSharingLevel = metadata.getResourceSharingLevel();
         this.environmentContext = metadata.getEnvironmentContext();
         this.instantiationType = metadata.getInstantiationType();
         this.serviceFunction = metadata.getServiceFunction();
diff --git a/catalog-ui/src/app/models/component-metadata.ts b/catalog-ui/src/app/models/component-metadata.ts
index 8a4b257..b635b3e 100644
--- a/catalog-ui/src/app/models/component-metadata.ts
+++ b/catalog-ui/src/app/models/component-metadata.ts
@@ -74,6 +74,7 @@
     namingPolicy: string;
     serviceType: string;
     serviceRole: string;
+    resourceSharingLevel: string;
     environmentContext: string;
     instantiationType: string;
 
@@ -136,6 +137,7 @@
     public namingPolicy: string;
     public serviceType: string;
     public serviceRole: string;
+    public resourceSharingLevel: string;
     public environmentContext: string;
     public instantiationType: string;
 
@@ -185,6 +187,7 @@
         this.resourceVendorModelNumber = response.resourceVendorModelNumber;
         this.serviceType = response.serviceType;
         this.serviceRole = response.serviceRole;
+        this.resourceSharingLevel = response.resourceSharingLevel;
         this.environmentContext = response.environmentContext;
         this.archived = response.archived;
         this.instantiationType = response.instantiationType;
diff --git a/catalog-ui/src/app/models/components/service.ts b/catalog-ui/src/app/models/components/service.ts
index d11a06a..64b4fd3 100644
--- a/catalog-ui/src/app/models/components/service.ts
+++ b/catalog-ui/src/app/models/components/service.ts
@@ -39,6 +39,7 @@
     public namingPolicy:string;
     public serviceType:string;
     public serviceRole:string;
+    public resourceSharingLevel:string;
     public serviceFunction:string;
     public environmentContext:string;
     public instantiationType:string;
@@ -63,6 +64,7 @@
             this.namingPolicy = component.namingPolicy;
             this.serviceType = component.serviceType;
             this.serviceRole = component.serviceRole;
+            this.resourceSharingLevel = component.resourceSharingLevel;
             this.serviceFunction = component.serviceFunction;
             this.instantiationType = component.instantiationType;
             this.environmentContext = component.environmentContext;
@@ -205,6 +207,7 @@
         this.namingPolicy = componentMetadata.namingPolicy;
         this.serviceType = componentMetadata.serviceType;
         this.serviceRole = componentMetadata.serviceRole;
+        this.resourceSharingLevel = componentMetadata.resourceSharingLevel;
         this.serviceFunction = componentMetadata.serviceFunction;
         this.environmentContext = componentMetadata.environmentContext;
         this.instantiationType = componentMetadata.instantiationType;
diff --git a/catalog-ui/src/app/models/componentsInstances/fullComponentInstance.ts b/catalog-ui/src/app/models/componentsInstances/fullComponentInstance.ts
index 50a9eeb..2367b20 100644
--- a/catalog-ui/src/app/models/componentsInstances/fullComponentInstance.ts
+++ b/catalog-ui/src/app/models/componentsInstances/fullComponentInstance.ts
@@ -29,6 +29,7 @@
     public serviceApiArtifacts:ArtifactGroupModel;
     public serviceType:string;
     public serviceRole:string;
+    public resourceSharingLevel:string;
 
     //resource
     public csarUUID:string;
@@ -71,6 +72,7 @@
             this.serviceApiArtifacts = (<Service>originComponent).serviceApiArtifacts;
             this.serviceType = (<Service>originComponent).serviceType;
             this.serviceRole = (<Service>originComponent).serviceRole;
+            this.resourceSharingLevel = (<Service>originComponent).resourceSharingLevel;
         }
         if(originComponent.componentType === ComponentType.RESOURCE) {
             this.isResourceInstance = true;
diff --git a/catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/info-tab/info-tab.component.html b/catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/info-tab/info-tab.component.html
index 71545f8..089d289 100644
--- a/catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/info-tab/info-tab.component.html
+++ b/catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/info-tab/info-tab.component.html
@@ -98,6 +98,12 @@
             <span class="value" data-tests-id="rightTab_serviceRole" tooltip="{{component.serviceRole}}">{{component.serviceRole}}</span>
         </div>
 
+        <!-- Service Role data-ng-if="selectedComponent.isService()"-->
+        <div class="component-details-panel-item" *ngIf="component.resourceSharingLevel">
+            <span class="name" [innerHTML]="'GENERAL_LABEL_RESOURCE_SHARING_LEVEL' | translate"></span>
+            <span class="value" data-tests-id="rightTab_resourceSharingLevel" tooltip="{{component.resourceSharingLevel}}">{{component.resourceSharingLevel}}</span>
+        </div>
+
         <!-- Contact ID -->
         <div class="component-details-panel-item" *ngIf="component.contactId">
             <span class="name" [innerHTML]="'GENERAL_LABEL_CONTACT_ID' | translate"></span>
diff --git a/catalog-ui/src/app/view-models/workspace/tabs/general/general-view-model.ts b/catalog-ui/src/app/view-models/workspace/tabs/general/general-view-model.ts
index e10dc98..104ca93 100644
--- a/catalog-ui/src/app/view-models/workspace/tabs/general/general-view-model.ts
+++ b/catalog-ui/src/app/view-models/workspace/tabs/general/general-view-model.ts
@@ -66,6 +66,7 @@
     browseFileLabel:string;
     componentCategories:componentCategories;
     instantiationTypes:Array<instantiationType>;
+    resourceSharingLevels:Array<string>;
     isHiddenCategorySelected: boolean;
 
     save():Promise<any>;
@@ -82,6 +83,7 @@
     initCategoreis():void;
     initEnvironmentContext():void;
     initInstantiationTypes():void;
+    initResourceSharingLevels():void;
     onInstantiationTypeChange():void;
     updateIcon():void;
     possibleToUpdateIcon():boolean;
@@ -256,6 +258,7 @@
             }
             // Init Instantiation types
             this.$scope.initInstantiationTypes();
+            this.$scope.initResourceSharingLevels();
         }
 
         if (this.cacheService.get(PREVIOUS_CSAR_COMPONENT)) { //keep the old component in the cache until checkout, so we dont need to pass it around
@@ -433,6 +436,15 @@
             }
         };
 
+        this.$scope.initResourceSharingLevels = ():void => {
+            if (this.$scope.componentType === ComponentType.SERVICE) {
+                this.$scope.resourceSharingLevels = new Array();
+                this.$scope.resourceSharingLevels.push("Shared");
+                this.$scope.resourceSharingLevels.push("NonShared");
+                this.$scope.resourceSharingLevels.push("");
+            }
+        };
+
         this.$scope.initEnvironmentContext = ():void => {
             if (this.$scope.componentType === ComponentType.SERVICE) {
                 this.$scope.environmentContextObj = this.cacheService.get('UIConfiguration').environmentContext;
diff --git a/catalog-ui/src/app/view-models/workspace/tabs/general/general-view.html b/catalog-ui/src/app/view-models/workspace/tabs/general/general-view.html
index 42a8aa3..3b9c551 100644
--- a/catalog-ui/src/app/view-models/workspace/tabs/general/general-view.html
+++ b/catalog-ui/src/app/view-models/workspace/tabs/general/general-view.html
@@ -435,6 +435,21 @@
 
                     <!--------------------- Instantiation Type -------------------->
 
+                    <!--------------------- Resource Sharing Level -------------------->
+                    <div class="i-sdc-form-item"
+                         data-ng-class="{'error': validateField(editForm.resourceSharingLevel)}"
+                         data-ng-if="component.isService()">
+                        <label class="i-sdc-form-label" translate="GENERAL_TAB_LABEL_RESOURCE_SHARING_LEVEL"></label>
+                        <select class="i-sdc-form-select"
+                                name="resourceSharingLevel"
+                                data-ng-class="{'view-mode': isViewMode()}"
+                                data-ng-model="component.resourceSharingLevel"
+                                data-tests-id="resourceSharingLevel">
+                        <option ng-repeat="level in resourceSharingLevels">{{level}}</option>
+                        </select>
+                    </div>
+                    <!--------------------- Resource Sharing Level -------------------->
+
                     <div class="meta-data" data-ng-if="component.creationDate">
                         <div>
                             <b>Created:</b>
diff --git a/catalog-ui/src/assets/languages/en_US.json b/catalog-ui/src/assets/languages/en_US.json
index a828ea3..a01fa50 100644
--- a/catalog-ui/src/assets/languages/en_US.json
+++ b/catalog-ui/src/assets/languages/en_US.json
@@ -28,6 +28,7 @@
     "GENERAL_LABEL_RESOURCE_MODEL_NUMBER":"Vendor Model Number:",
     "GENERAL_LABEL_SERVICE_TYPE": "Service Type:",
     "GENERAL_LABEL_SERVICE_ROLE": "Service Role:",
+    "GENERAL_LABEL_RESOURCE_SHARING_LEVEL": "Resource Sharing Level:",
     "GENERAL_LABEL_STATUS": "Status:",
     "GENERAL_LABEL_SERVICE_FUNCTION": "Service Function:",
     "GENERAL_LABEL_DESCRIPTION": "Description:",
@@ -49,6 +50,7 @@
     "GENERAL_TAB_LABEL_RESOURCE_MODEL_NUMBER":"Vendor Model Number",
     "GENERAL_TAB_LABEL_SERVICE_TYPE": "Service Type",
     "GENERAL_TAB_LABEL_SERVICE_ROLE": "Service Role",
+    "GENERAL_TAB_LABEL_RESOURCE_SHARING_LEVEL": "Resource Sharing Level:",
     "GENERAL_TAB_LABEL_SERVICE_FUNCTION": "Service Function",
 
     "=========== GENERAL ERROR PAGES ===========": "",
diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/components/ServiceMetadataDataDefinition.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/components/ServiceMetadataDataDefinition.java
index b8cc269..42e92a4 100644
--- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/components/ServiceMetadataDataDefinition.java
+++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/components/ServiceMetadataDataDefinition.java
@@ -39,6 +39,9 @@
 
 
     private String serviceRole = EMPTY_STR;
+    
+    
+    private String resourceSharingLevel = EMPTY_STR;
 
 
     private String instantiationType = EMPTY_STR;
@@ -69,6 +72,7 @@
         this.importServiceType = other.getImportServiceType();
         this.toscaServiceName = other.getToscaServiceName();
         serviceFunction = other.getServiceFunction();
+        resourceSharingLevel = other.getResourceSharingLevel();
     }
 
     public ServiceMetadataDataDefinition(JsonPresentationFieldsExtractor extractor) {
@@ -76,6 +80,7 @@
         serviceType = extractor.getServiceType();
         serviceRole = extractor.getServiceRole();
         serviceFunction = extractor.getServiceFunction();
+        resourceSharingLevel = extractor.getResourceSharingLevel();
     }
 
     public Boolean isEcompGeneratedNaming() {
diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/JsonPresentationFields.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/JsonPresentationFields.java
index 41c04e7..3da0d38 100644
--- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/JsonPresentationFields.java
+++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/JsonPresentationFields.java
@@ -65,6 +65,7 @@
     DERIVED_FROM_GENERIC_TYPE("derivedFromGenericType", null),
     DERIVED_FROM_GENERIC_VERSION("derivedFromGenericVersion", null),
     SERVICE_FUNCTION("serviceFunction", null),
+    RESOURCE_SHARING_LEVEL("resourceSharingLevel", null),
 
     DATA_TYPES("data_types", GraphPropertyEnum.DATA_TYPES),
 
diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/JsonPresentationFieldsExtractor.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/JsonPresentationFieldsExtractor.java
index 5f20c58..87baa55 100644
--- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/JsonPresentationFieldsExtractor.java
+++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/JsonPresentationFieldsExtractor.java
@@ -166,5 +166,9 @@
     public String getServiceFunction() {
         return (String) properties.get(JsonPresentationFields.SERVICE_FUNCTION.getPresentation());
     }
+    
+    public String getResourceSharingLevel() {
+        return (String) properties.get(JsonPresentationFields.RESOURCE_SHARING_LEVEL.getPresentation());
+    }
 
 }