Removed MsoLogger class
[so.git] / bpmn / so-bpmn-tasks / src / main / java / org / onap / so / bpmn / infrastructure / flowspecific / tasks / NetworkBBUtils.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.so.bpmn.infrastructure.flowspecific.tasks;
22
23 import java.util.List;
24 import java.util.Optional;
25
26 import org.onap.so.bpmn.common.BuildingBlockExecution;
27 import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
28 import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock;
29 import org.springframework.stereotype.Component;
30
31 @Component
32 public class NetworkBBUtils {   
33         
34         private static final String CLOUD_REGION_VER25 = "2.5"; 
35         private static final String CLOUD_REGION_AAIAIC25 = "AAIAIC25";
36         
37         /**
38          * BPMN access method to check if Relationship's Related-To value exists.
39          * 
40          * @param l3Network - L3Network object
41          * @param relatedToValue - String, ex: 'vf-module'
42          * @return boolean
43          */
44         public boolean isRelationshipRelatedToExists(Optional<org.onap.aai.domain.yang.L3Network> l3network, String relatedToValue) {
45                 boolean isRelatedToExists = false;
46                 if (l3network.isPresent()) {
47                         List<org.onap.aai.domain.yang.Relationship> relationshipList = l3network.get().getRelationshipList().getRelationship();
48                         for (org.onap.aai.domain.yang.Relationship relationship : relationshipList) {
49                             if (relationship.getRelatedTo().equals(relatedToValue)) { 
50                                 isRelatedToExists = true; 
51                                 break; 
52                             }
53                         }
54                 }
55                 return isRelatedToExists;
56         }
57         
58         /**
59          * BPMN access method to extract Cloud Region data
60          * @param execution
61          * @param motsValue (ex: SourceSystem.SDNC or SourceSystem.PO)
62          */
63         public String getCloudRegion(BuildingBlockExecution execution, SourceSystem sourceValue) {
64                 GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
65                 CloudRegion cloudRegion = gBBInput.getCloudRegion();
66                 String cloudRegionId = cloudRegion.getLcpCloudRegionId();
67                 if (sourceValue.equals(SourceSystem.SDNC) && CLOUD_REGION_VER25.equalsIgnoreCase(cloudRegion.getCloudRegionVersion())) { 
68                         cloudRegionId = CLOUD_REGION_AAIAIC25;
69                 }
70                 return cloudRegionId;
71         }
72                 
73         
74 }