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

openmrs / openmrs-core / 16392798112

19 Jul 2025 09:13PM UTC coverage: 65.246% (-0.005%) from 65.251%
16392798112

push

github

web-flow
maven(deps): bump org.hibernate.validator:hibernate-validator (#5141)

Bumps [org.hibernate.validator:hibernate-validator](https://github.com/hibernate/hibernate-validator) from 6.2.0.Final to 9.0.1.Final.
- [Changelog](https://github.com/hibernate/hibernate-validator/blob/9.0.1.Final/changelog.txt)
- [Commits](https://github.com/hibernate/hibernate-validator/compare/6.2.0.Final...9.0.1.Final)

---
updated-dependencies:
- dependency-name: org.hibernate.validator:hibernate-validator
  dependency-version: 9.0.1.Final
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

23572 of 36128 relevant lines covered (65.25%)

0.65 hits per line

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

76.92
/api/src/main/java/org/openmrs/ConceptName.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 java.util.Collection;
13
import java.util.Date;
14
import java.util.HashSet;
15
import java.util.Locale;
16

17
import org.apache.commons.lang3.StringUtils;
18
import org.codehaus.jackson.annotate.JsonIgnore;
19
import org.hibernate.envers.Audited;
20
import org.hibernate.search.mapper.pojo.bridge.mapping.annotation.ValueBridgeRef;
21
import org.hibernate.search.mapper.pojo.mapping.definition.annotation.DocumentId;
22
import org.hibernate.search.mapper.pojo.mapping.definition.annotation.FullTextField;
23
import org.hibernate.search.mapper.pojo.mapping.definition.annotation.GenericField;
24
import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed;
25
import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexedEmbedded;
26
import org.hibernate.search.mapper.pojo.mapping.definition.annotation.KeywordField;
27
import org.openmrs.api.ConceptNameType;
28
import org.openmrs.api.db.hibernate.search.SearchAnalysis;
29
import org.openmrs.api.db.hibernate.search.bridge.LocaleValueBridge;
30

31
/**
32
 * ConceptName is the real world term used to express a Concept within the idiom of a particular
33
 * locale.
34
 */
35
@Indexed
36
@Audited
37
public class ConceptName extends BaseOpenmrsObject implements Auditable, Voidable, java.io.Serializable {
38
        
39
        public static final long serialVersionUID = 2L;
40
        
41
        @DocumentId
42
        private Integer conceptNameId;
43
        
44
        @IndexedEmbedded(includeEmbeddedObjectId = true)
45
        private Concept concept;
46
        
47
        @FullTextField(analyzer = SearchAnalysis.NAME_ANALYZER)
48
        private String name;
49
        
50
        @KeywordField(valueBridge = @ValueBridgeRef(type = LocaleValueBridge.class))
51
        private Locale locale; 
52
        
53
        private User creator;
54
        
55
        private Date dateCreated;
56
        
57
        @GenericField
1✔
58
        private Boolean voided = false;
1✔
59
        
60
        private User voidedBy;
61
        
62
        private Date dateVoided;
63
        
64
        private String voidReason;
65
        
66
        private Collection<ConceptNameTag> tags;
67
        
68
        @GenericField
69
        private ConceptNameType conceptNameType;
70
        
71
        @GenericField
1✔
72
        private Boolean localePreferred = false;
1✔
73
        
74
        private User changedBy;
75
        
76
        private Date dateChanged;
77
        
78
        // Constructors
79
        
80
        /** default constructor */
81
        public ConceptName() {
1✔
82
        }
1✔
83
        
84
        /**
85
         * Convenience constructor to create a ConceptName object by primary key
86
         *
87
         * @param conceptNameId
88
         */
89
        public ConceptName(Integer conceptNameId) {
1✔
90
                this.conceptNameId = conceptNameId;
1✔
91
        }
1✔
92
        
93
        public ConceptName(String name, Locale locale) {
1✔
94
                setName(name);
1✔
95
                setLocale(locale);
1✔
96
        }
1✔
97
        
98
        /**
99
         * @return Returns the conceptId.
100
         */
101
        public Integer getConceptNameId() {
102
                return conceptNameId;
1✔
103
        }
104
        
105
        /**
106
         * @param conceptNameId The conceptId to set.
107
         */
108
        public void setConceptNameId(Integer conceptNameId) {
109
                this.conceptNameId = conceptNameId;
1✔
110
        }
1✔
111
        
112
        public Concept getConcept() {
113
                return concept;
1✔
114
        }
115
        
116
        public void setConcept(Concept concept) {
117
                this.concept = concept;
1✔
118
        }
1✔
119
        
120
        public String getName() {
121
                return name;
1✔
122
        }
123
        
124
        public void setName(String name) {
125
                if (name != null && StringUtils.isBlank(name) && StringUtils.isNotBlank(this.name)
1✔
126
                        && this.getConceptNameType().equals(ConceptNameType.SHORT)) {
×
127
                        this.setVoided(true);
×
128
                } else {
129
                        this.name = name;
1✔
130
                }
131
        }
1✔
132
        
133
        public Locale getLocale() {
134
                return locale;
1✔
135
        }
136
        
137
        public void setLocale(Locale locale) {
138
                this.locale = locale;
1✔
139
        }
1✔
140

141
        /**
142
         * @return Returns the creator.
143
         */
144
        @Override
145
        public User getCreator() {
146
                return creator;
1✔
147
        }
148
        
149
        /**
150
         * @param creator The creator to set.
151
         */
152
        @Override
153
        public void setCreator(User creator) {
154
                this.creator = creator;
1✔
155
        }
1✔
156
        
157
        /**
158
         * @return Returns the dateCreated.
159
         */
160
        @Override
161
        public Date getDateCreated() {
162
                return dateCreated;
1✔
163
        }
164
        
165
        /**
166
         * @param dateCreated The dateCreated to set.
167
         */
168
        @Override
169
        public void setDateCreated(Date dateCreated) {
170
                this.dateCreated = dateCreated;
1✔
171
        }
1✔
172
        
173
        /**
174
         * Returns whether the ConceptName has been voided.
175
         *
176
         * @return true if the ConceptName has been voided, false otherwise.
177
         * 
178
         * @deprecated as of 2.0, use {@link #getVoided()}
179
         */
180
        @Override
181
        @Deprecated
182
        @JsonIgnore
183
        public Boolean isVoided() {
184
                return getVoided();
×
185
        }
186
        
187
        /**
188
         * Returns whether the ConceptName has been voided.
189
         *
190
         * @return true if the ConceptName has been voided, false otherwise.
191
         */
192
        @Override
193
        public Boolean getVoided() {
194
                return voided;
1✔
195
        }
196
        
197
        /**
198
         * Sets the voided status of this ConceptName.
199
         *
200
         * @param voided the voided status to set.
201
         */
202
        @Override
203
        public void setVoided(Boolean voided) {
204
                this.voided = voided;
1✔
205
        }
1✔
206
        
207
        /**
208
         * Returns the User who voided this ConceptName.
209
         *
210
         * @return the User who voided this ConceptName, or null if not set
211
         */
212
        @Override
213
        public User getVoidedBy() {
214
                return voidedBy;
1✔
215
        }
216
        
217
        /**
218
         * Sets the User who voided this ConceptName.
219
         *
220
         * @param voidedBy the user who voided this ConceptName.
221
         */
222
        @Override
223
        public void setVoidedBy(User voidedBy) {
224
                this.voidedBy = voidedBy;
1✔
225
        }
1✔
226
        
227
        /**
228
         * Returns the Date this ConceptName was voided.
229
         *
230
         * @return the Date this ConceptName was voided.
231
         */
232
        @Override
233
        public Date getDateVoided() {
234
                return dateVoided;
1✔
235
        }
236
        
237
        /**
238
         * Sets the Data this ConceptName was voided.
239
         *
240
         * @param dateVoided the date the ConceptName was voided.
241
         */
242
        @Override
243
        public void setDateVoided(Date dateVoided) {
244
                this.dateVoided = dateVoided;
1✔
245
        }
1✔
246
        
247
        /**
248
         * Returns the reason this ConceptName was voided.
249
         *
250
         * @return the reason this ConceptName was voided
251
         */
252
        @Override
253
        public String getVoidReason() {
254
                return voidReason;
1✔
255
        }
256
        
257
        /**
258
         * Sets the reason this ConceptName was voided.
259
         *
260
         * @param voidReason the reason this ConceptName was voided
261
         */
262
        @Override
263
        public void setVoidReason(String voidReason) {
264
                this.voidReason = voidReason;
1✔
265
        }
1✔
266
        
267
        /**
268
         * Returns the tags which have been attached to this ConceptName.
269
         *
270
         * @return the tags.
271
         */
272
        public Collection<ConceptNameTag> getTags() {
273
                return tags;
1✔
274
        }
275
        
276
        /**
277
         * Set the tags which are attached to this ConceptName.
278
         *
279
         * @see Concept#setPreferredName(ConceptName)
280
         * @see Concept#setFullySpecifiedName(ConceptName)
281
         * @see Concept#setShortName(ConceptName)
282
         * @param tags the tags to set.
283
         */
284
        public void setTags(Collection<ConceptNameTag> tags) {
285
                this.tags = tags;
1✔
286
        }
1✔
287
        
288
        /**
289
         * @return the conceptNameType
290
         */
291
        public ConceptNameType getConceptNameType() {
292
                return this.conceptNameType;
1✔
293
        }
294
        
295
        /**
296
         * @param conceptNameType the conceptNameType to set
297
         */
298
        public void setConceptNameType(ConceptNameType conceptNameType) {
299
                this.conceptNameType = conceptNameType;
1✔
300
        }
1✔
301
        
302
        /**
303
         * Getter for localePreferred
304
         *
305
         * @return localPreferred
306
         * 
307
         * @deprecated as of 2.0, use {@link #getLocalePreferred()}
308
         */
309
        @Deprecated
310
        @JsonIgnore
311
        public Boolean isLocalePreferred() {
312
                return getLocalePreferred();
1✔
313
        }
314
        
315
        /**
316
         *
317
         * @return true if it is the localePreferred name otherwise false
318
         */
319
        public Boolean getLocalePreferred() {
320
                return localePreferred;
1✔
321
        }
322
        
323
        /**
324
         * @param localePreferred the localePreferred to set
325
         */
326
        public void setLocalePreferred(Boolean localePreferred) {
327
                this.localePreferred = localePreferred;
1✔
328
        }
1✔
329
        
330
        /**
331
         * Adds a tag to the concept name. If the tag is new (has no existing occurrences) a new
332
         * ConceptNameTag will be created with a blank description.
333
         *
334
         * @see Concept#setPreferredName(ConceptName)
335
         * @see Concept#setFullySpecifiedName(ConceptName)
336
         * @see Concept#setShortName(ConceptName)
337
         * @param tag human-readable text string for the tag
338
         */
339
        public void addTag(String tag) {
340
                addTag(tag, "");
1✔
341
        }
1✔
342
        
343
        /**
344
         * Adds a tag to the concept name. If the tag is new (has no existing occurrences) a new
345
         * ConceptNameTag will be created with the given description.
346
         *
347
         * @see Concept#setPreferredName(ConceptName)
348
         * @see Concept#setFullySpecifiedName(ConceptName)
349
         * @see Concept#setShortName(ConceptName)
350
         * @param tag human-readable text string for the tag
351
         * @param description description of the tag's purpose
352
         */
353
        public void addTag(String tag, String description) {
354
                ConceptNameTag nameTag = new ConceptNameTag(tag, description);
1✔
355
                addTag(nameTag);
1✔
356
        }
1✔
357
        
358
        /**
359
         * Attaches a tag to the concept name.
360
         *
361
         * @see Concept#setPreferredName(ConceptName)
362
         * @see Concept#setFullySpecifiedName(ConceptName)
363
         * @see Concept#setShortName(ConceptName)
364
         * @param tag the tag to add
365
         */
366
        public void addTag(ConceptNameTag tag) {
367
                if (tags == null) {
1✔
368
                        tags = new HashSet<>();
1✔
369
                }
370
                
371
                if (!tags.contains(tag)) {
1✔
372
                        tags.add(tag);
1✔
373
                }
374
        }
1✔
375
        
376
        /**
377
         * Removes a tag from the concept name.
378
         *
379
         * @see Concept#setPreferredName(ConceptName)
380
         * @see Concept#setFullySpecifiedName(ConceptName)
381
         * @see Concept#setShortName(ConceptName)
382
         * @param tag the tag to remove
383
         */
384
        public void removeTag(ConceptNameTag tag) {
385
                if (tags.contains(tag)) {
×
386
                        tags.remove(tag);
×
387
                }
388
        }
×
389
        
390
        /**
391
         * Checks whether the name has a particular tag.
392
         *
393
         * @see #isPreferred()
394
         * @see #isFullySpecifiedName()
395
         * @see #isIndexTerm()
396
         * @see #isSynonym()
397
         * @see #isShort()
398
         * @param tagToFind the tag for which to check
399
         * @return true if the tags include the specified tag, false otherwise
400
         */
401
        public Boolean hasTag(ConceptNameTag tagToFind) {
402
                return hasTag(tagToFind.getTag());
×
403
        }
404
        
405
        /**
406
         * Checks whether the name has a particular tag.
407
         *
408
         * @see #isPreferred()
409
         * @see #isFullySpecifiedName()
410
         * @see #isIndexTerm()
411
         * @see #isSynonym()
412
         * @see #isShort()
413
         * @param tagToFind the string of the tag for which to check
414
         * @return true if the tags include the specified tag, false otherwise
415
         */
416
        public Boolean hasTag(String tagToFind) {
417
                boolean foundTag = false;
×
418
                if (tags != null) {
×
419
                        for (ConceptNameTag nameTag : getTags()) {
×
420
                                if (nameTag.getTag().equals(tagToFind)) {
×
421
                                        foundTag = true;
×
422
                                        break;
×
423
                                }
424
                        }
×
425
                }
426
                return foundTag;
×
427
        }
428
        
429
        /**
430
         * Checks whether the name is explicitly marked as preferred in a locale with a matching
431
         * language. E.g 'en_US' and 'en_UK' for language en
432
         *
433
         * @see #isPreferredForLocale(Locale)
434
         * @param language ISO 639 2-letter code for a language
435
         * @return true if the name is preferred in a locale with a matching language code, otherwise
436
         *         false
437
         */
438
        public Boolean isPreferredInLanguage(String language) {
439
                return !StringUtils.isBlank(language) && this.locale != null && isPreferred()
×
440
                                && this.locale.getLanguage().equals(language);
×
441

442
        }
443
        
444
        /**
445
         * Checks whether the name is explicitly marked as preferred in a locale with a matching country
446
         * code E.g 'fr_RW' and 'en_RW' for country RW
447
         *
448
         * @see #isPreferredForLocale(Locale)
449
         * @param country ISO 3166 2-letter code for a country
450
         * @return true if the name is preferred in a locale with a matching country code, otherwise
451
         *         false
452
         */
453
        public Boolean isPreferredInCountry(String country) {
454
                return !StringUtils.isBlank(country) && this.locale != null && isPreferred()
×
455
                                && this.locale.getCountry().equals(country);
×
456

457
        }
458
        
459
        /**
460
         * Checks whether the name is explicitly marked as preferred for any locale. Note that this
461
         * method is different from {@link #isPreferredForLocale(Locale)} in that it checks if the given
462
         * name is marked as preferred irrespective of the locale in which it is preferred.
463
         *
464
         * @see #isPreferredForLocale(Locale)
465
         */
466
        public Boolean isPreferred() {
467
                return getLocalePreferred();
1✔
468
        }
469
        
470
        /**
471
         * Checks whether the name is explicitly marked as preferred for the given locale
472
         *
473
         * @param locale the locale in which the name is preferred
474
         * @return true if the name is marked as preferred for the given locale otherwise false.
475
         */
476
        public Boolean isPreferredForLocale(Locale locale) {
477
                return getLocalePreferred() && this.locale.equals(locale);
×
478
        }
479
        
480
        /**
481
         * Checks whether the concept name is explicitly marked as fully specified
482
         *
483
         * @return true if the name is marked as 'fully specified' otherwise false
484
         * @since Version 1.7
485
         */
486
        public Boolean isFullySpecifiedName() {
487
                return ConceptNameType.FULLY_SPECIFIED.equals(getConceptNameType());
1✔
488
        }
489
        
490
        /**
491
         * Convenience method for determining whether this is a short name.
492
         *
493
         * @return true if the name is marked as a short name, otherwise false
494
         */
495
        public Boolean isShort() {
496
                return ConceptNameType.SHORT.equals(getConceptNameType());
1✔
497
        }
498
        
499
        /**
500
         * Convenience method for checking whether this is an index Term.
501
         *
502
         * @return true if the name is marked as an index term, otherwise false
503
         * @since Version 1.7
504
         */
505
        public Boolean isIndexTerm() {
506
                return ConceptNameType.INDEX_TERM.equals(getConceptNameType());
1✔
507
        }
508
        
509
        /**
510
         * Convenience method for determining whether this is an index Term for a given locale.
511
         *
512
         * @param locale The locale in which this concept name should belong as an index term
513
         * @return true if the name is marked as an index term, otherwise false
514
         */
515
        public Boolean isIndexTermInLocale(Locale locale) {
516
                return getConceptNameType() != null && getConceptNameType().equals(ConceptNameType.INDEX_TERM)
×
517
                        && locale.equals(getLocale());
×
518
        }
519
        
520
        /**
521
         * Convenience method for determining whether this is a synonym in a given locale.
522
         *
523
         * @param locale The locale in which this synonym should belong
524
         * @return true if the concept name is marked as a synonym in the given locale, otherwise false
525
         */
526
        public Boolean isSynonymInLocale(Locale locale) {
527
                return getConceptNameType() == null && locale.equals(getLocale());
×
528
        }
529
        
530
        /**
531
         * Convenience method for checking whether this is a a synonym.
532
         *
533
         * @return true if the name is tagged as a synonym, false otherwise
534
         * @since Version 1.7
535
         */
536
        public Boolean isSynonym() {
537
                return getConceptNameType() == null;
1✔
538
        }
539
        
540
        /**
541
         * @see java.lang.Object#toString()
542
         */
543
        @Override
544
        public String toString() {
545
                if (this.name == null) {
1✔
546
                        return "ConceptNameId: " + this.conceptNameId;
×
547
                }
548
                
549
                return this.name;
1✔
550
        }
551
        
552
        /**
553
         * @since 1.5
554
         * @see org.openmrs.OpenmrsObject#getId()
555
         */
556
        @Override
557
        public Integer getId() {
558
                return getConceptNameId();
1✔
559
        }
560
        
561
        /**
562
         * @since 1.5
563
         * @see org.openmrs.OpenmrsObject#setId(java.lang.Integer)
564
         */
565
        @Override
566
        public void setId(Integer id) {
567
                setConceptNameId(id);
1✔
568
        }
1✔
569
        
570
        /**
571
         * @return Returns the changedBy.
572
         */
573
        @Override
574
        public User getChangedBy() {
575
                return changedBy;
1✔
576
        }
577
        
578
        /**
579
         * @param changedBy The user that changed this object
580
         */
581
        @Override
582
        public void setChangedBy(User changedBy) {
583
                this.changedBy = changedBy;
1✔
584
        }
1✔
585
        
586
        /**
587
         * @return Returns the date this object was changed
588
         */
589
        @Override
590
        public Date getDateChanged() {
591
                return dateChanged;
1✔
592
        }
593
        
594
        /**
595
         * @param dateChanged The date this object was changed
596
         */
597
        @Override
598
        public void setDateChanged(Date dateChanged) {
599
                this.dateChanged = dateChanged;
1✔
600
        }
1✔
601
}
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