Merge "Add support for CDS basic-auth"
[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
32 import org.modelmapper.ModelMapper;
33 import org.modelmapper.convention.MatchingStrategies;
34 import org.onap.so.bpmn.servicedecomposition.bbobjects.AllottedResource;
35 import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
36 import org.onap.so.bpmn.servicedecomposition.bbobjects.Collection;
37 import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration;
38 import org.onap.so.bpmn.servicedecomposition.bbobjects.CtagAssignment;
39 import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer;
40 import org.onap.so.bpmn.servicedecomposition.bbobjects.Entitlement;
41 import org.onap.so.bpmn.servicedecomposition.bbobjects.Evc;
42 import org.onap.so.bpmn.servicedecomposition.bbobjects.ForwarderEvc;
43 import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
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.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.InstanceGroup;
77 import org.onap.so.db.catalog.beans.InstanceGroupType;
78 import org.onap.so.db.catalog.beans.NetworkResourceCustomization;
79 import org.onap.so.db.catalog.beans.OrchestrationStatus;
80 import org.onap.so.db.catalog.beans.Service;
81 import org.onap.so.db.catalog.beans.VfModuleCustomization;
82 import org.onap.so.db.catalog.beans.VnfResourceCustomization;
83 import org.onap.so.db.catalog.beans.VnfVfmoduleCvnfcConfigurationCustomization;
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(CollectionResourceCustomization collectionCust, InstanceGroup instanceGroup) {
188                 ModelInfoInstanceGroup modelInfoInstanceGroup = modelMapper.map(instanceGroup, ModelInfoInstanceGroup.class);
189                 if(instanceGroup.getType() != null && instanceGroup.getType().equals(InstanceGroupType.L3_NETWORK))
190                         modelInfoInstanceGroup.setType(ModelInfoInstanceGroup.TYPE_L3_NETWORK);
191                 else
192                         modelInfoInstanceGroup.setType(ModelInfoInstanceGroup.TYPE_VNFC);
193                 if(collectionCust != null) {
194                         List<CollectionResourceInstanceGroupCustomization> instanceGroupCustList = instanceGroup.getCollectionInstanceGroupCustomizations();
195                         for(CollectionResourceInstanceGroupCustomization collectionInsatnceGroupCust : instanceGroupCustList) {
196                                 if(collectionInsatnceGroupCust.getModelCustomizationUUID().equalsIgnoreCase(collectionCust.getModelCustomizationUUID())) {
197                                         modelInfoInstanceGroup.setFunction(collectionInsatnceGroupCust.getFunction());
198                                         modelInfoInstanceGroup.setDescription(collectionInsatnceGroupCust.getDescription());
199                                         break;
200                                 }
201                         }
202                 }
203                 return modelInfoInstanceGroup;
204         }
205
206         protected ModelInfoCollection mapCatalogCollectionToCollection(CollectionResourceCustomization collectionCust,
207                         CollectionResource collectionResource) {
208                 ModelInfoCollection modelInfoCollection = new ModelInfoCollection();
209                 modelInfoCollection.setCollectionFunction(collectionCust.getFunction());
210                 modelInfoCollection.setCollectionRole(collectionCust.getRole());
211                 modelInfoCollection.setCollectionType(collectionCust.getType());
212                 modelInfoCollection.setDescription(collectionResource.getDescription());
213                 modelInfoCollection.setModelInvariantUUID(collectionResource.getModelInvariantUUID());
214                 modelInfoCollection.setModelVersionId(collectionResource.getModelUUID());
215                 modelInfoCollection.setModelCustomizationUUID(collectionCust.getModelCustomizationUUID());
216                 return modelInfoCollection;
217         }
218
219         public ServiceInstance mapAAIServiceInstanceIntoServiceInstance(
220                         org.onap.aai.domain.yang.ServiceInstance aaiServiceInstance) {
221                 ServiceInstance serviceInstance = modelMapper.map(aaiServiceInstance, ServiceInstance.class);
222                 if (aaiServiceInstance.getAllottedResources() != null) {
223                         for (org.onap.aai.domain.yang.AllottedResource allottedResource : aaiServiceInstance.getAllottedResources()
224                                         .getAllottedResource()) {
225                                 serviceInstance.getAllottedResources().add(mapAAIAllottedResource(allottedResource));
226                         }
227                 }
228                 serviceInstance.setOrchestrationStatus(
229                                 this.mapOrchestrationStatusFromAAI(aaiServiceInstance.getOrchestrationStatus()));
230                 return serviceInstance;
231         }
232
233         protected AllottedResource mapAAIAllottedResource(org.onap.aai.domain.yang.AllottedResource aaiAllottedResource) {
234                 AllottedResource allottedResource = modelMapper.map(aaiAllottedResource, AllottedResource.class);
235                 return allottedResource;
236         }
237
238         protected L3Network mapAAIL3Network(org.onap.aai.domain.yang.L3Network aaiL3Network) {
239                 L3Network network = modelMapper.map(aaiL3Network, L3Network.class);
240                 mapAllSubnetsIntoL3Network(aaiL3Network, network);
241                 mapAllCtagAssignmentsIntoL3Network(aaiL3Network, network);
242                 mapAllSegmentationAssignmentsIntoL3Network(aaiL3Network, network);
243                 network.setOrchestrationStatus(this.mapOrchestrationStatusFromAAI(aaiL3Network.getOrchestrationStatus()));
244                 return network;
245         }
246
247         protected void mapAllSegmentationAssignmentsIntoL3Network(org.onap.aai.domain.yang.L3Network aaiL3Network,
248                         L3Network network) {
249                 if (aaiL3Network.getSegmentationAssignments() != null) {
250                         for (org.onap.aai.domain.yang.SegmentationAssignment aaiSegmentationAssignment : aaiL3Network
251                                         .getSegmentationAssignments().getSegmentationAssignment()) {
252                                 network.getSegmentationAssignments().add(mapAAISegmentationAssignment(aaiSegmentationAssignment));
253                         }
254                 }
255         }
256
257         protected void mapAllCtagAssignmentsIntoL3Network(org.onap.aai.domain.yang.L3Network aaiL3Network,
258                         L3Network network) {
259                 if (aaiL3Network.getCtagAssignments() != null) {
260                         for (org.onap.aai.domain.yang.CtagAssignment aaiCtagAssignment : aaiL3Network.getCtagAssignments()
261                                         .getCtagAssignment()) {
262                                 network.getCtagAssignments().add(mapAAICtagAssignment(aaiCtagAssignment));
263                         }
264                 }
265         }
266
267         protected void mapAllSubnetsIntoL3Network(org.onap.aai.domain.yang.L3Network aaiL3Network, L3Network network) {
268                 if (aaiL3Network.getSubnets() != null) {
269                         for (org.onap.aai.domain.yang.Subnet aaiSubnet : aaiL3Network.getSubnets().getSubnet()) {
270                                 network.getSubnets().add(mapAAISubnet(aaiSubnet));
271                         }
272                 }
273         }
274
275         protected GenericVnf mapAAIGenericVnfIntoGenericVnf(org.onap.aai.domain.yang.GenericVnf aaiGenericVnf) {
276                 GenericVnf genericVnf = modelMapper.map(aaiGenericVnf, GenericVnf.class);
277                 mapAllVfModulesIntoGenericVnf(aaiGenericVnf, genericVnf);
278                 mapAllLagInterfacesIntoGenericVnf(aaiGenericVnf, genericVnf);
279                 mapAllEntitlementsIntoGenericVnf(aaiGenericVnf, genericVnf);
280                 mapAllLicensesIntoGenericVnf(aaiGenericVnf, genericVnf);
281                 genericVnf.setOrchestrationStatus(this.mapOrchestrationStatusFromAAI(aaiGenericVnf.getOrchestrationStatus()));
282                 return genericVnf;
283         }
284
285         protected void mapAllLicensesIntoGenericVnf(org.onap.aai.domain.yang.GenericVnf aaiGenericVnf,
286                         GenericVnf genericVnf) {
287                 if (aaiGenericVnf.getLicenses() != null) {
288                         for (org.onap.aai.domain.yang.License aaiLicense : aaiGenericVnf.getLicenses().getLicense()) {
289                                 genericVnf.setLicense(mapAAILicense(aaiLicense));
290                         }
291                 }
292         }
293
294         protected void mapAllEntitlementsIntoGenericVnf(org.onap.aai.domain.yang.GenericVnf aaiGenericVnf,
295                         GenericVnf genericVnf) {
296                 if (aaiGenericVnf.getEntitlements() != null) {
297                         for (org.onap.aai.domain.yang.Entitlement aaiEntitlement : aaiGenericVnf.getEntitlements()
298                                         .getEntitlement()) {
299                                 genericVnf.getEntitlements().add(mapAAIEntitlement(aaiEntitlement));
300                         }
301                 }
302         }
303
304         protected void mapAllLagInterfacesIntoGenericVnf(org.onap.aai.domain.yang.GenericVnf aaiGenericVnf,
305                         GenericVnf genericVnf) {
306                 if (aaiGenericVnf.getLagInterfaces() != null) {
307                         for (org.onap.aai.domain.yang.LagInterface aaiLagInterface : aaiGenericVnf.getLagInterfaces()
308                                         .getLagInterface()) {
309                                 genericVnf.getLagInterfaces().add(mapAAILagInterface(aaiLagInterface));
310                         }
311                 }
312         }
313
314         protected void mapAllVfModulesIntoGenericVnf(org.onap.aai.domain.yang.GenericVnf aaiGenericVnf,
315                         GenericVnf genericVnf) {
316                 if (aaiGenericVnf.getVfModules() != null) {
317                         for (org.onap.aai.domain.yang.VfModule aaiVfModule : aaiGenericVnf.getVfModules().getVfModule()) {
318                                 VfModule vfModule = mapAAIVfModule(aaiVfModule);
319                                 genericVnf.getVfModules().add(vfModule);
320                         }
321                 }
322         }
323
324         public OrchestrationStatus mapOrchestrationStatusFromAAI(String orchestrationStatus) {
325
326                 Optional<OrchestrationStatus> result = Arrays.asList(OrchestrationStatus.values()).stream()
327                 .filter(item -> item.fuzzyMap(orchestrationStatus))
328                 .findFirst();
329
330                 return result.orElse(null);
331
332         }
333
334         public RequestContext mapRequestContext(RequestDetails requestDetails) {
335                 RequestContext context = new RequestContext();
336                 modelMapper.map(requestDetails.getRequestInfo(), context);
337                 org.onap.so.serviceinstancebeans.RequestParameters requestParameters = requestDetails.getRequestParameters();
338                 if (null != requestParameters) {
339                         context.setSubscriptionServiceType(requestParameters.getSubscriptionServiceType());
340                         context.setRequestParameters(this.mapRequestParameters(requestDetails.getRequestParameters()));
341                         context.setUserParams(this.mapNameValueUserParams(requestDetails.getRequestParameters()));
342                 }
343                 if (requestDetails.getConfigurationParameters() != null) {
344                         context.setConfigurationParameters(requestDetails.getConfigurationParameters());
345                 }
346                 return context;
347         }
348
349         protected RequestParameters mapRequestParameters(org.onap.so.serviceinstancebeans.RequestParameters requestParameters) {
350                 RequestParameters requestParams = new RequestParameters();
351                 requestParams.setaLaCarte(requestParameters.getALaCarte());
352                 requestParams.setUsePreload(requestParameters.getUsePreload());
353                 requestParams.setSubscriptionServiceType(requestParameters.getSubscriptionServiceType());
354                 requestParams.setUserParams(requestParameters.getUserParams());
355                 requestParams.setPayload(requestParameters.getPayload());
356                 return requestParams;
357         }
358         
359         protected Map<String,Object> mapNameValueUserParams(org.onap.so.serviceinstancebeans.RequestParameters requestParameters) {             
360                 Map<String,Object> userParamsResult = new HashMap<String,Object>();
361                 if (requestParameters.getUserParams() != null) {
362                         List<Map<String, Object>> userParams = requestParameters.getUserParams();
363                         for (Map<String, Object> userParamsMap : userParams) {
364                                 if ( userParamsMap.containsKey(USER_PARAM_NAME_KEY) && (userParamsMap.get(USER_PARAM_NAME_KEY) instanceof String)
365                                                 && userParamsMap.containsKey(USER_PARAM_VALUE_KEY)) {
366                                         userParamsResult.put((String) userParamsMap.get(USER_PARAM_NAME_KEY), userParamsMap.get(USER_PARAM_VALUE_KEY));
367                                 }
368                         }
369                 }
370                 return userParamsResult;
371         }
372
373         protected OrchestrationContext mapOrchestrationContext(RequestDetails requestDetails) {
374                 OrchestrationContext context = new OrchestrationContext();
375                 context.setIsRollbackEnabled(!(requestDetails.getRequestInfo().getSuppressRollback()));
376                 return context;
377         }
378
379         protected CloudRegion mapCloudRegion(CloudConfiguration cloudConfiguration, org.onap.aai.domain.yang.CloudRegion aaiCloudRegion) {
380                 CloudRegion cloudRegion = new CloudRegion();
381                 if(cloudConfiguration != null)
382                         cloudRegion = modelMapper.map(cloudConfiguration, CloudRegion.class);
383                 if(aaiCloudRegion != null)
384                         modelMapper.map(aaiCloudRegion, cloudRegion);
385                 return cloudRegion;
386         }
387         
388         protected Tenant mapTenant(org.onap.aai.domain.yang.Tenant aaiTenant) {
389                 Tenant tenant = new Tenant();
390                 if(aaiTenant != null) {
391                         modelMapper.map(aaiTenant, tenant);
392                 }
393                 return tenant;
394         }
395
396         protected Collection mapAAICollectionIntoCollection(org.onap.aai.domain.yang.Collection aaiCollection) {
397                 Collection collection = new Collection();
398                 collection.setId(aaiCollection.getCollectionId());
399                 collection.setOrchestrationStatus(this.mapOrchestrationStatusFromAAI(aaiCollection.getOrchestrationStatus()));
400                 return collection;
401         }
402
403         protected org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup mapAAIInstanceGroupIntoInstanceGroup(
404                         org.onap.aai.domain.yang.InstanceGroup aaiInstanceGroup) {
405                 return modelMapper.map(aaiInstanceGroup,
406                                 org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup.class);
407         }
408
409         public RouteTableReference mapAAIRouteTableReferenceIntoRouteTableReference(
410                         org.onap.aai.domain.yang.RouteTableReference aaiRouteTableReference) {
411                 return modelMapper.map(aaiRouteTableReference, RouteTableReference.class);
412         }
413
414         protected ModelInfoNetwork mapCatalogNetworkToNetwork(NetworkResourceCustomization networkResourceCustomization) {
415                 modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
416                 ModelInfoNetwork modelInfoNetwork = modelMapper.map(networkResourceCustomization, ModelInfoNetwork.class);
417                 modelMapper.map(networkResourceCustomization.getNetworkResource(), modelInfoNetwork);
418                 modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STANDARD);
419                 return modelInfoNetwork;
420         }
421
422         protected ModelInfoGenericVnf mapCatalogVnfToVnf(VnfResourceCustomization vnfResourceCustomization) {
423                 ModelInfoGenericVnf modelInfoVnf = modelMapper.map(vnfResourceCustomization, ModelInfoGenericVnf.class);
424                 modelMapper.map(vnfResourceCustomization.getVnfResources(), modelInfoVnf);
425                 return modelInfoVnf;
426         }
427
428         protected ModelInfoVfModule mapCatalogVfModuleToVfModule(VfModuleCustomization vfResourceCustomization) {
429                 ModelInfoVfModule modelInfoVfModule = modelMapper.map(vfResourceCustomization, ModelInfoVfModule.class);
430                 modelMapper.map(vfResourceCustomization.getVfModule(), modelInfoVfModule);
431                 return modelInfoVfModule;
432         }
433
434         protected Platform mapRequestPlatform(org.onap.so.serviceinstancebeans.Platform platform) {
435                 return modelMapper.map(platform, Platform.class);
436         }
437
438         protected LineOfBusiness mapRequestLineOfBusiness(
439                         org.onap.so.serviceinstancebeans.LineOfBusiness lineOfBusiness) {
440                 return modelMapper.map(lineOfBusiness, LineOfBusiness.class);
441         }
442
443         public Configuration mapAAIConfiguration(org.onap.aai.domain.yang.Configuration configurationAAI) {
444                 modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
445                 Configuration configuration = modelMapper.map(configurationAAI, Configuration.class);
446                 modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STANDARD);
447                 configuration.getForwarderEvcs().addAll(mapAllForwarderEvcs(configurationAAI));
448                 configuration.getEvcs().addAll(mapAllEvcs(configurationAAI));
449                 configuration.setOrchestrationStatus(this.mapOrchestrationStatusFromAAI(configurationAAI.getOrchestrationStatus()));
450                 return configuration;
451         }
452
453         protected List<Evc> mapAllEvcs(org.onap.aai.domain.yang.Configuration configurationAAI) {
454                 List<Evc> listOfEvcs = new ArrayList<>();
455                 if (configurationAAI.getEvcs() != null) {
456                         for (org.onap.aai.domain.yang.Evc aaiEvc : configurationAAI.getEvcs().getEvc()) {
457                                 listOfEvcs.add(mapEvc(aaiEvc));
458                         }
459                 }
460                 return listOfEvcs;
461         }
462
463         protected Evc mapEvc(org.onap.aai.domain.yang.Evc aaiEvc) {
464                 return modelMapper.map(aaiEvc, Evc.class);
465         }
466
467         protected List<ForwarderEvc> mapAllForwarderEvcs(org.onap.aai.domain.yang.Configuration configurationAAI) {
468                 List<ForwarderEvc> listOfForwarderEvcs = new ArrayList<>();
469                 if (configurationAAI.getForwarderEvcs() != null) {
470                         for (org.onap.aai.domain.yang.ForwarderEvc aaiForwarderEvc : configurationAAI.getForwarderEvcs().getForwarderEvc()) {
471                                 listOfForwarderEvcs.add(mapForwarderEvc(aaiForwarderEvc));
472                         }
473                 }
474                 return listOfForwarderEvcs;
475         }
476
477         protected ForwarderEvc mapForwarderEvc(org.onap.aai.domain.yang.ForwarderEvc aaiForwarderEvc) {
478                 return modelMapper.map(aaiForwarderEvc, ForwarderEvc.class);
479         }
480
481         protected OwningEntity mapRequestOwningEntity(org.onap.so.serviceinstancebeans.OwningEntity owningEntity) {
482                 return modelMapper.map(owningEntity, OwningEntity.class);
483         }
484
485         protected Project mapRequestProject(org.onap.so.serviceinstancebeans.Project project) {
486                 return modelMapper.map(project, Project.class);
487         }
488
489         protected ModelInfoConfiguration mapCatalogConfigurationToConfiguration(
490                         ConfigurationResourceCustomization configurationResourceCustomization, 
491                         VnfVfmoduleCvnfcConfigurationCustomization vnfVfmoduleCvnfcConfigurationCustomization) {
492                 ModelInfoConfiguration modelInfoConfiguration = new ModelInfoConfiguration();
493                 modelInfoConfiguration.setModelVersionId(configurationResourceCustomization.getConfigurationResource().getModelUUID());
494                 modelInfoConfiguration.setModelCustomizationId(configurationResourceCustomization.getModelCustomizationUUID());
495                 modelInfoConfiguration.setModelInvariantId(configurationResourceCustomization.getConfigurationResource().getModelInvariantUUID());
496                 modelInfoConfiguration.setPolicyName(vnfVfmoduleCvnfcConfigurationCustomization.getPolicyName());
497                 return modelInfoConfiguration;
498         }
499
500         public NetworkResourceCustomization mapCollectionNetworkResourceCustToNetworkResourceCust(
501                         CollectionNetworkResourceCustomization collectionNetworkResourceCust) {
502                 return modelMapper.map(collectionNetworkResourceCust, NetworkResourceCustomization.class);
503         }
504 }