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