STARIONGROUP / COMET-IME-Community-Edition

The Concurrent Design Desktop Application and Excel Integration compliant with ECSS-E-TM-10-25 Annex A and Annex C
https://www.stariongroup.eu
Other
23 stars 5 forks source link

RelationalExpression Value refactoring #282

Open lxatstariongroup opened 4 years ago

lxatstariongroup commented 4 years ago

The RelationalExpression's value property is a ValueArray of strings. For every RelationalExpression.parameterType (BooleanParameterType, DateParameterType, etc) the specific string representation is defined in 10-25. Conversions for all possible ParameterTypes are located in the SDK (ParameterValueValidator, ValueSetConverter and ValueValidator classes).

In the ElementDefinitionBrowser, the Parameter's Manual and Reference properties are of object type (not string), so the WPF binding is actually on a the object's underlying DataType, which is for example a Boolean, or a DateTime datatype type and not a string. This value is converted to the 10-25 string representations and vice versa using the mentioned SDK Conversion and Validator classes.

In the RequirementsBrowser, the CDP4Requirements.ViewModels.RelationalExpressionDialogViewModel is used to create/edit a RelationalExpression. A ReactiveList<PrimitiveRow> is used for editting the RelationalExpression's Value, which is a ValueArray of string. The UI editor for this is a GridControl that binds to CDP4Requirements.ViewModels.RelationalExpressionDialogViewModel's Value property. So there is a row for every string in the CDP4Requirements.ViewModels.RelationalExpressionDialogViewModel's Value. This also means that a individual Row in the GridControl binds to a string! The DevExpress Date edit controls can work with strings as a datasource. However, DevExpress Date edit controls convert the selected value in the UI to a string themselves. This string format depends on the IME's Culture settings, which is almost always not the right 10-25 string representation. We added a temporary, Obsolete method to RelationalExpressionDialogViewModel for this (CurrentCultureStringToValueSetString) that converts this wrong string value back to a DateTime format and converts it to the right 10-25 string representation using the mentioned SDK conversion/validator classes.

The best solution however, is to make the RelationalExpressionDialogViewModel's Value property a ReactiveList<PrimitiveRow<object>>, so the DevExpress Date edit controls can work on correct values, as done in the ElementDefinitionBrowser.ParameterValueBaseRowViewModel. For inspiration: Look at the way the Manual property is handled in the following methods in ElementDefinitionBrowser.ParameterValueBaseRowViewModel:

Please notice that CDP4Requirements.ViewModels.RelationalExpressionDialogViewModel inherits from CDP4CommonView.RelationalExpressionDialogViewModel, which is an auto generated ViewModel. The Value property is defined in the generated version, so code generation has to be changed for this to be implemented. At this time this is done using T4 templates, so this has to be converted to DotLiquid first.

samatstariongroup commented 4 years ago

depends on https://github.com/RHEAGROUP/CDP4-IME-Community-Edition/issues/203