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;
26 import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer;
27 import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
28 import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
29 import org.onap.so.client.sdnc.beans.SDNCSvcAction;
30 import org.onap.so.client.sdnc.beans.SDNCSvcOperation;
31 import org.springframework.stereotype.Component;
33 import org.onap.sdnc.apps.client.model.GenericResourceApiParam;
34 import org.onap.sdnc.apps.client.model.GenericResourceApiParamParam;
35 import org.onap.sdnc.apps.client.model.GenericResourceApiRequestActionEnumeration;
36 import org.onap.sdnc.apps.client.model.GenericResourceApiRequestinformationRequestInformation;
37 import org.onap.sdnc.apps.client.model.GenericResourceApiSdncrequestheaderSdncRequestHeader;
38 import org.onap.sdnc.apps.client.model.GenericResourceApiServiceOperationInformation;
39 import org.onap.sdnc.apps.client.model.GenericResourceApiServiceinformationServiceInformation;
40 import org.onap.sdnc.apps.client.model.GenericResourceApiServicerequestinputServiceRequestInput;
43 public class ServiceTopologyOperationMapper{
45 static GeneralTopologyObjectMapper generalTopologyObjectMapper = new GeneralTopologyObjectMapper();
47 public GenericResourceApiServiceOperationInformation reqMapper (SDNCSvcOperation svcOperation,
48 SDNCSvcAction svcAction, GenericResourceApiRequestActionEnumeration resourceAction,ServiceInstance serviceInstance, Customer customer, RequestContext requestContext) {
50 String sdncReqId = UUID.randomUUID().toString();
51 GenericResourceApiServiceOperationInformation servOpInput = new GenericResourceApiServiceOperationInformation();
52 GenericResourceApiSdncrequestheaderSdncRequestHeader sdncRequestHeader = generalTopologyObjectMapper.buildSdncRequestHeader(svcAction, sdncReqId);
53 GenericResourceApiRequestinformationRequestInformation reqInfo = generalTopologyObjectMapper.buildGenericResourceApiRequestinformationRequestInformation(sdncReqId, resourceAction);
54 GenericResourceApiServiceinformationServiceInformation servInfo = generalTopologyObjectMapper.buildServiceInformation(serviceInstance, requestContext, customer, true);
55 GenericResourceApiServicerequestinputServiceRequestInput servReqInfo = new GenericResourceApiServicerequestinputServiceRequestInput();
57 servReqInfo.setServiceInstanceName(serviceInstance.getServiceInstanceId());
59 servOpInput.setSdncRequestHeader(sdncRequestHeader);
60 servOpInput.setRequestInformation(reqInfo);
61 servOpInput.setServiceInformation(servInfo);
62 servOpInput.setServiceRequestInput(servReqInfo);
64 if(requestContext.getUserParams()!=null){
65 for (Map.Entry<String, String> entry : requestContext.getUserParams().entrySet()) {
66 GenericResourceApiServicerequestinputServiceRequestInput serviceRequestInput = new GenericResourceApiServicerequestinputServiceRequestInput();
67 serviceRequestInput.setServiceInstanceName(serviceInstance.getServiceInstanceId());
68 GenericResourceApiParam serviceInputParameters = new GenericResourceApiParam();
69 GenericResourceApiParamParam paramItem = new GenericResourceApiParamParam();
70 paramItem.setName(entry.getKey());
71 paramItem.setValue(entry.getValue());
72 serviceInputParameters.addParamItem(paramItem );
73 serviceRequestInput.serviceInputParameters(serviceInputParameters);
74 servOpInput.setServiceRequestInput(serviceRequestInput );