Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "EMF/Query2/DevGuide"

< EMF‎ | Query2
Line 1: Line 1:
EMF Query2 Developer Guide
+
EMF Query2 Developer Guide  
  
== Installation ==
+
== Installation ==
  
== Overview of Query2 ==
+
== Overview of Query2 ==
Query2 provides easy mechanism to query emf metadata with minimal loading of resources. Query2 has an in-built indexing mechanism which indexes types, resources and references. This data is used during query execution and hence avoiding loading of resources wherever needed.
+
Hence, if you want to use query2, you are mandatorily required to setup indexing. After that you can use it execute queries. We will see how to set it up in later sections.
+
Query2 also provides you different ways to specify queries. We will see them in coming sections.
+
  
= Using Query2 =
+
Query2 provides easy mechanism to query emf metadata with minimal loading of resources. Query2 has an in-built indexing mechanism which indexes types, resources and references. This data is used during query execution and hence avoiding loading of resources wherever needed. Hence, if you want to use query2, you are mandatorily required to setup indexing. After that you can use it execute queries. We will see how to set it up in later sections. Query2 also provides you different ways to specify queries. We will see them in coming sections.  
== Setting up Indexes ==
+
''' Step 1 ''' Create dependency to index plugin: Add dependency to the plugins
+
# org.eclipse.emf.query.index.ui
+
# org.eclipse.emf.query.index
+
  
''' Step 2 ''' Using Indexing api:
+
= Using Query2  =
To index the resources, you can use IndexFactory as the starting point. It is a singleton class, which can keep the index for your complete workspace.
+
 
Following is code sample to index new resource:
+
== Setting up Indexes  ==
 +
 
 +
'''Step 1 ''' Create dependency to index plugin: Add dependency to the plugins
 +
 
 +
*org.eclipse.emf.query.index.ui
 +
*org.eclipse.emf.query.index
 +
 
 +
'''Step 2 ''' Using Indexing api: To index the resources, you can use IndexFactory as the starting point. It is a singleton class, which can keep the index for your complete workspace. Following is code sample to index new resource:  
 +
<pre>
 +
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.createPlatformResourceURI(resource.getFullPath().toString(), true), true));
 +
} catch (Exception e) {
 +
// Put your logging here
 +
}
 +
}
 +
});
 +
</pre>

Revision as of 06:07, 16 November 2010

EMF Query2 Developer Guide

Installation

Overview of Query2

Query2 provides easy mechanism to query emf metadata with minimal loading of resources. Query2 has an in-built indexing mechanism which indexes types, resources and references. This data is used during query execution and hence avoiding loading of resources wherever needed. Hence, if you want to use query2, you are mandatorily required to setup indexing. After that you can use it execute queries. We will see how to set it up in later sections. Query2 also provides you different ways to specify queries. We will see them in coming sections.

Using Query2

Setting up Indexes

Step 1 Create dependency to index plugin: Add dependency to the plugins

  • org.eclipse.emf.query.index.ui
  • org.eclipse.emf.query.index

Step 2 Using Indexing api: To index the resources, you can use IndexFactory as the starting point. It is a singleton class, which can keep the index for your complete workspace. Following is code sample to index new resource:

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.createPlatformResourceURI(resource.getFullPath().toString(),	true), true));
	} catch (Exception e) {
	// Put your logging here					
	}
	}
});

Back to the top