Removed MSB Invocation During AAI Calling
[holmes/common.git] / holmes-actions / src / main / java / org / onap / holmes / common / aai / entity / RelationshipList.java
1 /**
2  * Copyright 2017-2023 ZTE Corporation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 package org.onap.holmes.common.aai.entity;
18
19 import lombok.Getter;
20 import lombok.Setter;
21
22 import java.util.List;
23
24 @Setter
25 @Getter
26 public class RelationshipList {
27
28     private List<Relationship> relationships;
29
30     public Relationship getRelationship(String relatedTo) {
31         Relationship relationship = null;
32         if(null == relationships || relationships.isEmpty())
33             return  relationship;
34         for(int i = 0; i < relationships.size(); i++) {
35             if (relatedTo.equals(relationships.get(i).getRelatedTo())) {
36                 relationship = relationships.get(i);
37                 break;
38             }
39         }
40         return relationship;
41     }
42
43     @Setter
44     @Getter
45     public static class Relationship {
46         private String relatedLink;
47         private String relatedTo;
48         private List<RelatedToProperty> relatedToPropertyList;
49         private List<RelationshipData> relationshipDataList;
50
51         public String getRelatedToPropertyValue(String key) {
52             String value = "";
53             if (null == relatedToPropertyList || relatedToPropertyList.isEmpty()) {
54                 return "";
55             }
56             for(int i = 0; i < relatedToPropertyList.size(); i++) {
57                 if (key.equals(relatedToPropertyList.get(i).getPropertyKey())) {
58                     value = relatedToPropertyList.get(i).getPropertyValue();
59                     break;
60                 }
61             }
62             return value;
63         }
64
65         public String getRelationshipDataValue(String key) {
66             String value = "";
67             if (null == relationshipDataList || relationshipDataList.isEmpty()) {
68                 return "";
69             }
70             for(int i = 0; i < relationshipDataList.size(); i++) {
71                 if (key.equals(relationshipDataList.get(i).getRelationshipKey())) {
72                     value = relationshipDataList.get(i).getRelationshipValue();
73                     break;
74                 }
75             }
76             return value;
77         }
78     }
79
80     @Setter
81     @Getter
82     public static class RelationshipData {
83         private String relationshipKey;
84         private String relationshipValue;
85     }
86
87     @Getter
88     @Setter
89     public static class RelatedToProperty {
90         private String propertyKey;
91         private String propertyValue;
92     }
93
94 }