Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » IOclHelper and parsing ocl expression of any result type
IOclHelper and parsing ocl expression of any result type [message #18192] Fri, 27 January 2006 17:41 Go to next message
Radomil Dvorak is currently offline Radomil DvorakFriend
Messages: 249
Registered: July 2009
Senior Member
Hi,



Is there a safe way how to parse a general OCL expression of any result type

(similarly as with *.emf.ocl.query.QueryFactory) ?

IOclHelper only provides methods for creating set of constraint expressions.

The only method applicable in classifier context here is createInvariant and
I would expect that

it requires a Boolean type expression. However, it does not and
createInvariant(String expression)

method is used elsewhere for parsing a generic expression

(for instance:
org.eclipse.emf.ocl.examples.interpreter.console.OclResource .save(...)).



Could there be a stronger contract for clients to create a query like
OclExpression ?

I can not use QueryFactory itself as I need to use specific Environment.



Regards,

/Radek
Re: IOclHelper and parsing ocl expression of any result type [message #18209 is a reply to message #18192] Fri, 27 January 2006 18:27 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: stepper.sympedia.de

Hi Radek,

Some days ago I've tried the following:
try
{
String path = "c:/ws/mde/com.sympedia.density.mde/model/mde.deploy";
String expr = "Deployment.allInstances()->select(dependencies->exists(r : Reference | r.target.id = 'system'))";

EObject eObject = EcoreHelper.getXMIObject(path);
EClass eClass = eObject.eClass();

EcoreEnvironmentFactory factory = new EcoreEnvironmentFactory(EPackage.Registry.INSTANCE);
Map extentMap = factory.createExtentMap(eObject);
Environment env = factory.createClassifierContext(eClass);
OclExpression ast = ExpressionsUtil.createInvariant(env, expr, true);

Query query = QueryFactory.eINSTANCE.createQuery(ast);
query.setExtentMap(extentMap);

Object result = query.evaluate(eObject);
System.out.println("Success: " + result);
MessageDialog.openInformation(shell, "Success", result.toString());
}
catch (Exception ex)
{
ex.printStackTrace();
MessageDialog.openInformation(shell, "Failure", ex.toString());
}

If you use ExpressionsUtil, don't forget to add antlr to your prerequisites!

Cheers
/Eike


Radek Dvorak schrieb:
> Hi,
>
>
>
> Is there a safe way how to parse a general OCL expression of any result type
>
> (similarly as with *.emf.ocl.query.QueryFactory) ?
>
> IOclHelper only provides methods for creating set of constraint expressions.
>
> The only method applicable in classifier context here is createInvariant and
> I would expect that
>
> it requires a Boolean type expression. However, it does not and
> createInvariant(String expression)
>
> method is used elsewhere for parsing a generic expression
>
> (for instance:
> org.eclipse.emf.ocl.examples.interpreter.console.OclResource .save(...)).
>
>
>
> Could there be a stronger contract for clients to create a query like
> OclExpression ?
>
> I can not use QueryFactory itself as I need to use specific Environment.
>
>
>
> Regards,
>
> /Radek
>
>
Re: IOclHelper and parsing ocl expression of any result type [message #18244 is a reply to message #18192] Fri, 27 January 2006 19:35 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, Radek,

I agree that the ambiguity of the "createInvariant" method on the IOclHelper
is confusing. I think to have an additional "createQuery()" operation
would have been a good counterpart to createInvariant(), which could then
have asserted the boolean result type. As it is, adding this precondition
to the existing createInvariant() method would be an API-breaking change
but, hey, this is still version 1.0.0 after all.

How about you raise a bugzilla and we'll see what can best be done about it?

Thanks,

Christian



Radek Dvorak wrote:

> Hi,
>
>
>
> Is there a safe way how to parse a general OCL expression of any result
> type
>
> (similarly as with *.emf.ocl.query.QueryFactory) ?
>
> IOclHelper only provides methods for creating set of constraint
> expressions.
>
> The only method applicable in classifier context here is createInvariant
> and I would expect that
>
> it requires a Boolean type expression. However, it does not and
> createInvariant(String expression)
>
> method is used elsewhere for parsing a generic expression
>
> (for instance:
> org.eclipse.emf.ocl.examples.interpreter.console.OclResource .save(...)).
>
>
>
> Could there be a stronger contract for clients to create a query like
> OclExpression ?
>
> I can not use QueryFactory itself as I need to use specific Environment.
>
>
>
> Regards,
>
> /Radek
Re: IOclHelper and parsing ocl expression of any result type [message #18346 is a reply to message #18244] Mon, 30 January 2006 11:06 Go to previous messageGo to next message
Radomil Dvorak is currently offline Radomil DvorakFriend
Messages: 249
Registered: July 2009
Senior Member
Hi Christian,

I have submitted https://bugs.eclipse.org/bugs/show_bug.cgi?id=125684
I assume then that I can safely use "createInvariant" for my use-case until
this bug is resolved, right ?

Thanks,
/Radek


"Christian W. Damus" <cdamus@ca.ibm.com> wrote in message
news:drdsl9$1rf$1@utils.eclipse.org...
> Hi, Radek,
>
> I agree that the ambiguity of the "createInvariant" method on the
> IOclHelper
> is confusing. I think to have an additional "createQuery()" operation
> would have been a good counterpart to createInvariant(), which could then
> have asserted the boolean result type. As it is, adding this precondition
> to the existing createInvariant() method would be an API-breaking change
> but, hey, this is still version 1.0.0 after all.
>
> How about you raise a bugzilla and we'll see what can best be done about
> it?
>
> Thanks,
>
> Christian
>
>
>
> Radek Dvorak wrote:
>
>> Hi,
>>
>>
>>
>> Is there a safe way how to parse a general OCL expression of any result
>> type
>>
>> (similarly as with *.emf.ocl.query.QueryFactory) ?
>>
>> IOclHelper only provides methods for creating set of constraint
>> expressions.
>>
>> The only method applicable in classifier context here is createInvariant
>> and I would expect that
>>
>> it requires a Boolean type expression. However, it does not and
>> createInvariant(String expression)
>>
>> method is used elsewhere for parsing a generic expression
>>
>> (for instance:
>> org.eclipse.emf.ocl.examples.interpreter.console.OclResource .save(...)).
>>
>>
>>
>> Could there be a stronger contract for clients to create a query like
>> OclExpression ?
>>
>> I can not use QueryFactory itself as I need to use specific Environment.
>>
>>
>>
>> Regards,
>>
>> /Radek
>
Re: IOclHelper and parsing ocl expression of any result type [message #18379 is a reply to message #18346] Mon, 30 January 2006 13:55 Go to previous message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Yes, that is correct.

Thanks!

Christian


Radek Dvorak wrote:

> Hi Christian,
>
> I have submitted https://bugs.eclipse.org/bugs/show_bug.cgi?id=125684
> I assume then that I can safely use "createInvariant" for my use-case
> until this bug is resolved, right ?
>
> Thanks,
> /Radek
>
>
> "Christian W. Damus" <cdamus@ca.ibm.com> wrote in message
> news:drdsl9$1rf$1@utils.eclipse.org...
>> Hi, Radek,
>>
>> I agree that the ambiguity of the "createInvariant" method on the
>> IOclHelper
>> is confusing. I think to have an additional "createQuery()" operation
>> would have been a good counterpart to createInvariant(), which could then
>> have asserted the boolean result type. As it is, adding this
>> precondition to the existing createInvariant() method would be an
>> API-breaking change but, hey, this is still version 1.0.0 after all.
>>
>> How about you raise a bugzilla and we'll see what can best be done about
>> it?
>>
>> Thanks,
>>
>> Christian
>>
>>
>>
>> Radek Dvorak wrote:
>>
>>> Hi,
>>>
>>>
>>>
>>> Is there a safe way how to parse a general OCL expression of any result
>>> type
>>>
>>> (similarly as with *.emf.ocl.query.QueryFactory) ?
>>>
>>> IOclHelper only provides methods for creating set of constraint
>>> expressions.
>>>
>>> The only method applicable in classifier context here is createInvariant
>>> and I would expect that
>>>
>>> it requires a Boolean type expression. However, it does not and
>>> createInvariant(String expression)
>>>
>>> method is used elsewhere for parsing a generic expression
>>>
>>> (for instance:
>>> org.eclipse.emf.ocl.examples.interpreter.console.OclResource .save(...)).
>>>
>>>
>>>
>>> Could there be a stronger contract for clients to create a query like
>>> OclExpression ?
>>>
>>> I can not use QueryFactory itself as I need to use specific Environment.
>>>
>>>
>>>
>>> Regards,
>>>
>>> /Radek
>>
Re: IOclHelper and parsing ocl expression of any result type [message #564586 is a reply to message #18192] Fri, 27 January 2006 18:27 Go to previous message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6634
Registered: July 2009
Senior Member
Hi Radek,

Some days ago I've tried the following:
try
{
String path = "c:/ws/mde/com.sympedia.density.mde/model/mde.deploy";
String expr = "Deployment.allInstances()->select(dependencies->exists(r : Reference | r.target.id = 'system'))";

EObject eObject = EcoreHelper.getXMIObject(path);
EClass eClass = eObject.eClass();

EcoreEnvironmentFactory factory = new EcoreEnvironmentFactory(EPackage.Registry.INSTANCE);
Map extentMap = factory.createExtentMap(eObject);
Environment env = factory.createClassifierContext(eClass);
OclExpression ast = ExpressionsUtil.createInvariant(env, expr, true);

Query query = QueryFactory.eINSTANCE.createQuery(ast);
query.setExtentMap(extentMap);

Object result = query.evaluate(eObject);
System.out.println("Success: " + result);
MessageDialog.openInformation(shell, "Success", result.toString());
}
catch (Exception ex)
{
ex.printStackTrace();
MessageDialog.openInformation(shell, "Failure", ex.toString());
}

If you use ExpressionsUtil, don't forget to add antlr to your prerequisites!

Cheers
/Eike


Radek Dvorak schrieb:
> Hi,
>
>
>
> Is there a safe way how to parse a general OCL expression of any result type
>
> (similarly as with *.emf.ocl.query.QueryFactory) ?
>
> IOclHelper only provides methods for creating set of constraint expressions.
>
> The only method applicable in classifier context here is createInvariant and
> I would expect that
>
> it requires a Boolean type expression. However, it does not and
> createInvariant(String expression)
>
> method is used elsewhere for parsing a generic expression
>
> (for instance:
> org.eclipse.emf.ocl.examples.interpreter.console.OclResource .save(...)).
>
>
>
> Could there be a stronger contract for clients to create a query like
> OclExpression ?
>
> I can not use QueryFactory itself as I need to use specific Environment.
>
>
>
> Regards,
>
> /Radek
>
>


Re: IOclHelper and parsing ocl expression of any result type [message #564647 is a reply to message #18192] Fri, 27 January 2006 19:35 Go to previous message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, Radek,

I agree that the ambiguity of the "createInvariant" method on the IOclHelper
is confusing. I think to have an additional "createQuery()" operation
would have been a good counterpart to createInvariant(), which could then
have asserted the boolean result type. As it is, adding this precondition
to the existing createInvariant() method would be an API-breaking change
but, hey, this is still version 1.0.0 after all.

How about you raise a bugzilla and we'll see what can best be done about it?

Thanks,

Christian



Radek Dvorak wrote:

> Hi,
>
>
>
> Is there a safe way how to parse a general OCL expression of any result
> type
>
> (similarly as with *.emf.ocl.query.QueryFactory) ?
>
> IOclHelper only provides methods for creating set of constraint
> expressions.
>
> The only method applicable in classifier context here is createInvariant
> and I would expect that
>
> it requires a Boolean type expression. However, it does not and
> createInvariant(String expression)
>
> method is used elsewhere for parsing a generic expression
>
> (for instance:
> org.eclipse.emf.ocl.examples.interpreter.console.OclResource .save(...)).
>
>
>
> Could there be a stronger contract for clients to create a query like
> OclExpression ?
>
> I can not use QueryFactory itself as I need to use specific Environment.
>
>
>
> Regards,
>
> /Radek
Re: IOclHelper and parsing ocl expression of any result type [message #564810 is a reply to message #18244] Mon, 30 January 2006 11:06 Go to previous message
Radomil Dvorak is currently offline Radomil DvorakFriend
Messages: 249
Registered: July 2009
Senior Member
Hi Christian,

I have submitted https://bugs.eclipse.org/bugs/show_bug.cgi?id=125684
I assume then that I can safely use "createInvariant" for my use-case until
this bug is resolved, right ?

Thanks,
/Radek


"Christian W. Damus" <cdamus@ca.ibm.com> wrote in message
news:drdsl9$1rf$1@utils.eclipse.org...
> Hi, Radek,
>
> I agree that the ambiguity of the "createInvariant" method on the
> IOclHelper
> is confusing. I think to have an additional "createQuery()" operation
> would have been a good counterpart to createInvariant(), which could then
> have asserted the boolean result type. As it is, adding this precondition
> to the existing createInvariant() method would be an API-breaking change
> but, hey, this is still version 1.0.0 after all.
>
> How about you raise a bugzilla and we'll see what can best be done about
> it?
>
> Thanks,
>
> Christian
>
>
>
> Radek Dvorak wrote:
>
>> Hi,
>>
>>
>>
>> Is there a safe way how to parse a general OCL expression of any result
>> type
>>
>> (similarly as with *.emf.ocl.query.QueryFactory) ?
>>
>> IOclHelper only provides methods for creating set of constraint
>> expressions.
>>
>> The only method applicable in classifier context here is createInvariant
>> and I would expect that
>>
>> it requires a Boolean type expression. However, it does not and
>> createInvariant(String expression)
>>
>> method is used elsewhere for parsing a generic expression
>>
>> (for instance:
>> org.eclipse.emf.ocl.examples.interpreter.console.OclResource .save(...)).
>>
>>
>>
>> Could there be a stronger contract for clients to create a query like
>> OclExpression ?
>>
>> I can not use QueryFactory itself as I need to use specific Environment.
>>
>>
>>
>> Regards,
>>
>> /Radek
>
Re: IOclHelper and parsing ocl expression of any result type [message #564899 is a reply to message #18346] Mon, 30 January 2006 13:55 Go to previous message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Yes, that is correct.

Thanks!

Christian


Radek Dvorak wrote:

> Hi Christian,
>
> I have submitted https://bugs.eclipse.org/bugs/show_bug.cgi?id=125684
> I assume then that I can safely use "createInvariant" for my use-case
> until this bug is resolved, right ?
>
> Thanks,
> /Radek
>
>
> "Christian W. Damus" <cdamus@ca.ibm.com> wrote in message
> news:drdsl9$1rf$1@utils.eclipse.org...
>> Hi, Radek,
>>
>> I agree that the ambiguity of the "createInvariant" method on the
>> IOclHelper
>> is confusing. I think to have an additional "createQuery()" operation
>> would have been a good counterpart to createInvariant(), which could then
>> have asserted the boolean result type. As it is, adding this
>> precondition to the existing createInvariant() method would be an
>> API-breaking change but, hey, this is still version 1.0.0 after all.
>>
>> How about you raise a bugzilla and we'll see what can best be done about
>> it?
>>
>> Thanks,
>>
>> Christian
>>
>>
>>
>> Radek Dvorak wrote:
>>
>>> Hi,
>>>
>>>
>>>
>>> Is there a safe way how to parse a general OCL expression of any result
>>> type
>>>
>>> (similarly as with *.emf.ocl.query.QueryFactory) ?
>>>
>>> IOclHelper only provides methods for creating set of constraint
>>> expressions.
>>>
>>> The only method applicable in classifier context here is createInvariant
>>> and I would expect that
>>>
>>> it requires a Boolean type expression. However, it does not and
>>> createInvariant(String expression)
>>>
>>> method is used elsewhere for parsing a generic expression
>>>
>>> (for instance:
>>> org.eclipse.emf.ocl.examples.interpreter.console.OclResource .save(...)).
>>>
>>>
>>>
>>> Could there be a stronger contract for clients to create a query like
>>> OclExpression ?
>>>
>>> I can not use QueryFactory itself as I need to use specific Environment.
>>>
>>>
>>>
>>> Regards,
>>>
>>> /Radek
>>
Previous Topic:IOclHelper and parsing ocl expression of any result type
Next Topic:Incorrect OCL error messages on correct OCL
Goto Forum:
  


Current Time: Thu Sep 29 21:05:37 GMT 2022

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

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

Back to the top