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

openmrs / openmrs-core / 25697856754

11 May 2026 09:17PM UTC coverage: 63.458% (+0.04%) from 63.419%
25697856754

Pull #6089

github

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

61 of 65 new or added lines in 5 files covered. (93.85%)

6 existing lines in 3 files now uncovered.

23327 of 36760 relevant lines covered (63.46%)

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
/**
16
 * A builder for constructing {@link LocationSearchCriteria} instances.
17
 *
18
 * @since 2.9.0
19
 */
20
public class LocationSearchCriteriaBuilder {
1✔
21

22
        private String descendantOfLocationUuid;
23

24
        private Collection<String> locationTagUuids = new ArrayList<>();
1✔
25

26
        private LocationSearchCriteria.TagMatchMode tagMatchMode = LocationSearchCriteria.TagMatchMode.ALL;
1✔
27

28
        private String nameFragment;
29

30
        private boolean includeRetired = false;
1✔
31

32
        /**
33
         * @param uuid UUID of the ancestor location; only its descendants will be returned (root excluded)
34
         * @return this builder
35
         */
36
        public LocationSearchCriteriaBuilder setDescendantOfLocation(String uuid) {
37
                this.descendantOfLocationUuid = uuid;
1✔
38
                return this;
1✔
39
        }
40

41
        /**
42
         * @param uuid UUID of a tag to filter by
43
         * @return this builder
44
         */
45
        public LocationSearchCriteriaBuilder addTag(String uuid) {
46
                this.locationTagUuids.add(uuid);
1✔
47
                return this;
1✔
48
        }
49

50
        /**
51
         * @param uuids UUIDs of tags to filter by
52
         * @return this builder
53
         */
54
        public LocationSearchCriteriaBuilder addTags(Collection<String> uuids) {
NEW
55
                this.locationTagUuids.addAll(uuids);
×
NEW
56
                return this;
×
57
        }
58

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

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

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

86
        /**
87
         * @return a new {@link LocationSearchCriteria} from the current builder state
88
         */
89
        public LocationSearchCriteria build() {
90
                return new LocationSearchCriteria(descendantOfLocationUuid, locationTagUuids, tagMatchMode, nameFragment, includeRetired);
1✔
91
        }
92
}
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