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