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;
23 import org.onap.sdnc.northbound.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 import org.onap.so.client.exception.MapperException;
31 public class GeneralTopologyObjectMapper {
34 * Build GenericResourceApiRequestinformationRequestInformation
36 public GenericResourceApiRequestinformationRequestInformation buildGenericResourceApiRequestinformationRequestInformation(String sdncReqId, GenericResourceApiRequestActionEnumeration requestAction){
38 GenericResourceApiRequestinformationRequestInformation requestInformation = new GenericResourceApiRequestinformationRequestInformation();
39 requestInformation.setRequestId(sdncReqId);
40 requestInformation.setRequestAction(requestAction);
41 requestInformation.setSource("MSO");
42 return requestInformation;
45 * Build GenericResourceApiServiceinformationServiceInformation
47 public GenericResourceApiServiceinformationServiceInformation buildServiceInformation(ServiceInstance serviceInstance, RequestContext requestContext, Customer customer, boolean includeModelInformation){
48 GenericResourceApiServiceinformationServiceInformation serviceInformation = new GenericResourceApiServiceinformationServiceInformation();
49 serviceInformation.serviceId(serviceInstance.getServiceInstanceId());
50 if (requestContext != null) {
51 serviceInformation.setSubscriptionServiceType(requestContext.getProductFamilyId());
53 if (includeModelInformation) {
54 GenericResourceApiOnapmodelinformationOnapModelInformation onapModelInformation = new GenericResourceApiOnapmodelinformationOnapModelInformation();
55 onapModelInformation.setModelInvariantUuid(serviceInstance.getModelInfoServiceInstance().getModelInvariantUuid());
56 onapModelInformation.setModelVersion(serviceInstance.getModelInfoServiceInstance().getModelVersion());
57 onapModelInformation.setModelName(serviceInstance.getModelInfoServiceInstance().getModelName());
58 onapModelInformation.setModelUuid(serviceInstance.getModelInfoServiceInstance().getModelUuid());
59 serviceInformation.setOnapModelInformation(onapModelInformation );
61 serviceInformation.setServiceInstanceId(serviceInstance.getServiceInstanceId());
63 if (customer != null) {
64 serviceInformation.setGlobalCustomerId(customer.getGlobalCustomerId());
65 if(customer.getServiceSubscription() != null){
66 serviceInformation.setSubscriptionServiceType(customer.getServiceSubscription().getServiceType());
70 return serviceInformation;
73 * Build GenericResourceApiNetworkinformationNetworkInformation
75 public GenericResourceApiNetworkinformationNetworkInformation buildNetworkInformation(L3Network network){
76 GenericResourceApiNetworkinformationNetworkInformation networkInformation = new GenericResourceApiNetworkinformationNetworkInformation();
77 GenericResourceApiOnapmodelinformationOnapModelInformation onapModelInformation = new GenericResourceApiOnapmodelinformationOnapModelInformation();
78 if (network.getModelInfoNetwork() != null) {
79 onapModelInformation.setModelInvariantUuid(network.getModelInfoNetwork().getModelInvariantUUID());
80 onapModelInformation.setModelName(network.getModelInfoNetwork().getModelName());
81 onapModelInformation.setModelVersion(network.getModelInfoNetwork().getModelVersion());
82 onapModelInformation.setModelUuid(network.getModelInfoNetwork().getModelUUID());
83 onapModelInformation.setModelCustomizationUuid(network.getModelInfoNetwork().getModelCustomizationUUID());
84 networkInformation.setOnapModelInformation(onapModelInformation);
87 networkInformation.setFromPreload(null);
88 networkInformation.setNetworkId(network.getNetworkId());
89 //TODO fix this after network type filed included in L3Network object type
90 //networkInformation.setNetworkType(network.getNetwork);
91 return networkInformation;
94 * Build GenericResourceApiVnfinformationVnfInformation
96 public GenericResourceApiVnfinformationVnfInformation buildVnfInformation(GenericVnf vnf, ServiceInstance serviceInstance, boolean includeModelInformation){
97 GenericResourceApiVnfinformationVnfInformation vnfInformation = new GenericResourceApiVnfinformationVnfInformation();
98 if (includeModelInformation && vnf.getModelInfoGenericVnf() != null) {
99 GenericResourceApiOnapmodelinformationOnapModelInformation onapModelInformation = new GenericResourceApiOnapmodelinformationOnapModelInformation();
100 onapModelInformation.setModelInvariantUuid(vnf.getModelInfoGenericVnf().getModelInvariantUuid());
101 onapModelInformation.setModelName(vnf.getModelInfoGenericVnf().getModelName());
102 onapModelInformation.setModelVersion(vnf.getModelInfoGenericVnf().getModelVersion());
103 onapModelInformation.setModelUuid(vnf.getModelInfoGenericVnf().getModelUuid());
104 onapModelInformation.setModelCustomizationUuid(vnf.getModelInfoGenericVnf().getModelCustomizationUuid());
105 vnfInformation.setOnapModelInformation(onapModelInformation);
107 vnfInformation.setVnfId(vnf.getVnfId());
108 vnfInformation.setVnfType(vnf.getVnfType());
109 vnfInformation.setVnfName(vnf.getVnfName());
110 return vnfInformation;
113 * Build GenericResourceApiVfModuleinformationVfModuleInformation
115 public GenericResourceApiVfmoduleinformationVfModuleInformation buildVfModuleInformation(VfModule vfModule, GenericVnf vnf, ServiceInstance serviceInstance, boolean includeModelInformation) throws MapperException {
116 GenericResourceApiVfmoduleinformationVfModuleInformation vfModuleInformation = new GenericResourceApiVfmoduleinformationVfModuleInformation();
117 if (includeModelInformation) {
118 if (vfModule.getModelInfoVfModule() == null) {
119 throw new MapperException("VF Module model info is null for " + vfModule.getVfModuleId());
122 GenericResourceApiOnapmodelinformationOnapModelInformation onapModelInformation = new GenericResourceApiOnapmodelinformationOnapModelInformation();
123 onapModelInformation.setModelInvariantUuid(vfModule.getModelInfoVfModule().getModelInvariantUUID());
124 onapModelInformation.setModelName(vfModule.getModelInfoVfModule().getModelName());
125 onapModelInformation.setModelVersion(vfModule.getModelInfoVfModule().getModelVersion());
126 onapModelInformation.setModelUuid(vfModule.getModelInfoVfModule().getModelUUID());
127 onapModelInformation.setModelCustomizationUuid(vfModule.getModelInfoVfModule().getModelCustomizationUUID());
128 vfModuleInformation.setOnapModelInformation(onapModelInformation);
131 if (vfModule.getModelInfoVfModule() != null) {
132 vfModuleInformation.setVfModuleType(vfModule.getModelInfoVfModule().getModelName());
134 vfModuleInformation.setVfModuleId(vfModule.getVfModuleId());
135 vfModuleInformation.setFromPreload(null);
136 return vfModuleInformation;
138 public GenericResourceApiSdncrequestheaderSdncRequestHeader buildSdncRequestHeader(SDNCSvcAction svcAction, String sdncReqId){
139 GenericResourceApiSdncrequestheaderSdncRequestHeader sdncRequestHeader = new GenericResourceApiSdncrequestheaderSdncRequestHeader();
140 sdncRequestHeader.setSvcAction(svcAction.getSdncApiAction());
141 sdncRequestHeader.setSvcRequestId(sdncReqId);
142 return sdncRequestHeader;
146 * Build ConfigurationInformation
147 * @param configuration
148 * @param includeModelInformation
151 public GenericResourceApiConfigurationinformationConfigurationInformation buildConfigurationInformation(Configuration configuration, boolean includeModelInformation) {
152 GenericResourceApiConfigurationinformationConfigurationInformation configurationInformation = new GenericResourceApiConfigurationinformationConfigurationInformation();
153 configurationInformation.setConfigurationId(configuration.getConfigurationId());
154 configurationInformation.setConfigurationName(configuration.getConfigurationName());
155 configurationInformation.setConfigurationType(configuration.getConfigurationType());
156 if(includeModelInformation) {
157 GenericResourceApiOnapmodelinformationOnapModelInformation onapModelInformation = new GenericResourceApiOnapmodelinformationOnapModelInformation();
158 onapModelInformation.setModelInvariantUuid(configuration.getModelInfoConfiguration().getModelInvariantId());
159 onapModelInformation.setModelUuid(configuration.getModelInfoConfiguration().getModelVersionId());
160 onapModelInformation.setModelCustomizationUuid(configuration.getModelInfoConfiguration().getModelCustomizationId());
161 configurationInformation.setOnapModelInformation(onapModelInformation);
163 return configurationInformation;
168 * Build GcRequestInformation
170 * @param genericResourceApiParam
173 public GenericResourceApiGcrequestinputGcRequestInput buildGcRequestInformation(GenericVnf vnf,GenericResourceApiParam genericResourceApiParam) {
174 GenericResourceApiGcrequestinputGcRequestInput gcRequestInput = new GenericResourceApiGcrequestinputGcRequestInput();
175 gcRequestInput.setVnfId(vnf.getVnfId());
176 if(genericResourceApiParam != null) {
177 gcRequestInput.setInputParameters(genericResourceApiParam);
179 return gcRequestInput;