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.apps.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;
30 public class GeneralTopologyObjectMapper {
33 * Build GenericResourceApiRequestinformationRequestInformation
35 public GenericResourceApiRequestinformationRequestInformation buildGenericResourceApiRequestinformationRequestInformation(String sdncReqId, GenericResourceApiRequestActionEnumeration requestAction){
37 GenericResourceApiRequestinformationRequestInformation requestInformation = new GenericResourceApiRequestinformationRequestInformation();
38 requestInformation.setRequestId(sdncReqId);
39 requestInformation.setRequestAction(requestAction);
40 requestInformation.setSource("MSO");
41 return requestInformation;
44 * Build GenericResourceApiServiceinformationServiceInformation
46 public GenericResourceApiServiceinformationServiceInformation buildServiceInformation(ServiceInstance serviceInstance, RequestContext requestContext, Customer customer, boolean includeModelInformation){
47 GenericResourceApiServiceinformationServiceInformation serviceInformation = new GenericResourceApiServiceinformationServiceInformation();
48 serviceInformation.serviceId(serviceInstance.getServiceInstanceId());
49 if (requestContext != null) {
50 serviceInformation.setSubscriptionServiceType(requestContext.getProductFamilyId());
52 if (includeModelInformation) {
53 GenericResourceApiOnapmodelinformationOnapModelInformation onapModelInformation = new GenericResourceApiOnapmodelinformationOnapModelInformation();
54 onapModelInformation.setModelInvariantUuid(serviceInstance.getModelInfoServiceInstance().getModelInvariantUuid());
55 onapModelInformation.setModelVersion(serviceInstance.getModelInfoServiceInstance().getModelVersion());
56 onapModelInformation.setModelName(serviceInstance.getModelInfoServiceInstance().getModelName());
57 onapModelInformation.setModelUuid(serviceInstance.getModelInfoServiceInstance().getModelUuid());
58 serviceInformation.setOnapModelInformation(onapModelInformation );
60 serviceInformation.setServiceInstanceId(serviceInstance.getServiceInstanceId());
62 if (customer != null) {
63 serviceInformation.setGlobalCustomerId(customer.getGlobalCustomerId());
64 if(customer.getServiceSubscription() != null){
65 serviceInformation.setSubscriptionServiceType(customer.getServiceSubscription().getServiceType());
69 return serviceInformation;
72 * Build GenericResourceApiNetworkinformationNetworkInformation
74 public GenericResourceApiNetworkinformationNetworkInformation buildNetworkInformation(L3Network network){
75 GenericResourceApiNetworkinformationNetworkInformation networkInformation = new GenericResourceApiNetworkinformationNetworkInformation();
76 GenericResourceApiOnapmodelinformationOnapModelInformation onapModelInformation = new GenericResourceApiOnapmodelinformationOnapModelInformation();
77 if (network.getModelInfoNetwork() != null) {
78 onapModelInformation.setModelInvariantUuid(network.getModelInfoNetwork().getModelInvariantUUID());
79 onapModelInformation.setModelName(network.getModelInfoNetwork().getModelName());
80 onapModelInformation.setModelVersion(network.getModelInfoNetwork().getModelVersion());
81 onapModelInformation.setModelUuid(network.getModelInfoNetwork().getModelUUID());
82 onapModelInformation.setModelCustomizationUuid(network.getModelInfoNetwork().getModelCustomizationUUID());
83 networkInformation.setOnapModelInformation(onapModelInformation);
85 networkInformation.setNetworkId(network.getNetworkId());
86 //TODO fix this after network type filed included in L3Network object type
87 //networkInformation.setNetworkType(network.getNetwork);
88 return networkInformation;
91 * Build GenericResourceApiVnfinformationVnfInformation
93 public GenericResourceApiVnfinformationVnfInformation buildVnfInformation(GenericVnf vnf, ServiceInstance serviceInstance, boolean includeModelInformation){
94 GenericResourceApiVnfinformationVnfInformation vnfInformation = new GenericResourceApiVnfinformationVnfInformation();
95 if (includeModelInformation && vnf.getModelInfoGenericVnf() != null) {
96 GenericResourceApiOnapmodelinformationOnapModelInformation onapModelInformation = new GenericResourceApiOnapmodelinformationOnapModelInformation();
97 onapModelInformation.setModelInvariantUuid(vnf.getModelInfoGenericVnf().getModelInvariantUuid());
98 onapModelInformation.setModelName(vnf.getModelInfoGenericVnf().getModelName());
99 onapModelInformation.setModelVersion(vnf.getModelInfoGenericVnf().getModelVersion());
100 onapModelInformation.setModelUuid(vnf.getModelInfoGenericVnf().getModelUuid());
101 onapModelInformation.setModelCustomizationUuid(vnf.getModelInfoGenericVnf().getModelCustomizationUuid());
102 vnfInformation.setOnapModelInformation(onapModelInformation);
104 vnfInformation.setVnfId(vnf.getVnfId());
105 vnfInformation.setVnfType(vnf.getVnfType());
106 vnfInformation.setVnfName(vnf.getVnfName());
107 return vnfInformation;
110 * Build GenericResourceApiVfModuleinformationVfModuleInformation
112 public GenericResourceApiVfmoduleinformationVfModuleInformation buildVfModuleInformation(VfModule vfModule, GenericVnf vnf, ServiceInstance serviceInstance, boolean includeModelInformation){
113 GenericResourceApiVfmoduleinformationVfModuleInformation vfModuleInformation = new GenericResourceApiVfmoduleinformationVfModuleInformation();
114 if (includeModelInformation) {
115 GenericResourceApiOnapmodelinformationOnapModelInformation onapModelInformation = new GenericResourceApiOnapmodelinformationOnapModelInformation();
116 onapModelInformation.setModelInvariantUuid(vfModule.getModelInfoVfModule().getModelInvariantUUID());
117 onapModelInformation.setModelName(vfModule.getModelInfoVfModule().getModelName());
118 onapModelInformation.setModelVersion(vfModule.getModelInfoVfModule().getModelVersion());
119 onapModelInformation.setModelUuid(vfModule.getModelInfoVfModule().getModelUUID());
120 onapModelInformation.setModelCustomizationUuid(vfModule.getModelInfoVfModule().getModelCustomizationUUID());
121 vfModuleInformation.setOnapModelInformation(onapModelInformation);
123 if (vfModule.getModelInfoVfModule() != null) {
124 vfModuleInformation.setVfModuleType(vfModule.getModelInfoVfModule().getModelName());
126 vfModuleInformation.setVfModuleId(vfModule.getVfModuleId());
127 return vfModuleInformation;
129 public GenericResourceApiSdncrequestheaderSdncRequestHeader buildSdncRequestHeader(SDNCSvcAction svcAction, String sdncReqId){
130 GenericResourceApiSdncrequestheaderSdncRequestHeader sdncRequestHeader = new GenericResourceApiSdncrequestheaderSdncRequestHeader();
131 sdncRequestHeader.setSvcAction(svcAction.getSdncApiAction());
132 sdncRequestHeader.setSvcRequestId(sdncReqId);
133 return sdncRequestHeader;
137 * Build ConfigurationInformation
138 * @param configuration
139 * @param includeModelInformation
142 public GenericResourceApiConfigurationinformationConfigurationInformation buildConfigurationInformation(Configuration configuration, boolean includeModelInformation) {
143 GenericResourceApiConfigurationinformationConfigurationInformation configurationInformation = new GenericResourceApiConfigurationinformationConfigurationInformation();
144 configurationInformation.setConfigurationId(configuration.getConfigurationId());
145 configurationInformation.setConfigurationName(configuration.getConfigurationName());
146 configurationInformation.setConfigurationType(configuration.getConfigurationType());
147 if(includeModelInformation) {
148 GenericResourceApiOnapmodelinformationOnapModelInformation onapModelInformation = new GenericResourceApiOnapmodelinformationOnapModelInformation();
149 onapModelInformation.setModelInvariantUuid(configuration.getModelInfoConfiguration().getModelInvariantId());
150 onapModelInformation.setModelUuid(configuration.getModelInfoConfiguration().getModelVersionId());
151 onapModelInformation.setModelCustomizationUuid(configuration.getModelInfoConfiguration().getModelCustomizationId());
152 configurationInformation.setOnapModelInformation(onapModelInformation);
154 return configurationInformation;
159 * Build GcRequestInformation
161 * @param genericResourceApiParam
164 public GenericResourceApiGcrequestinputGcRequestInput buildGcRequestInformation(GenericVnf vnf,GenericResourceApiParam genericResourceApiParam) {
165 GenericResourceApiGcrequestinputGcRequestInput gcRequestInput = new GenericResourceApiGcrequestinputGcRequestInput();
166 gcRequestInput.setVnfId(vnf.getVnfId());
167 if(genericResourceApiParam != null) {
168 gcRequestInput.setInputParameters(genericResourceApiParam);
170 return gcRequestInput;