Replaced all tabs with spaces in java and pom.xml
[so.git] / bpmn / so-bpmn-tasks / src / main / java / org / onap / so / client / sdnc / mapper / GCTopologyOperationRequestMapper.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.so.client.sdnc.mapper;
22
23 import java.net.URI;
24 import java.util.UUID;
25 import org.onap.sdnc.northbound.client.model.GenericResourceApiConfigurationinformationConfigurationInformation;
26 import org.onap.sdnc.northbound.client.model.GenericResourceApiGcTopologyOperationInformation;
27 import org.onap.sdnc.northbound.client.model.GenericResourceApiGcrequestinputGcRequestInput;
28 import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration;
29 import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestinformationRequestInformation;
30 import org.onap.sdnc.northbound.client.model.GenericResourceApiSdncrequestheaderSdncRequestHeader;
31 import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceinformationServiceInformation;
32 import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration;
33 import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer;
34 import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
35 import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
36 import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
37 import org.onap.so.client.sdnc.beans.SDNCSvcAction;
38 import org.springframework.beans.factory.annotation.Autowired;
39 import org.springframework.stereotype.Component;
40
41 @Component(value = "sdncGCTopologyOperationRequestMapper")
42 public class GCTopologyOperationRequestMapper {
43
44     @Autowired
45     private GeneralTopologyObjectMapper generalTopologyObjectMapper;
46
47     public GenericResourceApiGcTopologyOperationInformation assignOrActivateVnrReqMapper(SDNCSvcAction svcAction,
48             GenericResourceApiRequestActionEnumeration reqAction, ServiceInstance serviceInstance,
49             RequestContext requestContext, Customer customer, Configuration vnrConfiguration, GenericVnf voiceVnf,
50             String sdncReqId, URI callbackUri) {
51
52         String msoRequestId = UUID.randomUUID().toString();
53         if (requestContext != null && requestContext.getMsoRequestId() != null) {
54             msoRequestId = requestContext.getMsoRequestId();
55         }
56         GenericResourceApiGcTopologyOperationInformation req = new GenericResourceApiGcTopologyOperationInformation();
57         GenericResourceApiSdncrequestheaderSdncRequestHeader sdncRequestHeader =
58                 generalTopologyObjectMapper.buildSdncRequestHeader(svcAction, sdncReqId, callbackUri.toString());
59         GenericResourceApiRequestinformationRequestInformation requestInformation = generalTopologyObjectMapper
60                 .buildGenericResourceApiRequestinformationRequestInformation(msoRequestId, reqAction);
61         GenericResourceApiServiceinformationServiceInformation serviceInformation =
62                 generalTopologyObjectMapper.buildServiceInformation(serviceInstance, requestContext, customer, false);
63         GenericResourceApiConfigurationinformationConfigurationInformation configurationInformation =
64                 generalTopologyObjectMapper.buildConfigurationInformation(vnrConfiguration, true);
65         GenericResourceApiGcrequestinputGcRequestInput gcRequestInput =
66                 generalTopologyObjectMapper.buildGcRequestInformation(voiceVnf, null);
67         req.setRequestInformation(requestInformation);
68         req.setSdncRequestHeader(sdncRequestHeader);
69         req.setServiceInformation(serviceInformation);
70         req.setConfigurationInformation(configurationInformation);
71         req.setGcRequestInput(gcRequestInput);
72
73         return req;
74
75     }
76
77
78     public GenericResourceApiGcTopologyOperationInformation deactivateOrUnassignVnrReqMapper(SDNCSvcAction svcAction,
79             ServiceInstance serviceInstance, RequestContext requestContext, Configuration vnrConfiguration,
80             String sdncReqId, URI callbackUri) {
81
82         String msoRequestId = null;
83         if (requestContext != null) {
84             msoRequestId = requestContext.getMsoRequestId();
85         }
86         GenericResourceApiGcTopologyOperationInformation req = new GenericResourceApiGcTopologyOperationInformation();
87         GenericResourceApiSdncrequestheaderSdncRequestHeader sdncRequestHeader =
88                 generalTopologyObjectMapper.buildSdncRequestHeader(svcAction, sdncReqId, callbackUri.toString());
89         GenericResourceApiRequestinformationRequestInformation requestInformation =
90                 generalTopologyObjectMapper.buildGenericResourceApiRequestinformationRequestInformation(msoRequestId,
91                         GenericResourceApiRequestActionEnumeration.DELETEGENERICCONFIGURATIONINSTANCE);
92         GenericResourceApiServiceinformationServiceInformation serviceInformation =
93                 new GenericResourceApiServiceinformationServiceInformation();
94         serviceInformation.setServiceInstanceId(serviceInstance.getServiceInstanceId());
95         GenericResourceApiConfigurationinformationConfigurationInformation configurationInformation =
96                 new GenericResourceApiConfigurationinformationConfigurationInformation();
97         configurationInformation.setConfigurationId(vnrConfiguration.getConfigurationId());
98         configurationInformation.setConfigurationType(vnrConfiguration.getConfigurationType());
99         req.setRequestInformation(requestInformation);
100         req.setSdncRequestHeader(sdncRequestHeader);
101         req.setServiceInformation(serviceInformation);
102         req.setConfigurationInformation(configurationInformation);
103         return req;
104
105     }
106
107 }