2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.onap.so.client.sdnc.mapper;
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;
41 @Component(value = "sdncGCTopologyOperationRequestMapper")
42 public class GCTopologyOperationRequestMapper {
45 private GeneralTopologyObjectMapper generalTopologyObjectMapper;
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) {
52 String msoRequestId = UUID.randomUUID().toString();
53 if (requestContext != null && requestContext.getMsoRequestId() != null) {
54 msoRequestId = requestContext.getMsoRequestId();
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);
78 public GenericResourceApiGcTopologyOperationInformation deactivateOrUnassignVnrReqMapper(SDNCSvcAction svcAction,
79 ServiceInstance serviceInstance, RequestContext requestContext, Configuration vnrConfiguration,
80 String sdncReqId, URI callbackUri) {
82 String msoRequestId = null;
83 if (requestContext != null) {
84 msoRequestId = requestContext.getMsoRequestId();
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);