Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Creating SelectEntry for Attributes of a Class
Creating SelectEntry for Attributes of a Class [message #636420] Mon, 01 November 2010 07:51 Go to next message
Animesh Kumar is currently offline Animesh KumarFriend
Messages: 79
Registered: September 2010
Location: Bangalore
Member
Hi All,
I was trying to retrieve all values stored for a class using Query2. I used the following code :-

ResourceSet rs = new ResourceSetImpl();
		QueryContext queryContext = getQueryContext(rs);
		QueryProcessor queryProcessor = QueryProcessorFactory.getDefault().createQueryProcessor(IndexFactory.getInstance());
		SelectEntry select = new SelectAlias("obj");
		FromType from = new FromType(/* aliasName */"obj", /* type URI */
		eClassURI, /* withoutsubtypes */false);
		Query query = new Query(new SelectEntry[] { select }, new FromEntry[] { from });
		ResultSet resultSet = queryProcessor.execute(query, queryContext);
		return resultSet;


The above snippet represents a query:-
Search:
from eClass /* Variable */ as obj select obj


But here the SelectEntry is only for the class and not for its attributes.

I want to create a SelectEntry for the attributes. I have the attributes retrieved but i have no idea about the format to be used to use those attributes in the code. How can i create a java code like the above for a query which is something like this :-

Search:
from eClass /* Variable */ as obj select obj.attribute1, obj.attribute2



Regards,
Animesh

[Updated on: Mon, 01 November 2010 07:54]

Report message to a moderator

Re: Creating SelectEntry for Attributes of a Class [message #636425 is a reply to message #636420] Mon, 01 November 2010 08:45 Go to previous messageGo to next message
saurav sarkar is currently offline saurav sarkarFriend
Messages: 428
Registered: July 2009
Senior Member
Hi Animesh,

You can specify attributes like this.

SelectAttrs selectMeName = new SelectAttrs("mm", new String[] { "name", "attrInt1" });
SelectEntry[] selectEntries = new SelectEntry[] { selectMeName };

Where mm is alias and the String array having all the attributes.

Check the SelectAttrs class.

Hope this helps.

cheers,
Saurav


[Updated on: Mon, 01 November 2010 08:46]

Report message to a moderator

Re: Creating SelectEntry for Attributes of a Class [message #636486 is a reply to message #636425] Mon, 01 November 2010 14:55 Go to previous message
Animesh Kumar is currently offline Animesh KumarFriend
Messages: 79
Registered: September 2010
Location: Bangalore
Member
Thanx Saurav,

That was exactly what i wanted Smile and its working now Smile


Regards,
Animesh
Previous Topic:Problem instantiating model
Next Topic:Modelling XBRL Taxonomy
Goto Forum:
  


Current Time: Sun Oct 20 18:47:00 GMT 2019

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

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

Back to the top