Dali Provisional API
Release 3.2

org.eclipse.jpt.jpa.core
Interface JpaProject

All Superinterfaces:
IAdaptable, JpaModel, Model
All Known Subinterfaces:
EclipseLinkJpaProject, JpaProject2_0

public interface JpaProject
extends JpaModel

A JPA project is associated with an Eclipse project (and its corresponding Java project). It holds the resource model that corresponds to the various JPA-related resources (the persistence.xml file, its mapping files [orm.xml], and the Java source files). It also holds the context model that represents the JPA metadata, as derived from spec-defined defaults, Java source code annotations, and XML descriptors.

To retrieve the JPA project corresponding to an Eclipse project:

 IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject("Foo Project");
 JpaProject jpaProject = (JpaProject) project.getAdapter(JpaProject.class);
 
This is a non-blocking call; and as a result it will return null if the JPA project is currently under construction. Use a JPA project reference to retrieve a JPA project in a blocking fashion that will return a JPA project once it has been constructed.

See org.eclipse.jpt.jpa.core/plugin.xml:org.eclipse.core.runtime.adapters.

Provisional API: This interface is part of an interim API that is still under development and expected to change significantly before reaching stability. It is available at this early stage to solicit feedback from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken (repeatedly) as the API evolves.

Since:
2.0
See Also:
JpaProject.Reference, ProjectAdapterFactory

Nested Class Summary
static interface JpaProject.Config
          The settings used to construct a JPA project.
static class JpaProject.ContextModelRootTransformer
           
static interface JpaProject.Manager
          The JPA project manager provides behavior to be used by all the JPA projects
static class JpaProject.ProjectEquals
           
static interface JpaProject.Reference
          Standard adapter for "synchronously" retrieving a JPA project (i.e. if necessary, wait for the JPA project to be constructed; thus the InterruptedException): IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject("Foo Project"); JpaProject.Reference jpaProjectRef = (JpaProject.Reference) project.getAdapter(JpaProject.Reference.class); JpaProject jpaProject = jpaProjectRef.getValue(); See org.eclipse.jpt.jpa.core/plugin.xml:org.eclipse.core.runtime.adapters.
 
Nested classes/interfaces inherited from interface org.eclipse.jpt.jpa.core.JpaModel
JpaModel.JpaVersionIsCompatibleWith
 
Field Summary
static org.eclipse.jpt.common.utility.transformer.Transformer<JpaProject,JpaContextModelRoot> CONTEXT_MODEL_ROOT_TRANSFORMER
           
static String DISCOVERS_ANNOTATED_CLASSES_PROPERTY
          ID string used when discoversAnnotatedClasses property is changed.
static String EXTERNAL_JAVA_RESOURCE_COMPILATION_UNITS_COLLECTION
          ID string used when the JPA project's collection of external Java resource compilation units changes.
static IProjectFacet FACET
          The JPA project facet.
static String FACET_ID
          The JPA project facet ID.
static IProjectFacetVersion FACET_VERSION
          The JPA project facet version.
static String FACET_VERSION_STRING
          The JPA project facet version string.
static String JPA_FILES_COLLECTION
          ID string used when the JPA project's collection of JPA files changes.
static String MARKER_TYPE
          The JPA validation marker type (value: "org.eclipse.jpt.jpa.core.problem").
static String MARKER_TYPE_SCOPE
           
static String MARKER_TYPE_SCOPE_
           
static String RELATIVE_MARKER_TYPE
           
static String USER_OVERRIDE_DEFAULT_CATALOG_PROPERTY
          ID string used when the JPA project's user override default catalog changes.
static String USER_OVERRIDE_DEFAULT_SCHEMA_PROPERTY
          ID string used when the JPA project's user override default schema changes.
 
Method Summary
 boolean discoversAnnotatedClasses()
          Return whether the JPA project will not generate error messages for any annotated classes that are not listed in the persistence.xml file or one of its mapping files.
 void dispose()
          The JPA project has been removed from the JPA model.
 Iterable<JavaResourceAbstractType> getAnnotatedJavaSourceTypes()
          Return the resource types of the JPA project's annotated Java classes (ignoring classes in JARs referenced in the persistence.xml).
 ConnectionProfile getConnectionProfile()
          Return the JPA project's connection.
 JpaContextModelRoot getContextModelRoot()
          Return the root of the JPA project's context model.
 JpaDataSource getDataSource()
          Return the data source the JPA project is mapped to.
 String getDefaultCatalog()
          Return the JPA project's default catalog; which is either the user override catalog or the database's default catalog.
 Catalog getDefaultDbCatalog()
          Return the JPA project's default database catalog.
 Schema getDefaultDbSchema()
          Return the JPA project's default database schema.
 SchemaContainer getDefaultDbSchemaContainer()
          Return the JPA project's default database schema container; which is either the JPA project's default catalog or the JPA project's database, depending on how the DTP model is implemented.
 JptXmlResource getDefaultOrmXmlResource()
          Return the XML resource model corresponding to the file META-INF/orm.xml if that file has the mapping file content type.
 String getDefaultSchema()
          Return the JPA project's default schema; which can be one of the following: the user override schema the default catalog's default schema the database's default schema (if catalogs are not supported)
 Iterable<JavaResourceCompilationUnit> getExternalJavaResourceCompilationUnits()
          Return the JPA project's external Java resource compilation units.
 int getExternalJavaResourceCompilationUnitsSize()
          Return the size of the JPA project's external Java resource compilation units.
 JavaResourceTypeCache getExternalJavaResourceTypeCache()
          Return the JPA project's external Java resource type cache.
 Iterable<JpaFile> getJarJpaFiles()
          Return the JPA project's JPA files for jars.
 IJavaProject getJavaProject()
          Return the Java project associated with the JPA project.
 JavaResourcePackage getJavaResourcePackage(String packageName)
          Return the Java resource package for the specified package.
 JavaResourcePackageFragmentRoot getJavaResourcePackageFragmentRoot(String jarFileName)
          Return the Java resource package fragement root for the specified JAR.
 Iterable<JavaResourcePackage> getJavaResourcePackages()
          Return the Java resource packages for the project.
 JavaResourceAbstractType getJavaResourceType(String typeName)
          Return the Java resource type for the fully qualified type name.
 JavaResourceAbstractType getJavaResourceType(String typeName, JavaResourceAnnotatedElement.AstNodeType astNodeType)
          Return the JavaResourceAbstractType with the fully qualified type name and astNodeType.
 JpaFile getJpaFile(IFile file)
          Return the JPA file corresponding to the specified file.
 Iterable<JpaFile> getJpaFiles()
          Return the JPA project's JPA files.
 int getJpaFilesSize()
          Return the size of the JPA project's JPA files.
 Iterable<String> getManagedTypeAnnotationNames()
          Return only the valid managed type annotation names (i.e.
 JpaProject.Manager getManager()
          Return the JPA project manager.
 JptXmlResource getMappingFileXmlResource(IPath runtimePath)
          Return the XML resource model corresponding to the file with the specified runtime path if that file has the mapping file content type (org.eclipse.jpt.jpa.core.content.mappingFile)
 String getName()
          Return the JPA project's name, which is the same as the associated Eclipse project's name.
 JptXmlResource getPersistenceXmlResource()
          Return the XML resource model corresponding to the file with runtime path META-INF/persistence.xml if that file has the persistence content type ("org.eclipse.jpt.jpa.core.content.persistence").
 IFile getPlatformFile(IPath runtimePath)
          Return an IFile that best represents the given runtime location
 Iterable<JavaResourceAbstractType> getPotentialJavaSourceTypes()
          Return only the valid potential types (i.e. those annotated with @Entity, @Embeddable, @MappedSuperclass, @Converter in JPA 2.1).
 IProject getProject()
          Return the Eclipse project associated with the JPA project.
 Iterable<String> getTypeMappingAnnotationNames()
          Return the valid type mapping annotation names (i.e.
 String getUserOverrideDefaultCatalog()
          Return the identifier of the catalog to be used as a default for the JPA project instead of the one that is associated by default with the connection profile.
 String getUserOverrideDefaultSchema()
          Return the identifier of the schema to be used as a default for the JPA project instead of the one that is associated by default with the connection profile.
 Iterable<IMessage> getValidationMessages(IReporter reporter)
          Return JPA project's validation messages.
 void javaElementChanged(ElementChangedEvent event)
          Synchronize the JPA project with the specified Java change.
 void projectChanged(IResourceDelta delta)
          Synchronize the JPA project with the specified project resource delta, watching for added and removed files in particular.
 void setDiscoversAnnotatedClasses(boolean discoversAnnotatedClasses)
          Set whether the JPA project will not generate error messages for any annotated classes that are not listed in the persistence.xml file or one of its mapping files.
 void setUserOverrideDefaultCatalog(String catalog)
          Set the identifier of the catalog to be used as a default for the JPA project instead of the one that is associated by default with the connection profile.
 void setUserOverrideDefaultSchema(String schema)
          Set the identifier of the schema to be used as a default for the JPA project instead of the one that is associated by default with the connection profile.
 void synchronizeContextModel()
          Should only be used by [incorrectly written] tests....
 
Methods inherited from interface org.eclipse.jpt.jpa.core.JpaModel
getJpaPlatform, getJpaProject, getJpaProjectManager, getParent, getResource, stateChanged
 
Methods inherited from interface org.eclipse.jpt.common.utility.model.Model
addChangeListener, addCollectionChangeListener, addListChangeListener, addPropertyChangeListener, addStateChangeListener, removeChangeListener, removeCollectionChangeListener, removeListChangeListener, removePropertyChangeListener, removeStateChangeListener
 
Methods inherited from interface org.eclipse.core.runtime.IAdaptable
getAdapter
 

Field Detail

FACET_ID

static final String FACET_ID
The JPA project facet ID.

Value: "jpt.jpa"

See Also:
Constant Field Values

FACET

static final IProjectFacet FACET
The JPA project facet.


FACET_VERSION_STRING

static final String FACET_VERSION_STRING
The JPA project facet version string.

Value: "1.0"

See Also:
Constant Field Values

FACET_VERSION

static final IProjectFacetVersion FACET_VERSION
The JPA project facet version.


MARKER_TYPE_SCOPE

static final String MARKER_TYPE_SCOPE

MARKER_TYPE_SCOPE_

static final String MARKER_TYPE_SCOPE_

RELATIVE_MARKER_TYPE

static final String RELATIVE_MARKER_TYPE
See Also:
Constant Field Values

MARKER_TYPE

static final String MARKER_TYPE
The JPA validation marker type (value: "org.eclipse.jpt.jpa.core.problem").

See org.eclipse.jpt.jpa.core/plugin.xml:org.eclipse.core.resources.markers.

See Also:
IMarker.getType()

CONTEXT_MODEL_ROOT_TRANSFORMER

static final org.eclipse.jpt.common.utility.transformer.Transformer<JpaProject,JpaContextModelRoot> CONTEXT_MODEL_ROOT_TRANSFORMER

JPA_FILES_COLLECTION

static final String JPA_FILES_COLLECTION
ID string used when the JPA project's collection of JPA files changes.

See Also:
Model.addCollectionChangeListener(String, org.eclipse.jpt.common.utility.model.listener.CollectionChangeListener), Constant Field Values

EXTERNAL_JAVA_RESOURCE_COMPILATION_UNITS_COLLECTION

static final String EXTERNAL_JAVA_RESOURCE_COMPILATION_UNITS_COLLECTION
ID string used when the JPA project's collection of external Java resource compilation units changes.

See Also:
Model.addCollectionChangeListener(String, org.eclipse.jpt.common.utility.model.listener.CollectionChangeListener), Constant Field Values

USER_OVERRIDE_DEFAULT_CATALOG_PROPERTY

static final String USER_OVERRIDE_DEFAULT_CATALOG_PROPERTY
ID string used when the JPA project's user override default catalog changes.

See Also:
Model.addPropertyChangeListener(String, org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener), Constant Field Values

USER_OVERRIDE_DEFAULT_SCHEMA_PROPERTY

static final String USER_OVERRIDE_DEFAULT_SCHEMA_PROPERTY
ID string used when the JPA project's user override default schema changes.

See Also:
Model.addPropertyChangeListener(String, org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener), Constant Field Values

DISCOVERS_ANNOTATED_CLASSES_PROPERTY

static final String DISCOVERS_ANNOTATED_CLASSES_PROPERTY
ID string used when discoversAnnotatedClasses property is changed.

See Also:
Model.addPropertyChangeListener(String, org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener), Constant Field Values
Method Detail

getManager

JpaProject.Manager getManager()
Return the JPA project manager.


getName

String getName()
Return the JPA project's name, which is the same as the associated Eclipse project's name.


getProject

IProject getProject()
Return the Eclipse project associated with the JPA project.


getJavaProject

IJavaProject getJavaProject()
Return the Java project associated with the JPA project.


getContextModelRoot

JpaContextModelRoot getContextModelRoot()
Return the root of the JPA project's context model.


dispose

void dispose()
The JPA project has been removed from the JPA model. Clean up any hooks to external resources etc.


getJpaFiles

Iterable<JpaFile> getJpaFiles()
Return the JPA project's JPA files.


getJpaFilesSize

int getJpaFilesSize()
Return the size of the JPA project's JPA files.


getJpaFile

JpaFile getJpaFile(IFile file)
Return the JPA file corresponding to the specified file. Return null if there is no JPA file associated with the specified file.


getExternalJavaResourceCompilationUnits

Iterable<JavaResourceCompilationUnit> getExternalJavaResourceCompilationUnits()
Return the JPA project's external Java resource compilation units.


getExternalJavaResourceCompilationUnitsSize

int getExternalJavaResourceCompilationUnitsSize()
Return the size of the JPA project's external Java resource compilation units.


getExternalJavaResourceTypeCache

JavaResourceTypeCache getExternalJavaResourceTypeCache()
Return the JPA project's external Java resource type cache.


getPersistenceXmlResource

JptXmlResource getPersistenceXmlResource()
Return the XML resource model corresponding to the file with runtime path META-INF/persistence.xml if that file has the persistence content type ("org.eclipse.jpt.jpa.core.content.persistence").

See Also:
XmlPersistence.DEFAULT_RUNTIME_PATH, XmlPersistence.CONTENT_TYPE

getMappingFileXmlResource

JptXmlResource getMappingFileXmlResource(IPath runtimePath)
Return the XML resource model corresponding to the file with the specified runtime path if that file has the mapping file content type (org.eclipse.jpt.jpa.core.content.mappingFile)

See Also:
ResourceMappingFile.Root.CONTENT_TYPE

getDefaultOrmXmlResource

JptXmlResource getDefaultOrmXmlResource()
Return the XML resource model corresponding to the file META-INF/orm.xml if that file has the mapping file content type.

See Also:
XmlEntityMappings.DEFAULT_RUNTIME_PATH

getAnnotatedJavaSourceTypes

Iterable<JavaResourceAbstractType> getAnnotatedJavaSourceTypes()
Return the resource types of the JPA project's annotated Java classes (ignoring classes in JARs referenced in the persistence.xml).


getPotentialJavaSourceTypes

Iterable<JavaResourceAbstractType> getPotentialJavaSourceTypes()
Return only the valid potential types (i.e. those annotated with @Entity, @Embeddable, @MappedSuperclass, @Converter in JPA 2.1). Java resource types that are directly part of the JPA project, ignoring those in JARs referenced in persistence.xml.

See Also:
getManagedTypeAnnotationNames()

getManagedTypeAnnotationNames

Iterable<String> getManagedTypeAnnotationNames()
Return only the valid managed type annotation names (i.e. @Entity, @Embeddable, @MappedSuperclass, @Converter in JPA 2.1).

See Also:
JavaManagedTypeDefinition.getAnnotationNames(JpaProject), JpaPlatform.getJavaManagedTypeDefinitions()

getTypeMappingAnnotationNames

Iterable<String> getTypeMappingAnnotationNames()
Return the valid type mapping annotation names (i.e. @Entity, @Embeddable, @MappedSuperclass).

See Also:
JavaTypeMappingDefinition.getAnnotationName(), JpaPlatform.getJavaTypeMappingDefinitions()

getJavaResourceType

JavaResourceAbstractType getJavaResourceType(String typeName)
Return the Java resource type for the fully qualified type name. Return null if invalid or absent.


getJavaResourceType

JavaResourceAbstractType getJavaResourceType(String typeName,
                                             JavaResourceAnnotatedElement.AstNodeType astNodeType)
Return the JavaResourceAbstractType with the fully qualified type name and astNodeType. Return null if invalid or absent or if the astNodeType does not match.


getJavaResourcePackage

JavaResourcePackage getJavaResourcePackage(String packageName)
Return the Java resource package for the specified package. Return null if invalid or absent.


getJavaResourcePackages

Iterable<JavaResourcePackage> getJavaResourcePackages()
Return the Java resource packages for the project. Return null if invalid or absent.


getJavaResourcePackageFragmentRoot

JavaResourcePackageFragmentRoot getJavaResourcePackageFragmentRoot(String jarFileName)
Return the Java resource package fragement root for the specified JAR. Return null if absent.


getJarJpaFiles

Iterable<JpaFile> getJarJpaFiles()
Return the JPA project's JPA files for jars.


projectChanged

void projectChanged(IResourceDelta delta)
Synchronize the JPA project with the specified project resource delta, watching for added and removed files in particular.


javaElementChanged

void javaElementChanged(ElementChangedEvent event)
Synchronize the JPA project with the specified Java change.


synchronizeContextModel

void synchronizeContextModel()
Should only be used by [incorrectly written] tests.... [The tests would be more valid if they modified the source code directly allowing resource/Java change events to synchronize the context model....]


getPlatformFile

IFile getPlatformFile(IPath runtimePath)
Return an IFile that best represents the given runtime location


getValidationMessages

Iterable<IMessage> getValidationMessages(IReporter reporter)
Return JPA project's validation messages.


getDataSource

JpaDataSource getDataSource()
Return the data source the JPA project is mapped to.


getConnectionProfile

ConnectionProfile getConnectionProfile()
Return the JPA project's connection. The connection profile is null if the JPA project's connection profile name does not match the name of a DTP connection profile.


getDefaultDbSchemaContainer

SchemaContainer getDefaultDbSchemaContainer()
Return the JPA project's default database schema container; which is either the JPA project's default catalog or the JPA project's database, depending on how the DTP model is implemented.


getDefaultCatalog

String getDefaultCatalog()
Return the JPA project's default catalog; which is either the user override catalog or the database's default catalog.


getDefaultDbCatalog

Catalog getDefaultDbCatalog()
Return the JPA project's default database catalog.

See Also:
getDefaultCatalog()

getDefaultSchema

String getDefaultSchema()
Return the JPA project's default schema; which can be one of the following:


getDefaultDbSchema

Schema getDefaultDbSchema()
Return the JPA project's default database schema.

See Also:
getDefaultSchema(), getDefaultDbSchemaContainer()

getUserOverrideDefaultCatalog

String getUserOverrideDefaultCatalog()
Return the identifier of the catalog to be used as a default for the JPA project instead of the one that is associated by default with the connection profile.

Returns:
The catalog identifier. May be null (implying the connection profile default catalog should be used).

setUserOverrideDefaultCatalog

void setUserOverrideDefaultCatalog(String catalog)
Set the identifier of the catalog to be used as a default for the JPA project instead of the one that is associated by default with the connection profile.


getUserOverrideDefaultSchema

String getUserOverrideDefaultSchema()
Return the identifier of the schema to be used as a default for the JPA project instead of the one that is associated by default with the connection profile.

Returns:
The schema identifier. May be null (implying the connection profile default schema should be used).

setUserOverrideDefaultSchema

void setUserOverrideDefaultSchema(String schema)
Set the identifier of the schema to be used as a default for the JPA project instead of the one that is associated by default with the connection profile.


discoversAnnotatedClasses

boolean discoversAnnotatedClasses()
Return whether the JPA project will not generate error messages for any annotated classes that are not listed in the persistence.xml file or one of its mapping files. If this flag is set to false, error messages will be generated for all of the annotated classes that are not explicitly listed. The JPA project always "discovers" annotated classes and allows the user to reference them throughout the model; this flag simply controls whether the error messages are generated during validation.

This is a user-specified preference that is probably only helpful when deploying to a JavaSE environment. The JPA spec says annotated classes are to be discovered automatically in a JavaEE environment; while the managed persistence classes must be explicitly listed in a JavaSE environment: "A list of all named managed persistence classes must be specified in Java SE environments to insure portability". This flag allows Dali to behave consistently with the user's JPA implementation, which may allow "discovery" in a JavaSE environment (e.g. EclipseLink). This setting can also be used when the user wants to explicitly list classes, even when the classes are "discovered" by the JPA implementation.


setDiscoversAnnotatedClasses

void setDiscoversAnnotatedClasses(boolean discoversAnnotatedClasses)
Set whether the JPA project will not generate error messages for any annotated classes that are not listed in the persistence.xml file or one of its mapping files.

See Also:
discoversAnnotatedClasses()

Dali Provisional API
Release 3.2

Copyright (c) 2012 Oracle. All rights reserved.