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 12:41  |
Eclipse User |
|
|
|
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 13:27   |
Eclipse User |
|
|
|
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 14:35   |
Eclipse User |
|
|
|
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 06:06   |
Eclipse User |
|
|
|
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 08:55  |
Eclipse User |
|
|
|
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 13:27  |
Eclipse User |
|
|
|
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 14:35  |
Eclipse User |
|
|
|
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 06:06  |
Eclipse User |
|
|
|
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 08:55  |
Eclipse User |
|
|
|
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
>>
|
|
|
Goto Forum:
Current Time: Sun May 11 13:56:03 EDT 2025
Powered by FUDForum. Page generated in 0.03544 seconds
|