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

opensrp / opensrp-client-native-form / #61

09 Oct 2023 12:39PM UTC coverage: 66.061% (-0.1%) from 66.188%
#61

Pull #666

github-actions

web-flow
Merge c872e1480 into f8c80cf2b
Pull Request #666: [Local merge] Optbp compression merge for

8440 of 12776 relevant lines covered (66.06%)

0.66 hits per line

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

73.82
android-json-form-wizard/src/main/java/com/vijay/jsonwizard/widgets/OptiBPWidgetFactory.java
1
package com.vijay.jsonwizard.widgets;
2

3
import static com.vijay.jsonwizard.constants.JsonFormConstants.CALCULATION;
4
import static com.vijay.jsonwizard.constants.JsonFormConstants.CONSTRAINTS;
5
import static com.vijay.jsonwizard.constants.JsonFormConstants.FIELDS;
6
import static com.vijay.jsonwizard.constants.JsonFormConstants.FIELDS_TO_USE_VALUE;
7
import static com.vijay.jsonwizard.constants.JsonFormConstants.KEY;
8
import static com.vijay.jsonwizard.constants.JsonFormConstants.LABEL;
9
import static com.vijay.jsonwizard.constants.JsonFormConstants.READ_ONLY;
10
import static com.vijay.jsonwizard.constants.JsonFormConstants.RELEVANCE;
11
import static com.vijay.jsonwizard.constants.JsonFormConstants.STEP1;
12
import static com.vijay.jsonwizard.constants.JsonFormConstants.TYPE;
13
import static com.vijay.jsonwizard.constants.JsonFormConstants.VALUE;
14

15
import android.annotation.SuppressLint;
16
import android.app.Activity;
17
import android.content.Context;
18
import android.content.Intent;
19
import android.graphics.Color;
20
import android.graphics.drawable.ColorDrawable;
21
import android.graphics.drawable.Drawable;
22
import android.graphics.drawable.GradientDrawable;
23
import android.graphics.drawable.ShapeDrawable;
24
import android.text.TextUtils;
25
import android.view.LayoutInflater;
26
import android.view.View;
27
import android.widget.EditText;
28
import android.widget.LinearLayout;
29
import android.widget.TextView;
30
import android.widget.Toast;
31

32
import androidx.core.content.ContextCompat;
33

34
import com.rey.material.util.ViewUtil;
35
import com.rey.material.widget.Button;
36
import com.vijay.jsonwizard.R;
37
import com.vijay.jsonwizard.constants.JsonFormConstants.OptibpConstants;
38
import com.vijay.jsonwizard.domain.WidgetArgs;
39
import com.vijay.jsonwizard.fragments.JsonFormFragment;
40
import com.vijay.jsonwizard.interfaces.CommonListener;
41
import com.vijay.jsonwizard.interfaces.FormWidgetFactory;
42
import com.vijay.jsonwizard.interfaces.JsonApi;
43
import com.vijay.jsonwizard.utils.FormUtils;
44
import com.vijay.jsonwizard.utils.Utils;
45

46
import org.apache.commons.lang3.StringUtils;
47
import org.jetbrains.annotations.NotNull;
48
import org.json.JSONArray;
49
import org.json.JSONException;
50
import org.json.JSONObject;
51

52
import java.util.ArrayList;
53
import java.util.HashSet;
54
import java.util.List;
55
import java.util.Set;
56

57
import timber.log.Timber;
58

59
public class OptiBPWidgetFactory implements FormWidgetFactory {
1✔
60

61
    @Override
62
    public List<View> getViewsFromJson(String stepName, Context context, JsonFormFragment formFragment, JSONObject jsonObject, CommonListener listener) throws Exception {
63
        return getViewsFromJson(stepName, context, formFragment, jsonObject, listener, false);
1✔
64
    }
65

66
    @Override
67
    public List<View> getViewsFromJson(String stepName, Context context, JsonFormFragment formFragment, JSONObject jsonObject, CommonListener listener, boolean popup) throws Exception {
68
        WidgetArgs widgetArgs = new WidgetArgs();
1✔
69
        widgetArgs.withStepName(stepName).withContext(context).withFormFragment(formFragment)
1✔
70
                .withJsonObject(jsonObject).withListener(listener).withPopup(popup);
1✔
71

72
        JSONArray canvasIds = new JSONArray();
1✔
73

74
        boolean readOnly = false;
1✔
75
        if (jsonObject.has(READ_ONLY)) {
1✔
76
            readOnly = jsonObject.getBoolean(READ_ONLY);
1✔
77
        }
78

79
        LinearLayout rootLayout = getRootLayout(context);
1✔
80
        setWidgetTags(rootLayout, canvasIds, widgetArgs);
1✔
81
        attachRefreshLogic(context, jsonObject, rootLayout);
1✔
82

83
        initBPFieldsKeys(jsonObject);
1✔
84
        EditText systolicBPEditText = getBPEditTextField(widgetArgs, BPFieldType.SYSTOLIC_BP);
1✔
85
        EditText diastolicBPEditText = getBPEditTextField(widgetArgs, BPFieldType.DIASTOLIC_BP);
1✔
86

87
        TextView labelTextView = initLabel(rootLayout, widgetArgs, readOnly);
1✔
88
        setWidgetTags(labelTextView, canvasIds, widgetArgs);
1✔
89

90
        boolean isRepeat = isRepeatMeasurement(BPFieldType.SYSTOLIC_BP, BPFieldType.DIASTOLIC_BP);
1✔
91
        Button launchButton = initLaunchButton(rootLayout, widgetArgs, readOnly, getRequestCode(isRepeat));
1✔
92
        setWidgetTags(launchButton, canvasIds, widgetArgs);
1✔
93

94
        setGlobalLayoutListener(rootLayout, systolicBPEditText, diastolicBPEditText);
1✔
95
        setUpOptiBpActivityResultListener(widgetArgs, getRequestCode(isRepeat), rootLayout, systolicBPEditText, diastolicBPEditText);
1✔
96

97
        ((JsonApi) context).addFormDataView(rootLayout);
1✔
98

99
        rootLayout.setTag(R.id.canvas_ids, canvasIds.toString());
1✔
100

101
        List<View> views = new ArrayList<>(1);
1✔
102
        views.add(rootLayout);
1✔
103
        return views;
1✔
104
    }
105

106
    private void setWidgetTags(View view, JSONArray canvasIds, WidgetArgs widgetArgs) throws JSONException {
107
        JSONObject jsonObject = widgetArgs.getJsonObject();
1✔
108
        FormUtils.setViewOpenMRSEntityAttributes(jsonObject, view);
1✔
109

110
        view.setId(ViewUtil.generateViewId());
1✔
111
        view.setTag(R.id.key, jsonObject.getString(KEY));
1✔
112
        view.setTag(R.id.type, widgetArgs.getJsonObject().getString(TYPE));
1✔
113
        view.setTag(R.id.extraPopup, widgetArgs.isPopup());
1✔
114
        view.setTag(R.id.address, widgetArgs.getStepName() + ":" + jsonObject.getString(KEY));
1✔
115
        canvasIds.put(view.getId());
1✔
116
    }
1✔
117

118
    private void initBPFieldsKeys(JSONObject jsonObject) throws JSONException {
119
        if (jsonObject.has(FIELDS_TO_USE_VALUE)
1✔
120
                && jsonObject.getJSONArray(FIELDS_TO_USE_VALUE).length() == 2) {
1✔
121
            JSONArray fields = jsonObject.getJSONArray(FIELDS_TO_USE_VALUE);
1✔
122
            BPFieldType.SYSTOLIC_BP.setKey(fields.get(0).toString());
1✔
123
            BPFieldType.DIASTOLIC_BP.setKey(fields.get(1).toString());
1✔
124
        } else {
1✔
125
            Timber.e("No field values defined to populate BP values");
×
126
        }
127
    }
1✔
128

129
    private TextView initLabel(LinearLayout rootLayout, WidgetArgs widgetArgs, boolean readOnly) throws JSONException {
130
        Context context = widgetArgs.getContext();
1✔
131
        TextView labelTextView = rootLayout.findViewById(R.id.optibp_label);
1✔
132
        labelTextView.setText(getLabelText(context, widgetArgs.getJsonObject()));
1✔
133
        if (readOnly) {
1✔
134
            labelTextView.setTextColor(ContextCompat.getColor(context, android.R.color.darker_gray));
×
135
        }
136
        return labelTextView;
1✔
137
    }
138

139
    private Button initLaunchButton(LinearLayout rootLayout, final WidgetArgs widgetArgs, boolean readOnly, final int requestCode) throws JSONException {
140
        final Context context = widgetArgs.getContext();
1✔
141
        final JSONObject jsonObject = widgetArgs.getJsonObject();
1✔
142
        Button launchButton = rootLayout.findViewById(R.id.optibp_launch_button);
1✔
143
        formatButtonWidget(launchButton, widgetArgs.getJsonObject());
1✔
144
        launchButton.setOnClickListener(view -> {
1✔
145
            try {
146
                Timber.w(" ONCLICK WITH JSON %s", jsonObject);
×
147
                Intent intent = new Intent(OptibpConstants.OPTIBP_LAUNCH_INTENT);
×
148
                intent.setType("text/json");
×
149
                Timber.e("OptibpWidget factory sending request %s", getInputJsonString(context, jsonObject, widgetArgs));
×
150
                intent.putExtra(Intent.EXTRA_TEXT, getInputJsonString(context, jsonObject, widgetArgs));
×
151
                ((Activity) context).startActivityForResult(Intent.createChooser(intent, ""), requestCode);
×
152
            } catch (Exception e) {
×
153
                Timber.e(e);
×
154
            }
×
155
        });
×
156

157
        if (readOnly) {
1✔
158
            launchButton.setBackgroundDrawable(new ColorDrawable(widgetArgs.getContext().getResources()
×
159
                    .getColor(android.R.color.darker_gray)));
×
160
            launchButton.setClickable(false);
×
161
            launchButton.setEnabled(false);
×
162
            launchButton.setFocusable(false);
×
163
        }
164

165
        return launchButton;
1✔
166
    }
167

168
    private void formatButtonWidget(Button button, JSONObject jsonObject) throws JSONException {
169
        if (jsonObject.has(OptibpConstants.OPTIBP_KEY_BUTTON_BG_COLOR)) {
1✔
170
            String colorString = jsonObject.getString(OptibpConstants.OPTIBP_KEY_BUTTON_BG_COLOR);
1✔
171
            setButtonBgColor(button, colorString);
1✔
172
        }
173
        if (jsonObject.has(OptibpConstants.OPTIBP_KEY_BUTTON_TEXT_COLOR)) {
1✔
174
            String colorString = jsonObject.getString(OptibpConstants.OPTIBP_KEY_BUTTON_TEXT_COLOR);
1✔
175
            button.setTextColor(Color.parseColor(colorString));
1✔
176
        }
177
        if (jsonObject.has(OptibpConstants.OPTIBP_KEY_BUTTON_TEXT)) {
1✔
178
            String buttonText = jsonObject.getString(OptibpConstants.OPTIBP_KEY_BUTTON_TEXT);
×
179
            button.setText(buttonText);
×
180
        }
181

182
    }
1✔
183

184
    public void setUpOptiBpActivityResultListener(final WidgetArgs widgetArgs, int requestCode, final LinearLayout rootLayout, EditText systolicEditText, final EditText diastolicEditText) {
185
        final Context context = widgetArgs.getContext();
1✔
186

187
        if (context instanceof JsonApi) {
1✔
188
            final JsonApi jsonApi = (JsonApi) context;
1✔
189
            jsonApi.addOnActivityResultListener(requestCode, (finalRequestCode, resultCode, data) -> {
1✔
190
                Timber.e("OptibpWidgetFactory optib requestCode %s resultCode %s", requestCode, resultCode);
1✔
191
                if(data != null)
1✔
192
                    Timber.e("OptibpWidgetFactory data %s",data.getStringExtra(Intent.EXTRA_TEXT));
1✔
193
                else Timber.e("OptibpWidgetFactory data is null");
×
194
                if (resultCode == Activity.RESULT_OK) {
1✔
195
                    if (finalRequestCode == OptibpConstants.OPTIBP_REQUEST_CODE ||
1✔
196
                            finalRequestCode == OptibpConstants.OPTIBP_REPEAT_REQUEST_CODE) {
197
                        try {
198
                            if (data != null) {
1✔
199
                                String resultJson = data.getStringExtra(Intent.EXTRA_TEXT);
1✔
200
                                Timber.d("Resultant OptiBP JSON: %s ", resultJson);
1✔
201
                                populateBPEditTextValues(resultJson, systolicEditText, diastolicEditText, widgetArgs);
1✔
202
                                String resultString = getValueString(resultJson);
1✔
203
                                if (StringUtils.isNotBlank(resultString)) {
1✔
204
                                    writeResult(jsonApi, rootLayout, resultString, widgetArgs);
1✔
205
                                } else {
206
                                    Timber.e("JSON Result  %s , Result String  %s", resultJson, resultString);
1✔
207
                                    Toast.makeText(context, context.getString(R.string.invalid_optibp_data), Toast.LENGTH_SHORT).show();
1✔
208
                                }
209
                            } else
1✔
210
                                Timber.e("NO RESULT FROM OPTIBP APP finalRequestCode %s, resultCode %s", finalRequestCode, resultCode);
×
211
                        } catch (Exception e) {
×
212
                            Timber.e(e);
×
213
                        }
1✔
214
                    }
215
                } else {
216
                    Timber.e("final Request code: %s,  ResultCode : %s , Data from OptiBP: %s ", finalRequestCode, resultCode, data);
×
217
                    Toast.makeText(context, context.getString(R.string.optibp_unable_to_receive), Toast.LENGTH_SHORT).show();
×
218
                }
219
            });
1✔
220
        }
221
    }
1✔
222

223
    private void setGlobalLayoutListener(final LinearLayout rootLayout, final EditText systolicBPEditText, final EditText diastolicBPEditText) {
224
        if (systolicBPEditText != null && diastolicBPEditText != null) {
1✔
225
            rootLayout.getViewTreeObserver().addOnGlobalLayoutListener(() -> {
1✔
226
                if (rootLayout.getVisibility() != View.VISIBLE
×
227
                        && TextUtils.isEmpty(systolicBPEditText.getText())
×
228
                        && TextUtils.isEmpty(diastolicBPEditText.getText())) {
×
229
                    Timber.i("OptiBP widget not visible");
×
230
                    toggleEditTextEnabled(systolicBPEditText, true);
×
231
                    toggleEditTextEnabled(diastolicBPEditText, true);
×
232
                }
233
            });
×
234
        }
235
    }
1✔
236

237
    private void setButtonBgColor(Button button, String colorString) {
238
        Drawable background = button.getBackground();
1✔
239
        if (background instanceof ShapeDrawable) {
1✔
240
            ((ShapeDrawable) background).getPaint().setColor(Color.parseColor(colorString));
×
241
        } else if (background instanceof GradientDrawable) {
1✔
242
            ((GradientDrawable) background).setColor(Color.parseColor(colorString));
×
243
        } else if (background instanceof ColorDrawable) {
1✔
244
            ((ColorDrawable) background).setColor(Color.parseColor(colorString));
×
245
        }
246
    }
1✔
247

248
    private void writeResult(JsonApi jsonApi, LinearLayout rootLayout, String resultJson, WidgetArgs widgetArgs) throws JSONException {
249
        // Write result JSON to widget value
250
        String key = (String) rootLayout.getTag(R.id.key);
1✔
251
        String openMrsEntityParent = (String) rootLayout.getTag(R.id.openmrs_entity_parent);
1✔
252
        String openMrsEntity = (String) rootLayout.getTag(R.id.openmrs_entity);
1✔
253
        String openMrsEntityId = (String) rootLayout.getTag(R.id.openmrs_entity_id);
1✔
254
        jsonApi.writeValue(widgetArgs.getStepName(), key, resultJson, openMrsEntityParent,
1✔
255
                openMrsEntity, openMrsEntityId, widgetArgs.isPopup());
1✔
256
    }
1✔
257

258
    protected void populateBPEditTextValues(String resultJsonString, EditText systolicBPEditText, EditText diastolicBPEditText, WidgetArgs widgetArgs) throws JSONException {
259
        if (systolicBPEditText != null) {
1✔
260
            systolicBPEditText.setText(getBPValue(resultJsonString, BPFieldType.SYSTOLIC_BP));
1✔
261
            toggleEditTextEnabled(systolicBPEditText, false);
1✔
262
        }
263
        if (diastolicBPEditText != null) {
1✔
264
            diastolicBPEditText.setText(getBPValue(resultJsonString, BPFieldType.DIASTOLIC_BP));
1✔
265
            toggleEditTextEnabled(diastolicBPEditText, false);
1✔
266
        }
267
    }
1✔
268

269
    private void toggleEditTextEnabled(EditText editText, boolean enabled) {
270
        editText.setEnabled(enabled);
1✔
271
        editText.setClickable(enabled);
1✔
272
        editText.setFocusable(enabled);
1✔
273
        editText.setFocusableInTouchMode(enabled);
1✔
274
    }
1✔
275

276
    protected String getBPValue(String resultJsonString, BPFieldType field) throws JSONException {
277
        if (resultJsonString != null) {
1✔
278
            JSONObject jsonObject = new JSONObject(resultJsonString);
1✔
279
            JSONArray result = jsonObject.getJSONArray(OptibpConstants.OPTIBP_REPORT_RESULT);
1✔
280
            JSONObject resultObject = result.getJSONObject(0);
1✔
281
            JSONArray component = resultObject.getJSONArray(OptibpConstants.OPTIBP_REPORT_COMPONENT);
1✔
282
            JSONObject bpComponent = ((JSONObject) component.get(BPFieldType.SYSTOLIC_BP.equals(field) ? 1 : 0));
1✔
283
            JSONObject valueQuantity = bpComponent.getJSONObject(OptibpConstants.OPTIBP_REPORT_VALUE_QUANTITY);
1✔
284
            int value = valueQuantity.getInt(VALUE);
1✔
285
            return String.valueOf(value);
1✔
286
        }
287
        return null;
×
288
    }
289

290
    protected String getValueString(String resultJsonString) throws JSONException {
291
        if (resultJsonString != null) {
1✔
292
            JSONObject jsonObject = new JSONObject(resultJsonString);
1✔
293
            JSONArray result = jsonObject.getJSONArray(OptibpConstants.OPTIBP_REPORT_RESULT);
1✔
294
            JSONObject resultObject = result.getJSONObject(0);
1✔
295
            JSONArray component = resultObject.getJSONArray(OptibpConstants.OPTIBP_REPORT_COMPONENT);
1✔
296
            JSONObject secondIndex = component.optJSONObject(2);
1✔
297
            String valueString = secondIndex.optString(OptibpConstants.OPTIBP_VALUE_STRING);
1✔
298
            Timber.d("Comparative Array from OPtibp: %s", valueString);
1✔
299
            return valueString;
1✔
300
        }
301
        return null;
1✔
302

303
    }
304

305
    protected EditText getBPEditTextField(WidgetArgs widgetArgs, BPFieldType field) {
306
        Context context = widgetArgs.getContext();
1✔
307
        EditText bpEditText = (EditText) widgetArgs.getFormFragment().getJsonApi().getFormDataView(widgetArgs.getStepName() + ":" + field.getKey());
1✔
308
        if (bpEditText == null) {
1✔
309
            Toast.makeText(context, context.getString(R.string.optibp_values_error), Toast.LENGTH_SHORT).show();
×
310
            Timber.e(context.getString(R.string.optibp_values_error));
×
311
            return null;
×
312
        }
313
        return bpEditText;
1✔
314
    }
315

316
    private int getRequestCode(boolean isRepeat) {
317
        return isRepeat ? OptibpConstants.OPTIBP_REPEAT_REQUEST_CODE : OptibpConstants.OPTIBP_REQUEST_CODE;
1✔
318
    }
319

320
    @SuppressWarnings("SameParameterValue")
321
    private boolean isRepeatMeasurement(BPFieldType systolicField, BPFieldType diastolicField) {
322
        return systolicField.getKey().contains("repeat") && diastolicField.getKey().contains("repeat");
1✔
323
    }
324

325
    protected String getInputJsonString(Context context, JSONObject jsonObject, WidgetArgs widgetArgs) throws JSONException {
326
        if (!jsonObject.has(OptibpConstants.OPTIBP_KEY_DATA)) {
1✔
327
            throw new JSONException(context.getString(R.string.missing_client_info));
×
328
        }
329
        JSONObject optiBPData = jsonObject.getJSONObject(OptibpConstants.OPTIBP_KEY_DATA);
1✔
330
        if (!optiBPData.has(OptibpConstants.OPTIBP_KEY_CLIENT_ID)
1✔
331
                || !optiBPData.has(OptibpConstants.OPTIBP_KEY_CLIENT_OPENSRP_ID)) {
1✔
332
            throw new JSONException(context.getString(R.string.missing_client_info));
×
333
        }
334
        if (TextUtils.isEmpty(optiBPData.getString(OptibpConstants.OPTIBP_KEY_CLIENT_ID))
1✔
335
                || TextUtils.isEmpty(optiBPData.getString(OptibpConstants.OPTIBP_KEY_CLIENT_OPENSRP_ID))) {
1✔
336
            throw new JSONException(context.getString(R.string.missing_client_info));
×
337
        }
338
        /***
339
         * Adding new calibration data here
340
         */
341
        appendHealthData(optiBPData, widgetArgs);
1✔
342
        optiBPData.put(OptibpConstants.CALIBRATION, getCalibrationData(Utils.decompress(optiBPData.optString(OptibpConstants.CALIBRATION),"UTF-8")));
1✔
343
        return optiBPData.toString();
1✔
344
    }
345

346
    private JSONArray getCalibrationData(String calibration) {
347
        try {
348
            if (Utils.checkIfValidJsonArray(calibration)) {
1✔
349
                return new JSONArray(calibration);
×
350
            }
351
            return StringUtils.isBlank(calibration) ? null : new JSONArray().put(new JSONObject(calibration));
1✔
352
        } catch (Exception e) {
×
353
            Timber.e(e);
×
354
            return null;
×
355
        }
356

357
    }
358

359
    private void appendHealthData(JSONObject returnObject, WidgetArgs widgetArgs) {
360
        try {
361
            JSONObject currentHeight = getSingleStepJsonObject(widgetArgs, STEP1, OptibpConstants.HEIGHT);
1✔
362
            JSONObject currentWeight = getSingleStepJsonObject(widgetArgs, STEP1, OptibpConstants.CURRENTWEIGHT);
1✔
363
            if (currentHeight != null && currentWeight != null) {
1✔
364
                returnObject.put(OptibpConstants.HEIGHT, Integer.parseInt(currentHeight.optString(VALUE)));
×
365
                returnObject.put(OptibpConstants.WEIGHT, Integer.parseInt(currentWeight.optString(VALUE)));
×
366
            }
367
        } catch (JSONException e) {
×
368
            Timber.e(e);
×
369
        }
1✔
370
    }
1✔
371

372
    private static JSONObject getSingleStepJsonObject(WidgetArgs widgetArgs, String stepName, String key) {
373
        JSONArray jsonArray = widgetArgs.getFormFragment().getJsonApi().getStep(stepName).optJSONArray(FIELDS);
1✔
374
        return Utils.getJsonObjectFromJsonArray(key, jsonArray);
1✔
375

376
    }
377

378
    private String getLabelText(Context context, JSONObject jsonObject) throws JSONException {
379
        if (!jsonObject.has(LABEL)) {
1✔
380
            return context.getString(R.string.optibp_label);
×
381
        }
382
        return jsonObject.getString(LABEL);
1✔
383
    }
384

385
    @SuppressLint("InflateParams")
386
    public LinearLayout getRootLayout(Context context) {
387
        return (LinearLayout) LayoutInflater.from(context).inflate(R.layout.native_form_item_optibp_widget, null);
×
388
    }
389

390
    @Override
391
    public @NotNull Set<String> getCustomTranslatableWidgetFields() {
392
        Set<String> customTranslatableWidgetFields = new HashSet<>();
×
393
        customTranslatableWidgetFields.add(LABEL);
×
394
        return customTranslatableWidgetFields;
×
395
    }
396

397
    private void attachRefreshLogic(Context context, JSONObject jsonObject, View view) {
398
        String relevance = jsonObject.optString(RELEVANCE);
1✔
399
        String constraints = jsonObject.optString(CONSTRAINTS);
1✔
400
        String calculation = jsonObject.optString(CALCULATION);
1✔
401

402
        if (StringUtils.isNotBlank(relevance) && context instanceof JsonApi) {
1✔
403
            view.setTag(R.id.relevance, relevance);
×
404
            ((JsonApi) context).addSkipLogicView(view);
×
405
        }
406

407
        if (StringUtils.isNotBlank(constraints) && context instanceof JsonApi) {
1✔
408
            view.setTag(R.id.constraints, constraints);
×
409
            ((JsonApi) context).addConstrainedView(view);
×
410
        }
411

412
        if (StringUtils.isNotBlank(calculation) && context instanceof JsonApi) {
1✔
413
            view.setTag(R.id.calculation, calculation);
×
414
            ((JsonApi) context).addCalculationLogicView(view);
×
415
        }
416
    }
1✔
417

418
    protected enum BPFieldType {
1✔
419
        DIASTOLIC_BP("bp_diastolic"), SYSTOLIC_BP("bp_systolic");  // TODO -> Add these KEYS to explicit documentation
1✔
420

421
        private String key;
422

423
        public String getKey() {
424
            return key;
1✔
425
        }
426

427
        public void setKey(String key) {
428
            this.key = key;
1✔
429
        }
1✔
430

431
        BPFieldType(String key) {
1✔
432
            this.key = key;
1✔
433
        }
1✔
434
    }
435
}
436

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