Skip to main content



      Home
Home » Eclipse Projects » Sirius » AQL query problems
AQL query problems [message #1719321] Thu, 07 January 2016 03:31 Go to next message
Eclipse UserFriend
Hi,

I would like to start using AQL queries but am a total novice, so I soon ran into some problems:

  1. my edge creation tool needs to query for a Precondition:
    aql:preSource.successors->size() < aql.preSource->getMaxSuccessorCount()
    where successors keeps references to other EObjects. size() works correctly, the query works if I replace the righthand side by an int constant.
    getMaxSuccessorCount() is an EOperation defined in the model. However this query does not work, how do I call getMaxSuccessorCount() correctly?

  2. how do I debug such queries correctly?
    The model requests interpreter simply shows no results, but also no error messages
    (of course I replaced the preSource reference by self.target and selected the correct node)

thanks
Christian
Re: AQL query problems [message #1719338 is a reply to message #1719321] Thu, 07 January 2016 05:41 Go to previous messageGo to next message
Eclipse UserFriend
Le 07/01/2016 09:31, Christian Pontesegger a écrit :
> Hi,
Hello
>
> I would like to start using AQL queries but am a total novice, so I soon
> ran into some problems:
>
> my edge creation tool needs to query for a Precondition:
> aql:preSource.successors->size() < aql.preSource->getMaxSuccessorCount()
> where successors keeps references to other EObjects. size() works
> correctly, the query works if I replace the righthand side by an int
> constant.
> getMaxSuccessorCount() is an EOperation defined in the model. However
> this query does not work, how do I call getMaxSuccessorCount() correctly?
First, you wrote "aql.preSource->getMaxSuccessorCount()". Simply write
preSource->getMaxSuccessorCount()
Second, check that presource is the good type on which you have
getMaxSuccessorCount() method
>
> how do I debug such queries correctly?
> The model requests interpreter simply shows no results, but also no
> error messages
> (of course I replaced the preSource reference by self.target and
> selected the correct node)
>
yes Interpreter view is a good way to test your expression. Choose
Sirius interpreter in the drop down list

> thanks
> Christian
>
Regards
Laurent
Re: AQL query problems [message #1719341 is a reply to message #1719338] Thu, 07 January 2016 05:56 Go to previous messageGo to next message
Eclipse UserFriend
a small (but important) addition

preSource.getMaxSuccessorCount() should call the EOperation. "->" is for operations which are to be applied on a collection of elements.
Re: AQL query problems [message #1719344 is a reply to message #1719341] Thu, 07 January 2016 06:30 Go to previous messageGo to next message
Eclipse UserFriend
sorry for the typo in my first post. The full query I am trying to use is:
aql:preSource.successors->size() < preSource.getMaxSuccessorCount()


I checked with the Model requests interpreter that
aql:self.target.eClass() returns the correct object type

My implementation currently returns a constant:
	public int getMaxSuccessorCount() {
		return 2;
	}


still aql:self.target.getMaxSuccessorCount() does not work, neither in the Interpreter view, nor for the precondition. When used in the precondition it always returns false and edge creation is disabled.

Getting no result indicates that either the statement is invalid or that some object there is not defined, right?

If I understand aql right, a simpler query like
aql:preSource.getSuccessors().size() < 2

Should also work, right? I would expect getSuccessors() to return an EList and afterwards size() should give me the amount of elements in that list. However also this query fails. I guess due to the same reason than the first one described above.


Re: AQL query problems [message #1719401 is a reply to message #1719344] Thu, 07 January 2016 11:23 Go to previous message
Eclipse UserFriend
> still aql:self.target.getMaxSuccessorCount() does not work, neither in the Interpreter view, nor for the precondition. When used in the precondition it always returns false and edge creation is disabled.

This definitely looks like a bug then. Isn't the implementation called at all ? did you try setting a breakpoint ? Can you confirm your ecore model is deployed as a plugin and is not in the runtime workspace ?

Furthermore, errors should have been reported in the interpreter view, isn't there anything in the error log neither ?
These areas have been improved quite a bit in the last few months, could you please give us the exact versions of AQL (org.eclipse.acceleo.query) and Sirius (org.eclipse.sirius) involved please ?

A query like :
aql:preSource.getSuccessors().size() < 2

would mean "call the method size() on every element which is in the collection returned by getSuccessors() whereas ->size() means "call the method size() on the collection.
In this case I guess there is no such method (could be an EOperation or a method contributed through an external Java class with the signature :
public int size(Successor s)

Let's say you start from an EPackage :
aql:self.eAllContents(ecore::EAttribute).name
will return a list containing all the names, a list of String then.

aql:self.eAllContents(ecore::EAttribute).someCall()

will apply the call on every EAttribute and return a list containing the results of these calls.


Previous Topic:Problem with the Create Node Tool
Next Topic:Is it possible to use Sirius without generated java code?
Goto Forum:
  


Current Time: Mon Jul 07 11:29:16 EDT 2025

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

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

Back to the top