Merge "Implement a separate task to query CatalogDB for"
[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
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,
49                                                                                          ServiceInstance serviceInstance,
50                                                                                          RequestContext requestContext,
51                                                                                          Customer customer,
52                                                                                          Configuration vnrConfiguration,
53                                                                                          GenericVnf voiceVnf, String sdncReqId,URI callbackUri) {
54
55         GenericResourceApiGcTopologyOperationInformation req = new GenericResourceApiGcTopologyOperationInformation();
56         GenericResourceApiSdncrequestheaderSdncRequestHeader sdncRequestHeader = generalTopologyObjectMapper.buildSdncRequestHeader(svcAction, sdncReqId,callbackUri.toString());
57         GenericResourceApiRequestinformationRequestInformation requestInformation = generalTopologyObjectMapper.buildGenericResourceApiRequestinformationRequestInformation(sdncReqId, reqAction);
58         GenericResourceApiServiceinformationServiceInformation serviceInformation = generalTopologyObjectMapper.buildServiceInformation(serviceInstance, requestContext, customer, false);
59         GenericResourceApiConfigurationinformationConfigurationInformation configurationInformation = generalTopologyObjectMapper.buildConfigurationInformation(vnrConfiguration,true);
60         GenericResourceApiGcrequestinputGcRequestInput gcRequestInput = generalTopologyObjectMapper.buildGcRequestInformation(voiceVnf,null);
61         req.setRequestInformation(requestInformation);
62         req.setSdncRequestHeader(sdncRequestHeader);
63         req.setServiceInformation(serviceInformation);
64         req.setConfigurationInformation(configurationInformation);
65         req.setGcRequestInput(gcRequestInput);
66
67         return req;
68
69     }
70
71
72     public GenericResourceApiGcTopologyOperationInformation deactivateOrUnassignVnrReqMapper(SDNCSvcAction svcAction,
73                                                                                              ServiceInstance serviceInstance,
74                                                                                              RequestContext requestContext,
75                                                                                              Configuration vnrConfiguration, String sdncReqId, URI callbackUri) {
76
77         GenericResourceApiGcTopologyOperationInformation req = new GenericResourceApiGcTopologyOperationInformation();     
78         GenericResourceApiSdncrequestheaderSdncRequestHeader sdncRequestHeader =
79                 generalTopologyObjectMapper.buildSdncRequestHeader(svcAction, sdncReqId,callbackUri.toString());
80         GenericResourceApiRequestinformationRequestInformation requestInformation = generalTopologyObjectMapper
81                 .buildGenericResourceApiRequestinformationRequestInformation(sdncReqId,
82                         GenericResourceApiRequestActionEnumeration.DELETEGENERICCONFIGURATIONINSTANCE);
83         GenericResourceApiServiceinformationServiceInformation serviceInformation = new GenericResourceApiServiceinformationServiceInformation();
84         serviceInformation.setServiceInstanceId(serviceInstance.getServiceInstanceId());
85         GenericResourceApiConfigurationinformationConfigurationInformation configurationInformation =
86                 new GenericResourceApiConfigurationinformationConfigurationInformation();
87         configurationInformation.setConfigurationId(vnrConfiguration.getConfigurationId());
88         req.setRequestInformation(requestInformation);
89         req.setSdncRequestHeader(sdncRequestHeader);
90         req.setServiceInformation(serviceInformation);
91         req.setConfigurationInformation(configurationInformation);
92         return req;
93
94     }
95
96 }