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

openmrs / openmrs-core / 8240141295

11 Mar 2024 09:46PM CUT coverage: 64.693% (-0.01%) from 64.705%
8240141295

push

github

web-flow
maven(deps): bump jacksonVersion from 2.16.1 to 2.16.2 (#4582)

Bumps `jacksonVersion` from 2.16.1 to 2.16.2.

Updates `com.fasterxml.jackson.core:jackson-core` from 2.16.1 to 2.16.2
- [Commits](https://github.com/FasterXML/jackson-core/compare/jackson-core-2.16.1...jackson-core-2.16.2)

Updates `com.fasterxml.jackson.core:jackson-annotations` from 2.16.1 to 2.16.2
- [Commits](https://github.com/FasterXML/jackson/commits)

Updates `com.fasterxml.jackson.core:jackson-databind` from 2.16.1 to 2.16.2
- [Commits](https://github.com/FasterXML/jackson/commits)

Updates `com.fasterxml.jackson.datatype:jackson-datatype-jsr310` from 2.16.1 to 2.16.2

---
updated-dependencies:
- dependency-name: com.fasterxml.jackson.core:jackson-core
  dependency-type: direct:production
  update-type: version-update:semver-patch
- dependency-name: com.fasterxml.jackson.core:jackson-annotations
  dependency-type: direct:production
  update-type: version-update:semver-patch
- dependency-name: com.fasterxml.jackson.core:jackson-databind
  dependency-type: direct:production
  update-type: version-update:semver-patch
- dependency-name: com.fasterxml.jackson.datatype:jackson-datatype-jsr310
  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>

22763 of 35186 relevant lines covered (64.69%)

0.65 hits per line

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

75.96
/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.search.annotations.Analyze;
24
import org.hibernate.search.annotations.Analyzer;
25
import org.hibernate.search.annotations.AnalyzerDef;
26
import org.hibernate.search.annotations.DocumentId;
27
import org.hibernate.search.annotations.Field;
28
import org.hibernate.search.annotations.FieldBridge;
29
import org.hibernate.search.annotations.Indexed;
30
import org.hibernate.search.annotations.IndexedEmbedded;
31
import org.hibernate.search.annotations.TokenFilterDef;
32
import org.hibernate.search.annotations.TokenizerDef;
33
import org.openmrs.api.ConceptNameType;
34
import org.openmrs.api.db.hibernate.search.bridge.LocaleFieldBridge;
35

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

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

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

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