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

openmrs / openmrs-core / 15205088843

23 May 2025 07:43AM UTC coverage: 65.083% (+0.01%) from 65.069%
15205088843

push

github

rkorytkowski
TRUNK-6300: Adding Windows test, cleaning up logs, adjusting variable name

2 of 2 new or added lines in 2 files covered. (100.0%)

336 existing lines in 18 files now uncovered.

23379 of 35922 relevant lines covered (65.08%)

0.65 hits per line

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

94.29
/api/src/main/java/org/openmrs/GlobalProperty.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 javax.persistence.Cacheable;
13
import java.util.Date;
14

15
import org.codehaus.jackson.annotate.JsonIgnore;
16
import org.hibernate.annotations.Cache;
17
import org.hibernate.annotations.CacheConcurrencyStrategy;
18
import org.hibernate.envers.Audited;
19
import org.openmrs.customdatatype.CustomDatatype;
20
import org.openmrs.customdatatype.CustomDatatypeUtil;
21
import org.openmrs.customdatatype.CustomValueDescriptor;
22
import org.openmrs.customdatatype.SingleCustomValue;
23

24
/**
25
 * Global properties are simple key-value pairs persisted in the database GPs can be thought of as
26
 * something similar to environment variables used in operating systems.
27
 */
28
@Audited
29
@Cacheable
30
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
31
public class GlobalProperty extends BaseOpenmrsObject implements CustomValueDescriptor, SingleCustomValue<GlobalProperty> {
32
        
33
        private static final long serialVersionUID = 1L;
34
        
35
        private String property = "";
1✔
36
        
37
        private String propertyValue = "";
1✔
38
        
39
        private transient Object typedValue;
40
        
41
        // if true, indicates that setValue has been called, and we need to invoke CustomDatatype's save
42
        private boolean dirty = false;
1✔
43
        
44
        private String description = "";
1✔
45
        
46
        private String datatypeClassname;
47
        
48
        private String datatypeConfig;
49
        
50
        private String preferredHandlerClassname;
51
        
52
        private String handlerConfig;
53
        
54
        private User changedBy;
55
        
56
        private Date dateChanged;
57
        
58
        private Privilege viewPrivilege;
59
        
60
        private Privilege editPrivilege;
61
        
62
        private Privilege deletePrivilege;
63
        
64
        
65
        /**
66
         * Default empty constructor
67
         */
68
        public GlobalProperty() {
1✔
69
        }
1✔
70
        
71
        /**
72
         * Constructor defining the key for this GP
73
         *
74
         * @param property key to name the property
75
         */
76
        public GlobalProperty(String property) {
1✔
77
                this.property = property;
1✔
78
        }
1✔
79
        
80
        /**
81
         * Constructor defining the key and value of this GP
82
         *
83
         * @param property key to name the property
84
         * @param value value to give to the property
85
         */
86
        public GlobalProperty(String property, String value) {
87
                this(property);
1✔
88
                this.propertyValue = value;
1✔
89
        }
1✔
90
        
91
        /**
92
         * Constructor defining key/value/description for this GP
93
         *
94
         * @param property key to name the property
95
         * @param value value to give to the property
96
         * @param description description of how this property is used
97
         */
98
        public GlobalProperty(String property, String value, String description) {
99
                this(property, value);
1✔
100
                this.description = description;
1✔
101
        }
1✔
102
        
103
        /**
104
         * Constructor defining key/value/description/customDatatype/datatypeConfig
105
         *
106
         * @param property
107
         * @param value
108
         * @param description
109
         * @param datatypeClass
110
         * @param datatypeConfig
111
         *
112
         * @since 1.9
113
         */
114
        public GlobalProperty(String property, String value, String description,
115
            Class<? extends CustomDatatype<?>> datatypeClass, String datatypeConfig) {
116
                this(property, value, description);
1✔
117
                this.datatypeClassname = datatypeClass.getName();
1✔
118
                this.datatypeConfig = datatypeConfig;
1✔
119
        }
1✔
120
        
121
        /**
122
         * @return Returns the property.
123
         */
124
        public String getProperty() {
125
                return property;
1✔
126
        }
127
        
128
        /**
129
         * @param property The property to set.
130
         */
131
        public void setProperty(String property) {
132
                this.property = property;
1✔
133
        }
1✔
134
        
135
        /**
136
         * @return Returns the propertyValue.
137
         */
138
        public String getPropertyValue() {
139
                return propertyValue;
1✔
140
        }
141
        
142
        /**
143
         * @param propertyValue The propertyValue to set.
144
         */
145
        public void setPropertyValue(String propertyValue) {
146
                this.propertyValue = propertyValue;
1✔
147
        }
1✔
148
        
149
        /**
150
         * @return the description
151
         */
152
        public String getDescription() {
153
                return description;
1✔
154
        }
155
        
156
        /**
157
         * @param description the description to set
158
         */
159
        public void setDescription(String description) {
160
                this.description = description;
1✔
161
        }
1✔
162
        
163
        /**
164
         * @since 1.5
165
         * @see org.openmrs.OpenmrsObject#getId()
166
         */
167
        @Override
168
        public Integer getId() {
UNCOV
169
                throw new UnsupportedOperationException();
×
170
        }
171
        
172
        /**
173
         * @since 1.5
174
         * @see org.openmrs.OpenmrsObject#setId(java.lang.Integer)
175
         */
176
        @Override
177
        public void setId(Integer id) {
UNCOV
178
                throw new UnsupportedOperationException();
×
179
        }
180
        
181
        /**
182
         * @see org.openmrs.customdatatype.CustomValueDescriptor#getDatatypeClassname()
183
         * @since 1.9
184
         */
185
        @Override
186
        public String getDatatypeClassname() {
187
                return datatypeClassname;
1✔
188
        }
189
        
190
        /**
191
         * @param datatypeClassname the datatypeClassname to set
192
         * @since 1.9
193
         */
194
        public void setDatatypeClassname(String datatypeClassname) {
195
                this.datatypeClassname = datatypeClassname;
1✔
196
        }
1✔
197
        
198
        /**
199
         * @see org.openmrs.customdatatype.CustomValueDescriptor#getDatatypeConfig()
200
         * @since 1.9
201
         */
202
        @Override
203
        public String getDatatypeConfig() {
204
                return datatypeConfig;
1✔
205
        }
206
        
207
        /**
208
         * @param datatypeConfig the datatypeConfig to set
209
         * @since 1.9
210
         */
211
        public void setDatatypeConfig(String datatypeConfig) {
212
                this.datatypeConfig = datatypeConfig;
1✔
213
        }
1✔
214
        
215
        /**
216
         * @see org.openmrs.customdatatype.CustomValueDescriptor#getPreferredHandlerClassname()
217
         * @since 1.9
218
         */
219
        @Override
220
        public String getPreferredHandlerClassname() {
221
                return preferredHandlerClassname;
1✔
222
        }
223
        
224
        /**
225
         * @param preferredHandlerClassname the preferredHandlerClassname to set
226
         * @since 1.9
227
         */
228
        public void setPreferredHandlerClassname(String preferredHandlerClassname) {
229
                this.preferredHandlerClassname = preferredHandlerClassname;
1✔
230
        }
1✔
231
        
232
        /**
233
         * @see org.openmrs.customdatatype.CustomValueDescriptor#getHandlerConfig()
234
         * @since 1.9
235
         */
236
        @Override
237
        public String getHandlerConfig() {
238
                return handlerConfig;
1✔
239
        }
240
        
241
        /**
242
         * @param handlerConfig the handlerConfig to set
243
         * @since 1.9
244
         */
245
        public void setHandlerConfig(String handlerConfig) {
246
                this.handlerConfig = handlerConfig;
1✔
247
        }
1✔
248
        
249
        /**
250
         * @see java.lang.Object#toString()
251
         */
252
        @Override
253
        public String toString() {
UNCOV
254
                return "property: " + getProperty() + " value: " + getPropertyValue();
×
255
        }
256
        
257
        /**
258
         * @see org.openmrs.customdatatype.SingleCustomValue#getDescriptor()
259
         *
260
         * @since 1.9
261
         */
262
        @Override
263
        public GlobalProperty getDescriptor() {
264
                return this;
1✔
265
        }
266
        
267
        /**
268
         * @see org.openmrs.customdatatype.SingleCustomValue#getValueReference()
269
         *
270
         * @since 1.9
271
         */
272
        @Override
273
        public String getValueReference() {
274
                return getPropertyValue();
1✔
275
        }
276
        
277
        /**
278
         * @see org.openmrs.customdatatype.SingleCustomValue#setValueReferenceInternal(java.lang.String)
279
         *
280
         * @since 1.9
281
         */
282
        @Override
283
        public void setValueReferenceInternal(String valueToPersist) {
284
                setPropertyValue(valueToPersist);
1✔
285
        }
1✔
286
        
287
        /**
288
         * @see org.openmrs.customdatatype.SingleCustomValue#getValue()
289
         *
290
         * @since 1.9
291
         */
292
        @Override
293
        public Object getValue() {
294
                if (typedValue == null) {
1✔
UNCOV
295
                        typedValue = CustomDatatypeUtil.getDatatypeOrDefault(this).fromReferenceString(getValueReference());
×
296
                }
297
                return typedValue;
1✔
298
        }
299
        
300
        /**
301
         * @see org.openmrs.customdatatype.SingleCustomValue#setValue(java.lang.Object)
302
         *
303
         * @since 1.9
304
         */
305
        @Override
306
        public <T> void setValue(T typedValue){
307
                this.typedValue = typedValue;
1✔
308
                dirty = true;
1✔
309
        }
1✔
310
        
311
        /**
312
         * @see org.openmrs.customdatatype.SingleCustomValue#isDirty()
313
         *
314
         * @deprecated as of 2.0, use {@link #getDirty()}
315
         */
316
        @Deprecated
317
        @JsonIgnore
318
        @Override
319
        public boolean isDirty() {
320
                return getDirty();
1✔
321
        }
322
        
323
        public boolean getDirty() {
324
                return dirty;
1✔
325
        }
326
        
327
        /**
328
         * @return Returns the changedBy.
329
         */
330
        public User getChangedBy() {
331
                return changedBy;
1✔
332
        }
333
        
334
        /**
335
         * @param changedBy The user that changed this object
336
         */
337
        public void setChangedBy(User changedBy) {
338
                this.changedBy = changedBy;
1✔
339
        }
1✔
340
        
341
        /**
342
         * @return Returns the date this object was changed
343
         */
344
        public Date getDateChanged() {
345
                return dateChanged;
1✔
346
        }
347
        
348
        /**
349
         * @param dateChanged The date this object was changed
350
         */
351
        public void setDateChanged(Date dateChanged) {
352
                this.dateChanged = dateChanged;
1✔
353
        }
1✔
354

355
        /**
356
         * Gets privilege which can view this globalProperty
357
         * @return the viewPrivilege the privilege instance
358
         * 
359
         * @since 2.7.0
360
         */
361
        public Privilege getViewPrivilege() {
362
                return viewPrivilege;
1✔
363
        }
364

365
        /**
366
         * Sets privilege which can view this globalProperty
367
         * @param viewPrivilege the viewPrivilege to set
368
         *                      
369
         * @since 2.7.0
370
         */
371
        public void setViewPrivilege(Privilege viewPrivilege) {
372
                this.viewPrivilege = viewPrivilege;
1✔
373
        }
1✔
374

375
        /**
376
         * Gets privilege which can edit this globalProperty
377
         * @return the editPrivilege the privilege instance
378
         * 
379
         * @since 2.7.0
380
         */
381
        public Privilege getEditPrivilege() {
382
                return editPrivilege;
1✔
383
        }
384

385
        /**
386
         * Sets privilege which can edit this globalProperty
387
         * @param editPrivilege the editPrivilege to set
388
         *                      
389
         * @since 2.7.0
390
         */
391
        public void setEditPrivilege(Privilege editPrivilege) {
392
                this.editPrivilege = editPrivilege;
1✔
393
        }
1✔
394

395
        /**
396
         * Get privilege which can delete this globalProperty
397
         * @return the deletePrivilege the privilege instance
398
         *
399
         * @since 2.7.0
400
         */
401
        public Privilege getDeletePrivilege() {
402
                return deletePrivilege;
1✔
403
        }
404

405
        /**
406
         * Sets privilege which can delete this globalProperty
407
         * @param deletePrivilege the deletePrivilege to set
408
         *
409
         * @since 2.7.0
410
         */
411
        public void setDeletePrivilege(Privilege deletePrivilege) {
412
                this.deletePrivilege = deletePrivilege;
1✔
413
        }
1✔
414
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc