Add service-resiliency handling in service-create
[transportpce.git] / servicehandler / src / main / java / org / opendaylight / transportpce / servicehandler / ServiceInput.java
index b8781c507896d22b0c039b1d7ca123e94d24f5be..a818df60cf14fe2b6f52ebb3204cf3b523c73490 100644 (file)
@@ -7,20 +7,24 @@
  */
 package org.opendaylight.transportpce.servicehandler;
 
-import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.ConnectionType;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.ServiceEndpoint;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.sdnc.request.header.SdncRequestHeader;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.sdnc.request.header.SdncRequestHeaderBuilder;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev161014.routing.constraints.HardConstraints;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev161014.routing.constraints.SoftConstraints;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceCreateInput;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceCreateInputBuilder;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceDeleteInput;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceCreateInput;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceCreateInputBuilder;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceDeleteInput;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.create.input.ServiceAEndBuilder;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.create.input.ServiceZEndBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.ConnectionType;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.RpcActions;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.ServiceEndpoint;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.sdnc.request.header.SdncRequestHeader;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.sdnc.request.header.SdncRequestHeaderBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.service.resiliency.ServiceResiliency;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constraints.rev211210.routing.constraints.HardConstraints;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constraints.rev211210.routing.constraints.SoftConstraints;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceCreateInput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceCreateInputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceDeleteInput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceFeasibilityCheckInput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceReconfigureInput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceCreateInput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceCreateInputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.TempServiceDeleteInput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service.create.input.ServiceAEndBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service.create.input.ServiceZEndBuilder;
 
 /**
  * Super class of {@link ServiceCreateInput} and {@link TempServiceCreateInput}.
@@ -30,6 +34,7 @@ import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service
  */
 public class ServiceInput {
     private String serviceName;
+    private String newServiceName;
     private String commonId;
     private ConnectionType connectionType;
     private SdncRequestHeader sdncRequestHeader;
@@ -39,6 +44,8 @@ public class ServiceInput {
     private ServiceEndpoint serviceZEnd;
     private String customer;
     private String customerContact;
+    private ServiceResiliency serviceResiliency;
+    private boolean serviceReconfigure;
 
     public ServiceInput(ServiceCreateInput serviceCreateInput) {
         setServiceName(serviceCreateInput.getServiceName());
@@ -51,11 +58,32 @@ public class ServiceInput {
         setServiceZEnd(serviceCreateInput.getServiceZEnd());
         setCustomer(serviceCreateInput.getCustomer());
         setCustomerContact(serviceCreateInput.getCustomerContact());
+        setServiceResiliency(serviceCreateInput.getServiceResiliency());
+        setServiceReconfigure(false);
+    }
+
+    public ServiceInput(ServiceReconfigureInput serviceReconfigureInput) {
+        setServiceName(serviceReconfigureInput.getServiceName());
+        setNewServiceName(serviceReconfigureInput.getNewServiceName());
+        setSdncRequestHeader(new SdncRequestHeaderBuilder()
+                .setRequestId(serviceReconfigureInput.getServiceName() + "-reconfigure")
+                .setRpcAction(RpcActions.ServiceReconfigure).build());
+        setCommonId(serviceReconfigureInput.getCommonId());
+        setConnectionType(serviceReconfigureInput.getConnectionType());
+        setHardConstraints(serviceReconfigureInput.getHardConstraints());
+        setSoftConstraints(serviceReconfigureInput.getSoftConstraints());
+        setServiceAEnd(serviceReconfigureInput.getServiceAEnd());
+        setServiceZEnd(serviceReconfigureInput.getServiceZEnd());
+        setCustomer(serviceReconfigureInput.getCustomer());
+        setCustomerContact(serviceReconfigureInput.getCustomerContact());
+        setServiceResiliency(serviceReconfigureInput.getServiceResiliency());
+        setServiceReconfigure(true);
     }
 
     public ServiceInput(ServiceDeleteInput serviceDeleteInput) {
         setServiceName(serviceDeleteInput.getServiceDeleteReqInfo().getServiceName());
         setSdncRequestHeader(serviceDeleteInput.getSdncRequestHeader());
+        setServiceReconfigure(false);
     }
 
     public ServiceInput(TempServiceCreateInput tempServiceCreateInput) {
@@ -69,6 +97,23 @@ public class ServiceInput {
         setServiceZEnd(tempServiceCreateInput.getServiceZEnd());
         setCustomer(tempServiceCreateInput.getCustomer());
         setCustomerContact(tempServiceCreateInput.getCustomerContact());
+        setServiceResiliency(tempServiceCreateInput.getServiceResiliency());
+        setServiceReconfigure(false);
+    }
+
+    public ServiceInput(ServiceFeasibilityCheckInput serviceFeasibilityCheckInput) {
+        setServiceName(serviceFeasibilityCheckInput.getCommonId());
+        setCommonId(serviceFeasibilityCheckInput.getCommonId());
+        setConnectionType(serviceFeasibilityCheckInput.getConnectionType());
+        setSdncRequestHeader(serviceFeasibilityCheckInput.getSdncRequestHeader());
+        setHardConstraints(serviceFeasibilityCheckInput.getHardConstraints());
+        setSoftConstraints(serviceFeasibilityCheckInput.getSoftConstraints());
+        setServiceAEnd(serviceFeasibilityCheckInput.getServiceAEnd());
+        setServiceZEnd(serviceFeasibilityCheckInput.getServiceZEnd());
+        setCustomer(serviceFeasibilityCheckInput.getCustomer());
+        setCustomerContact(serviceFeasibilityCheckInput.getCustomerContact());
+        setServiceResiliency(serviceFeasibilityCheckInput.getServiceResiliency());
+        setServiceReconfigure(false);
     }
 
     public ServiceInput(TempServiceDeleteInput tempServiceDeleteInput) {
@@ -76,10 +121,11 @@ public class ServiceInput {
         setServiceName(comId);
         setCommonId(comId);
         setSdncRequestHeader(new SdncRequestHeaderBuilder().setRequestId(comId).build());
+        setServiceReconfigure(false);
     }
 
     public ServiceCreateInput getServiceCreateInput() {
-        return new ServiceCreateInputBuilder().setServiceName(serviceName)
+        ServiceCreateInputBuilder serviceCreateInputBuilder = new ServiceCreateInputBuilder()
                 .setCommonId(commonId)
                 .setConnectionType(connectionType)
                 .setSdncRequestHeader(sdncRequestHeader)
@@ -88,18 +134,31 @@ public class ServiceInput {
                 .setServiceAEnd(new ServiceAEndBuilder(serviceAEnd).build())
                 .setServiceZEnd(new ServiceZEndBuilder(serviceZEnd).build())
                 .setCustomer(customer)
-                .setCustomerContact(customerContact).build();
+                .setCustomerContact(customerContact)
+                .setServiceResiliency(serviceResiliency);
+        if (isServiceReconfigure()) {
+            serviceCreateInputBuilder.setServiceName(newServiceName);
+        } else {
+            serviceCreateInputBuilder.setServiceName(serviceName);
+        }
+        return serviceCreateInputBuilder.build();
     }
 
     public TempServiceCreateInput getTempServiceCreateInput() {
-        return new TempServiceCreateInputBuilder().setCommonId(commonId)
-                .setConnectionType(connectionType).setSdncRequestHeader(sdncRequestHeader)
-                .setHardConstraints(hardConstraints).setSoftConstraints(softConstraints)
-                .setServiceAEnd(new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.temp.service
+        return new TempServiceCreateInputBuilder()
+                .setCommonId(commonId)
+                .setConnectionType(connectionType)
+                .setSdncRequestHeader(sdncRequestHeader)
+                .setHardConstraints(hardConstraints)
+                .setSoftConstraints(softConstraints)
+                .setServiceAEnd(new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.temp.service
                         .create.input.ServiceAEndBuilder(serviceAEnd).build())
-                .setServiceZEnd(new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.temp.service
-                        .create.input.ServiceZEndBuilder(serviceZEnd).build()).setCustomer(customer)
-                .setCustomerContact(customerContact).build();
+                .setServiceZEnd(new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.temp.service
+                        .create.input.ServiceZEndBuilder(serviceZEnd).build())
+                .setCustomer(customer)
+                .setCustomerContact(customerContact)
+                .setServiceResiliency(serviceResiliency)
+                .build();
     }
 
     public String getServiceName() {
@@ -181,4 +240,28 @@ public class ServiceInput {
     public void setCustomerContact(String customerContact) {
         this.customerContact = customerContact;
     }
+
+    public String getNewServiceName() {
+        return newServiceName;
+    }
+
+    public void setNewServiceName(String newServiceName) {
+        this.newServiceName = newServiceName;
+    }
+
+    public void setServiceResiliency(ServiceResiliency serviceResiliency) {
+        this.serviceResiliency = serviceResiliency;
+    }
+
+    public ServiceResiliency getServiceResiliency() {
+        return serviceResiliency;
+    }
+
+    public boolean isServiceReconfigure() {
+        return serviceReconfigure;
+    }
+
+    public void setServiceReconfigure(boolean serviceReconfigure) {
+        this.serviceReconfigure = serviceReconfigure;
+    }
 }