• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

openmrs / openmrs-core / 31843719412

14 Aug 2026 09:43PM UTC coverage: 64.329% (+0.007%) from 64.322%
31843719412

push

github

ibacher
TRUNK-6717: Replace reflective BeanUtils property access with direct PersonName getters (#6431)

11 of 11 new or added lines in 1 file covered. (100.0%)

60 existing lines in 11 files now uncovered.

24629 of 38286 relevant lines covered (64.33%)

0.64 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

72.73
/api/src/main/java/org/openmrs/Relationship.java
1
/**
2
 * This Source Code Form is subject to the terms of the Mozilla Public License,
3
 * v. 2.0. If a copy of the MPL was not distributed with this file, You can
4
 * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under
5
 * the terms of the Healthcare Disclaimer located at http://openmrs.org/license.
6
 *
7
 * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS
8
 * graphic logo is a trademark of OpenMRS Inc.
9
 */
10
package org.openmrs;
11

12
import org.hibernate.annotations.GenericGenerator;
13
import org.hibernate.annotations.Parameter;
14
import org.hibernate.envers.Audited;
15

16
import javax.persistence.Column;
17
import javax.persistence.Entity;
18
import javax.persistence.FetchType;
19
import javax.persistence.GeneratedValue;
20
import javax.persistence.GenerationType;
21
import javax.persistence.Id;
22
import javax.persistence.JoinColumn;
23
import javax.persistence.ManyToOne;
24
import javax.persistence.Table;
25
import java.util.Date;
26

27
/**
28
 * Relationship
29
 */
30
@Entity
31
@Table(name = "relationship")
32
@Audited
33
public class Relationship extends BaseChangeableOpenmrsData {
34
        
35
        public static final long serialVersionUID = 323423L;
36
        
37
        // Fields
38
        @Id
39
        @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "relationship_id_seq")
40
        @GenericGenerator(
41
                name = "relationship_id_seq",
42
                strategy = "native",
43
                parameters = @Parameter(name = "sequence", value = "relationship_relationship_id_seq")
44
        )
45
        @Column(name = "relationship_id")
46
        private Integer relationshipId;
47
        @ManyToOne(optional = false, fetch = FetchType.LAZY)
48
        @JoinColumn(name = "person_a", nullable = false)
49
        private Person personA;
50

51
        @ManyToOne(optional = false, fetch = FetchType.LAZY)
52
        @JoinColumn(name = "relationship", nullable = false)
53
        private RelationshipType relationshipType;
54

55
        @ManyToOne(optional = false, fetch = FetchType.LAZY)
56
        @JoinColumn(name = "person_b", nullable = false)
57
        private Person personB;
58

59
        @Column(name = "start_date",length = 19)
60
        private Date startDate;
61
        @Column(name = "end_date", length = 19)
62
        private Date endDate;
63
        
64
        // Constructors
65
        
66
        /** default constructor */
67
        public Relationship() {
1 ✔
68
        }
1 ✔
69
        
70
        /** constructor with id */
71
        public Relationship(Integer relationshipId) {
1 ✔
72
                this.relationshipId = relationshipId;
1 ✔
73
        }
1 ✔
74
        
75
        public Relationship(Person personA, Person personB, RelationshipType type) {
×
76
                this.personA = personA;
×
77
                this.personB = personB;
×
78
                this.relationshipType = type;
×
UNCOV
79
        }
×
80
        
81
        /**
82
         * Does a shallow copy of this Relationship. Does NOT copy relationshipId
83
         * 
84
         * @return a copy of this relationship
85
         */
86
        public Relationship copy() {
87
                return copyHelper(new Relationship());
1 ✔
88
        }
89
        
90
        /**
91
         * The purpose of this method is to allow subclasses of Relationship to delegate a portion of
92
         * their copy() method back to the superclass, in case the base class implementation changes.
93
         * 
94
         * @param target a Relationship that will have the state of <code>this</code> copied into it
95
         * @return the Relationship that was passed in, with state copied into it
96
         */
97
        protected Relationship copyHelper(Relationship target) {
98
                target.personA = getPersonA();
1 ✔
99
                target.relationshipType = getRelationshipType();
1 ✔
100
                target.personB = getPersonB();
1 ✔
101
                target.setCreator(getCreator());
1 ✔
102
                target.setDateCreated(getDateCreated());
1 ✔
103
                target.setVoided(getVoided());
1 ✔
104
                target.setVoidedBy(getVoidedBy());
1 ✔
105
                target.setDateVoided(getDateVoided());
1 ✔
106
                target.setVoidReason(getVoidReason());
1 ✔
107
                return target;
1 ✔
108
        }
109
        
110
        // Property accessors
111
        
112
        /**
113
         * @return Returns the personA.
114
         */
115
        public Person getPersonA() {
116
                return personA;
1 ✔
117
        }
118
        
119
        /**
120
         * @param personA The person to set.
121
         */
122
        public void setPersonA(Person personA) {
123
                this.personA = personA;
1 ✔
124
        }
1 ✔
125
        
126
        /**
127
         * @return Returns the relationship type.
128
         */
129
        public RelationshipType getRelationshipType() {
130
                return relationshipType;
1 ✔
131
        }
132
        
133
        /**
134
         * @param type The relationship type to set.
135
         */
136
        public void setRelationshipType(RelationshipType type) {
137
                this.relationshipType = type;
1 ✔
138
        }
1 ✔
139
        
140
        /**
141
         * @return Returns the relationshipId.
142
         */
143
        public Integer getRelationshipId() {
144
                return relationshipId;
1 ✔
145
        }
146
        
147
        /**
148
         * @param relationshipId The relationshipId to set.
149
         */
150
        public void setRelationshipId(Integer relationshipId) {
151
                this.relationshipId = relationshipId;
×
UNCOV
152
        }
×
153
        
154
        /**
155
         * @return Returns the personB.
156
         */
157
        public Person getPersonB() {
158
                return personB;
1 ✔
159
        }
160
        
161
        /**
162
         * @param personB The relative to set.
163
         */
164
        public void setPersonB(Person personB) {
165
                this.personB = personB;
1 ✔
166
        }
1 ✔
167
        
168
        /**
169
         * If not null, this indicates that the relationship started on a particular date
170
         * @since 1.9
171
         * @return the relationship's start date.
172
         */
173
        public Date getStartDate() {
174
                return this.startDate;
1 ✔
175
        }
176
        
177
        /**
178
         * @since 1.9
179
         * @param startDate relationship's start date.
180
         */
181
        public void setStartDate(Date startDate) {
182
                this.startDate = startDate;
1 ✔
183
        }
1 ✔
184
        
185
        /**
186
         * If not null, this indicates that the relationship ended on a particular date
187
         * @since 1.9
188
         * @return Returns relationship's end date.
189
         */
190
        public Date getEndDate() {
191
                return this.endDate;
1 ✔
192
        }
193
        
194
        /**
195
         * @since 1.9
196
         * @param endDate relationship's end date.
197
         */
198
        public void setEndDate(Date endDate) {
199
                this.endDate = endDate;
1 ✔
200
        }
1 ✔
201
        
202
        @Override
203
        public String toString() {
204
                String relType = getRelationshipType() == null ? "NULL" : getRelationshipType().getaIsToB();
×
UNCOV
205
                return personA + " is the " + relType + " of " + personB;
×
206
        }
207
        
208
        /**
209
         * @since 1.5
210
         * @see org.openmrs.OpenmrsObject#getId()
211
         */
212
        @Override
213
        public Integer getId() {
214
                
UNCOV
215
                return getRelationshipId();
×
216
        }
217
        
218
        /**
219
         * @since 1.5
220
         * @see org.openmrs.OpenmrsObject#setId(java.lang.Integer)
221
         */
222
        @Override
223
        public void setId(Integer id) {
UNCOV
224
                setRelationshipId(id);
×
225
                
UNCOV
226
        }
×
227
        
228
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc