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

openmrs / openmrs-core / 14624226260

23 Apr 2025 05:22PM UTC coverage: 63.798% (-0.003%) from 63.801%
14624226260

push

github

ibacher
Revert "TRUNK-6300 Add Storage Service"

This reverts commit 6751872ea.

We need a mechanism to provide a PropertySource and a default value for this property before this is workable.

22014 of 34506 relevant lines covered (63.8%)

0.64 hits per line

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

42.39
/api/src/main/java/org/openmrs/FormField.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.io.Serializable;
13
import java.util.Comparator;
14

15
import org.codehaus.jackson.annotate.JsonIgnore;
16

17
/**
18
 * The FormField object relates/orders the <code>fields</code> on a <code>form</code> A form can
19
 * have many 0 to n fields associated with it in a hierarchical manor. This FormField object governs
20
 * what/how that takes place
21
 *
22
 * @see org.openmrs.Form
23
 * @see org.openmrs.Field
24
 */
25
public class FormField extends BaseChangeableOpenmrsMetadata implements java.io.Serializable, Comparable<FormField> {
26
        
27
        public static final long serialVersionUID = 3456L;
28
        
29
        // Fields
30
        
31
        protected Integer formFieldId;
32
        
33
        protected FormField parent;
34
        
35
        protected Form form;
36
        
37
        protected Field field;
38
        
39
        protected Integer fieldNumber;
40
        
41
        protected String fieldPart;
42
        
43
        protected Integer pageNumber;
44
        
45
        protected Integer minOccurs;
46
        
47
        protected Integer maxOccurs;
48
        
49
        protected Boolean required = false;
1✔
50
        
51
        protected Float sortWeight;
52
        
53
        // Constructors
54
        
55
        /** default constructor */
56
        public FormField() {
1✔
57
        }
1✔
58
        
59
        /** constructor with id */
60
        public FormField(Integer formFieldId) {
1✔
61
                this.formFieldId = formFieldId;
1✔
62
        }
1✔
63
        
64
        // Property accessors
65
        
66
        /**
67
         * @return Returns the formFieldId.
68
         */
69
        public Integer getFormFieldId() {
70
                return formFieldId;
1✔
71
        }
72
        
73
        /**
74
         * @param formFieldId The formFieldId to set.
75
         */
76
        public void setFormFieldId(Integer formFieldId) {
77
                this.formFieldId = formFieldId;
1✔
78
        }
1✔
79
        
80
        /**
81
         * @return Returns the parent FormField.
82
         */
83
        public FormField getParent() {
84
                return parent;
1✔
85
        }
86
        
87
        /**
88
         * @param parent The formField to set as parent.
89
         */
90
        public void setParent(FormField parent) {
91
                this.parent = parent;
1✔
92
        }
1✔
93
        
94
        /**
95
         * @return Returns the form.
96
         */
97
        public Form getForm() {
98
                return form;
1✔
99
        }
100
        
101
        /**
102
         * @param form The form to set.
103
         */
104
        public void setForm(Form form) {
105
                this.form = form;
1✔
106
        }
1✔
107
        
108
        /**
109
         * @return Returns the field.
110
         */
111
        public Field getField() {
112
                return field;
1✔
113
        }
114
        
115
        /**
116
         * @param field The field to set.
117
         */
118
        public void setField(Field field) {
119
                this.field = field;
1✔
120
        }
1✔
121
        
122
        /**
123
         * @return Returns the fieldNumber.
124
         */
125
        public Integer getFieldNumber() {
126
                return fieldNumber;
1✔
127
        }
128
        
129
        /**
130
         * @param fieldNumber The fieldNumber to set.
131
         */
132
        public void setFieldNumber(Integer fieldNumber) {
133
                this.fieldNumber = fieldNumber;
1✔
134
        }
1✔
135
        
136
        /**
137
         * @return Returns the fieldPart.
138
         */
139
        public String getFieldPart() {
140
                return fieldPart;
1✔
141
        }
142
        
143
        /**
144
         * @param fieldPart The fieldPart to set.
145
         */
146
        public void setFieldPart(String fieldPart) {
147
                this.fieldPart = fieldPart;
1✔
148
        }
1✔
149
        
150
        /**
151
         * @return Returns the pageNumber.
152
         */
153
        public Integer getPageNumber() {
154
                return pageNumber;
1✔
155
        }
156
        
157
        /**
158
         * @param pageNumber The pageNumber to set.
159
         */
160
        public void setPageNumber(Integer pageNumber) {
161
                this.pageNumber = pageNumber;
1✔
162
        }
1✔
163
        
164
        /**
165
         * @return Returns the minOccurs.
166
         */
167
        public Integer getMinOccurs() {
168
                return minOccurs;
1✔
169
        }
170
        
171
        /**
172
         * @param minOccurs The minOccurs to set.
173
         */
174
        public void setMinOccurs(Integer minOccurs) {
175
                this.minOccurs = minOccurs;
1✔
176
        }
1✔
177
        
178
        /**
179
         * @return Returns the maxOccurs.
180
         */
181
        public Integer getMaxOccurs() {
182
                return maxOccurs;
1✔
183
        }
184
        
185
        /**
186
         * @param maxOccurs The maxOccurs to set.
187
         */
188
        public void setMaxOccurs(Integer maxOccurs) {
189
                this.maxOccurs = maxOccurs;
1✔
190
        }
1✔
191
        
192
        /**
193
         * @return Returns the required status.
194
         * 
195
         * @deprecated as of 2.0, use {@link #getRequired()}
196
         */
197
        @Deprecated
198
        @JsonIgnore
199
        public Boolean isRequired() {
200
                return getRequired();
×
201
        }
202
        
203
        /**
204
         * @return same as isRequired()
205
         */
206
        public Boolean getRequired() {
207
                return required == null ? Boolean.FALSE : required;
1✔
208
        }
209
        
210
        /**
211
         * @param required The required status to set.
212
         */
213
        public void setRequired(Boolean required) {
214
                this.required = required;
1✔
215
        }
1✔
216
        
217
        /**
218
         * @return Returns the sortWeight.
219
         */
220
        public Float getSortWeight() {
221
                return sortWeight;
1✔
222
        }
223
        
224
        /**
225
         * @param sortWeight The weight to order the formFields on.
226
         */
227
        public void setSortWeight(Float sortWeight) {
228
                this.sortWeight = sortWeight;
1✔
229
        }
1✔
230
        
231
        /**
232
         * @see java.lang.Object#toString()
233
         */
234
        @Override
235
        public String toString() {
236
                if (formFieldId == null) {
×
237
                        return "null";
×
238
                }
239
                
240
                return this.formFieldId.toString();
×
241
        }
242
        
243
        /**
244
         * @since 1.5
245
         * @see org.openmrs.OpenmrsObject#getId()
246
         */
247
        @Override
248
        public Integer getId() {
249
                return getFormFieldId();
×
250
        }
251
        
252
        /**
253
         * @since 1.5
254
         * @see org.openmrs.OpenmrsObject#setId(java.lang.Integer)
255
         */
256
        @Override
257
        public void setId(Integer id) {
258
                setFormFieldId(id);
×
259
                
260
        }
×
261
        
262
        @Override
263
        public int compareTo(FormField other) {
264
                DefaultComparator pnDefaultComparator = new DefaultComparator();
×
265
                return pnDefaultComparator.compare(this, other);
×
266
        }
267
        
268
        /**
269
         Provides a default comparator.
270
         @since 1.12
271
         **/
272
        public static class DefaultComparator implements Comparator<FormField>, Serializable {
×
273

274
                private static final long serialVersionUID = 1L;
275
                
276
                @Override
277
                public int compare(FormField ff1, FormField ff2) {
278
                        if (ff1.getSortWeight() != null || ff2.getSortWeight() != null) {
×
279
                                if (ff1.getSortWeight() == null) {
×
280
                                        return -1;
×
281
                                }
282
                                if (ff2.getSortWeight() == null) {
×
283
                                        return 1;
×
284
                                }
285
                                int c = ff1.getSortWeight().compareTo(ff2.getSortWeight());
×
286
                                if (c != 0) {
×
287
                                        return c;
×
288
                                }
289
                        }
290
                        if (ff1.getPageNumber() != null || ff2.getPageNumber() != null) {
×
291
                                if (ff1.getPageNumber() == null) {
×
292
                                        return -1;
×
293
                                }
294
                                if (ff2.getPageNumber() == null) {
×
295
                                        return 1;
×
296
                                }
297
                                int c = ff1.getPageNumber().compareTo(ff2.getPageNumber());
×
298
                                if (c != 0) {
×
299
                                        return c;
×
300
                                }
301
                        }
302
                        if (ff1.getFieldNumber() != null || ff2.getFieldNumber() != null) {
×
303
                                if (ff1.getFieldNumber() == null) {
×
304
                                        return -1;
×
305
                                }
306
                                if (ff2.getFieldNumber() == null) {
×
307
                                        return 1;
×
308
                                }
309
                                int c = ff1.getFieldNumber().compareTo(ff2.getFieldNumber());
×
310
                                if (c != 0) {
×
311
                                        return c;
×
312
                                }
313
                        }
314
                        if (ff1.getFieldPart() != null || ff2.getFieldPart() != null) {
×
315
                                if (ff1.getFieldPart() == null) {
×
316
                                        return -1;
×
317
                                }
318
                                if (ff2.getFieldPart() == null) {
×
319
                                        return 1;
×
320
                                }
321
                                int c = ff1.getFieldPart().compareTo(ff2.getFieldPart());
×
322
                                if (c != 0) {
×
323
                                        return c;
×
324
                                }
325
                        }
326
                        if (ff1.getField() != null && ff2.getField() != null) {
×
327
                                int c = ff1.getField().getName().compareTo(ff2.getField().getName());
×
328
                                if (c != 0) {
×
329
                                        return c;
×
330
                                }
331
                        }
332
                        if (ff1.getFormFieldId() == null && ff2.getFormFieldId() != null) {
×
333
                                return -1;
×
334
                        }
335
                        if (ff1.getFormFieldId() != null && ff2.getFormFieldId() == null) {
×
336
                                return 1;
×
337
                        }
338
                        if (ff1.getFormFieldId() == null && ff2.getFormFieldId() == null) {
×
339
                                return 1;
×
340
                        }
341
                        
342
                        return ff1.getFormFieldId().compareTo(ff2.getFormFieldId());
×
343
                }
344
        }
345
}
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