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