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

openmrs / openmrs-core / 25832252509

13 May 2026 11:25PM UTC coverage: 63.448% (+0.03%) from 63.419%
25832252509

Pull #6089

github

web-flow
Merge 19a2bfd5a into 0dab4c409
Pull Request #6089: TRUNK-6635 Add search by LocationSearchCriteria, with option to find …

60 of 64 new or added lines in 5 files covered. (93.75%)

11 existing lines in 7 files now uncovered.

23323 of 36759 relevant lines covered (63.45%)

0.63 hits per line

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

88.24
/api/src/main/java/org/openmrs/parameter/LocationSearchCriteriaBuilder.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.parameter;
11

12
import java.util.ArrayList;
13
import java.util.Collection;
14

15
import org.openmrs.Location;
16
import org.openmrs.LocationTag;
17

18
/**
19
 * A builder for constructing {@link LocationSearchCriteria} instances.
20
 *
21
 * @since 2.9.0
22
 */
23
public class LocationSearchCriteriaBuilder {
1✔
24

25
        private Location descendantOfLocation;
26

27
        private Collection<LocationTag> locationTags = new ArrayList<>();
1✔
28

29
        private LocationSearchCriteria.TagMatchMode tagMatchMode = LocationSearchCriteria.TagMatchMode.ALL;
1✔
30

31
        private String nameFragment;
32

33
        private boolean includeRetired = false;
1✔
34

35
        /**
36
         * @param location the ancestor location; only its descendants will be returned (root excluded)
37
         * @return this builder
38
         */
39
        public LocationSearchCriteriaBuilder setDescendantOfLocation(Location location) {
40
                this.descendantOfLocation = location;
1✔
41
                return this;
1✔
42
        }
43

44
        /**
45
         * @param tag a tag to filter by
46
         * @return this builder
47
         */
48
        public LocationSearchCriteriaBuilder addTag(LocationTag tag) {
49
                this.locationTags.add(tag);
1✔
50
                return this;
1✔
51
        }
52

53
        /**
54
         * @param tags tags to filter by
55
         * @return this builder
56
         */
57
        public LocationSearchCriteriaBuilder addTags(Collection<LocationTag> tags) {
NEW
58
                this.locationTags.addAll(tags);
×
NEW
59
                return this;
×
60
        }
61

62
        /**
63
         * @param tagMatchMode whether all or any tags must match; defaults to ALL
64
         * @return this builder
65
         */
66
        public LocationSearchCriteriaBuilder setTagMatchMode(LocationSearchCriteria.TagMatchMode tagMatchMode) {
67
                this.tagMatchMode = tagMatchMode;
1✔
68
                return this;
1✔
69
        }
70

71
        /**
72
         * @param nameFragment only return locations whose name starts with this value
73
         * @return this builder
74
         */
75
        public LocationSearchCriteriaBuilder setNameFragment(String nameFragment) {
76
                this.nameFragment = nameFragment;
1✔
77
                return this;
1✔
78
        }
79

80
        /**
81
         * @param includeRetired whether to include retired locations; defaults to false
82
         * @return this builder
83
         */
84
        public LocationSearchCriteriaBuilder includeRetired(boolean includeRetired) {
85
                this.includeRetired = includeRetired;
1✔
86
                return this;
1✔
87
        }
88

89
        /**
90
         * @return a new {@link LocationSearchCriteria} from the current builder state
91
         */
92
        public LocationSearchCriteria build() {
93
                return new LocationSearchCriteria(descendantOfLocation, locationTags, tagMatchMode, nameFragment, includeRetired);
1✔
94
        }
95
}
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