re base code
[sdc.git] / catalog-model / src / main / java / org / openecomp / sdc / be / model / RelationshipInfo.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2017 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.openecomp.sdc.be.model;
22
23 import org.openecomp.sdc.be.datatypes.elements.RelationshipInstDataDefinition;
24
25 public class RelationshipInfo {
26
27     private String requirement;
28     private String capabilityOwnerId;
29     private String requirementOwnerId;
30     private String id;
31
32     private RelationshipImpl relationship;
33
34     private String capability;
35
36     private String capabilityUid;
37     private String requirementUid;
38
39     public RelationshipInfo() {
40         super();
41     }
42
43     public RelationshipInfo(String requirement, RelationshipImpl relationship) {
44         super();
45         this.requirement = requirement;
46         this.relationship = relationship;
47     }
48
49     public RelationshipInfo(String requirement, RelationshipImpl relationship, String capability) {
50         super();
51         this.requirement = requirement;
52         this.relationship = relationship;
53         this.capability = capability;
54     }
55
56     public String getRequirement() {
57         return requirement;
58     }
59
60     public void setRequirement(String requirement) {
61         this.requirement = requirement;
62     }
63
64     public String getCapabilityOwnerId() {
65         return capabilityOwnerId;
66     }
67
68     public void setCapabilityOwnerId(String capabilityOwnerId) {
69         this.capabilityOwnerId = capabilityOwnerId;
70     }
71
72     public String getRequirementOwnerId() {
73         return requirementOwnerId;
74     }
75
76     public void setRequirementOwnerId(String requirementOwnerId) {
77         this.requirementOwnerId = requirementOwnerId;
78     }
79
80     public RelationshipImpl getRelationship() {
81         return relationship;
82     }
83
84     public void setRelationships(RelationshipImpl relationship) {
85         this.relationship = relationship;
86     }
87
88     public String getCapability() {
89         return capability;
90     }
91
92     public void setCapability(String capability) {
93         this.capability = capability;
94     }
95
96     public String getCapabilityUid() {
97         return capabilityUid;
98     }
99
100     public void setCapabilityUid(String capabilityUid) {
101         this.capabilityUid = capabilityUid;
102     }
103
104     public String getRequirementUid() {
105         return requirementUid;
106     }
107
108     public void setRequirementUid(String requirementUid) {
109         this.requirementUid = requirementUid;
110     }
111
112     public String getId() {
113         return id;
114     }
115
116     public void setId(String id) {
117         this.id = id;
118     }
119
120     @Override
121     public String toString() {
122         return "RequirementAndRelationshipPair [requirement=" + requirement + ", relationship=" + relationship
123                 + ", capability=" + capability + "]";
124     }
125
126     public boolean equalsTo( RelationshipInstDataDefinition savedRelation){
127         if ( savedRelation == null ){
128             return false;
129         }
130         if(getRelationship().getType() == null ){
131             if(savedRelation.getType() != null){
132                 return false;
133             }
134         }
135         else {
136             if ( !savedRelation.getType().equals(this.getRelationship().getType()) ){
137                 return false;
138             }
139         }
140         if ( !savedRelation.getCapabilityOwnerId().equals(this.getCapabilityOwnerId()) ){
141             return false;
142         }
143         if ( !savedRelation.getRequirementOwnerId().equals(this.getRequirementOwnerId()) ){
144             return false;
145         }
146         if ( !savedRelation.getRequirementId().equals(this.getRequirementUid()) ){
147             return false;
148         }
149         if ( !savedRelation.getCapabilityId().equals(this.getCapabilityUid()) ){
150             return false;
151         }
152         if ( !savedRelation.getRequirement().equals(this.getRequirement()) ){
153             return false;
154         }
155         return true;
156     }
157 }