Skip to main content



      Home
Home » Modeling » EMF » Creating SelectEntry for Attributes of a Class
Creating SelectEntry for Attributes of a Class [message #636420] Mon, 01 November 2010 03:51 Go to next message
Eclipse UserFriend
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

[Updated on: Mon, 01 November 2010 03:54] by Moderator

Re: Creating SelectEntry for Attributes of a Class [message #636425 is a reply to message #636420] Mon, 01 November 2010 04:45 Go to previous messageGo to next message
Eclipse UserFriend
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 04:46] by Moderator

Re: Creating SelectEntry for Attributes of a Class [message #636486 is a reply to message #636425] Mon, 01 November 2010 10:55 Go to previous message
Eclipse UserFriend
Thanx Saurav,

That was exactly what i wanted Smile and its working now Smile
Previous Topic:Problem instantiating model
Next Topic:Modelling XBRL Taxonomy
Goto Forum:
  


Current Time: Sun Jul 06 12:05:02 EDT 2025

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

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

Back to the top