Skip to content

ide-template: ModelValues.bool duplicates ModelValues.isTrue - one .edm flag is now read case-insensitively, every other one is not #7231

Description

@delchev

Summary

#7182 (#7144) fixed CompositionChildren.refusesMasterDelete reading relationshipMasterDeleteRefused="false" as true by introducing a new helper ModelValues.bool(map, key). ModelValues.isTrue(map, key) already existed for exactly this purpose - its javadoc says "the model persists its flags as strings" - and is what every other .edm flag is read through (ModelParameterProcessor.java:310-317, 328, 824, 897: dataPrimaryKey, dataUnique, isRequiredProperty, widgetIsMajor, detailCalendar, ...).

components/ide/ide-template/src/main/java/org/eclipse/dirigible/components/ide/template/service/model/ModelValues.java:

static boolean isTrue(Map<String, Object> map, String key) {          // line 118
    Object value = map == null ? null : map.get(key);
    return Boolean.TRUE.equals(value) || "true".equals(value);
}

static boolean bool(Map<String, Object> map, String key) {            // line 137
    Object value = map == null ? null : map.get(key);
    if (value instanceof Boolean flag) { return flag; }
    return value != null && Boolean.parseBoolean(value.toString().trim());
}

The new javadoc contrasts bool with truthy and never mentions isTrue. Result: two helpers for "is this string flag true", and relationshipMasterDeleteRefused is the one attribute in the whole model that honours "TRUE" / " true " while isRequiredProperty="TRUE" is still false. bool has exactly one caller (CompositionChildren).

Fix

Replace the call with isTrue(property, "relationshipMasterDeleteRefused") and delete bool - or, if case-insensitive parsing is wanted, make isTrue do it for every flag. One rule, one helper.

Found reviewing #7182.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions