Uploaded image for project: 'Fluid Infusion'
  1. Fluid Infusion
  2. FLUID-6208

Model shrinkage is not relayed - failure to clear target model when change is not of type DELETE

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Critical
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Data Binder
    • Labels:
      None

      Description

      Whilst FLUID-5585 covered a wide range of cases of relaying partial or complete DELETE changes, we've failed to cover an obvious case of "removal through ADD" - it is perfectly possible that a relay rule on receiving an ADD change at some terminal may relay this to its target as a shrinkage of previously visible model material - requiring a DELETE of some kind in order to honour it.

      This was encountered in work on at https://github.com/GPII/universal/pull/549 for https://issues.gpii.net/browse/GPII-2556. Here we had a complex free transform which relayed a preference set onto a collection of visible controls.

      gpii.pcpChannel.sessionToPCP = function (model, transformSpec) {
          var schemas = transformSpec.ontologyMetadata.flat.schemas;
          var outModel = fluid.filterKeys(model, ["userToken", "activeContextName"]);
          var settingControls = {};
          var activePreferences = fluid.get(model, ["preferences", "contexts", model.activeContextName, "preferences"]);
          fluid.each(activePreferences, function (prefsVal, prefsKey) {
              if (prefsKey.startsWith("http://registry.gpii.net/applications")) {
                  var solKey = prefsKey.substring("http://registry.gpii.net/applications/".length);
                  var solution = model.solutionsRegistryEntries[solKey];
                  if (solution) {
                      fluid.each(prefsVal, function (innerPrefsVal, innerPrefsKey) {
                          gpii.pcpChannel.emitSettingControl(settingControls, schemas[innerPrefsKey], innerPrefsVal, [prefsKey, innerPrefsKey], solution.name);
                      });
                  }
              } else {
                  gpii.pcpChannel.emitSettingControl(settingControls, schemas[prefsKey], prefsVal, [prefsKey]);
              }
          });
          outModel.settingControls = settingControls;
          fluid.set(outModel, "preferences.contexts", fluid.transform(fluid.get(model, "preferences.contexts"), function (contextVal) {
              return fluid.filterKeys(contextVal, ["name"]);
          }));
          return outModel;
      };
      

      Depending on the exact order in which model changes occurred within the ContextManager, it was possible for this rule to leave the output model as

      {
          "path": [],
          "type": "ADD",
          "value": {
              "userToken": "context1",
              "activeContextName": "bright",
              "settingControls": {
                  "http://registry\\.gpii\\.net/common/magnification": {
                      "value": 2,
                      "schema": {
                          "title": "Magnification",
                          "description": "Level of magnification",
                          "type": "number",
                          "min": 1,
                          "divisibleBy": 0.1
                      }
                  },
                  "http://registry\\.gpii\\.net/common/volume": {
                      "value": 0.5,
                      "schema": {
                          "title": "Volume",
                          "description": "General volume of the operating system",
                          "type": "number",
                          "min": 0,
                          "max": 1
                      }
                  }
              },
              "preferences": {
                  "contexts": {
                      "gpii-default": {
                          "name": "Default preferences"
                      },
                      "bright": {
                          "name": "bright"
                      },
                      "noise": {
                          "name": "noise"
                      },
                      "brightandnoise": {
                          "name": "bright and noise"
                      }
                  }
              }
          }
      }
      

      a combination of the old and new model state, rather than the expected contents of

      {
          "path": [],
          "type": "ADD",
          "value": {
              "userToken": "context1",
              "activeContextName": "bright",
              "settingControls": {
                  "http://registry\\.gpii\\.net/common/magnification": {
                      "value": 2,
                      "schema": {
                          "title": "Magnification",
                          "description": "Level of magnification",
                          "type": "number",
                          "min": 1,
                          "divisibleBy": 0.1
                      }
                  }
              },
              "preferences": {
                  "contexts": {
                      "gpii-default": {
                          "name": "Default preferences"
                      },
                      "bright": {
                          "name": "bright"
                      },
                      "noise": {
                          "name": "noise"
                      },
                      "brightandnoise": {
                          "name": "bright and noise"
                      }
                  }
              }
          }
      }
      

      which just includes one control output.

        Attachments

          Activity

            People

            Assignee:
            antranig Antranig Basman
            Reporter:
            antranig Antranig Basman
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated: