2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 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.GenericResourceApiParam;
26 import org.onap.sdnc.northbound.client.model.GenericResourceApiParamParam;
27 import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration;
28 import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestinformationRequestInformation;
29 import org.onap.sdnc.northbound.client.model.GenericResourceApiSdncrequestheaderSdncRequestHeader;
30 import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceOperationInformation;
31 import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceinformationServiceInformation;
32 import org.onap.sdnc.northbound.client.model.GenericResourceApiServicerequestinputServiceRequestInput;
33 import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer;
34 import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
35 import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
36 import org.onap.so.client.sdnc.beans.SDNCSvcAction;
37 import org.onap.so.client.sdnc.beans.SDNCSvcOperation;
38 import org.springframework.beans.factory.annotation.Autowired;
39 import org.springframework.stereotype.Component;
42 public class ServiceTopologyOperationMapper {
45 public GeneralTopologyObjectMapper generalTopologyObjectMapper;
47 public GenericResourceApiServiceOperationInformation reqMapper(SDNCSvcOperation svcOperation,
48 SDNCSvcAction svcAction, GenericResourceApiRequestActionEnumeration resourceAction,
49 ServiceInstance serviceInstance, Customer customer, RequestContext requestContext) {
51 String sdncReqId = UUID.randomUUID().toString();
52 String msoRequestId = UUID.randomUUID().toString();
53 if (requestContext != null && requestContext.getMsoRequestId() != null) {
54 msoRequestId = requestContext.getMsoRequestId();
56 GenericResourceApiServiceOperationInformation servOpInput = new GenericResourceApiServiceOperationInformation();
57 GenericResourceApiSdncrequestheaderSdncRequestHeader sdncRequestHeader =
58 generalTopologyObjectMapper.buildSdncRequestHeader(svcAction, sdncReqId);
59 GenericResourceApiRequestinformationRequestInformation reqInfo = generalTopologyObjectMapper
60 .buildGenericResourceApiRequestinformationRequestInformation(msoRequestId, resourceAction);
61 GenericResourceApiServiceinformationServiceInformation servInfo =
62 generalTopologyObjectMapper.buildServiceInformation(serviceInstance, requestContext, customer, true);
63 GenericResourceApiServicerequestinputServiceRequestInput servReqInfo =
64 new GenericResourceApiServicerequestinputServiceRequestInput();
66 servReqInfo.setServiceInstanceName(serviceInstance.getServiceInstanceName());
68 servOpInput.setSdncRequestHeader(sdncRequestHeader);
69 servOpInput.setRequestInformation(reqInfo);
70 servOpInput.setServiceInformation(servInfo);
71 servOpInput.setServiceRequestInput(servReqInfo);
73 if (requestContext != null && requestContext.getUserParams() != null) {
74 for (Map.Entry<String, Object> entry : requestContext.getUserParams().entrySet()) {
75 GenericResourceApiServicerequestinputServiceRequestInput serviceRequestInput =
76 new GenericResourceApiServicerequestinputServiceRequestInput();
77 serviceRequestInput.setServiceInstanceName(serviceInstance.getServiceInstanceName());
78 GenericResourceApiParam serviceInputParameters = new GenericResourceApiParam();
79 GenericResourceApiParamParam paramItem = new GenericResourceApiParamParam();
80 paramItem.setName(entry.getKey());
81 paramItem.setValue(generalTopologyObjectMapper.mapUserParamValue(entry.getValue()));
82 serviceInputParameters.addParamItem(paramItem);
83 serviceRequestInput.serviceInputParameters(serviceInputParameters);
84 servOpInput.setServiceRequestInput(serviceRequestInput);