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