org.eclipse.jpt.jpa.core
Interface JpaProject

All Superinterfaces:
org.eclipse.core.runtime.IAdaptable, IResourcePart, JpaNode, Model
All Known Subinterfaces:
EclipseLinkJpaProject, JpaProject2_0

public interface JpaProject
extends JpaNode

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.

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
Version:
3.0

Nested Class Summary
static interface JpaProject.Config
          The settings used to construct a JPA project.
 
Field Summary
static java.lang.String DISCOVERS_ANNOTATED_CLASSES_PROPERTY
          ID string used when discoversAnnotatedClasses property is changed.
static java.lang.String EXTERNAL_JAVA_RESOURCE_COMPILATION_UNITS_COLLECTION
          ID string used when the JPA project's collection of external Java resource compilation units changes.
static java.lang.String JPA_FILES_COLLECTION
          ID string used when the JPA project's collection of JPA files changes.
static java.lang.String USER_OVERRIDE_DEFAULT_CATALOG_PROPERTY
          ID string used when the JPA project's user override default catalog changes.
static java.lang.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.
 java.lang.Iterable<java.lang.String> getAnnotatedJavaSourceClassNames()
          Return the names 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.
 Synchronizer getContextModelSynchronizer()
          Return the synchronizer that will synchronize the context model with the resource model whenever the resource model changes.
 JpaDataSource getDataSource()
          Return the data source the JPA project is mapped to.
 java.lang.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.
 JpaXmlResource getDefaultOrmXmlResource()
          Return the XML resource model corresponding to the file META-INF/orm.xml if that file has the mapping file content type.
 java.lang.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)
 java.lang.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.
 JavaResourcePersistentTypeCache getExternalJavaResourcePersistentTypeCache()
          Return the JPA project's external Java resource persistent type cache.
 java.lang.Iterable<JpaFile> getJarJpaFiles()
          Return the JPA project's JPA files for jars.
 org.eclipse.jdt.core.IJavaProject getJavaProject()
          Return the Java project associated with the JPA project.
 JavaResourcePackage getJavaResourcePackage(java.lang.String packageName)
          Return the Java resource package for the specified package.
 JavaResourcePackageFragmentRoot getJavaResourcePackageFragmentRoot(java.lang.String jarFileName)
          Return the Java resource package fragement root for the specified JAR.
 java.lang.Iterable<JavaResourcePackage> getJavaResourcePackages()
          Return the Java resource packages for the project.
 JavaResourcePersistentType getJavaResourcePersistentType(java.lang.String typeName)
          Return the Java resource persistent type for the specified type.
 JpaFile getJpaFile(org.eclipse.core.resources.IFile file)
          Return the JPA file corresponding to the specified file.
 java.lang.Iterable<JpaFile> getJpaFiles()
          Return the JPA project's JPA files.
 int getJpaFilesSize()
          Return the size of the JPA project's JPA files.
 JpaPlatform getJpaPlatform()
          Return the vendor-specific JPA platform that builds the JPA project and its contents.
 java.lang.Iterable<java.lang.String> getMappedJavaSourceClassNames()
          Return only the names of those valid mapped (i.e.
 JpaXmlResource getMappingFileXmlResource(org.eclipse.core.runtime.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")
 CommandExecutor getModifySharedDocumentCommandExecutor()
          Return the project-wide implementation of the CommandExecutor interface.
 java.lang.String getName()
          Return the JPA project's name, which is the same as the associated Eclipse project's name.
 JpaXmlResource 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").
 org.eclipse.core.resources.IFile getPlatformFile(org.eclipse.core.runtime.IPath runtimePath)
          Return an IFile that best represents the given runtime location
 org.eclipse.core.resources.IProject getProject()
          Return the Eclipse project associated with the JPA project.
 JpaRootContextNode getRootContextNode()
          Return the root of the JPA project's context model.
 CallbackSynchronizer getUpdateSynchronizer()
          Return the synchronizer that will update the context model whenever it has any changes.
 java.lang.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.
 java.lang.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.
 java.lang.Iterable<org.eclipse.wst.validation.internal.provisional.core.IMessage> getValidationMessages(org.eclipse.wst.validation.internal.provisional.core.IReporter reporter)
          Return JPA project's validation messages.
 void javaElementChanged(org.eclipse.jdt.core.ElementChangedEvent event)
          Synchronize the JPA project with the specified Java change.
 void projectChanged(org.eclipse.core.resources.IResourceDelta delta)
          Synchronize the JPA project with the specified project resource delta, watching for added and removed files in particular.
 void setContextModelSynchronizer(Synchronizer synchronizer)
          Set the synchronizer that will keep the context model synchronized with the resource model whenever the resource model changes.
 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 setThreadLocalModifySharedDocumentCommandExecutor(CommandExecutor commandExecutor)
          Set a thread-specific implementation of the CommandExecutor interface that will be used to execute a command to modify a shared document.
 void setUpdateSynchronizer(CallbackSynchronizer synchronizer)
          Set the synchronizer that will update the context model whenever it has any changes.
 void setUserOverrideDefaultCatalog(java.lang.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(java.lang.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()
          The JPA project's resource model has changed; synchronize the JPA project's context model with it.
 org.eclipse.core.runtime.IStatus synchronizeContextModel(org.eclipse.core.runtime.IProgressMonitor monitor)
          This is the callback used by the context model synchronizer to perform the actual "synchronize".
 void synchronizeContextModelAndWait()
          Force the JPA project's context model to synchronize with it resource model synchronously.
 org.eclipse.core.runtime.IStatus update(org.eclipse.core.runtime.IProgressMonitor monitor)
          This is the callback used by the update synchronizer to perform the actual "update".
 void updateAndWait()
          Force the JPA project to "update" synchronously.
 
Methods inherited from interface org.eclipse.jpt.jpa.core.JpaNode
getJpaProject, getParent, stateChanged
 
Methods inherited from interface org.eclipse.jpt.common.utility.model.Model
addChangeListener, addCollectionChangeListener, addListChangeListener, addPropertyChangeListener, addStateChangeListener, addTreeChangeListener, removeChangeListener, removeCollectionChangeListener, removeListChangeListener, removePropertyChangeListener, removeStateChangeListener, removeTreeChangeListener
 
Methods inherited from interface org.eclipse.core.runtime.IAdaptable
getAdapter
 
Methods inherited from interface org.eclipse.jpt.common.core.IResourcePart
getResource
 

Field Detail

JPA_FILES_COLLECTION

static final java.lang.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 java.lang.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 java.lang.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 java.lang.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 java.lang.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

getName

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


getProject

org.eclipse.core.resources.IProject getProject()
Return the Eclipse project associated with the JPA project.


getJavaProject

org.eclipse.jdt.core.IJavaProject getJavaProject()
Return the Java project associated with the JPA project.


getJpaPlatform

JpaPlatform getJpaPlatform()
Return the vendor-specific JPA platform that builds the JPA project and its contents.


getRootContextNode

JpaRootContextNode getRootContextNode()
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

java.lang.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(org.eclipse.core.resources.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

java.lang.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.


getExternalJavaResourcePersistentTypeCache

JavaResourcePersistentTypeCache getExternalJavaResourcePersistentTypeCache()
Return the JPA project's external Java resource persistent type cache.


getPersistenceXmlResource

JpaXmlResource 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:
JptJpaCorePlugin.DEFAULT_PERSISTENCE_XML_RUNTIME_PATH, JptJpaCorePlugin.PERSISTENCE_XML_CONTENT_TYPE

getMappingFileXmlResource

JpaXmlResource getMappingFileXmlResource(org.eclipse.core.runtime.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:
JptJpaCorePlugin.MAPPING_FILE_CONTENT_TYPE

getDefaultOrmXmlResource

JpaXmlResource 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:
JptJpaCorePlugin.DEFAULT_ORM_XML_RUNTIME_PATH

getAnnotatedJavaSourceClassNames

java.lang.Iterable<java.lang.String> getAnnotatedJavaSourceClassNames()
Return the names of the JPA project's annotated Java classes (ignoring classes in JARs referenced in the persistence.xml).


getMappedJavaSourceClassNames

java.lang.Iterable<java.lang.String> getMappedJavaSourceClassNames()
Return only the names of those valid mapped (i.e. annotated with @Entity, @Embeddable, etc.) Java resource persistent types that are directly part of the JPA project, ignoring those in JARs referenced in persistence.xml.


getJavaResourcePersistentType

JavaResourcePersistentType getJavaResourcePersistentType(java.lang.String typeName)
Return the Java resource persistent type for the specified type. Return null if invalid or absent.


getJavaResourcePackage

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


getJavaResourcePackages

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


getJavaResourcePackageFragmentRoot

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


getJarJpaFiles

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


projectChanged

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


javaElementChanged

void javaElementChanged(org.eclipse.jdt.core.ElementChangedEvent event)
Synchronize the JPA project with the specified Java change.


getContextModelSynchronizer

Synchronizer getContextModelSynchronizer()
Return the synchronizer that will synchronize the context model with the resource model whenever the resource model changes.


setContextModelSynchronizer

void setContextModelSynchronizer(Synchronizer synchronizer)
Set the synchronizer that will keep the context model synchronized with the resource model whenever the resource model changes. Before setting the synchronizer, clients should save the current synchronizer so it can be restored later.

See Also:
getContextModelSynchronizer()

synchronizeContextModel

void synchronizeContextModel()
The JPA project's resource model has changed; synchronize the JPA project's context model with it. This method is typically called when the resource model state has changed when it is synchronized with its underlying Eclipse resource as the result of an Eclipse resource change event. This method can also be called when a client (e.g. a JUnit test case) has manipulated the resource model via its API (as opposed to modifying the underlying Eclipse resource directly) and needs the context model to be synchronized accordingly (since manipulating the resource model via its API will not trigger this method). Whether the context model is synchronously (or asynchronously) depends on the current context model synchronizer.

See Also:
synchronizeContextModelAndWait()

synchronizeContextModelAndWait

void synchronizeContextModelAndWait()
Force the JPA project's context model to synchronize with it resource model synchronously.

See Also:
synchronizeContextModel(), updateAndWait()

synchronizeContextModel

org.eclipse.core.runtime.IStatus synchronizeContextModel(org.eclipse.core.runtime.IProgressMonitor monitor)
This is the callback used by the context model synchronizer to perform the actual "synchronize".


getUpdateSynchronizer

CallbackSynchronizer getUpdateSynchronizer()
Return the synchronizer that will update the context model whenever it has any changes. This allows any intra-JPA project dependencies to be updated.


setUpdateSynchronizer

void setUpdateSynchronizer(CallbackSynchronizer synchronizer)
Set the synchronizer that will update the context model whenever it has any changes. This allows any intra-JPA project dependencies to be updated. Before setting the update synchronizer, clients should save the current synchronizer so it can be restored later.

See Also:
getUpdateSynchronizer()

updateAndWait

void updateAndWait()
Force the JPA project to "update" synchronously.

See Also:
synchronizeContextModelAndWait()

update

org.eclipse.core.runtime.IStatus update(org.eclipse.core.runtime.IProgressMonitor monitor)
This is the callback used by the update synchronizer to perform the actual "update".


getPlatformFile

org.eclipse.core.resources.IFile getPlatformFile(org.eclipse.core.runtime.IPath runtimePath)
Return an IFile that best represents the given runtime location


getValidationMessages

java.lang.Iterable<org.eclipse.wst.validation.internal.provisional.core.IMessage> getValidationMessages(org.eclipse.wst.validation.internal.provisional.core.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

java.lang.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

java.lang.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

java.lang.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(java.lang.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

java.lang.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(java.lang.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()

setThreadLocalModifySharedDocumentCommandExecutor

void setThreadLocalModifySharedDocumentCommandExecutor(CommandExecutor commandExecutor)
Set a thread-specific implementation of the CommandExecutor interface that will be used to execute a command to modify a shared document. If necessary, the command executor can be cleared by setting it to null. This allows background clients to modify documents that are already present in the UI. See implementations of CommandExecutor.


getModifySharedDocumentCommandExecutor

CommandExecutor getModifySharedDocumentCommandExecutor()
Return the project-wide implementation of the CommandExecutor interface.