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

openmrs / openmrs-core / 41717837886

03 Nov 2026 08:59PM UTC coverage: 68.971% (+0.05%) from 68.922%
41717837886

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%)

413 existing lines in 30 files now uncovered.

26445 of 38342 relevant lines covered (68.97%)

0.69 hits per line

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

60.0
/api/src/main/java/org/openmrs/OrderType.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 org.apache.commons.lang3.StringUtils;
13
import org.hibernate.annotations.GenericGenerator;
14
import org.hibernate.annotations.Parameter;
15
import org.hibernate.envers.Audited;
16
import org.openmrs.annotation.Independent;
17
import org.openmrs.api.APIException;
18
import org.openmrs.api.context.Context;
19
import org.openmrs.util.CollectionUtil;
20

21
import javax.persistence.AttributeOverride;
22
import javax.persistence.AttributeOverrides;
23
import javax.persistence.Column;
24
import javax.persistence.Entity;
25
import javax.persistence.FetchType;
26
import javax.persistence.GeneratedValue;
27
import javax.persistence.GenerationType;
28
import javax.persistence.Id;
29
import javax.persistence.JoinColumn;
30
import javax.persistence.JoinTable;
31
import javax.persistence.ManyToMany;
32
import javax.persistence.ManyToOne;
33
import javax.persistence.Table;
34
import javax.persistence.UniqueConstraint;
35
import java.util.Collection;
36
import java.util.LinkedHashSet;
37
import java.util.Set;
38

39
/**
40
 * OrderTypes are used to classify different types of Orders e.g to distinguish between Serology and
41
 * Radiology TestOrders
42
 *
43
 */
44
@Entity
45
@Table(name = "order_type")
46
@Audited
47
public class OrderType extends BaseChangeableOpenmrsMetadata {
48
        
49
        public static final long serialVersionUID = 23232L;
50
        
51
        public static final String DRUG_ORDER_TYPE_UUID = "131168f4-15f5-102d-96e4-000c29c2a5d7";
52
        
53
        public static final String TEST_ORDER_TYPE_UUID = "52a447d3-a64a-11e3-9aeb-50e549534c5e";
54
        
55
        public static final String REFERRAL_ORDER_TYPE_UUID = "f1b63696-2b6c-11ec-8d3d-0242ac130003";
56

57
        @Id
58
        @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "order_type_id_seq")
59
        @GenericGenerator(
60
                name = "order_type_id_seq",
61
                strategy = "native",
62
                parameters = @Parameter(name = "sequence", value = "order_type_order_type_id_seq")
63
        )
64
        @Column(name = "order_type_id", nullable = false)
65
        private Integer orderTypeId;
66
        
67
        @Column(name = "java_class_name", nullable = false)
68
        private String javaClassName;
69
        
70
        @ManyToOne(fetch = FetchType.LAZY)
71
        @JoinColumn(name = "parent")
72
        private OrderType parent;
73
        
74
        @Independent
75
        @ManyToMany
76
        @JoinTable(
77
                name = "order_type_class_map", 
78
                joinColumns = @JoinColumn(name = "order_type_id"), 
79
                inverseJoinColumns = @JoinColumn(name = "concept_class_id"), 
80
                uniqueConstraints = @UniqueConstraint(columnNames = {"order_type_id", "concept_class_id"})
81
        )
82
        private Set<ConceptClass> conceptClasses;
83
        
84
        /**
85
         * default constructor
86
         */
87
        public OrderType() {
1 ✔
88
        }
1 ✔
89
        
90
        /**
91
         * Constructor with ID
92
         * 
93
         * @param orderTypeId the ID of the {@link OrderType}
94
         */
95
        public OrderType(Integer orderTypeId) {
×
96
                this.orderTypeId = orderTypeId;
×
UNCOV
97
        }
×
98
        
99
        /**
100
         * Convenience constructor that takes in the elements required to save this OrderType to the
101
         * database
102
         * 
103
         * @param name The name of this order Type
104
         * @param description A short description about this order type
105
         * @param javaClassName The fully qualified java class name
106
         */
107
        public OrderType(String name, String description, String javaClassName) {
×
108
                setName(name);
×
109
                setDescription(description);
×
110
                setJavaClassName(javaClassName);
×
UNCOV
111
        }
×
112
        
113
        /**
114
         * @return Returns the orderTypeId.
115
         */
116
        public Integer getOrderTypeId() {
117
                return orderTypeId;
1 ✔
118
        }
119
        
120
        /**
121
         * @param orderTypeId The orderTypeId to set.
122
         */
123
        public void setOrderTypeId(Integer orderTypeId) {
124
                this.orderTypeId = orderTypeId;
×
UNCOV
125
        }
×
126
        
127
        /**
128
         * @see OpenmrsObject#getId()
129
         */
130
        @Override
131
        public Integer getId() {
132
                return getOrderTypeId();
1 ✔
133
        }
134
        
135
        /**
136
         * @see OpenmrsObject#setId(Integer)
137
         */
138
        @Override
139
        public void setId(Integer id) {
UNCOV
140
                setOrderTypeId(id);
×
141
                
UNCOV
142
        }
×
143
        
144
        /**
145
         * @return Returns the Java className as String
146
         */
147
        public String getJavaClassName() {
148
                return javaClassName;
1 ✔
149
        }
150
        
151
        /**
152
         * @param javaClassName The Java class to set as String
153
         */
154
        public void setJavaClassName(String javaClassName) {
155
                this.javaClassName = javaClassName;
1 ✔
156
        }
1 ✔
157
        
158
        /**
159
         * @return Returns the {@link OrderType}
160
         */
161
        public OrderType getParent() {
162
                return parent;
1 ✔
163
        }
164
        
165
        /**
166
         * @param parent The {@link OrderType} to set
167
         */
168
        public void setParent(OrderType parent) {
169
                this.parent = parent;
1 ✔
170
        }
1 ✔
171
        
172
        /**
173
         * @return Get the {@link ConceptClass}es
174
         */
175
        public Collection<ConceptClass> getConceptClasses() {
176
                if (conceptClasses == null) {
1 ✔
177
                        conceptClasses = new LinkedHashSet<>();
1 ✔
178
                }
179
                return conceptClasses;
1 ✔
180
        }
181
        
182
        /**
183
         * @param conceptClasses the collection containing the {@link ConceptClass}es
184
         */
185
        public void setConceptClasses(Collection<ConceptClass> conceptClasses) {
186
                this.conceptClasses = CollectionUtil.setCollection(this.conceptClasses, conceptClasses);
1 ✔
187
        }
1 ✔
188
        
189
        /**
190
         * Convenience method that returns a {@link Class} object for the associated
191
         * javaClassName
192
         * 
193
         * @return The Java class as {@link Class}
194
         * @throws APIException
195
         */
196
        public Class getJavaClass() {
197
                try {
198
                        return Context.loadClass(javaClassName);
1 ✔
199
                }
UNCOV
200
                catch (ClassNotFoundException e) {
×
201
                        //re throw as a runtime exception
UNCOV
202
                        throw new APIException("OrderType.failed.load.class", new Object[] { javaClassName }, e);
×
203
                }
204
        }
205
        
206
        /**
207
         * Convenience method that adds the specified concept class
208
         * 
209
         * @param conceptClass the ConceptClass to add
210
         * <strong>Should</strong> add the specified concept class
211
         * <strong>Should</strong> not add a duplicate concept class
212
         */
213
        public void addConceptClass(ConceptClass conceptClass) {
214
                getConceptClasses().add(conceptClass);
1 ✔
215
        }
1 ✔
216
        
217
        /**
218
         * @see BaseOpenmrsObject#toString()
219
         */
220
        @Override
221
        public String toString() {
222
                if (StringUtils.isNotBlank(getName())) {
1 ✔
223
                        return getName();
1 ✔
224
                }
225
                return super.toString();
1 ✔
226
        }
227
}
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