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

openmrs / openmrs-core / 41717832711

30 Oct 2026 04:16PM UTC coverage: 66.75% (+0.003%) from 66.747%
41717832711

push

github

ibacher
TRUNK-6863: Remove the generation token before clearing a node's cache locally (#6791)

1 of 1 new or added line in 1 file covered. (100.0%)

419 existing lines in 31 files now uncovered.

26279 of 39369 relevant lines covered (66.75%)

0.67 hits per line

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

77.36
/api/src/main/java/org/openmrs/Program.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.HashSet;
13
import java.util.Locale;
14
import java.util.Set;
15

16
import org.hibernate.envers.Audited;
17
import org.openmrs.annotation.AllowDirectAccess;
18
import org.openmrs.util.CollectionUtil;
19

20
/**
21
 * Program
22
 */
23
@Audited
24
public class Program extends BaseChangeableOpenmrsMetadata {
25
        
26
        public static final long serialVersionUID = 3214567L;
27
        
28
        // ******************
29
        // Properties
30
        // ******************
31
        
32
        private Integer programId;
33
        
34
        private Concept concept;
35
        
36
        /**
37
         * Represents the possible outcomes for this program. The concept should have answers or a
38
         * memberSet.
39
         */
40
        private Concept outcomesConcept;
41
        
42
        @AllowDirectAccess
1 ✔
43
        private Set<ProgramWorkflow> allWorkflows = new HashSet<>();
44
        
45
        // ******************
46
        // Constructors
47
        // ******************
48
        
49
        /** Default Constructor */
50
        public Program() {
1 ✔
51
        }
1 ✔
52
        
53
        /** Constructor with id */
54
        public Program(Integer programId) {
1 ✔
55
                setProgramId(programId);
1 ✔
56
        }
1 ✔
57
        
58
        /**
59
         * Constructor with name
60
         *
61
         * @since 1.10
62
         */
63
        public Program(String name) {
1 ✔
64
                setName(name);
1 ✔
65
        }
1 ✔
66
        
67
        // ******************
68
        // Instance methods
69
        // ******************
70
        
71
        /**
72
         * Adds a new {@link ProgramWorkflow} to this Program
73
         *
74
         * @param workflow - the {@link ProgramWorkflow} to add
75
         */
76
        public void addWorkflow(ProgramWorkflow workflow) {
77
                workflow.setProgram(this);
1 ✔
78
                getAllWorkflows().add(workflow);
1 ✔
79
        }
1 ✔
80
        
81
        /**
82
         * Removes a {@link ProgramWorkflow} from this Program
83
         *
84
         * @param workflow - the {@link ProgramWorkflow} to remove
85
         */
86
        public void removeWorkflow(ProgramWorkflow workflow) {
87
                if (getAllWorkflows().contains(workflow)) {
×
88
                        getAllWorkflows().remove(workflow);
×
UNCOV
89
                        workflow.setProgram(null);
×
90
                }
UNCOV
91
        }
×
92
        
93
        /**
94
         * Retires a {@link ProgramWorkflow}
95
         *
96
         * @param workflow - the {@link ProgramWorkflow} to retire
97
         */
98
        public void retireWorkflow(ProgramWorkflow workflow) {
99
                workflow.setRetired(true);
×
UNCOV
100
        }
×
101
        
102
        /**
103
         * Returns a {@link ProgramWorkflow} whose {@link Concept} has any {@link ConceptName} that
104
         * matches the given <code>name</code>
105
         *
106
         * @param name the {@link ProgramWorkflow} name, in any {@link Locale}
107
         * @return a {@link ProgramWorkflow} which has the passed <code>name</code> in any
108
         *         {@link Locale}
109
         */
110
        public ProgramWorkflow getWorkflowByName(String name) {
111
                for (ProgramWorkflow pw : getAllWorkflows()) {
1 ✔
112
                        if (pw.getConcept().isNamed(name)) {
1 ✔
113
                                return pw;
1 ✔
114
                        }
115
                }
×
UNCOV
116
                return null;
×
117
        }
118
        
119
        /** @see Object#toString() */
120
        @Override
121
        public String toString() {
122
                return "Program(id=" + getProgramId() + ", concept=" + getConcept() + ", workflows=" + getWorkflows() + ")";
1 ✔
123
        }
124
        
125
        // ******************
126
        // Property Access
127
        // ******************
128
        
129
        public Concept getConcept() {
130
                return concept;
1 ✔
131
        }
132
        
133
        public void setConcept(Concept concept) {
134
                this.concept = concept;
1 ✔
135
        }
1 ✔
136
        
137
        public Concept getOutcomesConcept() {
138
                return outcomesConcept;
1 ✔
139
        }
140
        
141
        public void setOutcomesConcept(Concept concept) {
142
                this.outcomesConcept = concept;
1 ✔
143
        }
1 ✔
144
        
145
        public Integer getProgramId() {
146
                return programId;
1 ✔
147
        }
148
        
149
        public void setProgramId(Integer programId) {
150
                this.programId = programId;
1 ✔
151
        }
1 ✔
152
        
153
        /**
154
         * Get only the non-retired workflows
155
         *
156
         * @return Returns a Set&lt;ProgramWorkflow&gt; of all non-retired workflows
157
         */
158
        public Set<ProgramWorkflow> getWorkflows() {
159
                Set<ProgramWorkflow> ret = new HashSet<>();
1 ✔
160
                for (ProgramWorkflow workflow : getAllWorkflows()) {
1 ✔
161
                        if (!workflow.getRetired()) {
1 ✔
162
                                ret.add(workflow);
1 ✔
163
                        }
164
                }
1 ✔
165
                return ret;
1 ✔
166
        }
167
        
168
        /**
169
         * Get the workflow with the specified ID
170
         *
171
         * @return the workflow matching the given id or null if none found
172
         * @since 1.6
173
         */
174
        public ProgramWorkflow getWorkflow(Integer programWorkflowId) {
175
                if (getWorkflows() != null) {
1 ✔
176
                        for (ProgramWorkflow wf : getWorkflows()) {
1 ✔
177
                                if (wf.getId().equals(programWorkflowId)) {
1 ✔
178
                                        return wf;
1 ✔
179
                                }
180
                        }
1 ✔
181
                }
UNCOV
182
                return null;
×
183
        }
184
        
185
        /**
186
         * Get all workflows...including the retired ones
187
         *
188
         * @return Returns a Set&lt;ProgramWorkflow&gt; of all workflows
189
         */
190
        public Set<ProgramWorkflow> getAllWorkflows() {
191
                if (allWorkflows == null) {
1 ✔
UNCOV
192
                        allWorkflows = new HashSet<>();
×
193
                }
194
                return allWorkflows;
1 ✔
195
        }
196
        
197
        public void setAllWorkflows(Set<ProgramWorkflow> allWorkflows) {
198
                this.allWorkflows = CollectionUtil.setCollection(this.allWorkflows, allWorkflows);
1 ✔
199
        }
1 ✔
200
        
201
        /**
202
         * @since 1.5
203
         * @see org.openmrs.OpenmrsObject#getId()
204
         */
205
        @Override
206
        public Integer getId() {
207
                
208
                return getProgramId();
1 ✔
209
        }
210
        
211
        /**
212
         * @since 1.5
213
         * @see org.openmrs.OpenmrsObject#setId(java.lang.Integer)
214
         */
215
        @Override
216
        public void setId(Integer id) {
UNCOV
217
                setProgramId(id);
×
218
                
UNCOV
219
        }
×
220
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc