pyecore icon indicating copy to clipboard operation
pyecore copied to clipboard

A query language to get classes from model

Open mertserezli opened this issue 7 years ago • 9 comments

Hello, I am trying to build an UI for a project that uses pyecore. The users want to get classes by a query. I would like that feature. Thanks!

mertserezli avatar Dec 14 '18 09:12 mertserezli

Hi @mertserezli !

Thanks a lot for the idea! Indeed, it would be very great to have this feature into PyEcore. I try to start a student project on translation from OCL to Python that could provide a nice way of expressing queries on models. Regarding the queries and the hypotethical language, what are the expressions/constraints you need to express? If there is not so much complex queries, a first simple version could be easy to build.

aranega avatar Dec 14 '18 10:12 aranega

@aranega

  • Pick packages and its contents
  • Pick classes by names
  • Pick class's super classes
  • Pick class's sub classes
  • Pick class's with a specified function

mertserezli avatar Dec 14 '18 11:12 mertserezli

Got it, thatnks for the examples. Did these queries are 'frozen', I mean, do your users need to write the queries themselves of do you need to write the query, your users could select bag of elements (or the full model) and select one of your queries? (just to know, as Python is quite expressive, with few methods in the later case, it would be possible to have a quick and flexible framework). Sorry for all these questions.

aranega avatar Dec 14 '18 15:12 aranega

The users should write the queries. Those queries are not frozen. Expressiveness is important here.

mertserezli avatar Dec 14 '18 15:12 mertserezli

Ok, I got i, so it means that the user is familiar with the metamodel they will build the queries on. I'll keep this in mind and try to find a solution. The thing is always delicate as it should be simple enough to let you express complex queries as simple as possible. I think a pure external DSL would not be a good idea as it would require the implementation of many things Python provide you for free to gain maximum expressiveness.

aranega avatar Dec 14 '18 15:12 aranega

@mertserezli I think use antlr4 + pyecore is pretty easy to add a query front end. I created one for our DSL model.

CFAndy avatar Dec 25 '18 00:12 CFAndy

I know this is an older post, but I might steer your attention towards Essential Object Query (EOQ):

https://gitlab.com/eoq/essentialobjectquery

and its Python implementation, which is based on pyecore:

https://gitlab.com/eoq/py/pyeoq

EOQ is a query and transaction system for domain-specific models, which solved most of our issues when working with complex-domain specific models.

annighoefer avatar Jun 09 '20 09:06 annighoefer

Wow! That's... just ... amazing! Thanks a lot for the links. I hesitate to put a section in the readme about projects using pyecore. Would it be ok if I list EOQ and the python implementation there?

aranega avatar Jun 09 '20 09:06 aranega

Please feel free to do so. The more people use EOQ, the better it (hopefully) becomes.

annighoefer avatar Jun 09 '20 09:06 annighoefer