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;
26 import org.onap.sdnc.northbound.client.model.GenericResourceApiConfigurationinformationConfigurationInformation;
27 import org.onap.sdnc.northbound.client.model.GenericResourceApiGcTopologyOperationInformation;
28 import org.onap.sdnc.northbound.client.model.GenericResourceApiGcrequestinputGcRequestInput;
29 import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration;
30 import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestinformationRequestInformation;
31 import org.onap.sdnc.northbound.client.model.GenericResourceApiSdncrequestheaderSdncRequestHeader;
32 import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceinformationServiceInformation;
33 import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration;
34 import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer;
35 import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
36 import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
37 import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
38 import org.onap.so.client.sdnc.beans.SDNCSvcAction;
39 import org.springframework.beans.factory.annotation.Autowired;
40 import org.springframework.stereotype.Component;
42 @Component(value = "sdncGCTopologyOperationRequestMapper")
43 public class GCTopologyOperationRequestMapper {
46 private GeneralTopologyObjectMapper generalTopologyObjectMapper;
48 public GenericResourceApiGcTopologyOperationInformation assignOrActivateVnrReqMapper(SDNCSvcAction svcAction,
49 GenericResourceApiRequestActionEnumeration reqAction,
50 ServiceInstance serviceInstance,
51 RequestContext requestContext,
53 Configuration vnrConfiguration,
54 GenericVnf voiceVnf, String sdncReqId,URI callbackUri) {
56 String msoRequestId = UUID.randomUUID().toString();
57 if (requestContext != null && requestContext.getMsoRequestId() != null) {
58 msoRequestId = requestContext.getMsoRequestId();
60 GenericResourceApiGcTopologyOperationInformation req = new GenericResourceApiGcTopologyOperationInformation();
61 GenericResourceApiSdncrequestheaderSdncRequestHeader sdncRequestHeader = generalTopologyObjectMapper.buildSdncRequestHeader(svcAction, sdncReqId,callbackUri.toString());
62 GenericResourceApiRequestinformationRequestInformation requestInformation = generalTopologyObjectMapper.buildGenericResourceApiRequestinformationRequestInformation(msoRequestId, reqAction);
63 GenericResourceApiServiceinformationServiceInformation serviceInformation = generalTopologyObjectMapper.buildServiceInformation(serviceInstance, requestContext, customer, false);
64 GenericResourceApiConfigurationinformationConfigurationInformation configurationInformation = generalTopologyObjectMapper.buildConfigurationInformation(vnrConfiguration,true);
65 GenericResourceApiGcrequestinputGcRequestInput gcRequestInput = generalTopologyObjectMapper.buildGcRequestInformation(voiceVnf,null);
66 req.setRequestInformation(requestInformation);
67 req.setSdncRequestHeader(sdncRequestHeader);
68 req.setServiceInformation(serviceInformation);
69 req.setConfigurationInformation(configurationInformation);
70 req.setGcRequestInput(gcRequestInput);
77 public GenericResourceApiGcTopologyOperationInformation deactivateOrUnassignVnrReqMapper(SDNCSvcAction svcAction,
78 ServiceInstance serviceInstance,
79 RequestContext requestContext,
80 Configuration vnrConfiguration, 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 = generalTopologyObjectMapper
90 .buildGenericResourceApiRequestinformationRequestInformation(msoRequestId,
91 GenericResourceApiRequestActionEnumeration.DELETEGENERICCONFIGURATIONINSTANCE);
92 GenericResourceApiServiceinformationServiceInformation serviceInformation = new GenericResourceApiServiceinformationServiceInformation();
93 serviceInformation.setServiceInstanceId(serviceInstance.getServiceInstanceId());
94 GenericResourceApiConfigurationinformationConfigurationInformation configurationInformation =
95 new GenericResourceApiConfigurationinformationConfigurationInformation();
96 configurationInformation.setConfigurationId(vnrConfiguration.getConfigurationId());
97 configurationInformation.setConfigurationType(vnrConfiguration.getConfigurationType());
98 req.setRequestInformation(requestInformation);
99 req.setSdncRequestHeader(sdncRequestHeader);
100 req.setServiceInformation(serviceInformation);
101 req.setConfigurationInformation(configurationInformation);