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

openmrs / openmrs-core / 10621293521

29 Aug 2024 07:19PM CUT coverage: 64.73% (-0.003%) from 64.733%
10621293521

push

github

web-flow
maven(deps): bump net.bytebuddy:byte-buddy from 1.15.0 to 1.15.1 (#4735)

Bumps [net.bytebuddy:byte-buddy](https://github.com/raphw/byte-buddy) from 1.15.0 to 1.15.1.
- [Release notes](https://github.com/raphw/byte-buddy/releases)
- [Changelog](https://github.com/raphw/byte-buddy/blob/master/release-notes.md)
- [Commits](https://github.com/raphw/byte-buddy/compare/byte-buddy-1.15.0...byte-buddy-1.15.1)

---
updated-dependencies:
- dependency-name: net.bytebuddy:byte-buddy
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

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

22959 of 35469 relevant lines covered (64.73%)

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.apache.lucene.analysis.core.LowerCaseFilterFactory;
19
import org.apache.lucene.analysis.miscellaneous.ASCIIFoldingFilterFactory;
20
import org.apache.lucene.analysis.standard.StandardFilterFactory;
21
import org.apache.lucene.analysis.standard.StandardTokenizerFactory;
22
import org.codehaus.jackson.annotate.JsonIgnore;
23
import org.hibernate.envers.Audited;
24
import org.hibernate.search.annotations.Analyze;
25
import org.hibernate.search.annotations.Analyzer;
26
import org.hibernate.search.annotations.AnalyzerDef;
27
import org.hibernate.search.annotations.DocumentId;
28
import org.hibernate.search.annotations.Field;
29
import org.hibernate.search.annotations.FieldBridge;
30
import org.hibernate.search.annotations.Indexed;
31
import org.hibernate.search.annotations.IndexedEmbedded;
32
import org.hibernate.search.annotations.TokenFilterDef;
33
import org.hibernate.search.annotations.TokenizerDef;
34
import org.openmrs.api.ConceptNameType;
35
import org.openmrs.api.db.hibernate.search.bridge.LocaleFieldBridge;
36

37
/**
38
 * ConceptName is the real world term used to express a Concept within the idiom of a particular
39
 * locale.
40
 */
41
@Indexed
42
@AnalyzerDef(
43
        name = "ConceptNameAnalyzer", tokenizer = @TokenizerDef(factory = StandardTokenizerFactory.class), filters = {
44
        @TokenFilterDef(factory = StandardFilterFactory.class), 
45
                @TokenFilterDef(factory = LowerCaseFilterFactory.class), 
46
                @TokenFilterDef(factory = ASCIIFoldingFilterFactory.class)
47
        })
48
@Analyzer(definition = "ConceptNameAnalyzer")
49
@Audited
50
public class ConceptName extends BaseOpenmrsObject implements Auditable, Voidable, java.io.Serializable {
51
        
52
        public static final long serialVersionUID = 2L;
53
        
54
        @DocumentId
55
        private Integer conceptNameId;
56
        
57
        @IndexedEmbedded(includeEmbeddedObjectId = true)
58
        private Concept concept;
59
        
60
        @Field
61
        private String name;
62
        
63
        @Field(analyze = Analyze.NO)
64
        @FieldBridge(impl = LocaleFieldBridge.class)
65
        // ABK: upgraded from a plain string to a full locale object
66
        private Locale locale; 
67
        
68
        private User creator;
69
        
70
        private Date dateCreated;
71
        
72
        @Field
1✔
73
        private Boolean voided = false;
1✔
74
        
75
        private User voidedBy;
76
        
77
        private Date dateVoided;
78
        
79
        private String voidReason;
80
        
81
        private Collection<ConceptNameTag> tags;
82
        
83
        @Field
84
        private ConceptNameType conceptNameType;
85
        
86
        @Field
1✔
87
        private Boolean localePreferred = false;
1✔
88
        
89
        private User changedBy;
90
        
91
        private Date dateChanged;
92
        
93
        // Constructors
94
        
95
        /** default constructor */
96
        public ConceptName() {
1✔
97
        }
1✔
98
        
99
        /**
100
         * Convenience constructor to create a ConceptName object by primary key
101
         *
102
         * @param conceptNameId
103
         */
104
        public ConceptName(Integer conceptNameId) {
1✔
105
                this.conceptNameId = conceptNameId;
1✔
106
        }
1✔
107
        
108
        public ConceptName(String name, Locale locale) {
1✔
109
                setName(name);
1✔
110
                setLocale(locale);
1✔
111
        }
1✔
112
        
113
        /**
114
         * @return Returns the conceptId.
115
         */
116
        public Integer getConceptNameId() {
117
                return conceptNameId;
1✔
118
        }
119
        
120
        /**
121
         * @param conceptNameId The conceptId to set.
122
         */
123
        public void setConceptNameId(Integer conceptNameId) {
124
                this.conceptNameId = conceptNameId;
1✔
125
        }
1✔
126
        
127
        public Concept getConcept() {
128
                return concept;
1✔
129
        }
130
        
131
        public void setConcept(Concept concept) {
132
                this.concept = concept;
1✔
133
        }
1✔
134
        
135
        public String getName() {
136
                return name;
1✔
137
        }
138
        
139
        public void setName(String name) {
140
                if (name != null && StringUtils.isBlank(name) && StringUtils.isNotBlank(this.name)
1✔
141
                        && this.getConceptNameType().equals(ConceptNameType.SHORT)) {
×
142
                        this.setVoided(true);
×
143
                } else {
144
                        this.name = name;
1✔
145
                }
146
        }
1✔
147
        
148
        public Locale getLocale() {
149
                return locale;
1✔
150
        }
151
        
152
        public void setLocale(Locale locale) {
153
                this.locale = locale;
1✔
154
        }
1✔
155

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

457
        }
458
        
459
        /**
460
         * Checks whether the name is explicitly marked as preferred in a locale with a matching country
461
         * code E.g 'fr_RW' and 'en_RW' for country RW
462
         *
463
         * @see #isPreferredForLocale(Locale)
464
         * @param country ISO 3166 2-letter code for a country
465
         * @return true if the name is preferred in a locale with a matching country code, otherwise
466
         *         false
467
         */
468
        public Boolean isPreferredInCountry(String country) {
469
                return !StringUtils.isBlank(country) && this.locale != null && isPreferred()
×
470
                                && this.locale.getCountry().equals(country);
×
471

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

© 2025 Coveralls, Inc