Containerization feature of SO
[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 org.onap.sdnc.apps.client.model.*;
24 import org.onap.so.bpmn.servicedecomposition.bbobjects.*;
25 import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
26 import org.onap.so.client.sdnc.beans.SDNCSvcAction;
27 import org.springframework.stereotype.Component;
28
29 @Component(value = "sdncGCTopologyOperationRequestMapper")
30 public class GCTopologyOperationRequestMapper {
31
32     private static final GeneralTopologyObjectMapper generalTopologyObjectMapper = new GeneralTopologyObjectMapper();
33
34     public GenericResourceApiGcTopologyOperationInformation assignOrActivateVnrReqMapper(SDNCSvcAction svcAction,
35                                                                                          GenericResourceApiRequestActionEnumeration reqAction,
36                                                                                          ServiceInstance serviceInstance,
37                                                                                          RequestContext requestContext,
38                                                                                          Customer customer,
39                                                                                          Configuration vnrConfiguration,
40                                                                                          GenericVnf voiceVnf) {
41
42         GenericResourceApiGcTopologyOperationInformation req = new GenericResourceApiGcTopologyOperationInformation();
43         String sdncReqId = requestContext.getMsoRequestId();
44         GenericResourceApiSdncrequestheaderSdncRequestHeader sdncRequestHeader = generalTopologyObjectMapper.buildSdncRequestHeader(svcAction, sdncReqId);// TODO Set URL
45         GenericResourceApiRequestinformationRequestInformation requestInformation = generalTopologyObjectMapper.buildGenericResourceApiRequestinformationRequestInformation(sdncReqId, reqAction);
46         GenericResourceApiServiceinformationServiceInformation serviceInformation = generalTopologyObjectMapper.buildServiceInformation(serviceInstance, requestContext, customer, false);
47         GenericResourceApiConfigurationinformationConfigurationInformation configurationInformation = generalTopologyObjectMapper.buildConfigurationInformation(vnrConfiguration,true);
48         GenericResourceApiGcrequestinputGcRequestInput gcRequestInput = generalTopologyObjectMapper.buildGcRequestInformation(voiceVnf,null);
49         req.setRequestInformation(requestInformation);
50         req.setSdncRequestHeader(sdncRequestHeader);
51         req.setServiceInformation(serviceInformation);
52         req.setConfigurationInformation(configurationInformation);
53         req.setGcRequestInput(gcRequestInput);
54
55         return req;
56
57     }
58
59
60     public GenericResourceApiGcTopologyOperationInformation deactivateOrUnassignVnrReqMapper(SDNCSvcAction svcAction,
61                                                                                              ServiceInstance serviceInstance,
62                                                                                              RequestContext requestContext,
63                                                                                              Configuration vnrConfiguration) {
64
65         GenericResourceApiGcTopologyOperationInformation req = new GenericResourceApiGcTopologyOperationInformation();
66         String sdncReqId = requestContext.getMsoRequestId();
67         GenericResourceApiSdncrequestheaderSdncRequestHeader sdncRequestHeader =
68                 generalTopologyObjectMapper.buildSdncRequestHeader(svcAction, sdncReqId);// TODO Set URL
69         GenericResourceApiRequestinformationRequestInformation requestInformation = generalTopologyObjectMapper
70                 .buildGenericResourceApiRequestinformationRequestInformation(sdncReqId,
71                         GenericResourceApiRequestActionEnumeration.DELETEGENERICCONFIGURATIONINSTANCE);
72         GenericResourceApiServiceinformationServiceInformation serviceInformation = new GenericResourceApiServiceinformationServiceInformation();
73         serviceInformation.setServiceInstanceId(serviceInstance.getServiceInstanceId());
74         GenericResourceApiConfigurationinformationConfigurationInformation configurationInformation =
75                 new GenericResourceApiConfigurationinformationConfigurationInformation();
76         configurationInformation.setConfigurationId(vnrConfiguration.getConfigurationId());
77         req.setRequestInformation(requestInformation);
78         req.setSdncRequestHeader(sdncRequestHeader);
79         req.setServiceInformation(serviceInformation);
80         req.setConfigurationInformation(configurationInformation);
81         return req;
82
83     }
84
85
86 }