The org.pentaho.metadata.repository.IMetadataDomainRepository interface defines methods to allow access to Metadata Domains. A Metadata Domain consists of Physical and Logical Metadata Models, which are used in various applications within the Pentaho suite of products.
The key methods in IMetadataDomainRepository are the storeDomain, getDomain, and getDomainIds. Please see the Javadoc for the entire set of methods available.
The org.pentaho.metadata.repository.FileBasedMetadataDomainRepository implementation reads and writes domains to a specified folder on the filesystem, based on a call to setDomainFolder(String).
The org.pentaho.metadata.repository.InMemoryMetadataDomainRepository implementations stores domains in memory
This class, located in the bi-platform-plugin-services project, is the BI Platform's implementation of the metadata repository. This class inherits from the FileBasedMetadataDomainRepository, and handles legacy support for XMI files that appear in root solution folders within the BI Platform. This class also handles metadata security.
In order to load an existing XMI file into a domain repository outside of the BI Platform, you should first load the XMI file into a Domain object, and then store the domain in the repository. The org.pentaho.metadata.util.XmiParser class should be used to parse the XMI file, using the parseXmi(InputStream) call.
Developers can load Metadata Queries into memory by using the org.pentaho.metadata.query.model.util.QueryXmlHelper class. A call to the fromXML(IMetadataDomainRepository repo, String XML) method will load a Query object.
Within the BI Platform, the org.pentaho.platform.plugin.action.pentahometadata.MetadataQueryComponent handles the execution of the metadata queries. This class is located in the bi-platform-plugin-actions project. The execute method of this class determines the type of physical model that is executing (SQL or Inline ETL), and creates an IPentahoResultSet. Helper classes within the Metadata system that make this possible include the org.pentaho.metadata.query.impl.sql.SqlGenerator class, which generates a SQL statement, as well as the InlineEtlQueryExecutor class, which generates an in memory result set.
At the time of this writing, there is no encapsulation of the IPentahoResultSet generation within the Metadata project. Projects not utilizing the BI Platform will need to implement the logic for managing JDBC connections and determining which physical model should be executed based on the Query object. See the MetadataQueryComponent for an example implementation.