Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Implementing EMF Query2 Indexing(Trying to Implement the Query2 Index)
Implementing EMF Query2 Indexing [message #691070] Thu, 30 June 2011 16:28 Go to next message
Roshan S. is currently offline Roshan S.Friend
Messages: 125
Registered: July 2009
Senior Member
Hi,

I'm trying to implement indexing on my EMF domain model. I am following the developer guide here: http://wiki.eclipse.org/EMF/Query2/DevGuide

1. To start off I created an eCore model (ccnet) and then also generated the edit and editor plugins using the genmodel.

2. I created a new plugin called com..index and I added the dependencies from step 1 in the guide: Note that the dependencies for index are in the org.eclipse.emf.query2 package and not the query package as in the guide.
org.eclipse.emf.query2.index.ui
org.eclipse.emf.query2.index

3. I added the extension point as in step 3 to support my file extension, ccnet:
<extension
point="org.eclipse.emf.ecore.extension_parser">
<parser
class="com.index.builder.CcnetIndexFactory"
type="ccnet">
</parser>
</extension>

4. I implemented the Resource.Factory class for the QueryBuilder extension point as follows:

public class CcnetIndexFactory implements org.eclipse.emf.ecore.resource.Resource.Factory {

@Override
public Resource createResource(final URI uri) {
Index indexFactory = IndexFactory.getInstance();
IndexFactory.getInstance().executeUpdateCommand(
new UpdateCommandAdapter() {

@Override
public void execute(final IndexUpdater updater) {
final ResourceIndexer indexer = new ResourceIndexer();
final ResourceSet rs = new ResourceSetImpl();
try {
indexer.resourceChanged(updater, rs.getResource(uri, true));
} catch (Exception e) {
System.out.println(e);
}
}
});
return null;
}
}

4. After launching I added the QueryIndexBuilder and QueryIndexNature to my test project.

5. When I try to load the editor I get a stack overflow exception, when I debug and step through the program i can see that the CcnetIndexFactory.createResource(URI), just keeps getting called in an infinite loop.

I'm surely setting something up incorrectly, but I'm not sure what I'm doing wrong.

Any help is appreciated.

Thanks,
Roshan
Re: Implementing EMF Query2 Indexing [message #691306 is a reply to message #691070] Fri, 01 July 2011 07:51 Go to previous message
saurav sarkar is currently offline saurav sarkarFriend
Messages: 428
Registered: July 2009
Senior Member
Hi Roshan,

Comments below

Roshan Soni wrote on Thu, 30 June 2011 12:28
Hi,

I'm trying to implement indexing on my EMF domain model. I am following the developer guide here: http://wiki.eclipse.org/EMF/Query2/DevGuide

1. To start off I created an eCore model (ccnet) and then also generated the edit and editor plugins using the genmodel.

2. I created a new plugin called com..index and I added the dependencies from step 1 in the guide: Note that the dependencies for index are in the org.eclipse.emf.query2 package and not the query package as in the guide.
org.eclipse.emf.query2.index.ui
org.eclipse.emf.query2.index

3. I added the extension point as in step 3 to support my file extension, ccnet:
<extension
point="org.eclipse.emf.ecore.extension_parser">
<parser
class="com.index.builder.CcnetIndexFactory"
type="ccnet">
</parser>
</extension>



The class here is supposed to be the Factory class which is supposed to create your type of resource.If you feel it is XMI or XML you can put XMIResourceFactoryImpl and XMLResourceFactoryImpl.

Quote:

4. I implemented the Resource.Factory class for the QueryBuilder extension point as follows:

public class CcnetIndexFactory implements org.eclipse.emf.ecore.resource.Resource.Factory {

@Override
public Resource createResource(final URI uri) {
Index indexFactory = IndexFactory.getInstance();
IndexFactory.getInstance().executeUpdateCommand(
new UpdateCommandAdapter() {

@Override
public void execute(final IndexUpdater updater) {
final ResourceIndexer indexer = new ResourceIndexer();
final ResourceSet rs = new ResourceSetImpl();
try {
indexer.resourceChanged(updater, rs.getResource(uri, true));
} catch (Exception e) {
System.out.println(e);
}
}
});
return null;
}
}

4. After launching I added the QueryIndexBuilder and QueryIndexNature to my test project.



You need not call any indexing API from yourself.The Index builder will automatically visit your type of files in your workspace and index it.

Quote:

5. When I try to load the editor I get a stack overflow exception, when I debug and step through the program i can see that the CcnetIndexFactory.createResource(URI), just keeps getting called in an infinite loop.

I'm surely setting something up incorrectly, but I'm not sure what I'm doing wrong.


Correcting the above points will solve your problem
Quote:

Any help is appreciated.

Thanks,
Roshan


cheers,
Saurav


Previous Topic:Problems with references/proxy
Next Topic:Master/slave model: how to replicate changes?
Goto Forum:
  


Current Time: Thu Mar 28 22:41:02 GMT 2024

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

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

Back to the top