merged ONAP refactor and fluent builder method 16/109516/8
authorBenjamin, Max <max.benjamin@att.com>
Wed, 24 Jun 2020 14:44:53 +0000 (10:44 -0400)
committerBenjamin, Max (mb388a) <mb388a@att.com>
Tue, 30 Jun 2020 13:38:04 +0000 (09:38 -0400)
WorkflowAction refactoring
merged ONAP refactor and fluent builder method types

Issue-ID: SO-3005
Signed-off-by: Benjamin, Max (mb388a) <mb388a@att.com>
Change-Id: I5c2a7dbcdf645efe408f81c1abbc7bfe8770fe9e

12 files changed:
adapters/mso-catalog-db-adapter/pom.xml
adapters/mso-openstack-adapters/pom.xml
adapters/mso-requests-db-adapter/pom.xml
adapters/mso-sdnc-adapter/pom.xml
bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/BuildingBlockBase.java [new file with mode: 0644]
bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/ExecuteBuildingBlock.java
bpmn/so-bpmn-infrastructure-common/pom.xml
bpmn/so-bpmn-tasks/pom.xml
bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ConfigBuildingBlocksDataObject.java
bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java
mso-api-handlers/mso-api-handler-infra/pom.xml
pom.xml

index 0201dd6..bfb600f 100644 (file)
       </plugin>
     </plugins>
     <pluginManagement>
-    <plugins>
-    <plugin>
-      <groupId>org.eclipse.m2e</groupId>
-        <artifactId>lifecycle-mapping</artifactId>
-        <version>1.0.0</version>
-        <configuration>
-          <lifecycleMappingMetadata>
-            <pluginExecutions>
+      <plugins>
+        <plugin>
+          <groupId>org.eclipse.m2e</groupId>
+          <artifactId>lifecycle-mapping</artifactId>
+          <version>1.0.0</version>
+          <configuration>
+            <lifecycleMappingMetadata>
+              <pluginExecutions>
                 <pluginExecution>
                   <pluginExecutionFilter>
                     <groupId>org.apache.maven.plugins</groupId>
index 9cee288..893f50c 100644 (file)
       <artifactId>openstack4j-jersey2</artifactId>
       <version>3.2.0</version>
     </dependency>
-        <dependency>
+    <dependency>
       <groupId>org.glassfish.jersey.core</groupId>
       <artifactId>jersey-client</artifactId>
       <version>2.22.1</version>
index ba179b6..55e59d1 100644 (file)
                     </ignore>
                   </action>
                 </pluginExecution>
-                  <pluginExecution>
+                <pluginExecution>
                   <pluginExecutionFilter>
                     <groupId>org.apache.maven.plugins</groupId>
                     <artifactId>maven-dependency-plugin</artifactId>
index 0c320fa..8bc9501 100644 (file)
@@ -16,7 +16,7 @@
 
   <build>
     <finalName>${project.artifactId}-${project.version}</finalName>
-      <pluginManagement>
+    <pluginManagement>
       <plugins>
         <plugin>
           <groupId>org.eclipse.m2e</groupId>
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/BuildingBlockBase.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/BuildingBlockBase.java
new file mode 100644 (file)
index 0000000..5be06f9
--- /dev/null
@@ -0,0 +1,101 @@
+package org.onap.so.bpmn.servicedecomposition.entities;
+
+import java.io.Serializable;
+import org.onap.so.serviceinstancebeans.RequestDetails;
+
+public abstract class BuildingBlockBase<T extends BuildingBlockBase<T>> implements Serializable {
+
+    private static final long serialVersionUID = 4671883098039479717L;
+
+    private Boolean aLaCarte;
+    private String apiVersion;
+    private Boolean isResume;
+    private String resourceId;
+    private String requestId;
+    private String requestAction;
+    private RequestDetails requestDetails;
+    private WorkflowResourceIds workflowResourceIds;
+    private String vnfType;
+
+    public T setaLaCarte(Boolean aLaCarte) {
+        this.aLaCarte = aLaCarte;
+        return (T) this;
+    }
+
+    public T setApiVersion(String apiVersion) {
+        this.apiVersion = apiVersion;
+        return (T) this;
+    }
+
+    public T setResume(Boolean resume) {
+        isResume = resume;
+        return (T) this;
+    }
+
+    public T setResourceId(String resourceId) {
+        this.resourceId = resourceId;
+        return (T) this;
+    }
+
+    public T setRequestId(String requestId) {
+        this.requestId = requestId;
+        return (T) this;
+    }
+
+    public T setRequestAction(String requestAction) {
+        this.requestAction = requestAction;
+        return (T) this;
+    }
+
+    public T setRequestDetails(RequestDetails requestDetails) {
+        this.requestDetails = requestDetails;
+        return (T) this;
+    }
+
+    public T setWorkflowResourceIds(WorkflowResourceIds workflowResourceIds) {
+        this.workflowResourceIds = workflowResourceIds;
+        return (T) this;
+    }
+
+    public T setVnfType(String vnfType) {
+        this.vnfType = vnfType;
+        return (T) this;
+    }
+
+    public Boolean isResume() {
+        return isResume;
+    }
+
+    public String getRequestId() {
+        return requestId;
+    }
+
+    public String getApiVersion() {
+        return apiVersion;
+    }
+
+    public String getResourceId() {
+        return resourceId;
+    }
+
+    public String getRequestAction() {
+        return requestAction;
+    }
+
+    public Boolean isaLaCarte() {
+        return aLaCarte;
+    }
+
+    public String getVnfType() {
+        return vnfType;
+    }
+
+    public WorkflowResourceIds getWorkflowResourceIds() {
+        return workflowResourceIds;
+    }
+
+    public RequestDetails getRequestDetails() {
+        return requestDetails;
+    }
+
+}
index abd301f..e867b67 100644 (file)
@@ -23,20 +23,12 @@ package org.onap.so.bpmn.servicedecomposition.entities;
 import java.io.Serializable;
 import org.onap.so.serviceinstancebeans.RequestDetails;
 
-public class ExecuteBuildingBlock implements Serializable {
+public class ExecuteBuildingBlock extends BuildingBlockBase<ExecuteBuildingBlock> implements Serializable {
 
-    private static final long serialVersionUID = 2L;
     private BuildingBlock buildingBlock;
-    private String requestId;
-    private String apiVersion;
-    private String resourceId;
-    private String requestAction;
-    private String vnfType;
-    private Boolean aLaCarte;
-    private Boolean homing = false;
-    private WorkflowResourceIds workflowResourceIds;
-    private RequestDetails requestDetails;
     private ConfigurationResourceKeys configurationResourceKeys;
+    private Boolean homing = false;
+    private static final long serialVersionUID = 3L;
 
     public BuildingBlock getBuildingBlock() {
         return buildingBlock;
@@ -47,60 +39,6 @@ public class ExecuteBuildingBlock implements Serializable {
         return this;
     }
 
-    public String getRequestId() {
-        return requestId;
-    }
-
-    public ExecuteBuildingBlock setRequestId(String requestId) {
-        this.requestId = requestId;
-        return this;
-    }
-
-    public String getApiVersion() {
-        return apiVersion;
-    }
-
-    public ExecuteBuildingBlock setApiVersion(String apiVersion) {
-        this.apiVersion = apiVersion;
-        return this;
-    }
-
-    public String getResourceId() {
-        return resourceId;
-    }
-
-    public ExecuteBuildingBlock setResourceId(String resourceId) {
-        this.resourceId = resourceId;
-        return this;
-    }
-
-    public String getRequestAction() {
-        return requestAction;
-    }
-
-    public ExecuteBuildingBlock setRequestAction(String requestAction) {
-        this.requestAction = requestAction;
-        return this;
-    }
-
-    public Boolean isaLaCarte() {
-        return aLaCarte;
-    }
-
-    public ExecuteBuildingBlock setaLaCarte(Boolean aLaCarte) {
-        this.aLaCarte = aLaCarte;
-        return this;
-    }
-
-    public String getVnfType() {
-        return vnfType;
-    }
-
-    public ExecuteBuildingBlock setVnfType(String vnfType) {
-        this.vnfType = vnfType;
-        return this;
-    }
-
     public Boolean isHoming() {
         return homing;
     }
@@ -110,24 +48,6 @@ public class ExecuteBuildingBlock implements Serializable {
         return this;
     }
 
-    public WorkflowResourceIds getWorkflowResourceIds() {
-        return workflowResourceIds;
-    }
-
-    public ExecuteBuildingBlock setWorkflowResourceIds(WorkflowResourceIds workflowResourceIds) {
-        this.workflowResourceIds = workflowResourceIds;
-        return this;
-    }
-
-    public RequestDetails getRequestDetails() {
-        return requestDetails;
-    }
-
-    public ExecuteBuildingBlock setRequestDetails(RequestDetails requestDetails) {
-        this.requestDetails = requestDetails;
-        return this;
-    }
-
     public ConfigurationResourceKeys getConfigurationResourceKeys() {
         return configurationResourceKeys;
     }
index 92bf43f..075f6f8 100644 (file)
@@ -55,7 +55,7 @@
     </plugins>
     <pluginManagement>
       <plugins>
-      <plugin>
+        <plugin>
           <groupId>org.eclipse.m2e</groupId>
           <artifactId>lifecycle-mapping</artifactId>
           <version>1.0.0</version>
index dec9560..f7a4e5e 100644 (file)
           <groupId>javax.ws.rs</groupId>
           <artifactId>jsr311-api</artifactId>
         </exclusion>
-       <exclusion>
+        <exclusion>
           <groupId>io.swagger</groupId>
           <artifactId>swagger-annotations</artifactId>
         </exclusion>
index 1852485..e154375 100644 (file)
@@ -22,25 +22,22 @@ package org.onap.so.bpmn.infrastructure.workflow.tasks;
 
 import java.util.List;
 import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlockBase;
 import org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds;
 import org.onap.so.db.catalog.beans.macro.OrchestrationFlow;
 import org.onap.so.serviceinstancebeans.RequestDetails;
 import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
+import java.io.Serializable;
+import java.util.List;
 
-public class ConfigBuildingBlocksDataObject {
+public class ConfigBuildingBlocksDataObject extends BuildingBlockBase<ConfigBuildingBlocksDataObject>
+        implements Serializable {
 
-    private ServiceInstancesRequest sIRequest;
+    private static final long serialVersionUID = 3L;
+    private DelegateExecution execution;
     private List<OrchestrationFlow> orchFlows;
-    private String requestId;
     private Resource resourceKey;
-    private String apiVersion;
-    private String resourceId;
-    private String requestAction;
-    private boolean aLaCarte;
-    private String vnfType;
-    private WorkflowResourceIds workflowResourceIds;
-    private RequestDetails requestDetails;
-    private DelegateExecution execution;
+    private ServiceInstancesRequest sIRequest;
 
     public ServiceInstancesRequest getsIRequest() {
         return sIRequest;
@@ -60,15 +57,6 @@ public class ConfigBuildingBlocksDataObject {
         return this;
     }
 
-    public String getRequestId() {
-        return requestId;
-    }
-
-    public ConfigBuildingBlocksDataObject setRequestId(String requestId) {
-        this.requestId = requestId;
-        return this;
-    }
-
     public Resource getResourceKey() {
         return resourceKey;
     }
@@ -78,69 +66,6 @@ public class ConfigBuildingBlocksDataObject {
         return this;
     }
 
-    public String getApiVersion() {
-        return apiVersion;
-    }
-
-    public ConfigBuildingBlocksDataObject setApiVersion(String apiVersion) {
-        this.apiVersion = apiVersion;
-        return this;
-    }
-
-    public String getResourceId() {
-        return resourceId;
-    }
-
-    public ConfigBuildingBlocksDataObject setResourceId(String resourceId) {
-        this.resourceId = resourceId;
-        return this;
-    }
-
-    public String getRequestAction() {
-        return requestAction;
-    }
-
-    public ConfigBuildingBlocksDataObject setRequestAction(String requestAction) {
-        this.requestAction = requestAction;
-        return this;
-    }
-
-    public boolean isaLaCarte() {
-        return aLaCarte;
-    }
-
-    public ConfigBuildingBlocksDataObject setaLaCarte(boolean aLaCarte) {
-        this.aLaCarte = aLaCarte;
-        return this;
-    }
-
-    public String getVnfType() {
-        return vnfType;
-    }
-
-    public ConfigBuildingBlocksDataObject setVnfType(String vnfType) {
-        this.vnfType = vnfType;
-        return this;
-    }
-
-    public WorkflowResourceIds getWorkflowResourceIds() {
-        return workflowResourceIds;
-    }
-
-    public ConfigBuildingBlocksDataObject setWorkflowResourceIds(WorkflowResourceIds workflowResourceIds) {
-        this.workflowResourceIds = workflowResourceIds;
-        return this;
-    }
-
-    public RequestDetails getRequestDetails() {
-        return requestDetails;
-    }
-
-    public ConfigBuildingBlocksDataObject setRequestDetails(RequestDetails requestDetails) {
-        this.requestDetails = requestDetails;
-        return this;
-    }
-
     public DelegateExecution getExecution() {
         return execution;
     }
index a057fe0..25c2286 100644 (file)
@@ -176,25 +176,32 @@ public class WorkflowAction {
             final String bpmnRequest = (String) execution.getVariable(BBConstants.G_BPMN_REQUEST);
             ServiceInstancesRequest sIRequest =
                     new ObjectMapper().readValue(bpmnRequest, ServiceInstancesRequest.class);
-            RequestDetails requestDetails = sIRequest.getRequestDetails();
-            String uri = (String) execution.getVariable(BBConstants.G_URI);
+
             final String requestId = (String) execution.getVariable(BBConstants.G_REQUEST_ID);
-            final boolean aLaCarte = (boolean) execution.getVariable(BBConstants.G_ALACARTE);
+
+            String uri = (String) execution.getVariable(BBConstants.G_URI);
             boolean isResume = isUriResume(uri);
-            String requestAction = (String) execution.getVariable(BBConstants.G_ACTION);
+
+            final boolean isALaCarte = (boolean) execution.getVariable(BBConstants.G_ALACARTE);
+            Resource resource = getResource(bbInputSetupUtils, isResume, isALaCarte, uri, requestId);
+
             WorkflowResourceIds workflowResourceIds = populateResourceIdsFromApiHandler(execution);
-            Resource resource = getResource(bbInputSetupUtils, isResume, aLaCarte, uri, requestId);
+            RequestDetails requestDetails = sIRequest.getRequestDetails();
+            String requestAction = (String) execution.getVariable(BBConstants.G_ACTION);
             String resourceId = getResourceId(resource, requestAction, requestDetails, workflowResourceIds);
             WorkflowType resourceType = resource.getResourceType();
+
             String serviceInstanceId = getServiceInstanceId(execution, resourceId, resourceType);
+
             fillExecution(execution, requestDetails.getRequestInfo().getSuppressRollback(), resourceId, resourceType);
             List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();
-            if (isRequestMacroServiceResume(aLaCarte, resourceType, requestAction, serviceInstanceId)) {
+
+            if (isRequestMacroServiceResume(isALaCarte, resourceType, requestAction, serviceInstanceId)) {
                 flowsToExecute = bbInputSetupUtils.loadOriginalFlowExecutionPath(requestId);
                 if (flowsToExecute == null) {
                     buildAndThrowException(execution, "Could not resume Macro flow. Error loading execution path.");
                 }
-            } else if (aLaCarte && isResume) {
+            } else if (isALaCarte && isResume) {
                 flowsToExecute = bbInputSetupUtils.loadOriginalFlowExecutionPath(requestId);
                 if (flowsToExecute == null) {
                     buildAndThrowException(execution,
@@ -208,14 +215,13 @@ public class WorkflowAction {
                 final String apiVersion = (String) execution.getVariable(BBConstants.G_APIVERSION);
                 final String serviceType =
                         Optional.ofNullable((String) execution.getVariable(BBConstants.G_SERVICE_TYPE)).orElse("");
-                if (aLaCarte) {
+                if (isALaCarte) {
                     if (orchFlows == null || orchFlows.isEmpty()) {
                         orchFlows = queryNorthBoundRequestCatalogDb(execution, requestAction, resourceType, true,
                                 cloudOwner, serviceType);
                     }
                     Resource resourceKey = getResourceKey(sIRequest, resourceType);
-                    boolean isConfiguration = isConfiguration(orchFlows);
-                    if (isConfiguration && !requestAction.equalsIgnoreCase(CREATEINSTANCE)) {
+                    if (isConfiguration(orchFlows) && !requestAction.equalsIgnoreCase(CREATEINSTANCE)) {
                         List<ExecuteBuildingBlock> configBuildingBlocks = getConfigBuildingBlocks(
                                 new ConfigBuildingBlocksDataObject().setsIRequest(sIRequest).setOrchFlows(orchFlows)
                                         .setRequestId(requestId).setResourceKey(resourceKey).setApiVersion(apiVersion)
@@ -319,7 +325,7 @@ public class WorkflowAction {
                     logger.info("Found {}", foundObjects);
 
                     if (orchFlows == null || orchFlows.isEmpty()) {
-                        orchFlows = queryNorthBoundRequestCatalogDb(execution, requestAction, resourceType, aLaCarte,
+                        orchFlows = queryNorthBoundRequestCatalogDb(execution, requestAction, resourceType, isALaCarte,
                                 cloudOwner, serviceType);
                     }
                     boolean vnfReplace = false;
index 2f25d40..afb734d 100644 (file)
 
   <build>
     <finalName>${project.artifactId}-${project.version}</finalName>
-       <pluginManagement>
+    <pluginManagement>
       <plugins>
         <plugin>
           <groupId>org.eclipse.m2e</groupId>
diff --git a/pom.xml b/pom.xml
index b2fd0d5..ae743ac 100644 (file)
--- a/pom.xml
+++ b/pom.xml
     </plugins>
     <pluginManagement>
       <plugins>
-           <plugin>
+        <plugin>
           <groupId>org.eclipse.m2e</groupId>
           <artifactId>lifecycle-mapping</artifactId>
           <version>1.0.0</version>
                     <execute />
                   </action>
                 </pluginExecution>
-                 <pluginExecution>
+                <pluginExecution>
                   <pluginExecutionFilter>
                     <groupId>org.codehaus.gmaven</groupId>
                     <artifactId>groovy-maven-plugin</artifactId>