Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Derived Attributes are validated(Derived attribute is a computed attribute and should not be validated)
Derived Attributes are validated [message #1854349] Mon, 15 August 2022 17:24
Yigal Spinner is currently offline Yigal SpinnerFriend
Messages: 127
Registered: July 2009
Senior Member
In the Validation code in EObjectValidator.java:
  protected boolean validate_DataValueConforms
    (EObject eObject, EAttribute eAttribute, DiagnosticChain diagnostics, Map<Object, Object> context)
  {
    if (!eObject.eIsSet(eAttribute))
    {
      return true;
    }
    boolean result = true;
    EDataType eDataType = eAttribute.getEAttributeType();
. . .

The code checks is the EAttribute is set regardless if it is derived or not.

The code should be something like this:
  protected boolean validate_DataValueConforms
    (EObject eObject, EAttribute eAttribute, DiagnosticChain diagnostics, Map<Object, Object> context)
  {
    if (eAttribute.isDerived() || !eObject.eIsSet(eAttribute))
    {
      return true;
    }
    boolean result = true;
    EDataType eDataType = eAttribute.getEAttributeType();
. . .


Since my derived attribute in the model has complex calculation, I do not wish to run the calculation every time the model is validated.

How can I make validation skip the derived attributes?
Derived Attributes are really not important for validation

Another option is to generate in the implementation of the class under eIsSet(), return always false for derived attributes:
    public boolean eIsSet(int featureID) {
        switch (featureID) {
            case FSDModelPackage.WIDGET_PART_LAYOUT__WIDTH:
                return getWidth() != WIDTH_EDEFAULT;
            case FSDModelPackage.WIDGET_PART_LAYOUT__HEIGHT:
                return getHeight() != HEIGHT_EDEFAULT;
            case FSDModelPackage.WIDGET_PART_LAYOUT__OVERRIDE_WIDTH:
                return overrideWidth != OVERRIDE_WIDTH_EDEFAULT;
            case FSDModelPackage.WIDGET_PART_LAYOUT__OVERRIDE_HEIGHT:
                return overrideHeight != OVERRIDE_HEIGHT_EDEFAULT;
            case FSDModelPackage.WIDGET_PART_LAYOUT__COLUMN_POSITION:
                return columnPosition != COLUMN_POSITION_EDEFAULT;
            case FSDModelPackage.WIDGET_PART_LAYOUT__ROW_POSITION:
                return rowPosition != ROW_POSITION_EDEFAULT;
            case FSDModelPackage.WIDGET_PART_LAYOUT__WIDTH_UI:
                return false; // CMT54208:25713 Derived value, do not check
            case FSDModelPackage.WIDGET_PART_LAYOUT__HEIGHT_UI:
                return false; // CMT54208:25713 Derived value, do not check
        }
        return super.eIsSet(featureID);
    }


Thanks
Yigal
Previous Topic:a registered resource factory is needed" outside the generated editor
Next Topic:[CDO] Prevent timeout of custom long-running CDOQuery
Goto Forum:
  


Current Time: Tue Apr 23 09:41:56 GMT 2024

Powered by FUDForum. Page generated in 0.03518 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top