2bb383e4ecb67f37b10eb82e331ffafd78ff1a0e
[so.git] / bpmn / MSOCommonBPMN / src / main / java / org / onap / so / bpmn / servicedecomposition / tasks / BBInputSetupMapperLayer.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Modifications Copyright (c) 2019 Samsung
8  * ================================================================================
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  * ============LICENSE_END=========================================================
21  */
22
23 package org.onap.so.bpmn.servicedecomposition.tasks;
24
25 import org.modelmapper.ModelMapper;
26 import org.modelmapper.convention.MatchingStrategies;
27 import org.onap.so.bpmn.servicedecomposition.bbobjects.AggregateRoute;
28 import org.onap.so.bpmn.servicedecomposition.bbobjects.AllottedResource;
29 import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
30 import org.onap.so.bpmn.servicedecomposition.bbobjects.Collection;
31 import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration;
32 import org.onap.so.bpmn.servicedecomposition.bbobjects.CtagAssignment;
33 import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer;
34 import org.onap.so.bpmn.servicedecomposition.bbobjects.Entitlement;
35 import org.onap.so.bpmn.servicedecomposition.bbobjects.Evc;
36 import org.onap.so.bpmn.servicedecomposition.bbobjects.ForwarderEvc;
37 import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
38 import org.onap.so.bpmn.servicedecomposition.bbobjects.HostRoute;
39 import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network;
40 import org.onap.so.bpmn.servicedecomposition.bbobjects.LagInterface;
41 import org.onap.so.bpmn.servicedecomposition.bbobjects.LineOfBusiness;
42 import org.onap.so.bpmn.servicedecomposition.bbobjects.NetworkPolicy;
43 import org.onap.so.bpmn.servicedecomposition.bbobjects.OwningEntity;
44 import org.onap.so.bpmn.servicedecomposition.bbobjects.Platform;
45 import org.onap.so.bpmn.servicedecomposition.bbobjects.Project;
46 import org.onap.so.bpmn.servicedecomposition.bbobjects.RouteTableReference;
47 import org.onap.so.bpmn.servicedecomposition.bbobjects.RouteTarget;
48 import org.onap.so.bpmn.servicedecomposition.bbobjects.SegmentationAssignment;
49 import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
50 import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription;
51 import org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet;
52 import org.onap.so.bpmn.servicedecomposition.bbobjects.Tenant;
53 import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule;
54 import org.onap.so.bpmn.servicedecomposition.bbobjects.Vnfc;
55 import org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf;
56 import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup;
57 import org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBinding;
58 import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
59 import org.onap.so.bpmn.servicedecomposition.generalobjects.License;
60 import org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext;
61 import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
62 import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestParameters;
63 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoCollection;
64 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoConfiguration;
65 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf;
66 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup;
67 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoNetwork;
68 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance;
69 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceProxy;
70 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule;
71 import org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization;
72 import org.onap.so.db.catalog.beans.CollectionResource;
73 import org.onap.so.db.catalog.beans.CollectionResourceCustomization;
74 import org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization;
75 import org.onap.so.db.catalog.beans.ConfigurationResourceCustomization;
76 import org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization;
77 import org.onap.so.db.catalog.beans.InstanceGroup;
78 import org.onap.so.db.catalog.beans.InstanceGroupType;
79 import org.onap.so.db.catalog.beans.NetworkResourceCustomization;
80 import org.onap.so.db.catalog.beans.OrchestrationStatus;
81 import org.onap.so.db.catalog.beans.Service;
82 import org.onap.so.db.catalog.beans.ServiceProxyResourceCustomization;
83 import org.onap.so.db.catalog.beans.VfModuleCustomization;
84 import org.onap.so.db.catalog.beans.VnfResourceCustomization;
85 import org.onap.so.serviceinstancebeans.CloudConfiguration;
86 import org.onap.so.serviceinstancebeans.RequestDetails;
87 import org.slf4j.Logger;
88 import org.slf4j.LoggerFactory;
89 import org.springframework.stereotype.Component;
90 import java.util.ArrayList;
91 import java.util.Arrays;
92 import java.util.HashMap;
93 import java.util.List;
94 import java.util.Map;
95 import java.util.Optional;
96
97 @Component("BBInputSetupMapperLayer")
98 public class BBInputSetupMapperLayer {
99     private static final String USER_PARAM_NAME_KEY = "name";
100     private static final String USER_PARAM_VALUE_KEY = "value";
101
102     private static final Logger logger = LoggerFactory.getLogger(BBInputSetupMapperLayer.class);
103
104     private ModelMapper modelMapper = new ModelMapper();
105
106     public Customer mapAAICustomer(org.onap.aai.domain.yang.Customer customerAAI) {
107         return modelMapper.map(customerAAI, Customer.class);
108     }
109
110     public ServiceSubscription mapAAIServiceSubscription(
111             org.onap.aai.domain.yang.ServiceSubscription serviceSubscriptionAAI) {
112         return modelMapper.map(serviceSubscriptionAAI, ServiceSubscription.class);
113     }
114
115     protected Project mapAAIProject(org.onap.aai.domain.yang.Project aaiProject) {
116         return modelMapper.map(aaiProject, Project.class);
117     }
118
119     protected OwningEntity mapAAIOwningEntity(org.onap.aai.domain.yang.OwningEntity aaiOwningEntity) {
120         return modelMapper.map(aaiOwningEntity, OwningEntity.class);
121     }
122
123     protected Platform mapAAIPlatform(org.onap.aai.domain.yang.Platform aaiPlatform) {
124         return modelMapper.map(aaiPlatform, Platform.class);
125     }
126
127     protected LineOfBusiness mapAAILineOfBusiness(org.onap.aai.domain.yang.LineOfBusiness aaiLineOfBusiness) {
128         return modelMapper.map(aaiLineOfBusiness, LineOfBusiness.class);
129     }
130
131     protected SegmentationAssignment mapAAISegmentationAssignment(
132             org.onap.aai.domain.yang.SegmentationAssignment aaiSegmentationAssignment) {
133         return modelMapper.map(aaiSegmentationAssignment, SegmentationAssignment.class);
134     }
135
136     protected AggregateRoute mapAAIAggregateRoute(org.onap.aai.domain.yang.AggregateRoute aaiAggregateRoute) {
137         return modelMapper.map(aaiAggregateRoute, AggregateRoute.class);
138     }
139
140     protected CtagAssignment mapAAICtagAssignment(org.onap.aai.domain.yang.CtagAssignment aaiCtagAssignment) {
141         return modelMapper.map(aaiCtagAssignment, CtagAssignment.class);
142     }
143
144     protected Subnet mapAAISubnet(org.onap.aai.domain.yang.Subnet aaiSubnet) {
145         Subnet subnet = modelMapper.map(aaiSubnet, Subnet.class);
146         mapAllHostRoutesIntoSubnet(aaiSubnet, subnet);
147         return subnet;
148     }
149
150     protected void mapAllHostRoutesIntoSubnet(org.onap.aai.domain.yang.Subnet aaiSubnet, Subnet subnet) {
151         if (aaiSubnet.getHostRoutes() != null) {
152             for (org.onap.aai.domain.yang.HostRoute aaiHostRoute : aaiSubnet.getHostRoutes().getHostRoute()) {
153                 subnet.getHostRoutes().add(mapAAIHostRoute(aaiHostRoute));
154             }
155         }
156     }
157
158     protected HostRoute mapAAIHostRoute(org.onap.aai.domain.yang.HostRoute aaiHostRoute) {
159         return modelMapper.map(aaiHostRoute, HostRoute.class);
160     }
161
162     protected License mapAAILicense(org.onap.aai.domain.yang.License aaiLicense) {
163         return modelMapper.map(aaiLicense, License.class);
164     }
165
166     protected Entitlement mapAAIEntitlement(org.onap.aai.domain.yang.Entitlement aaiEntitlement) {
167         return modelMapper.map(aaiEntitlement, Entitlement.class);
168     }
169
170     protected LagInterface mapAAILagInterface(org.onap.aai.domain.yang.LagInterface aaiLagInterface) {
171         return modelMapper.map(aaiLagInterface, LagInterface.class);
172     }
173
174     protected VfModule mapAAIVfModule(org.onap.aai.domain.yang.VfModule aaiVfModule) {
175         VfModule vfModule = modelMapper.map(aaiVfModule, VfModule.class);
176         vfModule.setOrchestrationStatus(this.mapOrchestrationStatusFromAAI(aaiVfModule.getOrchestrationStatus()));
177
178         ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
179         modelInfoVfModule.setIsBaseBoolean(aaiVfModule.isIsBaseVfModule());
180         vfModule.setModelInfoVfModule(modelInfoVfModule);
181         return vfModule;
182     }
183
184     public NetworkPolicy mapAAINetworkPolicy(org.onap.aai.domain.yang.NetworkPolicy aaiNetworkPolicy) {
185         return modelMapper.map(aaiNetworkPolicy, NetworkPolicy.class);
186     }
187
188     protected VolumeGroup mapAAIVolumeGroup(org.onap.aai.domain.yang.VolumeGroup aaiVolumeGroup) {
189         VolumeGroup volumeGroup = modelMapper.map(aaiVolumeGroup, VolumeGroup.class);
190         ModelInfoVfModule modelInfo = new ModelInfoVfModule();
191         modelInfo.setModelCustomizationUUID(aaiVolumeGroup.getModelCustomizationId());
192         volumeGroup.setModelInfoVfModule(modelInfo);
193         volumeGroup.setOrchestrationStatus(this.mapOrchestrationStatusFromAAI(aaiVolumeGroup.getOrchestrationStatus()));
194         return volumeGroup;
195     }
196
197     protected void setPlatformAndLOBIntoServiceInstance(Platform platformMSO, LineOfBusiness lineOfBusinessMSO,
198             ServiceInstance serviceInstance, Map<ResourceKey, String> resourcesToBeOrchestrated) {
199         String vnfId = resourcesToBeOrchestrated.get(ResourceKey.GENERIC_VNF_ID);
200         if (vnfId != null && !serviceInstance.getVnfs().isEmpty()) {
201             for (GenericVnf vnf : serviceInstance.getVnfs()) {
202                 if (vnf.getVnfId().equalsIgnoreCase(vnfId)) {
203                     vnf.setPlatform(platformMSO);
204                     vnf.setLineOfBusiness(lineOfBusinessMSO);
205                     break;
206                 }
207             }
208         }
209     }
210
211     public ModelInfoServiceInstance mapCatalogServiceIntoServiceInstance(Service service) {
212         return modelMapper.map(service, ModelInfoServiceInstance.class);
213     }
214
215     protected ModelInfoInstanceGroup mapCatalogInstanceGroupToInstanceGroup(
216             CollectionResourceCustomization collectionCust, InstanceGroup instanceGroup) {
217         ModelInfoInstanceGroup modelInfoInstanceGroup = modelMapper.map(instanceGroup, ModelInfoInstanceGroup.class);
218         if (instanceGroup.getType() != null && instanceGroup.getType().equals(InstanceGroupType.L3_NETWORK))
219             modelInfoInstanceGroup.setType(ModelInfoInstanceGroup.TYPE_L3_NETWORK);
220         else
221             modelInfoInstanceGroup.setType(ModelInfoInstanceGroup.TYPE_VNFC);
222         if (collectionCust != null) {
223             List<CollectionResourceInstanceGroupCustomization> instanceGroupCustList =
224                     instanceGroup.getCollectionInstanceGroupCustomizations();
225             for (CollectionResourceInstanceGroupCustomization collectionInsatnceGroupCust : instanceGroupCustList) {
226                 if (collectionInsatnceGroupCust.getModelCustomizationUUID()
227                         .equalsIgnoreCase(collectionCust.getModelCustomizationUUID())) {
228                     modelInfoInstanceGroup.setFunction(collectionInsatnceGroupCust.getFunction());
229                     modelInfoInstanceGroup.setDescription(collectionInsatnceGroupCust.getDescription());
230                     break;
231                 }
232             }
233         }
234         return modelInfoInstanceGroup;
235     }
236
237     protected ModelInfoCollection mapCatalogCollectionToCollection(CollectionResourceCustomization collectionCust,
238             CollectionResource collectionResource) {
239         ModelInfoCollection modelInfoCollection = new ModelInfoCollection();
240         modelInfoCollection.setCollectionFunction(collectionCust.getFunction());
241         modelInfoCollection.setCollectionRole(collectionCust.getRole());
242         modelInfoCollection.setCollectionType(collectionCust.getType());
243         modelInfoCollection.setDescription(collectionResource.getDescription());
244         modelInfoCollection.setModelInvariantUUID(collectionResource.getModelInvariantUUID());
245         modelInfoCollection.setModelVersionId(collectionResource.getModelUUID());
246         modelInfoCollection.setModelCustomizationUUID(collectionCust.getModelCustomizationUUID());
247         return modelInfoCollection;
248     }
249
250     public ServiceInstance mapAAIServiceInstanceIntoServiceInstance(
251             org.onap.aai.domain.yang.ServiceInstance aaiServiceInstance) {
252         ServiceInstance serviceInstance = modelMapper.map(aaiServiceInstance, ServiceInstance.class);
253         if (aaiServiceInstance.getAllottedResources() != null) {
254             for (org.onap.aai.domain.yang.AllottedResource allottedResource : aaiServiceInstance.getAllottedResources()
255                     .getAllottedResource()) {
256                 serviceInstance.getAllottedResources().add(mapAAIAllottedResource(allottedResource));
257             }
258         }
259         serviceInstance.setOrchestrationStatus(
260                 this.mapOrchestrationStatusFromAAI(aaiServiceInstance.getOrchestrationStatus()));
261         return serviceInstance;
262     }
263
264     protected AllottedResource mapAAIAllottedResource(org.onap.aai.domain.yang.AllottedResource aaiAllottedResource) {
265         AllottedResource allottedResource = modelMapper.map(aaiAllottedResource, AllottedResource.class);
266         return allottedResource;
267     }
268
269     protected L3Network mapAAIL3Network(org.onap.aai.domain.yang.L3Network aaiL3Network) {
270         L3Network network = modelMapper.map(aaiL3Network, L3Network.class);
271         mapAllSubnetsIntoL3Network(aaiL3Network, network);
272         mapAllCtagAssignmentsIntoL3Network(aaiL3Network, network);
273         mapAllSegmentationAssignmentsIntoL3Network(aaiL3Network, network);
274         mapAllAggregateRoutesIntoL3Network(aaiL3Network, network);
275         network.setOrchestrationStatus(this.mapOrchestrationStatusFromAAI(aaiL3Network.getOrchestrationStatus()));
276         return network;
277     }
278
279     protected void mapAllAggregateRoutesIntoL3Network(org.onap.aai.domain.yang.L3Network aaiL3Network,
280             L3Network network) {
281         if (aaiL3Network.getAggregateRoutes() != null) {
282             for (org.onap.aai.domain.yang.AggregateRoute aaiAggregateRoute : aaiL3Network.getAggregateRoutes()
283                     .getAggregateRoute()) {
284                 network.getAggregateRoutes().add(mapAAIAggregateRoute(aaiAggregateRoute));
285             }
286         }
287     }
288
289     protected void mapAllSegmentationAssignmentsIntoL3Network(org.onap.aai.domain.yang.L3Network aaiL3Network,
290             L3Network network) {
291         if (aaiL3Network.getSegmentationAssignments() != null) {
292             for (org.onap.aai.domain.yang.SegmentationAssignment aaiSegmentationAssignment : aaiL3Network
293                     .getSegmentationAssignments().getSegmentationAssignment()) {
294                 network.getSegmentationAssignments().add(mapAAISegmentationAssignment(aaiSegmentationAssignment));
295             }
296         }
297     }
298
299     protected void mapAllCtagAssignmentsIntoL3Network(org.onap.aai.domain.yang.L3Network aaiL3Network,
300             L3Network network) {
301         if (aaiL3Network.getCtagAssignments() != null) {
302             for (org.onap.aai.domain.yang.CtagAssignment aaiCtagAssignment : aaiL3Network.getCtagAssignments()
303                     .getCtagAssignment()) {
304                 network.getCtagAssignments().add(mapAAICtagAssignment(aaiCtagAssignment));
305             }
306         }
307     }
308
309     protected void mapAllSubnetsIntoL3Network(org.onap.aai.domain.yang.L3Network aaiL3Network, L3Network network) {
310         if (aaiL3Network.getSubnets() != null) {
311             for (org.onap.aai.domain.yang.Subnet aaiSubnet : aaiL3Network.getSubnets().getSubnet()) {
312                 network.getSubnets().add(mapAAISubnet(aaiSubnet));
313             }
314         }
315     }
316
317     protected GenericVnf mapAAIGenericVnfIntoGenericVnf(org.onap.aai.domain.yang.GenericVnf aaiGenericVnf) {
318         GenericVnf genericVnf = modelMapper.map(aaiGenericVnf, GenericVnf.class);
319         mapAllVfModulesIntoGenericVnf(aaiGenericVnf, genericVnf);
320         mapAllLagInterfacesIntoGenericVnf(aaiGenericVnf, genericVnf);
321         mapAllEntitlementsIntoGenericVnf(aaiGenericVnf, genericVnf);
322         mapAllLicensesIntoGenericVnf(aaiGenericVnf, genericVnf);
323         genericVnf.setOrchestrationStatus(this.mapOrchestrationStatusFromAAI(aaiGenericVnf.getOrchestrationStatus()));
324         return genericVnf;
325     }
326
327     protected Pnf mapAAIPnfIntoPnf(org.onap.aai.domain.yang.Pnf aaiPnf) {
328         return modelMapper.map(aaiPnf, Pnf.class);
329     }
330
331     protected void mapAllLicensesIntoGenericVnf(org.onap.aai.domain.yang.GenericVnf aaiGenericVnf,
332             GenericVnf genericVnf) {
333         if (aaiGenericVnf.getLicenses() != null) {
334             for (org.onap.aai.domain.yang.License aaiLicense : aaiGenericVnf.getLicenses().getLicense()) {
335                 genericVnf.setLicense(mapAAILicense(aaiLicense));
336             }
337         }
338     }
339
340     protected void mapAllEntitlementsIntoGenericVnf(org.onap.aai.domain.yang.GenericVnf aaiGenericVnf,
341             GenericVnf genericVnf) {
342         if (aaiGenericVnf.getEntitlements() != null) {
343             for (org.onap.aai.domain.yang.Entitlement aaiEntitlement : aaiGenericVnf.getEntitlements()
344                     .getEntitlement()) {
345                 genericVnf.getEntitlements().add(mapAAIEntitlement(aaiEntitlement));
346             }
347         }
348     }
349
350     protected void mapAllLagInterfacesIntoGenericVnf(org.onap.aai.domain.yang.GenericVnf aaiGenericVnf,
351             GenericVnf genericVnf) {
352         if (aaiGenericVnf.getLagInterfaces() != null) {
353             for (org.onap.aai.domain.yang.LagInterface aaiLagInterface : aaiGenericVnf.getLagInterfaces()
354                     .getLagInterface()) {
355                 genericVnf.getLagInterfaces().add(mapAAILagInterface(aaiLagInterface));
356             }
357         }
358     }
359
360     protected void mapAllVfModulesIntoGenericVnf(org.onap.aai.domain.yang.GenericVnf aaiGenericVnf,
361             GenericVnf genericVnf) {
362         if (aaiGenericVnf.getVfModules() != null) {
363             for (org.onap.aai.domain.yang.VfModule aaiVfModule : aaiGenericVnf.getVfModules().getVfModule()) {
364                 VfModule vfModule = mapAAIVfModule(aaiVfModule);
365                 genericVnf.getVfModules().add(vfModule);
366             }
367         }
368     }
369
370     public OrchestrationStatus mapOrchestrationStatusFromAAI(String orchestrationStatus) {
371
372         Optional<OrchestrationStatus> result = Arrays.asList(OrchestrationStatus.values()).stream()
373                 .filter(item -> item.fuzzyMap(orchestrationStatus)).findFirst();
374
375         return result.orElse(null);
376
377     }
378
379     public RequestContext mapRequestContext(RequestDetails requestDetails) {
380         RequestContext context = new RequestContext();
381         if (null != requestDetails.getRequestInfo()) {
382             modelMapper.map(requestDetails.getRequestInfo(), context);
383         }
384         org.onap.so.serviceinstancebeans.RequestParameters requestParameters = requestDetails.getRequestParameters();
385         if (null != requestParameters) {
386             context.setSubscriptionServiceType(requestParameters.getSubscriptionServiceType());
387             context.setRequestParameters(this.mapRequestParameters(requestDetails.getRequestParameters()));
388             context.setUserParams(this.mapNameValueUserParams(requestDetails.getRequestParameters()));
389         }
390         if (requestDetails.getConfigurationParameters() != null) {
391             context.setConfigurationParameters(requestDetails.getConfigurationParameters());
392         }
393         return context;
394     }
395
396     protected RequestParameters mapRequestParameters(
397             org.onap.so.serviceinstancebeans.RequestParameters requestParameters) {
398         RequestParameters requestParams = new RequestParameters();
399         requestParams.setaLaCarte(requestParameters.getALaCarte());
400         requestParams.setUsePreload(requestParameters.getUsePreload());
401         requestParams.setSubscriptionServiceType(requestParameters.getSubscriptionServiceType());
402         requestParams.setUserParams(requestParameters.getUserParams());
403         requestParams.setPayload(requestParameters.getPayload());
404         return requestParams;
405     }
406
407     protected Map<String, Object> mapNameValueUserParams(
408             org.onap.so.serviceinstancebeans.RequestParameters requestParameters) {
409         Map<String, Object> userParamsResult = new HashMap<String, Object>();
410         if (requestParameters.getUserParams() != null) {
411             List<Map<String, Object>> userParams = requestParameters.getUserParams();
412             for (Map<String, Object> userParamsMap : userParams) {
413                 if (userParamsMap.containsKey(USER_PARAM_NAME_KEY)
414                         && (userParamsMap.get(USER_PARAM_NAME_KEY) instanceof String)
415                         && userParamsMap.containsKey(USER_PARAM_VALUE_KEY)) {
416                     userParamsResult.put((String) userParamsMap.get(USER_PARAM_NAME_KEY),
417                             userParamsMap.get(USER_PARAM_VALUE_KEY));
418                 }
419             }
420         }
421         return userParamsResult;
422     }
423
424     protected OrchestrationContext mapOrchestrationContext(RequestDetails requestDetails) {
425         OrchestrationContext context = new OrchestrationContext();
426         if (requestDetails.getRequestInfo() != null) {
427             context.setIsRollbackEnabled(!(requestDetails.getRequestInfo().getSuppressRollback()));
428         } else {
429             context.setIsRollbackEnabled(false);
430         }
431         return context;
432     }
433
434     protected CloudRegion mapCloudRegion(CloudConfiguration cloudConfiguration,
435             org.onap.aai.domain.yang.CloudRegion aaiCloudRegion) {
436         CloudRegion cloudRegion = new CloudRegion();
437         if (cloudConfiguration != null)
438             cloudRegion = modelMapper.map(cloudConfiguration, CloudRegion.class);
439         if (aaiCloudRegion != null)
440             modelMapper.map(aaiCloudRegion, cloudRegion);
441         return cloudRegion;
442     }
443
444     protected Tenant mapTenant(org.onap.aai.domain.yang.Tenant aaiTenant) {
445         Tenant tenant = new Tenant();
446         if (aaiTenant != null) {
447             modelMapper.map(aaiTenant, tenant);
448         }
449         return tenant;
450     }
451
452     protected Collection mapAAICollectionIntoCollection(org.onap.aai.domain.yang.Collection aaiCollection) {
453         Collection collection = new Collection();
454         collection.setId(aaiCollection.getCollectionId());
455         collection.setOrchestrationStatus(this.mapOrchestrationStatusFromAAI(aaiCollection.getOrchestrationStatus()));
456         return collection;
457     }
458
459     protected org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup mapAAIInstanceGroupIntoInstanceGroup(
460             org.onap.aai.domain.yang.InstanceGroup aaiInstanceGroup) {
461         return modelMapper.map(aaiInstanceGroup, org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup.class);
462     }
463
464     public RouteTableReference mapAAIRouteTableReferenceIntoRouteTableReference(
465             org.onap.aai.domain.yang.RouteTableReference aaiRouteTableReference) {
466         return modelMapper.map(aaiRouteTableReference, RouteTableReference.class);
467     }
468
469     protected ModelInfoNetwork mapCatalogNetworkToNetwork(NetworkResourceCustomization networkResourceCustomization) {
470         modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
471         ModelInfoNetwork modelInfoNetwork = modelMapper.map(networkResourceCustomization, ModelInfoNetwork.class);
472         modelMapper.map(networkResourceCustomization.getNetworkResource(), modelInfoNetwork);
473         modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STANDARD);
474         return modelInfoNetwork;
475     }
476
477     protected ModelInfoGenericVnf mapCatalogVnfToVnf(VnfResourceCustomization vnfResourceCustomization) {
478         ModelInfoGenericVnf modelInfoVnf = modelMapper.map(vnfResourceCustomization, ModelInfoGenericVnf.class);
479         modelMapper.map(vnfResourceCustomization.getVnfResources(), modelInfoVnf);
480         return modelInfoVnf;
481     }
482
483     protected ModelInfoVfModule mapCatalogVfModuleToVfModule(VfModuleCustomization vfResourceCustomization) {
484         ModelInfoVfModule modelInfoVfModule = modelMapper.map(vfResourceCustomization, ModelInfoVfModule.class);
485         modelMapper.map(vfResourceCustomization.getVfModule(), modelInfoVfModule);
486         return modelInfoVfModule;
487     }
488
489     protected Platform mapRequestPlatform(org.onap.so.serviceinstancebeans.Platform platform) {
490         return modelMapper.map(platform, Platform.class);
491     }
492
493     protected LineOfBusiness mapRequestLineOfBusiness(org.onap.so.serviceinstancebeans.LineOfBusiness lineOfBusiness) {
494         return modelMapper.map(lineOfBusiness, LineOfBusiness.class);
495     }
496
497     public Configuration mapAAIConfiguration(org.onap.aai.domain.yang.Configuration configurationAAI) {
498         modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
499         Configuration configuration = modelMapper.map(configurationAAI, Configuration.class);
500         modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STANDARD);
501         configuration.getForwarderEvcs().addAll(mapAllForwarderEvcs(configurationAAI));
502         configuration.getEvcs().addAll(mapAllEvcs(configurationAAI));
503         configuration
504                 .setOrchestrationStatus(this.mapOrchestrationStatusFromAAI(configurationAAI.getOrchestrationStatus()));
505         return configuration;
506     }
507
508     protected List<Evc> mapAllEvcs(org.onap.aai.domain.yang.Configuration configurationAAI) {
509         List<Evc> listOfEvcs = new ArrayList<>();
510         if (configurationAAI.getEvcs() != null) {
511             for (org.onap.aai.domain.yang.Evc aaiEvc : configurationAAI.getEvcs().getEvc()) {
512                 listOfEvcs.add(mapEvc(aaiEvc));
513             }
514         }
515         return listOfEvcs;
516     }
517
518     protected Evc mapEvc(org.onap.aai.domain.yang.Evc aaiEvc) {
519         return modelMapper.map(aaiEvc, Evc.class);
520     }
521
522     protected List<ForwarderEvc> mapAllForwarderEvcs(org.onap.aai.domain.yang.Configuration configurationAAI) {
523         List<ForwarderEvc> listOfForwarderEvcs = new ArrayList<>();
524         if (configurationAAI.getForwarderEvcs() != null) {
525             for (org.onap.aai.domain.yang.ForwarderEvc aaiForwarderEvc : configurationAAI.getForwarderEvcs()
526                     .getForwarderEvc()) {
527                 listOfForwarderEvcs.add(mapForwarderEvc(aaiForwarderEvc));
528             }
529         }
530         return listOfForwarderEvcs;
531     }
532
533     protected ForwarderEvc mapForwarderEvc(org.onap.aai.domain.yang.ForwarderEvc aaiForwarderEvc) {
534         return modelMapper.map(aaiForwarderEvc, ForwarderEvc.class);
535     }
536
537     protected OwningEntity mapRequestOwningEntity(org.onap.so.serviceinstancebeans.OwningEntity owningEntity) {
538         return modelMapper.map(owningEntity, OwningEntity.class);
539     }
540
541     protected Project mapRequestProject(org.onap.so.serviceinstancebeans.Project project) {
542         return modelMapper.map(project, Project.class);
543     }
544
545     protected ModelInfoConfiguration mapCatalogConfigurationToConfiguration(
546             ConfigurationResourceCustomization configurationResourceCustomization,
547             CvnfcConfigurationCustomization cvnfcConfigurationCustomization) {
548
549         ModelInfoConfiguration modelInfoConfiguration = new ModelInfoConfiguration();
550         modelInfoConfiguration
551                 .setModelVersionId(configurationResourceCustomization.getConfigurationResource().getModelUUID());
552         modelInfoConfiguration.setModelCustomizationId(configurationResourceCustomization.getModelCustomizationUUID());
553         modelInfoConfiguration.setModelInvariantId(
554                 configurationResourceCustomization.getConfigurationResource().getModelInvariantUUID());
555         modelInfoConfiguration.setConfigurationRole(configurationResourceCustomization.getRole());
556         modelInfoConfiguration.setConfigurationType(configurationResourceCustomization.getType());
557         if (cvnfcConfigurationCustomization != null) {
558             modelInfoConfiguration.setPolicyName(cvnfcConfigurationCustomization.getPolicyName());
559         }
560         return modelInfoConfiguration;
561     }
562
563     protected ModelInfoConfiguration mapCatalogConfigurationToConfiguration(
564             CvnfcConfigurationCustomization cvnfcConfigurationCustomization) {
565         ModelInfoConfiguration modelInfoConfiguration = new ModelInfoConfiguration();
566         modelInfoConfiguration
567                 .setModelVersionId(cvnfcConfigurationCustomization.getConfigurationResource().getModelUUID());
568         modelInfoConfiguration.setModelCustomizationId(cvnfcConfigurationCustomization.getModelCustomizationUUID());
569         modelInfoConfiguration.setModelInvariantId(
570                 cvnfcConfigurationCustomization.getConfigurationResource().getModelInvariantUUID());
571         modelInfoConfiguration.setPolicyName(cvnfcConfigurationCustomization.getPolicyName());
572         modelInfoConfiguration.setConfigurationType(cvnfcConfigurationCustomization.getConfigurationType());
573         modelInfoConfiguration.setConfigurationRole(cvnfcConfigurationCustomization.getConfigurationRole());
574         return modelInfoConfiguration;
575     }
576
577     public NetworkResourceCustomization mapCollectionNetworkResourceCustToNetworkResourceCust(
578             CollectionNetworkResourceCustomization collectionNetworkResourceCust) {
579         return modelMapper.map(collectionNetworkResourceCust, NetworkResourceCustomization.class);
580     }
581
582     public Vnfc mapAAIVnfc(org.onap.aai.domain.yang.Vnfc vnfcAAI) {
583         return modelMapper.map(vnfcAAI, Vnfc.class);
584     }
585
586     public VpnBinding mapAAIVpnBinding(org.onap.aai.domain.yang.VpnBinding aaiVpnBinding) {
587         VpnBinding vpnBinding = modelMapper.map(aaiVpnBinding, VpnBinding.class);
588         mapAllRouteTargetsToAAIVpnBinding(aaiVpnBinding, vpnBinding);
589         return vpnBinding;
590     }
591
592     protected void mapAllRouteTargetsToAAIVpnBinding(org.onap.aai.domain.yang.VpnBinding aaiVpnBinding,
593             VpnBinding vpnBinding) {
594         if (aaiVpnBinding.getRouteTargets() != null) {
595             for (org.onap.aai.domain.yang.RouteTarget aaiRouteTarget : aaiVpnBinding.getRouteTargets()
596                     .getRouteTarget()) {
597                 vpnBinding.getRouteTargets().add(mapAAIRouteTarget(aaiRouteTarget));
598             }
599         }
600     }
601
602     public RouteTarget mapAAIRouteTarget(org.onap.aai.domain.yang.RouteTarget aaiRouteTarget) {
603         return modelMapper.map(aaiRouteTarget, RouteTarget.class);
604     }
605
606     protected ModelInfoServiceProxy mapServiceProxyCustomizationToServiceProxy(
607             ServiceProxyResourceCustomization serviceProxyCustomization) {
608         ModelInfoServiceProxy modelInfoServiceProxy =
609                 modelMapper.map(serviceProxyCustomization.getSourceService(), ModelInfoServiceProxy.class);
610         modelInfoServiceProxy.setModelInstanceName(serviceProxyCustomization.getModelInstanceName());
611         return modelInfoServiceProxy;
612     }
613 }