Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » cross resouce containment and validation
cross resouce containment and validation [message #505489] Thu, 31 December 2009 10:42 Go to next message
Simon Bernard is currently offline Simon BernardFriend
Messages: 345
Registered: July 2009
Senior Member
Hi,
I have 2 problems with emf validation because I use cross resource
containment.

1) When you have cross containment resource, you can have objects
which contain objets which are proxy, but the validation don't verify
that the object which will validate is a proxy or not.. so a lot of
errors are raised but not really relevant. (ex : a feature with an empty
value)

2) Unresolve proxy are not detected because the method
"validate_EveryProxyResolves" of EObjectValidor verify only proxy on
reference but not in containement.

I propose two solution :
========================
1) add a test to verify that the objet is not a proxy before to validate
it in the validator generated by EMF.

/**
* Calls <code>validateXXX</code> for the corresponding classifier of the
* model. <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Override
protected boolean validate(int classifierID, Object value,
DiagnosticChain diagnostics, Map<Object, Object> context)
{
if (value instanceof EObject && ((EObject) value).eIsProxy())
return true;

switch (classifierID)
{
case MyPackage.MY_OBJECT:
return validateMYOBJECT((MyObject) value, diagnostics, context);
.... ....
}
}


2)In EObjectValidator add test through containment to the
"validate_EveryProxyResolves" :
for (EObject content : eObject.eContents())
{
if (content.eIsProxy())
{
result &= false;
if (diagnostics != null)
{
diagnostics.add(createDiagnostic(Diagnostic.ERROR,
DIAGNOSTIC_SOURCE, EOBJECT__EVERY_PROXY_RESOLVES,
_UI_UnresolvedProxy_diagnostic", new Object[] {
getFeatureLabel(content.eContainingFeature(), context),
getObjectLabel(eObject, context), getObjectLabel(content, context)
}, new Object[] { eObject, content.eContainingFeature(), content },
context));
}
else
{
break;
}
}
}

If you are agree, I open two bug ?
Re: cross resouce containment and validation [message #505498 is a reply to message #505489] Thu, 31 December 2009 11:55 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
Simon,

Comments below.

Simon Bernard wrote:
> Hi,
> I have 2 problems with emf validation because I use cross resource
> containment.
>
> 1) When you have cross containment resource, you can have objects
> which contain objets which are proxy, but the validation don't verify
> that the object which will validate is a proxy or not.. so a lot of
> errors are raised but not really relevant. (ex : a feature with an
> empty value)
>
> 2) Unresolve proxy are not detected because the method
> "validate_EveryProxyResolves" of EObjectValidor verify only proxy on
> reference but not in containement.
>
> I propose two solution :
> ========================
> 1) add a test to verify that the objet is not a proxy before to
> validate it in the validator generated by EMF.
>
> /**
> * Calls <code>validateXXX</code> for the corresponding classifier of the
> * model. <!-- begin-user-doc --> <!-- end-user-doc -->
> *
> * @generated
> */
> @Override
> protected boolean validate(int classifierID, Object value,
> DiagnosticChain diagnostics, Map<Object, Object> context)
> {
> if (value instanceof EObject && ((EObject) value).eIsProxy())
> return true;
>
> switch (classifierID)
> {
> case MyPackage.MY_OBJECT:
> return validateMYOBJECT((MyObject) value, diagnostics,
> context);
> .... ....
> }
> }
>
>
> 2)In EObjectValidator add test through containment to the
> "validate_EveryProxyResolves" :
> for (EObject content : eObject.eContents())
> {
> if (content.eIsProxy())
> {
> result &= false;
> if (diagnostics != null)
> {
> diagnostics.add(createDiagnostic(Diagnostic.ERROR,
> DIAGNOSTIC_SOURCE, EOBJECT__EVERY_PROXY_RESOLVES,
> _UI_UnresolvedProxy_diagnostic", new Object[] {
> getFeatureLabel(content.eContainingFeature(), context),
> getObjectLabel(eObject, context),
> getObjectLabel(content, context) }, new Object[] { eObject,
> content.eContainingFeature(), content }, context));
> }
> else
> {
> break;
> }
> }
> }
>
> If you are agree, I open two bug ?
Yes, please open a bugzilla about the whole issue. I'm not totally sure
about generating the guard for case 1 though; we just shouldn't visit
such objects, so perhaps that guard should be in the Diagnostician.
I'll investigate more fully.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: cross resouce containment and validation [message #505511 is a reply to message #505498] Thu, 31 December 2009 15:27 Go to previous message
Simon Bernard is currently offline Simon BernardFriend
Messages: 345
Registered: July 2009
Senior Member
Thx Ed Merkrs, The bug is open :
https://bugs.eclipse.org/bugs/show_bug.cgi?id=298678

Ed Merks a écrit :
> Simon,
>
> Comments below.
>
> Simon Bernard wrote:
>> Hi,
>> I have 2 problems with emf validation because I use cross resource
>> containment.
>>
>> 1) When you have cross containment resource, you can have objects
>> which contain objets which are proxy, but the validation don't verify
>> that the object which will validate is a proxy or not.. so a lot of
>> errors are raised but not really relevant. (ex : a feature with an
>> empty value)
>>
>> 2) Unresolve proxy are not detected because the method
>> "validate_EveryProxyResolves" of EObjectValidor verify only proxy on
>> reference but not in containement.
>>
>> I propose two solution :
>> ========================
>> 1) add a test to verify that the objet is not a proxy before to
>> validate it in the validator generated by EMF.
>>
>> /**
>> * Calls <code>validateXXX</code> for the corresponding classifier of the
>> * model. <!-- begin-user-doc --> <!-- end-user-doc -->
>> *
>> * @generated
>> */
>> @Override
>> protected boolean validate(int classifierID, Object value,
>> DiagnosticChain diagnostics, Map<Object, Object> context)
>> {
>> if (value instanceof EObject && ((EObject) value).eIsProxy())
>> return true;
>>
>> switch (classifierID)
>> {
>> case MyPackage.MY_OBJECT:
>> return validateMYOBJECT((MyObject) value, diagnostics,
>> context);
>> .... ....
>> }
>> }
>>
>>
>> 2)In EObjectValidator add test through containment to the
>> "validate_EveryProxyResolves" :
>> for (EObject content : eObject.eContents())
>> {
>> if (content.eIsProxy())
>> {
>> result &= false;
>> if (diagnostics != null)
>> {
>> diagnostics.add(createDiagnostic(Diagnostic.ERROR,
>> DIAGNOSTIC_SOURCE, EOBJECT__EVERY_PROXY_RESOLVES,
>> _UI_UnresolvedProxy_diagnostic", new Object[] {
>> getFeatureLabel(content.eContainingFeature(), context),
>> getObjectLabel(eObject, context),
>> getObjectLabel(content, context) }, new Object[] { eObject,
>> content.eContainingFeature(), content }, context));
>> }
>> else
>> {
>> break;
>> }
>> }
>> }
>>
>> If you are agree, I open two bug ?
> Yes, please open a bugzilla about the whole issue. I'm not totally sure
> about generating the guard for case 1 though; we just shouldn't visit
> such objects, so perhaps that guard should be in the Diagnostician.
> I'll investigate more fully.
Previous Topic:umlclass Operation Manage Parameters types not working
Next Topic:Is EMF suitable to implement key/keyref pairs?
Goto Forum:
  


Current Time: Thu Apr 25 23:33:54 GMT 2024

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

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

Back to the top