Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Modeling (top-level project) » Is there a query language to query the ECore model itself?(How can we express and run queries on an ECore model using a query language?)
Is there a query language to query the ECore model itself? [message #1810449] Mon, 12 August 2019 09:46 Go to next message
Seref Arikan is currently offline Seref ArikanFriend
Messages: 73
Registered: August 2010
Member
Greetings,

I have various XSDs which I can represent as ECore models. I'd like to query these models to see all subtypes/supertypes of a type, or find all types with a particular attribute name (and or type).

The query language implementations I found so far seem to support queries on the instances of objects which comply with the ECore model, but not the ECore model itself.

So I'm looking for a meta-model query language for ECore (I think). Is there an Eclipse project that would allow me to run such queries from the comfort of Eclipse IDE?

Thanks,
Seref
Re: Is there a query language to query the ECore model itself? [message #1810454 is a reply to message #1810449] Mon, 12 August 2019 11:35 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
Given that any specific Ecore instance is an instanceof EcorePackage.eINSTANCE, any query language that works on models will also work on Ecore. I'm sure the most significant issue is bounding the space of instances to consider during the query. But assuming you have the set of Ecore models you want to query, I doubt you need a query language for the simple things you describe....

For example, here I query Ecore itself:
  public static void main(String[] args)
  {
    EClass x = EcorePackage.Literals.ESTRUCTURAL_FEATURE;
    String lookingForName = "name";
    Set<EObject> models = new HashSet<EObject>();
    models.add(EcorePackage.eINSTANCE);
    for (TreeIterator<EObject> i = EcoreUtil.getAllContents(models); i.hasNext();)
    {
      EObject eObject = i.next();
      if (eObject instanceof EClass)
      {
        EClass otherEClass = (EClass)eObject;
        if (x.isSuperTypeOf((EClass)eObject))
        {
          System.out.println("It's a sublcass: " + otherEClass);
        }

        for (EStructuralFeature eStructuralFeature : otherEClass.getEStructuralFeatures())
        {
          if (lookingForName.equals(eStructuralFeature.getName()))
          {
            System.out.println("It has the feautre: " + otherEClass.getName() + " : " + eStructuralFeature);
          }
        }
      }
    }
  }


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Is there a query language to query the ECore model itself? [message #1810456 is a reply to message #1810454] Mon, 12 August 2019 11:43 Go to previous messageGo to next message
Seref Arikan is currently offline Seref ArikanFriend
Messages: 73
Registered: August 2010
Member
Hi Ed,

This is really helpful. Thanks a lot.

Cheers
Seref
Re: Is there a query language to query the ECore model itself? [message #1814618 is a reply to message #1810456] Fri, 13 September 2019 21:10 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Apologies for the very slow response.; the Thunderbird RSS feed only notified me an hour ago.

You can use the Interactive Xtext OCL Console to evaluate Ecore queries such as "self.eAllSuperTypes" or OCL "self->closure(eSuperTypes)" after selecting an EClass in some EMF tool.

Regards

Ed Willink
"
Re: Is there a query language to query the ECore model itself? [message #1814636 is a reply to message #1814618] Sun, 15 September 2019 08:58 Go to previous message
Seref Arikan is currently offline Seref ArikanFriend
Messages: 73
Registered: August 2010
Member
Hi Ed,
Thanks, this is still useful. Looks like what you're describing is pretty much what I've been looking for.

All the best
Seref
Previous Topic:Issues with Eclipse Modeling [Mars] - regarding marketplace and installation details
Next Topic:Eclipse Modeling Tools - SysML 1.6 Sequence Diagram Issue
Goto Forum:
  


Current Time: Mon Apr 29 09:09:31 GMT 2024

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

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

Back to the top