Merge "Set response code in UpdateAAIGenericVnf"
[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         if (null != requestDetails.getRequestInfo()) {
354             modelMapper.map(requestDetails.getRequestInfo(), context);
355         }
356         org.onap.so.serviceinstancebeans.RequestParameters requestParameters = requestDetails.getRequestParameters();
357         if (null != requestParameters) {
358             context.setSubscriptionServiceType(requestParameters.getSubscriptionServiceType());
359             context.setRequestParameters(this.mapRequestParameters(requestDetails.getRequestParameters()));
360             context.setUserParams(this.mapNameValueUserParams(requestDetails.getRequestParameters()));
361         }
362         if (requestDetails.getConfigurationParameters() != null) {
363             context.setConfigurationParameters(requestDetails.getConfigurationParameters());
364         }
365         return context;
366     }
367
368     protected RequestParameters mapRequestParameters(
369             org.onap.so.serviceinstancebeans.RequestParameters requestParameters) {
370         RequestParameters requestParams = new RequestParameters();
371         requestParams.setaLaCarte(requestParameters.getALaCarte());
372         requestParams.setUsePreload(requestParameters.getUsePreload());
373         requestParams.setSubscriptionServiceType(requestParameters.getSubscriptionServiceType());
374         requestParams.setUserParams(requestParameters.getUserParams());
375         requestParams.setPayload(requestParameters.getPayload());
376         return requestParams;
377     }
378
379     protected Map<String, Object> mapNameValueUserParams(
380             org.onap.so.serviceinstancebeans.RequestParameters requestParameters) {
381         Map<String, Object> userParamsResult = new HashMap<String, Object>();
382         if (requestParameters.getUserParams() != null) {
383             List<Map<String, Object>> userParams = requestParameters.getUserParams();
384             for (Map<String, Object> userParamsMap : userParams) {
385                 if (userParamsMap.containsKey(USER_PARAM_NAME_KEY)
386                         && (userParamsMap.get(USER_PARAM_NAME_KEY) instanceof String)
387                         && userParamsMap.containsKey(USER_PARAM_VALUE_KEY)) {
388                     userParamsResult.put((String) userParamsMap.get(USER_PARAM_NAME_KEY),
389                             userParamsMap.get(USER_PARAM_VALUE_KEY));
390                 }
391             }
392         }
393         return userParamsResult;
394     }
395
396     protected OrchestrationContext mapOrchestrationContext(RequestDetails requestDetails) {
397         OrchestrationContext context = new OrchestrationContext();
398         if (requestDetails.getRequestInfo() != null) {
399             context.setIsRollbackEnabled(!(requestDetails.getRequestInfo().getSuppressRollback()));
400         } else {
401             context.setIsRollbackEnabled(false);
402         }
403         return context;
404     }
405
406     protected CloudRegion mapCloudRegion(CloudConfiguration cloudConfiguration,
407             org.onap.aai.domain.yang.CloudRegion aaiCloudRegion) {
408         CloudRegion cloudRegion = new CloudRegion();
409         if (cloudConfiguration != null)
410             cloudRegion = modelMapper.map(cloudConfiguration, CloudRegion.class);
411         if (aaiCloudRegion != null)
412             modelMapper.map(aaiCloudRegion, cloudRegion);
413         return cloudRegion;
414     }
415
416     protected Tenant mapTenant(org.onap.aai.domain.yang.Tenant aaiTenant) {
417         Tenant tenant = new Tenant();
418         if (aaiTenant != null) {
419             modelMapper.map(aaiTenant, tenant);
420         }
421         return tenant;
422     }
423
424     protected Collection mapAAICollectionIntoCollection(org.onap.aai.domain.yang.Collection aaiCollection) {
425         Collection collection = new Collection();
426         collection.setId(aaiCollection.getCollectionId());
427         collection.setOrchestrationStatus(this.mapOrchestrationStatusFromAAI(aaiCollection.getOrchestrationStatus()));
428         return collection;
429     }
430
431     protected org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup mapAAIInstanceGroupIntoInstanceGroup(
432             org.onap.aai.domain.yang.InstanceGroup aaiInstanceGroup) {
433         return modelMapper.map(aaiInstanceGroup, org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup.class);
434     }
435
436     public RouteTableReference mapAAIRouteTableReferenceIntoRouteTableReference(
437             org.onap.aai.domain.yang.RouteTableReference aaiRouteTableReference) {
438         return modelMapper.map(aaiRouteTableReference, RouteTableReference.class);
439     }
440
441     protected ModelInfoNetwork mapCatalogNetworkToNetwork(NetworkResourceCustomization networkResourceCustomization) {
442         modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
443         ModelInfoNetwork modelInfoNetwork = modelMapper.map(networkResourceCustomization, ModelInfoNetwork.class);
444         modelMapper.map(networkResourceCustomization.getNetworkResource(), modelInfoNetwork);
445         modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STANDARD);
446         return modelInfoNetwork;
447     }
448
449     protected ModelInfoGenericVnf mapCatalogVnfToVnf(VnfResourceCustomization vnfResourceCustomization) {
450         ModelInfoGenericVnf modelInfoVnf = modelMapper.map(vnfResourceCustomization, ModelInfoGenericVnf.class);
451         modelMapper.map(vnfResourceCustomization.getVnfResources(), modelInfoVnf);
452         return modelInfoVnf;
453     }
454
455     protected ModelInfoVfModule mapCatalogVfModuleToVfModule(VfModuleCustomization vfResourceCustomization) {
456         ModelInfoVfModule modelInfoVfModule = modelMapper.map(vfResourceCustomization, ModelInfoVfModule.class);
457         modelMapper.map(vfResourceCustomization.getVfModule(), modelInfoVfModule);
458         return modelInfoVfModule;
459     }
460
461     protected Platform mapRequestPlatform(org.onap.so.serviceinstancebeans.Platform platform) {
462         return modelMapper.map(platform, Platform.class);
463     }
464
465     protected LineOfBusiness mapRequestLineOfBusiness(org.onap.so.serviceinstancebeans.LineOfBusiness lineOfBusiness) {
466         return modelMapper.map(lineOfBusiness, LineOfBusiness.class);
467     }
468
469     public Configuration mapAAIConfiguration(org.onap.aai.domain.yang.Configuration configurationAAI) {
470         modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
471         Configuration configuration = modelMapper.map(configurationAAI, Configuration.class);
472         modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STANDARD);
473         configuration.getForwarderEvcs().addAll(mapAllForwarderEvcs(configurationAAI));
474         configuration.getEvcs().addAll(mapAllEvcs(configurationAAI));
475         configuration
476                 .setOrchestrationStatus(this.mapOrchestrationStatusFromAAI(configurationAAI.getOrchestrationStatus()));
477         return configuration;
478     }
479
480     protected List<Evc> mapAllEvcs(org.onap.aai.domain.yang.Configuration configurationAAI) {
481         List<Evc> listOfEvcs = new ArrayList<>();
482         if (configurationAAI.getEvcs() != null) {
483             for (org.onap.aai.domain.yang.Evc aaiEvc : configurationAAI.getEvcs().getEvc()) {
484                 listOfEvcs.add(mapEvc(aaiEvc));
485             }
486         }
487         return listOfEvcs;
488     }
489
490     protected Evc mapEvc(org.onap.aai.domain.yang.Evc aaiEvc) {
491         return modelMapper.map(aaiEvc, Evc.class);
492     }
493
494     protected List<ForwarderEvc> mapAllForwarderEvcs(org.onap.aai.domain.yang.Configuration configurationAAI) {
495         List<ForwarderEvc> listOfForwarderEvcs = new ArrayList<>();
496         if (configurationAAI.getForwarderEvcs() != null) {
497             for (org.onap.aai.domain.yang.ForwarderEvc aaiForwarderEvc : configurationAAI.getForwarderEvcs()
498                     .getForwarderEvc()) {
499                 listOfForwarderEvcs.add(mapForwarderEvc(aaiForwarderEvc));
500             }
501         }
502         return listOfForwarderEvcs;
503     }
504
505     protected ForwarderEvc mapForwarderEvc(org.onap.aai.domain.yang.ForwarderEvc aaiForwarderEvc) {
506         return modelMapper.map(aaiForwarderEvc, ForwarderEvc.class);
507     }
508
509     protected OwningEntity mapRequestOwningEntity(org.onap.so.serviceinstancebeans.OwningEntity owningEntity) {
510         return modelMapper.map(owningEntity, OwningEntity.class);
511     }
512
513     protected Project mapRequestProject(org.onap.so.serviceinstancebeans.Project project) {
514         return modelMapper.map(project, Project.class);
515     }
516
517     protected ModelInfoConfiguration mapCatalogConfigurationToConfiguration(
518             ConfigurationResourceCustomization configurationResourceCustomization,
519             CvnfcConfigurationCustomization cvnfcConfigurationCustomization) {
520         ModelInfoConfiguration modelInfoConfiguration = new ModelInfoConfiguration();
521         modelInfoConfiguration
522                 .setModelVersionId(configurationResourceCustomization.getConfigurationResource().getModelUUID());
523         modelInfoConfiguration.setModelCustomizationId(configurationResourceCustomization.getModelCustomizationUUID());
524         modelInfoConfiguration.setModelInvariantId(
525                 configurationResourceCustomization.getConfigurationResource().getModelInvariantUUID());
526         modelInfoConfiguration.setPolicyName(cvnfcConfigurationCustomization.getPolicyName());
527         return modelInfoConfiguration;
528     }
529
530     protected ModelInfoConfiguration mapCatalogConfigurationToConfiguration(
531             CvnfcConfigurationCustomization cvnfcConfigurationCustomization) {
532         ModelInfoConfiguration modelInfoConfiguration = new ModelInfoConfiguration();
533         modelInfoConfiguration
534                 .setModelVersionId(cvnfcConfigurationCustomization.getConfigurationResource().getModelUUID());
535         modelInfoConfiguration.setModelCustomizationId(cvnfcConfigurationCustomization.getModelCustomizationUUID());
536         modelInfoConfiguration.setModelInvariantId(
537                 cvnfcConfigurationCustomization.getConfigurationResource().getModelInvariantUUID());
538         modelInfoConfiguration.setPolicyName(cvnfcConfigurationCustomization.getPolicyName());
539         modelInfoConfiguration.setConfigurationType(cvnfcConfigurationCustomization.getConfigurationType());
540         modelInfoConfiguration.setConfigurationRole(cvnfcConfigurationCustomization.getConfigurationRole());
541         return modelInfoConfiguration;
542     }
543
544     public NetworkResourceCustomization mapCollectionNetworkResourceCustToNetworkResourceCust(
545             CollectionNetworkResourceCustomization collectionNetworkResourceCust) {
546         return modelMapper.map(collectionNetworkResourceCust, NetworkResourceCustomization.class);
547     }
548
549     public Vnfc mapAAIVnfc(org.onap.aai.domain.yang.Vnfc vnfcAAI) {
550         return modelMapper.map(vnfcAAI, Vnfc.class);
551     }
552 }