Ingest and Process Service Function

Intial commit of writing service function to AAI
Update schema.sql table to pass all unit tests
Update local sql to setup CI server for test
Update schema to work and fix passwords

Issue-ID: SO-2763
Signed-off-by: Benjamin, Max (mb388a) <mb388a@att.com>
Change-Id: I8c517a485841574cde849e1c4e86c3bb7b7dcf89
diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V8.6__Update_Service_Function.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V8.6__Update_Service_Function.sql
new file mode 100644
index 0000000..51be8be
--- /dev/null
+++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V8.6__Update_Service_Function.sql
@@ -0,0 +1,4 @@
+use catalogdb;
+
+ALTER TABLE service
+    ADD COLUMN IF NOT EXISTS service_function varchar(200) DEFAULT NULL;
\ No newline at end of file
diff --git a/adapters/mso-openstack-adapters/src/test/resources/schema.sql b/adapters/mso-openstack-adapters/src/test/resources/schema.sql
index 6b791e7..3357fec 100644
--- a/adapters/mso-openstack-adapters/src/test/resources/schema.sql
+++ b/adapters/mso-openstack-adapters/src/test/resources/schema.sql
@@ -801,6 +801,7 @@
   `TOSCA_CSAR_ARTIFACT_UUID` varchar(200) DEFAULT NULL,
   `SERVICE_TYPE` varchar(200) DEFAULT NULL,
   `SERVICE_ROLE` varchar(200) DEFAULT NULL,
+  `SERVICE_FUNCTION` varchar(200) DEFAULT NULL,
   `ENVIRONMENT_CONTEXT` varchar(200) DEFAULT NULL,
   `WORKLOAD_CONTEXT` varchar(200) DEFAULT NULL,
   `SERVICE_CATEGORY` varchar(200) DEFAULT NULL,
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java
index 4bc3f88..f524b96 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java
@@ -1377,6 +1377,7 @@
 
             service.setServiceType(serviceMetadata.getValue("serviceType"));
             service.setServiceRole(serviceMetadata.getValue("serviceRole"));
+            service.setServiceFunction(serviceMetadata.getValue("serviceFunction"));
             service.setCategory(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY));
 
             service.setDescription(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
diff --git a/asdc-controller/src/test/resources/schema.sql b/asdc-controller/src/test/resources/schema.sql
index 7ed1e99..f94f74d 100644
--- a/asdc-controller/src/test/resources/schema.sql
+++ b/asdc-controller/src/test/resources/schema.sql
@@ -804,6 +804,7 @@
   `TOSCA_CSAR_ARTIFACT_UUID` varchar(200) DEFAULT NULL,
   `SERVICE_TYPE` varchar(200) DEFAULT NULL,
   `SERVICE_ROLE` varchar(200) DEFAULT NULL,
+  `SERVICE_FUNCTION` varchar(200) DEFAULT NULL,
   `ENVIRONMENT_CONTEXT` varchar(200) DEFAULT NULL,
   `WORKLOAD_CONTEXT` varchar(200) DEFAULT NULL,
   `SERVICE_CATEGORY` varchar(200) DEFAULT NULL,
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/modelinfo/ModelInfoServiceInstance.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/modelinfo/ModelInfoServiceInstance.java
index bc330ee..b554d7a 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/modelinfo/ModelInfoServiceInstance.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/modelinfo/ModelInfoServiceInstance.java
@@ -35,6 +35,8 @@
     private String serviceType;
     @JsonProperty("service-role")
     private String serviceRole;
+    @JsonProperty("service-function")
+    private String serviceFunction;
     @JsonProperty("environment-context")
     private String environmentContext;
     @JsonProperty("workload-context")
@@ -77,6 +79,14 @@
         this.serviceRole = serviceRole;
     }
 
+    public String getServiceFunction() {
+        return serviceFunction;
+    }
+
+    public void setServiceFunction(String serviceFunction) {
+        this.serviceFunction = serviceFunction;
+    }
+
     public String getEnvironmentContext() {
         return environmentContext;
     }
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/aai/mapper/AAIObjectMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/aai/mapper/AAIObjectMapper.java
index 9de8e18..614401d 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/aai/mapper/AAIObjectMapper.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/aai/mapper/AAIObjectMapper.java
@@ -22,18 +22,33 @@
 
 package org.onap.so.client.aai.mapper;
 
-import org.modelmapper.ModelMapper;
-import org.modelmapper.PropertyMap;
-import org.onap.aai.domain.yang.RouteTargets;
-import org.onap.so.bpmn.servicedecomposition.bbobjects.*;
-import org.springframework.stereotype.Component;
 import java.util.List;
 import org.modelmapper.Converter;
+import org.modelmapper.ModelMapper;
+import org.modelmapper.PropertyMap;
 import org.modelmapper.spi.MappingContext;
-import org.onap.so.bpmn.servicedecomposition.bbobjects.HostRoute;
-import org.onap.so.bpmn.servicedecomposition.bbobjects.SegmentationAssignment;
+import org.onap.aai.domain.yang.RouteTargets;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.Collection;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration;
 import org.onap.so.bpmn.servicedecomposition.bbobjects.CtagAssignment;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.HostRoute;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.NetworkPolicy;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.OwningEntity;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.Project;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.RouteTarget;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.SegmentationAssignment;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription;
 import org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBinding;
+import org.springframework.stereotype.Component;
 
 @Component
 public class AAIObjectMapper {
@@ -46,6 +61,7 @@
                 protected void configure() {
                     map().setServiceType(source.getModelInfoServiceInstance().getServiceType());
                     map().setServiceRole(source.getModelInfoServiceInstance().getServiceRole());
+                    map().setServiceFunction(source.getModelInfoServiceInstance().getServiceFunction());
                     map().setModelInvariantId(source.getModelInfoServiceInstance().getModelInvariantUuid());
                     map().setModelVersionId(source.getModelInfoServiceInstance().getModelUuid());
                     map().setEnvironmentContext(source.getModelInfoServiceInstance().getEnvironmentContext());
@@ -178,6 +194,7 @@
 
     private Converter<List<Subnet>, org.onap.aai.domain.yang.Subnets> convertSubnets =
             new Converter<List<Subnet>, org.onap.aai.domain.yang.Subnets>() {
+                @Override
                 public org.onap.aai.domain.yang.Subnets convert(
                         MappingContext<List<Subnet>, org.onap.aai.domain.yang.Subnets> context) {
                     return mapToAAISubNets(context.getSource());
@@ -186,6 +203,7 @@
 
     private Converter<List<CtagAssignment>, org.onap.aai.domain.yang.CtagAssignments> convertCtagAssignments =
             new Converter<List<CtagAssignment>, org.onap.aai.domain.yang.CtagAssignments>() {
+                @Override
                 public org.onap.aai.domain.yang.CtagAssignments convert(
                         MappingContext<List<CtagAssignment>, org.onap.aai.domain.yang.CtagAssignments> context) {
                     return mapToAAICtagAssignmentList(context.getSource());
@@ -194,6 +212,7 @@
 
     private Converter<List<SegmentationAssignment>, org.onap.aai.domain.yang.SegmentationAssignments> convertSegmentationAssignments =
             new Converter<List<SegmentationAssignment>, org.onap.aai.domain.yang.SegmentationAssignments>() {
+                @Override
                 public org.onap.aai.domain.yang.SegmentationAssignments convert(
                         MappingContext<List<SegmentationAssignment>, org.onap.aai.domain.yang.SegmentationAssignments> context) {
                     return mapToAAISegmentationAssignmentList(context.getSource());
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/aai/mapper/AAIObjectMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/aai/mapper/AAIObjectMapperTest.java
index dc64e4e..1e58a83 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/aai/mapper/AAIObjectMapperTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/aai/mapper/AAIObjectMapperTest.java
@@ -138,6 +138,7 @@
         ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
         modelInfoServiceInstance.setServiceType("SITYPE");
         modelInfoServiceInstance.setServiceRole("SIROLE");
+        modelInfoServiceInstance.setServiceFunction("SIFUNCTION");
         modelInfoServiceInstance.setModelInvariantUuid("MIUUID");
         modelInfoServiceInstance.setModelUuid("MUUID");
         modelInfoServiceInstance.setEnvironmentContext("EC");
@@ -163,6 +164,8 @@
                 serviceInstance.getModelInfoServiceInstance().getEnvironmentContext());
         assertEquals(AAIServiceInstance.getWorkloadContext(),
                 serviceInstance.getModelInfoServiceInstance().getWorkloadContext());
+        assertEquals(AAIServiceInstance.getServiceFunction(),
+                serviceInstance.getModelInfoServiceInstance().getServiceFunction());
     }
 
     @Test
diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/Service.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/Service.java
index 3f3742f..8222b72 100644
--- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/Service.java
+++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/Service.java
@@ -79,6 +79,9 @@
     @Column(name = "SERVICE_ROLE")
     private String serviceRole;
 
+    @Column(name = "SERVICE_FUNCTION")
+    private String serviceFunction;
+
     @Column(name = "ENVIRONMENT_CONTEXT")
     private String environmentContext;
 
@@ -470,4 +473,13 @@
     public void setControllerActor(String controllerActor) {
         this.controllerActor = controllerActor;
     }
+
+    public String getServiceFunction() {
+        return serviceFunction;
+    }
+
+    public void setServiceFunction(String serviceFunction) {
+        this.serviceFunction = serviceFunction;
+    }
+
 }
diff --git a/mso-catalog-db/src/test/resources/schema.sql b/mso-catalog-db/src/test/resources/schema.sql
index 6573def..0249170 100644
--- a/mso-catalog-db/src/test/resources/schema.sql
+++ b/mso-catalog-db/src/test/resources/schema.sql
@@ -802,6 +802,7 @@
   `TOSCA_CSAR_ARTIFACT_UUID` varchar(200) DEFAULT NULL,
   `SERVICE_TYPE` varchar(200) DEFAULT NULL,
   `SERVICE_ROLE` varchar(200) DEFAULT NULL,
+  `SERVICE_FUNCTION` varchar(200) DEFAULT NULL,
   `ENVIRONMENT_CONTEXT` varchar(200) DEFAULT NULL,
   `WORKLOAD_CONTEXT` varchar(200) DEFAULT NULL,
   `SERVICE_CATEGORY` varchar(200) DEFAULT NULL,