diff options
author | bvosburgh | 2010-01-19 19:36:17 +0000 |
---|---|---|
committer | bvosburgh | 2010-01-19 19:36:17 +0000 |
commit | 62085289e47c5915e30047daeb594ccb4a7135c5 (patch) | |
tree | 15e671e5bd8938396c7512384a9ed3620502cc65 | |
parent | 04d8fcd7a4df6c52abeecb2066633d4565c7f04b (diff) | |
download | webtools.dali-62085289e47c5915e30047daeb594ccb4a7135c5.tar.gz webtools.dali-62085289e47c5915e30047daeb594ccb4a7135c5.tar.xz webtools.dali-62085289e47c5915e30047daeb594ccb4a7135c5.zip |
[233567] rework sync between resource model and AST
188 files changed, 3131 insertions, 2035 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/GenericJpaModel.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/GenericJpaProjectManager.java index 622fa56629..e8bef3c898 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/GenericJpaModel.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/GenericJpaProjectManager.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2009 Oracle. All rights reserved. + * Copyright (c) 2006, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -54,7 +54,7 @@ import org.eclipse.wst.common.project.facet.core.events.IFacetedProjectListener; import org.eclipse.wst.common.project.facet.core.events.IProjectFacetActionEvent; /** - * The JPA model maintains a list of all JPA projects in the workspace. + * The JPA project manager maintains a list of all JPA projects in the workspace. * It keeps the list (and the state of the JPA projects themselves) * synchronized with the workspace by listening for various * changes:<ul> @@ -117,9 +117,9 @@ import org.eclipse.wst.common.project.facet.core.events.IProjectFacetActionEvent * -> {@link IResourceDelta#CHANGED} facet settings file * </ul> */ -class GenericJpaModel +class GenericJpaProjectManager extends AbstractModel - implements JpaModel + implements JpaProjectManager { /** * All the JPA projects in the workspace. @@ -161,7 +161,7 @@ class GenericJpaModel /** * Listen for Java changes (unless the Dali UI is active). - * @see #javaElementChangeListenerIsActive + * @see #javaElementChangeListenerIsActive() */ private final JavaElementChangeListener javaElementChangeListener = new JavaElementChangeListener(); @@ -171,7 +171,7 @@ class GenericJpaModel /** * internal - called by the Dali plug-in */ - GenericJpaModel() { + GenericJpaProjectManager() { super(); } @@ -191,7 +191,7 @@ class GenericJpaModel } private void start_() { - debug("*** JPA model START ***"); //$NON-NLS-1$ + debug("*** JPA project manager START ***"); //$NON-NLS-1$ try { this.buildJpaProjects(); this.eventHandler.start(); @@ -234,7 +234,7 @@ class GenericJpaModel } private void stop_() { - debug("*** JPA model STOP ***"); //$NON-NLS-1$ + debug("*** JPA project manager STOP ***"); //$NON-NLS-1$ JavaCore.removeElementChangedListener(this.javaElementChangeListener); FacetedProjectFramework.removeListener(this.facetedProjectListener); this.getWorkspace().removeResourceChangeListener(this.resourceChangeListener); @@ -250,7 +250,7 @@ class GenericJpaModel } - // ********** JpaModel implementation ********** + // ********** JpaProjectManager implementation ********** public Iterable<JpaProject> getJpaProjects() { try { @@ -407,7 +407,7 @@ class GenericJpaModel return new EventHandlerCommand() { @Override void execute_() { - GenericJpaModel.this.projectChanged_(delta); + GenericJpaProjectManager.this.projectChanged_(delta); } @Override public String toString() { @@ -437,7 +437,7 @@ class GenericJpaModel return new EventHandlerCommand() { @Override void execute_() { - GenericJpaModel.this.projectPostCleanBuild_(project); + GenericJpaProjectManager.this.projectPostCleanBuild_(project); } @Override public String toString() { @@ -465,7 +465,7 @@ class GenericJpaModel return new EventHandlerCommand() { @Override void execute_() { - GenericJpaModel.this.projectPreDelete_(project); + GenericJpaProjectManager.this.projectPreDelete_(project); } @Override public String toString() { @@ -496,7 +496,7 @@ class GenericJpaModel return new EventHandlerCommand() { @Override void execute_() { - GenericJpaModel.this.checkForJpaFacetTransition_(project); + GenericJpaProjectManager.this.checkForJpaFacetTransition_(project); } @Override public String toString() { @@ -533,7 +533,7 @@ class GenericJpaModel return new EventHandlerCommand() { @Override void execute_() { - GenericJpaModel.this.jpaFacetedProjectPostInstall_(event); + GenericJpaProjectManager.this.jpaFacetedProjectPostInstall_(event); } @Override public String toString() { @@ -546,7 +546,7 @@ class GenericJpaModel IProject project = event.getProject().getProject(); IDataModel dataModel = (IDataModel) event.getActionConfig(); - // assume(?) this is the first event to indicate we need to add the JPA project to the JPA model + // assume(?) this is the first event to indicate we need to add the JPA project to the JPA project manager this.addJpaProject(project); boolean buildOrmXml = dataModel.getBooleanProperty(JpaFacetInstallDataModelProperties.CREATE_ORM_XML); @@ -595,7 +595,7 @@ class GenericJpaModel return new EventHandlerCommand() { @Override void execute_() { - GenericJpaModel.this.jpaFacetedProjectPreUninstall_(project); + GenericJpaProjectManager.this.jpaFacetedProjectPreUninstall_(project); } @Override public String toString() { @@ -605,7 +605,7 @@ class GenericJpaModel } /* private */ void jpaFacetedProjectPreUninstall_(IProject project) { - // assume(?) this is the first event to indicate we need to remove the JPA project from the JPA model + // assume(?) this is the first event to indicate we need to remove the JPA project from the JPA project manager this.removeJpaProject(this.getJpaProject_(project)); } @@ -620,7 +620,7 @@ class GenericJpaModel return new EventHandlerCommand() { @Override void execute_() { - GenericJpaModel.this.javaElementChanged_(event); + GenericJpaProjectManager.this.javaElementChanged_(event); } @Override public String toString() { @@ -679,15 +679,15 @@ class GenericJpaModel /** * If this "pause" command is executing (asynchronously) on a different - * thread than the JPA model:<ol> - * <li>it will set the flag to <code>true</code>, allowing the JPA model to - * resume executing on its own thread - * <li>then it will suspend its command executor until the JPA model sets - * the flag back to <code>false</code>. + * thread than the JPA project manager:<ol> + * <li>it will set the flag to <code>true</code>, allowing the JPA project + * manager to resume executing on its own thread + * <li>then it will suspend its command executor until the JPA project + * manager sets the flag back to <code>false</code>. * </ol> * If this "pause" command is executing (synchronously) on the same thread - * as the JPA model, it will simply set the flag to <code>true</code> and - * return. + * as the JPA project manager, it will simply set the flag to + * <code>true</code> and return. */ private static class PauseCommand implements Command @@ -737,7 +737,7 @@ class GenericJpaModel /** * Visit the workspace resource tree, adding a JPA project to the - * JPA model for each open Eclipse project that has a JPA facet. + * JPA project manager for each open Eclipse project that has a JPA facet. */ private class ResourceProxyVisitor implements IResourceProxyVisitor { ResourceProxyVisitor() { @@ -764,7 +764,7 @@ class GenericJpaModel if (resourceProxy.isAccessible()) { // the project exists and is open IProject project = (IProject) resourceProxy.requestResource(); if (JptCorePlugin.projectHasJpaFacet(project)) { - GenericJpaModel.this.addJpaProject(project); + GenericJpaProjectManager.this.addJpaProject(project); } } } @@ -780,7 +780,7 @@ class GenericJpaModel // ********** command ********** /** - * Command that holds the JPA model lock while + * Command that holds the JPA project manager lock while * executing. */ private abstract class EventHandlerCommand @@ -792,12 +792,12 @@ class GenericJpaModel public final void execute() { try { - GenericJpaModel.this.lock.acquire(); + GenericJpaProjectManager.this.lock.acquire(); this.execute_(); } catch (RuntimeException ex) { JptCorePlugin.log(ex); } finally { - GenericJpaModel.this.lock.release(); + GenericJpaProjectManager.this.lock.release(); } } @@ -886,7 +886,7 @@ class GenericJpaModel } private void processPostChangeProjectDelta(IResourceDelta delta) { - GenericJpaModel.this.projectChanged(delta); + GenericJpaProjectManager.this.projectChanged(delta); } private void processPostChangeSettingsFolderDelta(IFolder folder, IResourceDelta delta) { @@ -906,7 +906,7 @@ class GenericJpaModel case IResourceDelta.ADDED : case IResourceDelta.REMOVED : case IResourceDelta.CHANGED : - GenericJpaModel.this.checkForJpaFacetTransition(file.getProject()); + GenericJpaProjectManager.this.checkForJpaFacetTransition(file.getProject()); break; case IResourceDelta.ADDED_PHANTOM : break; // ignore @@ -954,7 +954,7 @@ class GenericJpaModel private void processProjectPostCleanBuild(IProject project) { debug("\tProject CLEAN: ", project.getName()); //$NON-NLS-1$ - GenericJpaModel.this.projectPostCleanBuild(project); + GenericJpaProjectManager.this.projectPostCleanBuild(project); } @Override @@ -968,7 +968,7 @@ class GenericJpaModel // ********** faceted project listener ********** /** - * Forward the Faceted project change event back to the JPA model. + * Forward the Faceted project change event back to the JPA project manager. */ private class FacetedProjectListener implements IFacetedProjectListener { @@ -1000,14 +1000,14 @@ class GenericJpaModel private void processPostInstallEvent(IProjectFacetActionEvent event) { debug("Facet POST_INSTALL: ", event.getProjectFacet()); //$NON-NLS-1$ if (event.getProjectFacet().getId().equals(JptCorePlugin.FACET_ID)) { - GenericJpaModel.this.jpaFacetedProjectPostInstall(event); + GenericJpaProjectManager.this.jpaFacetedProjectPostInstall(event); } } private void processPreUninstallEvent(IProjectFacetActionEvent event) { debug("Facet PRE_UNINSTALL: ", event.getProjectFacet()); //$NON-NLS-1$ if (event.getProjectFacet().getId().equals(JptCorePlugin.FACET_ID)) { - GenericJpaModel.this.jpaFacetedProjectPreUninstall(event); + GenericJpaProjectManager.this.jpaFacetedProjectPreUninstall(event); } } @@ -1022,7 +1022,7 @@ class GenericJpaModel // ********** Java element change listener ********** /** - * Forward the Java element change event back to the JPA model. + * Forward the Java element change event back to the JPA project manager. */ private class JavaElementChangeListener implements IElementChangedListener { /** @@ -1040,7 +1040,7 @@ class GenericJpaModel public void elementChanged(ElementChangedEvent event) { if (this.active) { - GenericJpaModel.this.javaElementChanged(event); + GenericJpaProjectManager.this.javaElementChanged(event); } } @@ -1062,7 +1062,7 @@ class GenericJpaModel // ********** DEBUG ********** - // @see JpaModelTests#testDEBUG() + // @see JpaProjectManagerTests#testDEBUG() private static final boolean DEBUG = false; /** diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/JpaProject.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/JpaProject.java index 4f63da8621..690321dcd9 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/JpaProject.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/JpaProject.java @@ -210,6 +210,11 @@ public interface JpaProject void javaElementChanged(ElementChangedEvent event); + // ********** synchronize context model with resource model ********** + + void synchronizeContextModel(); + + // ********** project "update" ********** /** diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/JpaModel.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/JpaProjectManager.java index 09518e5a70..63ef0d5f9a 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/JpaModel.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/JpaProjectManager.java @@ -14,7 +14,7 @@ import org.eclipse.core.resources.IProject; import org.eclipse.jpt.utility.model.Model; /** - * The JPA model holds all the JPA projects in the workspace. + * The JPA project manager holds all the JPA projects in the workspace. * <p> * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -22,7 +22,7 @@ import org.eclipse.jpt.utility.model.Model; * pioneering adopters on the understanding that any code that uses this API * will almost certainly be broken (repeatedly) as the API evolves. */ -public interface JpaModel extends Model { +public interface JpaProjectManager extends Model { /** * Return the JPA model's JPA projects. diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/JpaResourceModel.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/JpaResourceModel.java index 92a3c3be15..4719ec3777 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/JpaResourceModel.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/JpaResourceModel.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 Oracle. All rights reserved. + * Copyright (c) 2008, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -11,21 +11,21 @@ package org.eclipse.jpt.core; /** * Listeners are notified whenever anything in the JPA resource model changes. - * + * <p> * 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. */ -public interface JpaResourceModel -{ +public interface JpaResourceModel { + /** * Return the resource type of the model. This may potentially change. * Return null if it cannot be determined, the content type or version is null. */ JpaResourceType getResourceType(); - + /** * Changes to the resource model result in events. * In particular, the JPA project performs an "update" whenever a resource @@ -37,4 +37,5 @@ public interface JpaResourceModel * @see #addResourceModelListener(ResourceModelListener) */ void removeResourceModelListener(JpaResourceModelListener listener); + } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/JpaResourceModelListener.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/JpaResourceModelListener.java index d8d8d85933..742d79e873 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/JpaResourceModelListener.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/JpaResourceModelListener.java @@ -23,5 +23,5 @@ import java.util.EventListener; public interface JpaResourceModelListener extends EventListener { - void resourceModelChanged(); + void resourceModelChanged(JpaResourceModel jpaResourceModel); } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/JptCorePlugin.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/JptCorePlugin.java index 9909d061e1..82d7e3cd43 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/JptCorePlugin.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/JptCorePlugin.java @@ -58,7 +58,7 @@ import org.osgi.util.tracker.ServiceTracker; */ public class JptCorePlugin extends Plugin { - private volatile GenericJpaModel jpaModel; + private volatile GenericJpaProjectManager jpaProjectManager; private volatile ServiceTracker parserTracker; private static volatile boolean flushPreferences = true; @@ -240,10 +240,11 @@ public class JptCorePlugin extends Plugin { // ********** public static methods ********** /** - * Return the singular JPA model corresponding to the current workspace. + * Return the singular JPA project manager corresponding + * to the current workspace. */ - public static JpaModel getJpaModel() { - return INSTANCE.getJpaModel_(); + public static JpaProjectManager getJpaProjectManager() { + return INSTANCE.getJpaProjectManager_(); } /** @@ -252,7 +253,7 @@ public class JptCorePlugin extends Plugin { * JPA project. */ public static JpaProject getJpaProject(IProject project) { - return getJpaModel().getJpaProject(project); + return getJpaProjectManager().getJpaProject(project); } /** @@ -260,7 +261,7 @@ public class JptCorePlugin extends Plugin { * or <code>null</code> if unable to associate the specified file with a JPA file. */ public static JpaFile getJpaFile(IFile file) { - return getJpaModel().getJpaFile(file); + return getJpaProjectManager().getJpaFile(file); } /** @@ -270,7 +271,7 @@ public class JptCorePlugin extends Plugin { * (e.g. when the user changes a project's JPA platform). */ public static void rebuildJpaProject(IProject project) { - getJpaModel().rebuildJpaProject(project); + getJpaProjectManager().rebuildJpaProject(project); } /** @@ -517,7 +518,7 @@ public class JptCorePlugin extends Plugin { * This method is called (via reflection) when the test plug-in is loaded. * The prefs end up getting flushed after the test case has deleted the * project, resulting resource exceptions in the log, e.g. - * Resource '/JpaModelTests' is not open. + * Resource '/JpaProjectManagerTests' is not open. * @see JptCoreTestsPlugin#start(BundleContext) */ @SuppressWarnings("unused") @@ -636,17 +637,17 @@ public class JptCorePlugin extends Plugin { } /** - * Return whether the model manager's Java change listener is active. + * Return whether the JPA project manager's Java change listener is active. */ public static boolean javaElementChangeListenerIsActive() { - return getJpaModel().javaElementChangeListenerIsActive(); + return getJpaProjectManager().javaElementChangeListenerIsActive(); } /** - * Set whether the model manager's Java change listener is active. + * Set whether the JPA project manager's Java change listener is active. */ public static void setJavaElementChangeListenerIsActive(boolean javaElementChangeListenerIsActive) { - getJpaModel().setJavaElementChangeListenerIsActive(javaElementChangeListenerIsActive); + getJpaProjectManager().setJavaElementChangeListenerIsActive(javaElementChangeListenerIsActive); } /** @@ -692,9 +693,9 @@ public class JptCorePlugin extends Plugin { @Override public void stop(BundleContext context) throws Exception { try { - if (this.jpaModel != null) { - this.jpaModel.stop(); - this.jpaModel = null; + if (this.jpaProjectManager != null) { + this.jpaProjectManager.stop(); + this.jpaProjectManager = null; } if (this.parserTracker != null) { this.parserTracker.close(); @@ -705,16 +706,16 @@ public class JptCorePlugin extends Plugin { } } - private synchronized GenericJpaModel getJpaModel_() { - if (this.jpaModel == null) { - this.jpaModel = this.buildJpaModel(); - this.jpaModel.start(); + private synchronized GenericJpaProjectManager getJpaProjectManager_() { + if (this.jpaProjectManager == null) { + this.jpaProjectManager = this.buildJpaProjectManager(); + this.jpaProjectManager.start(); } - return this.jpaModel; + return this.jpaProjectManager; } - private GenericJpaModel buildJpaModel() { - return new GenericJpaModel(); + private GenericJpaProjectManager buildJpaProjectManager() { + return new GenericJpaProjectManager(); } public synchronized SAXParserFactory getSAXParserFactory() { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/AbstractJpaNode.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/AbstractJpaNode.java index eb0f9fe2a7..679090e938 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/AbstractJpaNode.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/AbstractJpaNode.java @@ -161,7 +161,9 @@ public abstract class AbstractJpaNode protected void aspectChanged(String aspectName) { if (this.aspectTriggersUpdate(aspectName)) { - // System.out.println(Thread.currentThread() + " \"update\" change: " + this + ": " + aspectName); +// String msg = Thread.currentThread() + " aspect change: " + this + ": " + aspectName; +// System.out.println(msg); +// new Exception(msg).printStackTrace(System.out); this.getJpaProject().update(); } } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/AbstractJpaProject.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/AbstractJpaProject.java index d305d9c4bd..bc36be9082 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/AbstractJpaProject.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/AbstractJpaProject.java @@ -1181,7 +1181,7 @@ public abstract class AbstractJpaProject protected void update(Iterable<JavaResourceCompilationUnit> javaResourceCompilationUnits) { for (JavaResourceCompilationUnit javaResourceCompilationUnit : javaResourceCompilationUnits) { - javaResourceCompilationUnit.update(); + javaResourceCompilationUnit.synchronizeWithJavaSource(); } } @@ -1223,7 +1223,7 @@ public abstract class AbstractJpaProject ICompilationUnit compilationUnit = (ICompilationUnit) delta.getElement(); for (JavaResourceCompilationUnit jrcu : this.getCombinedJavaResourceCompilationUnits()) { if (jrcu.getCompilationUnit().equals(compilationUnit)) { - jrcu.update(); + jrcu.synchronizeWithJavaSource(); // TODO ? this.resolveJavaTypes(); // might have new member types now... break; // there *shouldn't* be any more... } @@ -1313,8 +1313,11 @@ public abstract class AbstractJpaProject protected DefaultResourceModelListener() { super(); } - public void resourceModelChanged() { - AbstractJpaProject.this.update(); + public void resourceModelChanged(JpaResourceModel jpaResourceModel) { +// String msg = Thread.currentThread() + " resource model change: " + jpaResourceModel; +// System.out.println(msg); +// new Exception(msg).printStackTrace(System.out); + AbstractJpaProject.this.synchronizeContextModel(jpaResourceModel); } } @@ -1548,6 +1551,18 @@ public abstract class AbstractJpaProject } + // ********** synchronize context model with resource model ********** + + // TODO ... + protected void synchronizeContextModel(@SuppressWarnings("unused") JpaResourceModel jpaResourceModel) { + this.synchronizeContextModel(); + } + + public void synchronizeContextModel() { + this.update(); + } + + // ********** project "update" ********** public Updater getUpdater() { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaQuery.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaQuery.java index 0d4a41289d..0f3c687b3e 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaQuery.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaQuery.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -9,9 +9,9 @@ ******************************************************************************/ package org.eclipse.jpt.core.internal.context.java; -import java.util.ArrayList; -import java.util.List; import java.util.ListIterator; +import java.util.Vector; + import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jpt.core.context.Query; import org.eclipse.jpt.core.context.QueryHint; @@ -33,17 +33,17 @@ public abstract class AbstractJavaQuery extends AbstractJavaJpaContextNode protected String query; - protected final List<JavaQueryHint> hints; + protected final Vector<JavaQueryHint> hints; - protected BaseNamedQueryAnnotation resourceQuery; + protected BaseNamedQueryAnnotation queryAnnotation; protected AbstractJavaQuery(JavaJpaContextNode parent) { super(parent); - this.hints = new ArrayList<JavaQueryHint>(); + this.hints = new Vector<JavaQueryHint>(); } protected BaseNamedQueryAnnotation getResourceQuery() { - return this.resourceQuery; + return this.queryAnnotation; } public String getName() { @@ -53,14 +53,14 @@ public abstract class AbstractJavaQuery extends AbstractJavaJpaContextNode public void setName(String newName) { String oldName = this.name; this.name = newName; - this.resourceQuery.setName(newName); - firePropertyChanged(Query.NAME_PROPERTY, oldName, newName); + this.queryAnnotation.setName(newName); + firePropertyChanged(NAME_PROPERTY, oldName, newName); } protected void setName_(String newName) { String oldName = this.name; this.name = newName; - firePropertyChanged(Query.NAME_PROPERTY, oldName, newName); + firePropertyChanged(NAME_PROPERTY, oldName, newName); } public String getQuery() { @@ -70,14 +70,14 @@ public abstract class AbstractJavaQuery extends AbstractJavaJpaContextNode public void setQuery(String newQuery) { String oldQuery = this.query; this.query = newQuery; - this.resourceQuery.setQuery(newQuery); - firePropertyChanged(Query.QUERY_PROPERTY, oldQuery, newQuery); + this.queryAnnotation.setQuery(newQuery); + firePropertyChanged(QUERY_PROPERTY, oldQuery, newQuery); } protected void setQuery_(String newQuery) { String oldQuery = this.query; this.query = newQuery; - firePropertyChanged(Query.QUERY_PROPERTY, oldQuery, newQuery); + firePropertyChanged(QUERY_PROPERTY, oldQuery, newQuery); } public ListIterator<JavaQueryHint> hints() { @@ -92,12 +92,12 @@ public abstract class AbstractJavaQuery extends AbstractJavaJpaContextNode JavaQueryHint hint = getJpaFactory().buildJavaQueryHint(this); this.hints.add(index, hint); this.getResourceQuery().addHint(index); - this.fireItemAdded(Query.HINTS_LIST, index, hint); + this.fireItemAdded(HINTS_LIST, index, hint); return hint; } protected void addHint(int index, JavaQueryHint hint) { - addItemToList(index, hint, this.hints, Query.HINTS_LIST); + addItemToList(index, hint, this.hints, HINTS_LIST); } protected void addHint(JavaQueryHint hint) { @@ -111,45 +111,43 @@ public abstract class AbstractJavaQuery extends AbstractJavaJpaContextNode public void removeHint(int index) { JavaQueryHint removedHint = this.hints.remove(index); this.getResourceQuery().removeHint(index); - fireItemRemoved(Query.HINTS_LIST, index, removedHint); + fireItemRemoved(HINTS_LIST, index, removedHint); } protected void removeHint_(JavaQueryHint hint) { - removeItemFromList(hint, this.hints, Query.HINTS_LIST); + removeItemFromList(hint, this.hints, HINTS_LIST); } public void moveHint(int targetIndex, int sourceIndex) { CollectionTools.move(this.hints, targetIndex, sourceIndex); this.getResourceQuery().moveHint(targetIndex, sourceIndex); - fireItemMoved(Query.HINTS_LIST, targetIndex, sourceIndex); + fireItemMoved(HINTS_LIST, targetIndex, sourceIndex); } - protected void initialize(BaseNamedQueryAnnotation queryAnnotation) { - this.resourceQuery = queryAnnotation; - this.name = queryAnnotation.getName(); - this.query = queryAnnotation.getQuery(); + protected void initialize(BaseNamedQueryAnnotation annotation) { + this.queryAnnotation = annotation; + this.name = annotation.getName(); + this.query = annotation.getQuery(); this.initializeQueryHints(); } - protected void update(BaseNamedQueryAnnotation queryAnnotation) { - this.resourceQuery = queryAnnotation; - this.setName_(queryAnnotation.getName()); - this.setQuery_(queryAnnotation.getQuery()); + protected void update(BaseNamedQueryAnnotation annotation) { + this.queryAnnotation = annotation; + this.setName_(annotation.getName()); + this.setQuery_(annotation.getQuery()); this.updateQueryHints(); getPersistenceUnit().addQuery(this); } protected void initializeQueryHints() { - ListIterator<QueryHintAnnotation> resourceHints = this.resourceQuery.hints(); - - while(resourceHints.hasNext()) { + for (ListIterator<QueryHintAnnotation> resourceHints = this.queryAnnotation.hints(); resourceHints.hasNext(); ) { this.hints.add(createQueryHint(resourceHints.next())); } } protected void updateQueryHints() { ListIterator<JavaQueryHint> contextHints = hints(); - ListIterator<QueryHintAnnotation> resourceHints = this.resourceQuery.hints(); + ListIterator<QueryHintAnnotation> resourceHints = this.queryAnnotation.hints(); while (contextHints.hasNext()) { JavaQueryHint hint = contextHints.next(); @@ -173,11 +171,11 @@ public abstract class AbstractJavaQuery extends AbstractJavaJpaContextNode } public TextRange getValidationTextRange(CompilationUnit astRoot) { - return this.resourceQuery.getTextRange(astRoot); + return this.queryAnnotation.getTextRange(astRoot); } public TextRange getNameTextRange(CompilationUnit astRoot) { - return this.resourceQuery.getNameTextRange(astRoot); + return this.queryAnnotation.getNameTextRange(astRoot); } public boolean overrides(Query other) { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/VirtualAssociationOverrideAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/VirtualAssociationOverrideAnnotation.java index 827b7b1980..debfe67de5 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/VirtualAssociationOverrideAnnotation.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/VirtualAssociationOverrideAnnotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 Oracle. All rights reserved. + * Copyright (c) 2008, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -88,8 +88,8 @@ public abstract class VirtualAssociationOverrideAnnotation } @Override - public void update(CompilationUnit astRoot) { - super.update(astRoot); + public void synchronizeWith(CompilationUnit astRoot) { + super.synchronizeWith(astRoot); //Rebuilt every time so no need to implement update() } } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/GenericRootContextNode.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/GenericRootContextNode.java index b2b5cdbecd..ec63528cc0 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/GenericRootContextNode.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/GenericRootContextNode.java @@ -1,9 +1,9 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. - * + * * Contributors: * Oracle - initial API and implementation ******************************************************************************/ @@ -35,80 +35,116 @@ import org.eclipse.jst.j2ee.model.internal.validation.ValidationCancelledExcepti import org.eclipse.wst.validation.internal.provisional.core.IMessage; import org.eclipse.wst.validation.internal.provisional.core.IReporter; +/** + * the context model root + */ public class GenericRootContextNode extends AbstractJpaContextNode implements JpaRootContextNode2_0 { /* This object has no parent, so it must point to the JPA project explicitly. */ protected final JpaProject jpaProject; - + /* Main context object. */ protected PersistenceXml persistenceXml; - - + + public GenericRootContextNode(JpaProject jpaProject) { - super(null); + super(null); // the JPA project is not really a "parent"... if (jpaProject == null) { throw new NullPointerException(); } this.jpaProject = jpaProject; - JpaXmlResource resource = getPersistenceXmlResource(); - if (resource != null) { - this.persistenceXml = buildPersistenceXml(resource); - } + this.initialize(); } - - + + @Override protected boolean requiresParent() { return false; } - - - // **************** JpaNode impl ******************************************* - + + protected void initialize() { + JpaXmlResource resource = this.resolvePersistenceXmlResource(); + if (resource != null) { + this.persistenceXml = this.buildPersistenceXml(resource); + } + } + + public void update(IProgressMonitor monitor) { + JpaXmlResource resource = this.resolvePersistenceXmlResource(); + if (resource == null) { + this.setPersistenceXml(null); + } else { + if (this.persistenceXml == null) { + this.setPersistenceXml(this.buildPersistenceXml(resource)); + } else { + this.persistenceXml.update(resource); + } + } + } + + @Override + public void postUpdate() { + super.postUpdate(); + if (this.persistenceXml != null) { + this.persistenceXml.postUpdate(); + } + } + + + // ********** AbstractJpaNode overrides ********** + @Override public JpaProject getJpaProject() { return this.jpaProject; } - + @Override public IResource getResource() { return this.getProject(); } - + protected IProject getProject() { return this.jpaProject.getProject(); } - - - // **************** JpaContextNode impl ************************************ - + + + // ********** AbstractJpaContextNode overrides ********** + @Override public PersistenceUnit getPersistenceUnit() { return null; } - + @Override public MappingFileRoot getMappingFileRoot() { return null; } - - - // **************** persistence xml **************************************** - + + + // ********** persistence.xml ********** + public PersistenceXml getPersistenceXml() { return this.persistenceXml; } - + protected void setPersistenceXml(PersistenceXml persistenceXml) { PersistenceXml old = this.persistenceXml; this.persistenceXml = persistenceXml; this.firePropertyChanged(PERSISTENCE_XML_PROPERTY, old, persistenceXml); } - - // *************** metamodel **************** + protected JpaXmlResource resolvePersistenceXmlResource() { + return this.jpaProject.getPersistenceXmlResource(); + } + + protected PersistenceXml buildPersistenceXml(JpaXmlResource resource) { + return this.getJpaFactory().buildPersistenceXml(this, resource); + } + + + // ********** metamodel ********** public void initializeMetamodel() { if (this.persistenceXml != null) { @@ -129,41 +165,8 @@ public class GenericRootContextNode } - // **************** updating *********************************************** - - public void update(IProgressMonitor monitor) { - JpaXmlResource resource = getPersistenceXmlResource(); - - if (resource != null) { - if (this.persistenceXml == null) { - this.setPersistenceXml(this.buildPersistenceXml(resource)); - } else { - this.persistenceXml.update(resource); - } - } else { - this.setPersistenceXml(null); - } - } - - @Override - public void postUpdate() { - super.postUpdate(); - if (this.persistenceXml != null) { - this.persistenceXml.postUpdate(); - } - } - - protected JpaXmlResource getPersistenceXmlResource() { - return this.jpaProject.getPersistenceXmlResource(); - } - - protected PersistenceXml buildPersistenceXml(JpaXmlResource resource) { - return this.getJpaFactory().buildPersistenceXml(this, resource); - } - - - // **************** Validation ********************************************* - + // ********** validation ********** + public void validate(List<IMessage> messages, IReporter reporter) { if (reporter.isCancelled()) { throw new ValidationCancelledException(); @@ -172,7 +175,7 @@ public class GenericRootContextNode if (this.persistenceXml == null) { messages.add( DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, + IMessage.HIGH_SEVERITY, this.buildMissingFileMessageID(), this ) @@ -187,15 +190,14 @@ public class GenericRootContextNode protected String buildMissingFileMessageID() { return this.getPlatformFile().exists() ? - JpaValidationMessages.PERSISTENCE_XML_INVALID_CONTENT - : + JpaValidationMessages.PERSISTENCE_XML_INVALID_CONTENT : JpaValidationMessages.PROJECT_NO_PERSISTENCE_XML; } protected IFile getPlatformFile() { return this.jpaProject.convertToPlatformFile(JptCorePlugin.DEFAULT_PERSISTENCE_XML_FILE_PATH); } - + protected void validateOrphanClasses(List<IMessage> messages) { Persistence persistence = this.persistenceXml.getPersistence(); if (persistence == null) { @@ -213,7 +215,7 @@ public class GenericRootContextNode orphans.remove(annotatedClassName); } } - + // TODO remove 'jrcu' // replace jrcu.getFile() with jrpt.getFile() // replace jrpt.getMappingAnnotation().getTextRange(jrcu.buildASTRoot()) @@ -246,4 +248,5 @@ public class GenericRootContextNode } } } + } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/persistence/GenericPersistenceXml.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/persistence/GenericPersistenceXml.java index c6c0be510e..24c5e4230d 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/persistence/GenericPersistenceXml.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/persistence/GenericPersistenceXml.java @@ -1,9 +1,9 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. - * + * * Contributors: * Oracle - initial API and implementation *******************************************************************************/ @@ -17,7 +17,6 @@ import org.eclipse.jpt.core.JpaStructureNode; import org.eclipse.jpt.core.JptCorePlugin; import org.eclipse.jpt.core.context.JpaRootContextNode; import org.eclipse.jpt.core.context.persistence.Persistence; -import org.eclipse.jpt.core.context.persistence.PersistenceUnit; import org.eclipse.jpt.core.internal.context.persistence.AbstractPersistenceXmlContextNode; import org.eclipse.jpt.core.internal.validation.DefaultJpaValidationMessages; import org.eclipse.jpt.core.internal.validation.JpaValidationMessages; @@ -29,67 +28,74 @@ import org.eclipse.jpt.core.utility.TextRange; import org.eclipse.wst.validation.internal.provisional.core.IMessage; import org.eclipse.wst.validation.internal.provisional.core.IReporter; +/** + * context model persistence.xml + */ public class GenericPersistenceXml extends AbstractPersistenceXmlContextNode implements PersistenceXml2_0 { - protected JpaXmlResource persistenceXmlResource; - + protected JpaXmlResource persistenceXmlResource; // never null + protected Persistence persistence; - + protected JpaResourceType resourceType; - + + public GenericPersistenceXml(JpaRootContextNode parent, JpaXmlResource resource) { super(parent); - if (! resource.getContentType().isKindOf(JptCorePlugin.PERSISTENCE_XML_CONTENT_TYPE)) { + if ( ! resource.getContentType().isKindOf(JptCorePlugin.PERSISTENCE_XML_CONTENT_TYPE)) { throw new IllegalArgumentException("Resource " + resource + " must have persistence xml content type"); //$NON-NLS-1$ //$NON-NLS-2$ } this.persistenceXmlResource = resource; if (resource.getRootObject() != null) { - this.persistence = buildPersistence((XmlPersistence) resource.getRootObject()); + this.persistence = this.buildPersistence((XmlPersistence) resource.getRootObject()); this.resourceType = resource.getResourceType(); } } - + + + // ********** XmlFile implementation ********** + public JpaXmlResource getXmlResource() { return this.persistenceXmlResource; } - - // **************** JpaNode impl ******************************************* - + + + // ********** AbstractJpaNode overrides ********** + @Override public IResource getResource() { return this.persistenceXmlResource.getFile(); } - - - // **************** JpaStructureNode impl ********************************** - - public String getId() { - // isn't actually displayed, so needs no details page - return null; - } - + + + // ********** AbstractJpaContextNode overrides ********** + @Override public JpaResourceType getResourceType() { return this.persistenceXmlResource.getResourceType(); } - - - // **************** persistence ******************************************** - + + + // ********** persistence ********** + public Persistence getPersistence() { return this.persistence; } - - protected void setPersistence(Persistence newPersistence) { - Persistence oldPersistence = this.persistence; - this.persistence = newPersistence; - firePropertyChanged(PERSISTENCE_PROPERTY, oldPersistence, newPersistence); + + protected void setPersistence(Persistence persistence) { + Persistence old = this.persistence; + this.persistence = persistence; + this.firePropertyChanged(PERSISTENCE_PROPERTY, old, persistence); + } + + protected Persistence buildPersistence(XmlPersistence xmlPersistence) { + return this.getContextNodeFactory().buildPersistence(this, xmlPersistence); } - - - // **************** metamodel ******************** + + + // ********** metamodel ********** public void initializeMetamodel() { if (this.persistence != null) { @@ -110,42 +116,41 @@ public class GenericPersistenceXml } - // **************** updating *********************************************** + // ********** updating ********** //TODO I haven't yet figured out if we do not need the resource object passed in now. //I don't think we will even build AbstractPersistenceXml if the resource object is null //I'm pretty sure this won't change now, but need to investigate - KFB - public void update(JpaXmlResource persistenceResource) { - XmlPersistence oldXmlPersistence = - (this.persistence == null) ? null : this.persistence.getXmlPersistence(); - XmlPersistence newXmlPersistence = (XmlPersistence) persistenceResource.getRootObject(); - JpaResourceType newResourceType = persistenceResource.getResourceType(); - - this.persistenceXmlResource = persistenceResource; - + public void update(JpaXmlResource resource) { + XmlPersistence oldXmlPersistence = (this.persistence == null) ? null : this.persistence.getXmlPersistence(); + XmlPersistence newXmlPersistence = (XmlPersistence) resource.getRootObject(); + JpaResourceType newResourceType = resource.getResourceType(); + + this.persistenceXmlResource = resource; + // if the old and new xml persistences are different instances, // we scrap the old and rebuild. this can happen when the resource // model drastically changes, such as a cvs checkout or an edit reversion - if (oldXmlPersistence != newXmlPersistence || newXmlPersistence == null || valuesAreDifferent(this.resourceType, newResourceType)) { + if ((oldXmlPersistence != newXmlPersistence) || (newXmlPersistence == null) || this.valuesAreDifferent(this.resourceType, newResourceType)) { if (this.persistence != null) { this.getJpaFile(this.persistenceXmlResource.getFile()).removeRootStructureNode(this.persistenceXmlResource); this.persistence.dispose(); this.setPersistence(null); } } - + if (newXmlPersistence != null) { if (this.persistence != null) { this.persistence.update(newXmlPersistence); } else { - setPersistence(buildPersistence(newXmlPersistence)); + this.setPersistence(this.buildPersistence(newXmlPersistence)); } this.getJpaFile(this.persistenceXmlResource.getFile()).addRootStructureNode(this.persistenceXmlResource, this.persistence); } this.resourceType = newResourceType; } - + @Override public void postUpdate() { super.postUpdate(); @@ -153,33 +158,39 @@ public class GenericPersistenceXml this.persistence.postUpdate(); } } - - protected Persistence buildPersistence(XmlPersistence xmlPersistence) { - return getContextNodeFactory().buildPersistence(this, xmlPersistence); + + + // ********** JpaStructureNode implementation ********** + + public String getId() { + // isn't actually displayed, so needs no details page + return null; } - - - // ************************************************************************* - + public JpaStructureNode getStructureNode(int textOffset) { if (this.persistence.containsOffset(textOffset)) { return this.persistence.getStructureNode(textOffset); } return this; } - + // never actually selected public TextRange getSelectionTextRange() { return TextRange.Empty.instance(); } - + + public void dispose() { + this.persistence.dispose(); + } + + + // ********** validation ********** + + // never actually selected public TextRange getValidationTextRange() { return TextRange.Empty.instance(); } - - - // **************** validation ********************************************* - + @Override public void validate(List<IMessage> messages, IReporter reporter) { super.validate(messages, reporter); @@ -198,7 +209,4 @@ public class GenericPersistenceXml this.persistence.validate(messages, reporter); } - public void dispose() { - this.persistence.dispose(); - } } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/resource/java/source/SourceAssociationOverrides1_0Annotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/resource/java/source/SourceAssociationOverrides1_0Annotation.java index 859946da3f..44bf07b668 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/resource/java/source/SourceAssociationOverrides1_0Annotation.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/resource/java/source/SourceAssociationOverrides1_0Annotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/resource/java/source/SourceNamedQuery1_0Annotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/resource/java/source/SourceNamedQuery1_0Annotation.java index 8aa0a58141..6e1de34158 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/resource/java/source/SourceNamedQuery1_0Annotation.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/resource/java/source/SourceNamedQuery1_0Annotation.java @@ -1,5 +1,5 @@ /******************************************************************************* -* Copyright (c) 2009 Oracle. All rights reserved. +* Copyright (c) 2009, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -16,7 +16,7 @@ import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; import org.eclipse.jpt.core.utility.jdt.Type; /** - * SourceNamedQuery1_0Annotation + * javax.persistence.NamedQuery */ public final class SourceNamedQuery1_0Annotation extends SourceNamedQueryAnnotation diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/SourceMapKeyJoinColumns2_0Annotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/SourceMapKeyJoinColumns2_0Annotation.java index f1b537e546..7c49be455a 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/SourceMapKeyJoinColumns2_0Annotation.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/SourceMapKeyJoinColumns2_0Annotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. + * Copyright (c) 2009, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -50,8 +50,8 @@ public final class SourceMapKeyJoinColumns2_0Annotation AnnotationContainerTools.initialize(this, astRoot); } - public void update(CompilationUnit astRoot) { - AnnotationContainerTools.update(this, astRoot); + public void synchronizeWith(CompilationUnit astRoot) { + AnnotationContainerTools.synchronize(this, astRoot); } @Override @@ -66,8 +66,8 @@ public final class SourceMapKeyJoinColumns2_0Annotation return this.getAnnotationName(); } - public org.eclipse.jdt.core.dom.Annotation getContainerJdtAnnotation(CompilationUnit astRoot) { - return this.getJdtAnnotation(astRoot); + public org.eclipse.jdt.core.dom.Annotation getContainerAstAnnotation(CompilationUnit astRoot) { + return this.getAstAnnotation(astRoot); } public String getElementName() { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceAccess2_0Annotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceAccess2_0Annotation.java index 318d880818..0fa89552f4 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceAccess2_0Annotation.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceAccess2_0Annotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. + * Copyright (c) 2009, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -12,7 +12,7 @@ package org.eclipse.jpt.core.internal.jpa2.resource.java.source; import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jpt.core.internal.resource.java.source.SourceAnnotation; import org.eclipse.jpt.core.internal.utility.jdt.EnumDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter; +import org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationElementAdapter; import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; import org.eclipse.jpt.core.jpa2.resource.java.Access2_0Annotation; import org.eclipse.jpt.core.jpa2.resource.java.JPA2_0; @@ -40,7 +40,7 @@ public final class SourceAccess2_0Annotation public SourceAccess2_0Annotation(JavaResourcePersistentMember parent, Member member) { super(parent, member, DECLARATION_ANNOTATION_ADAPTER); - this.valueAdapter = new ShortCircuitAnnotationElementAdapter<String>(member, VALUE_ADAPTER); + this.valueAdapter = new MemberAnnotationElementAdapter<String>(member, VALUE_ADAPTER); } public String getAnnotationName() { @@ -51,8 +51,8 @@ public final class SourceAccess2_0Annotation this.value = this.buildValue(astRoot); } - public void update(CompilationUnit astRoot) { - this.setValue(this.buildValue(astRoot)); + public void synchronizeWith(CompilationUnit astRoot) { + this.syncValue(this.buildValue(astRoot)); } @Override @@ -69,13 +69,16 @@ public final class SourceAccess2_0Annotation } public void setValue(AccessType value) { - if (this.attributeValueHasNotChanged(this.value, value)) { - return; + if (this.attributeValueHasChanged(this.value, value)) { + this.value = value; + this.valueAdapter.setValue(AccessType.toJavaAnnotationValue(value)); } + } + + private void syncValue(AccessType astValue) { AccessType old = this.value; - this.value = value; - this.valueAdapter.setValue(AccessType.toJavaAnnotationValue(value)); - this.firePropertyChanged(VALUE_PROPERTY, old, value); + this.value = astValue; + this.firePropertyChanged(VALUE_PROPERTY, old, astValue); } private AccessType buildValue(CompilationUnit astRoot) { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceAssociationOverride2_0Annotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceAssociationOverride2_0Annotation.java index 02cf8620ad..d2b442e6e9 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceAssociationOverride2_0Annotation.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceAssociationOverride2_0Annotation.java @@ -1,5 +1,5 @@ /******************************************************************************* -* Copyright (c) 2009 Oracle. All rights reserved. +* Copyright (c) 2009, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -57,9 +57,9 @@ public final class SourceAssociationOverride2_0Annotation } @Override - public void update(CompilationUnit astRoot) { - super.update(astRoot); - this.updateJoinTable(astRoot); + public void synchronizeWith(CompilationUnit astRoot) { + super.synchronizeWith(astRoot); + this.syncJoinTable(astRoot); } //************ AssociationOverride2_0Annotation implementation **************** @@ -69,50 +69,55 @@ public final class SourceAssociationOverride2_0Annotation return this.joinTable; } + public JoinTableAnnotation getNonNullJoinTable() { + return (this.joinTable != null) ? this.joinTable : new NullAssociationOverrideJoinTableAnnotation(this); + } + public NestableJoinTableAnnotation addJoinTable() { - NestableJoinTableAnnotation table = buildJoinTableAnnotation(this, this.member, this.daa); - table.newAnnotation(); - this.setJoinTable(table); - return table; + if (this.joinTable != null) { + throw new IllegalStateException("'joinTable' element already exists: " + this.joinTable); //$NON-NLS-1$ + } + this.joinTable = buildJoinTableAnnotation(this, this.member, this.daa); + this.joinTable.newAnnotation(); + return this.joinTable; } public JoinColumnAnnotation addJoinTable(AnnotationInitializer initializer) { NestableJoinTableAnnotation table = buildJoinTableAnnotation(this, this.member, this.daa); JoinColumnAnnotation joinColumn = (JoinColumnAnnotation) initializer.initializeAnnotation(table); table.newAnnotation(); - this.setJoinTable(table); + this.joinTable = table; return joinColumn; } public void removeJoinTable() { + if (this.joinTable == null) { + throw new IllegalStateException("'joinTable' element does not exist"); //$NON-NLS-1$ + } this.joinTable.removeAnnotation(); - setJoinTable(null); + this.joinTable = null; } - private void setJoinTable(NestableJoinTableAnnotation joinTable) { - JoinTableAnnotation old = this.joinTable; - this.joinTable = joinTable; - this.firePropertyChanged(JOIN_TABLE_PROPERTY, old, joinTable); - } - - public JoinTableAnnotation getNonNullJoinTable() { - return (this.joinTable != null) ? this.joinTable : new NullAssociationOverrideJoinTableAnnotation(this); - } - - private void updateJoinTable(CompilationUnit astRoot) { + private void syncJoinTable(CompilationUnit astRoot) { if (this.joinTableAdapter.getAnnotation(astRoot) == null) { - this.setJoinTable(null); + this.syncJoinTable_(null); } else { if (this.joinTable == null) { NestableJoinTableAnnotation table = buildJoinTableAnnotation(this, this.member, this.daa); table.initialize(astRoot); - this.setJoinTable(table); + this.syncJoinTable_(table); } else { - this.joinTable.update(astRoot); + this.joinTable.synchronizeWith(astRoot); } } } + private void syncJoinTable_(NestableJoinTableAnnotation astJoinTable) { + JoinTableAnnotation old = this.joinTable; + this.joinTable = astJoinTable; + this.firePropertyChanged(JOIN_TABLE_PROPERTY, old, astJoinTable); + } + // ********** static methods ********** diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceAssociationOverrides2_0Annotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceAssociationOverrides2_0Annotation.java index 62dead13dc..9a72dd220e 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceAssociationOverrides2_0Annotation.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceAssociationOverrides2_0Annotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. + * Copyright (c) 2009, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceCacheable2_0Annotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceCacheable2_0Annotation.java index 812163a0c4..85fd521da8 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceCacheable2_0Annotation.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceCacheable2_0Annotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. + * Copyright (c) 2009, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -13,7 +13,7 @@ import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jpt.core.internal.resource.java.source.SourceAnnotation; import org.eclipse.jpt.core.internal.utility.jdt.BooleanExpressionConverter; import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter; +import org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationElementAdapter; import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; import org.eclipse.jpt.core.jpa2.resource.java.Cacheable2_0Annotation; import org.eclipse.jpt.core.jpa2.resource.java.JPA2_0; @@ -41,7 +41,7 @@ public final class SourceCacheable2_0Annotation public SourceCacheable2_0Annotation(JavaResourcePersistentType parent, Type type) { super(parent, type, DECLARATION_ANNOTATION_ADAPTER); - this.valueAdapter = new ShortCircuitAnnotationElementAdapter<Boolean>(type, VALUE_ADAPTER); + this.valueAdapter = new MemberAnnotationElementAdapter<Boolean>(type, VALUE_ADAPTER); } public String getAnnotationName() { @@ -52,8 +52,8 @@ public final class SourceCacheable2_0Annotation this.value = this.buildValue(astRoot); } - public void update(CompilationUnit astRoot) { - this.setValue(this.buildValue(astRoot)); + public void synchronizeWith(CompilationUnit astRoot) { + this.syncValue(this.buildValue(astRoot)); } @Override @@ -70,13 +70,16 @@ public final class SourceCacheable2_0Annotation } public void setValue(Boolean value) { - if (this.attributeValueHasNotChanged(this.value, value)) { - return; + if (this.attributeValueHasChanged(this.value, value)) { + this.value = value; + this.valueAdapter.setValue(value); } + } + + private void syncValue(Boolean astValue) { Boolean old = this.value; - this.value = value; - this.valueAdapter.setValue(value); - this.firePropertyChanged(VALUE_PROPERTY, old, value); + this.value = astValue; + this.firePropertyChanged(VALUE_PROPERTY, old, astValue); } private Boolean buildValue(CompilationUnit astRoot) { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceCollectionTable2_0Annotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceCollectionTable2_0Annotation.java index ff3fcaa92e..c275fd698e 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceCollectionTable2_0Annotation.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceCollectionTable2_0Annotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. + * Copyright (c) 2009, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -37,7 +37,7 @@ import org.eclipse.jpt.utility.internal.iterators.CloneListIterator; /** * javax.persistence.CollectionTable */ -public class SourceCollectionTable2_0Annotation +public final class SourceCollectionTable2_0Annotation extends SourceBaseTableAnnotation implements CollectionTable2_0Annotation { @@ -69,9 +69,9 @@ public class SourceCollectionTable2_0Annotation } @Override - public void update(CompilationUnit astRoot) { - super.update(astRoot); - AnnotationContainerTools.update(this.joinColumnsContainer, astRoot); + public void synchronizeWith(CompilationUnit astRoot) { + super.synchronizeWith(astRoot); + AnnotationContainerTools.synchronize(this.joinColumnsContainer, astRoot); } @@ -187,8 +187,8 @@ public class SourceCollectionTable2_0Annotation return SourceCollectionTable2_0Annotation.this.getAnnotationName(); } - public org.eclipse.jdt.core.dom.Annotation getContainerJdtAnnotation(CompilationUnit astRoot) { - return SourceCollectionTable2_0Annotation.this.getJdtAnnotation(astRoot); + public org.eclipse.jdt.core.dom.Annotation getContainerAstAnnotation(CompilationUnit astRoot) { + return SourceCollectionTable2_0Annotation.this.getAstAnnotation(astRoot); } public String getElementName() { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceElementCollection2_0Annotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceElementCollection2_0Annotation.java index 444ee39f06..8fb02cf695 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceElementCollection2_0Annotation.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceElementCollection2_0Annotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. + * Copyright (c) 2009, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -14,7 +14,7 @@ import org.eclipse.jpt.core.internal.resource.java.source.SourceAnnotation; import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; import org.eclipse.jpt.core.internal.utility.jdt.EnumDeclarationAnnotationElementAdapter; import org.eclipse.jpt.core.internal.utility.jdt.JDTTools; -import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter; +import org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationElementAdapter; import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; import org.eclipse.jpt.core.internal.utility.jdt.SimpleTypeStringExpressionConverter; import org.eclipse.jpt.core.jpa2.resource.java.ElementCollection2_0Annotation; @@ -50,8 +50,8 @@ public final class SourceElementCollection2_0Annotation public SourceElementCollection2_0Annotation(JavaResourcePersistentAttribute parent, Attribute attribute) { super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); - this.targetClassAdapter = new ShortCircuitAnnotationElementAdapter<String>(attribute, TARGET_CLASS_ADAPTER); - this.fetchAdapter = new ShortCircuitAnnotationElementAdapter<String>(attribute, FETCH_ADAPTER); + this.targetClassAdapter = new MemberAnnotationElementAdapter<String>(attribute, TARGET_CLASS_ADAPTER); + this.fetchAdapter = new MemberAnnotationElementAdapter<String>(attribute, FETCH_ADAPTER); } @@ -65,10 +65,10 @@ public final class SourceElementCollection2_0Annotation this.fetch = this.buildFetch(astRoot); } - public void update(CompilationUnit astRoot) { - this.setTargetClass(this.buildTargetClass(astRoot)); - this.setFullyQualifiedTargetClassName(this.buildFullyQualifiedTargetClassName(astRoot)); - this.setFetch(this.buildFetch(astRoot)); + public void synchronizeWith(CompilationUnit astRoot) { + this.syncTargetClass(this.buildTargetClass(astRoot)); + this.syncFullyQualifiedTargetClassName(this.buildFullyQualifiedTargetClassName(astRoot)); + this.syncFetch(this.buildFetch(astRoot)); } @Override @@ -85,13 +85,16 @@ public final class SourceElementCollection2_0Annotation } public void setTargetClass(String targetClass) { - if (this.attributeValueHasNotChanged(this.targetClass, targetClass)) { - return; + if (this.attributeValueHasChanged(this.targetClass, targetClass)) { + this.targetClass = targetClass; + this.targetClassAdapter.setValue(targetClass); } + } + + private void syncTargetClass(String astTargetClass) { String old = this.targetClass; - this.targetClass = targetClass; - this.targetClassAdapter.setValue(targetClass); - this.firePropertyChanged(TARGET_CLASS_PROPERTY, old, targetClass); + this.targetClass = astTargetClass; + this.firePropertyChanged(TARGET_CLASS_PROPERTY, old, astTargetClass); } private String buildTargetClass(CompilationUnit astRoot) { @@ -107,7 +110,7 @@ public final class SourceElementCollection2_0Annotation return this.fullyQualifiedTargetClassName; } - private void setFullyQualifiedTargetClassName(String name) { + private void syncFullyQualifiedTargetClassName(String name) { String old = this.fullyQualifiedTargetClassName; this.fullyQualifiedTargetClassName = name; this.firePropertyChanged(FULLY_QUALIFIED_TARGET_CLASS_NAME_PROPERTY, old, name); @@ -123,13 +126,16 @@ public final class SourceElementCollection2_0Annotation } public void setFetch(FetchType fetch) { - if (this.attributeValueHasNotChanged(this.fetch, fetch)) { - return; + if (this.attributeValueHasChanged(this.fetch, fetch)) { + this.fetch = fetch; + this.fetchAdapter.setValue(FetchType.toJavaAnnotationValue(fetch)); } + } + + private void syncFetch(FetchType astFetch) { FetchType old = this.fetch; - this.fetch = fetch; - this.fetchAdapter.setValue(FetchType.toJavaAnnotationValue(fetch)); - this.firePropertyChanged(FETCH_PROPERTY, old, fetch); + this.fetch = astFetch; + this.firePropertyChanged(FETCH_PROPERTY, old, astFetch); } private FetchType buildFetch(CompilationUnit astRoot) { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceGeneratedAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceGeneratedAnnotation.java index 0c2e89ac29..4b42b4060c 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceGeneratedAnnotation.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceGeneratedAnnotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. + * Copyright (c) 2009, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -17,8 +17,7 @@ import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jpt.core.internal.resource.java.source.SourceAnnotation; import org.eclipse.jpt.core.internal.utility.jdt.AnnotationStringArrayExpressionConverter; import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitArrayAnnotationElementAdapter; +import org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationElementAdapter; import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; import org.eclipse.jpt.core.jpa2.resource.java.GeneratedAnnotation; import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; @@ -28,6 +27,7 @@ import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; import org.eclipse.jpt.core.utility.jdt.ExpressionConverter; import org.eclipse.jpt.core.utility.jdt.IndexedAnnotationAdapter; import org.eclipse.jpt.core.utility.jdt.Type; +import org.eclipse.jpt.utility.internal.CollectionTools; import org.eclipse.jpt.utility.internal.iterators.CloneListIterator; /** @@ -64,11 +64,11 @@ public final class SourceGeneratedAnnotation } private AnnotationElementAdapter<String[]> buildAnnotationElementAdapter(DeclarationAnnotationElementAdapter<String[]> daea) { - return new ShortCircuitArrayAnnotationElementAdapter<String>(this.member, daea); + return new MemberAnnotationElementAdapter<String[]>(this.member, daea); } private AnnotationElementAdapter<String> buildAdapter(DeclarationAnnotationElementAdapter<String> daea) { - return new ShortCircuitAnnotationElementAdapter<String>(this.member, daea); + return new MemberAnnotationElementAdapter<String>(this.member, daea); } public void initialize(CompilationUnit astRoot) { @@ -77,10 +77,10 @@ public final class SourceGeneratedAnnotation this.comments = this.buildComments(astRoot); } - public void update(CompilationUnit astRoot) { - this.updateValues(astRoot); - this.setDate_(this.buildDate(astRoot)); - this.setComments_(this.buildComments(astRoot)); + public void synchronizeWith(CompilationUnit astRoot) { + this.syncValues(astRoot); + this.syncDate(this.buildDate(astRoot)); + this.syncComments(this.buildComments(astRoot)); } public IndexedAnnotationAdapter getIndexedAnnotationAdapter() { @@ -113,39 +113,39 @@ public final class SourceGeneratedAnnotation } public void addValue(int index, String value) { - this.addValue_(index, value); - this.valueAdapter.setValue(this.values.toArray(new String[this.values.size()])); - } - - private void addValue_(int index, String value) { - this.addItemToList(index, value, this.values, VALUES_LIST); + this.values.add(index, value); + this.writeValues(); } public void moveValue(int targetIndex, int sourceIndex) { - this.moveItemInList(targetIndex, sourceIndex, this.values, VALUES_LIST); - this.valueAdapter.setValue(this.values.toArray(new String[this.values.size()])); + CollectionTools.move(this.values, targetIndex, sourceIndex); + this.writeValues(); } public void removeValue(String value) { - this.removeItemFromList(value, this.values, VALUES_LIST); - this.valueAdapter.setValue(this.values.toArray(new String[this.values.size()])); + this.values.remove(value); + this.writeValues(); } public void removeValue(int index) { - this.removeItemFromList(index, this.values, VALUES_LIST); + this.values.remove(index); + this.writeValues(); + } + + private void writeValues() { this.valueAdapter.setValue(this.values.toArray(new String[this.values.size()])); } private void initializeValues(CompilationUnit astRoot) { - String[] javaValues = this.valueAdapter.getValue(astRoot); - for (int i = 0; i < javaValues.length; i++) { - this.values.add(javaValues[i]); + String[] astValues = this.valueAdapter.getValue(astRoot); + for (int i = 0; i < astValues.length; i++) { + this.values.add(astValues[i]); } } - private void updateValues(CompilationUnit astRoot) { - String[] javaValues = this.valueAdapter.getValue(astRoot); - this.synchronizeList(Arrays.asList(javaValues), this.values, VALUES_LIST); + private void syncValues(CompilationUnit astRoot) { + String[] astValues = this.valueAdapter.getValue(astRoot); + this.synchronizeList(Arrays.asList(astValues), this.values, VALUES_LIST); } // ***** date @@ -154,19 +154,16 @@ public final class SourceGeneratedAnnotation } public void setDate(String date) { - if (this.attributeValueHasNotChanged(this.date, date)) { - return; + if (this.attributeValueHasChanged(this.date, date)) { + this.date = date; + this.dateAdapter.setValue(date); } - String old = this.date; - this.date = date; - this.dateAdapter.setValue(date); - this.firePropertyChanged(DATE_PROPERTY, old, date); } - protected void setDate_(String date) { + protected void syncDate(String astDate) { String old = this.date; - this.date = date; - this.firePropertyChanged(DATE_PROPERTY, old, date); + this.date = astDate; + this.firePropertyChanged(DATE_PROPERTY, old, astDate); } private String buildDate(CompilationUnit astRoot) { @@ -179,19 +176,16 @@ public final class SourceGeneratedAnnotation } public void setComments(String comments) { - if (this.attributeValueHasNotChanged(this.comments, comments)) { - return; + if (this.attributeValueHasChanged(this.comments, comments)) { + this.comments = comments; + this.commentsAdapter.setValue(comments); } - String old = this.date; - this.comments = comments; - this.commentsAdapter.setValue(comments); - this.firePropertyChanged(COMMENTS_PROPERTY, old, comments); } - protected void setComments_(String comments) { + protected void syncComments(String astComments) { String old = this.date; - this.comments = comments; - this.firePropertyChanged(COMMENTS_PROPERTY, old, comments); + this.comments = astComments; + this.firePropertyChanged(COMMENTS_PROPERTY, old, astComments); } private String buildComments(CompilationUnit astRoot) { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceMapKeyClass2_0Annotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceMapKeyClass2_0Annotation.java index 58f7cfeff1..f5d0448944 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceMapKeyClass2_0Annotation.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceMapKeyClass2_0Annotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. + * Copyright (c) 2009, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -13,7 +13,7 @@ import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jpt.core.internal.resource.java.source.SourceAnnotation; import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; import org.eclipse.jpt.core.internal.utility.jdt.JDTTools; -import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter; +import org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationElementAdapter; import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; import org.eclipse.jpt.core.internal.utility.jdt.SimpleTypeStringExpressionConverter; import org.eclipse.jpt.core.jpa2.resource.java.JPA2_0; @@ -43,7 +43,7 @@ public final class SourceMapKeyClass2_0Annotation public SourceMapKeyClass2_0Annotation(JavaResourcePersistentAttribute parent, Attribute attribute) { super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); - this.valueAdapter = new ShortCircuitAnnotationElementAdapter<String>(attribute, VALUE_ADAPTER); + this.valueAdapter = new MemberAnnotationElementAdapter<String>(attribute, VALUE_ADAPTER); } public String getAnnotationName() { @@ -55,9 +55,9 @@ public final class SourceMapKeyClass2_0Annotation this.fullyQualifiedClassName = this.buildFullyQualifiedClassName(astRoot); } - public void update(CompilationUnit astRoot) { - this.setValue(this.buildValue(astRoot)); - this.setFullyQualifiedClassName(this.buildFullyQualifiedClassName(astRoot)); + public void synchronizeWith(CompilationUnit astRoot) { + this.syncValue(this.buildValue(astRoot)); + this.syncFullyQualifiedClassName(this.buildFullyQualifiedClassName(astRoot)); } @Override @@ -74,13 +74,16 @@ public final class SourceMapKeyClass2_0Annotation } public void setValue(String value) { - if (this.attributeValueHasNotChanged(this.value, value)) { - return; + if (this.attributeValueHasChanged(this.value, value)) { + this.value = value; + this.valueAdapter.setValue(value); } + } + + private void syncValue(String astValue) { String old = this.value; - this.value = value; - this.valueAdapter.setValue(value); - this.firePropertyChanged(VALUE_PROPERTY, old, value); + this.value = astValue; + this.firePropertyChanged(VALUE_PROPERTY, old, astValue); } private String buildValue(CompilationUnit astRoot) { @@ -96,10 +99,10 @@ public final class SourceMapKeyClass2_0Annotation return this.fullyQualifiedClassName; } - private void setFullyQualifiedClassName(String fullyQualifiedClassName) { + private void syncFullyQualifiedClassName(String astfullyQualifiedClassName) { String old = this.fullyQualifiedClassName; - this.fullyQualifiedClassName = fullyQualifiedClassName; - this.firePropertyChanged(FULLY_QUALIFIED_CLASS_NAME_PROPERTY, old, fullyQualifiedClassName); + this.fullyQualifiedClassName = astfullyQualifiedClassName; + this.firePropertyChanged(FULLY_QUALIFIED_CLASS_NAME_PROPERTY, old, astfullyQualifiedClassName); } private String buildFullyQualifiedClassName(CompilationUnit astRoot) { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceMapsId2_0Annotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceMapsId2_0Annotation.java index cdace3c20a..bfe2594dbf 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceMapsId2_0Annotation.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceMapsId2_0Annotation.java @@ -1,19 +1,18 @@ /******************************************************************************* - * Copyright (c) 2009 Oracle. - * All rights reserved. This program and the accompanying materials are - * made available under the terms of the Eclipse Public License v1.0 which - * accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle - initial API and implementation - *******************************************************************************/ + * Copyright (c) 2009, 2010 Oracle. All rights reserved. + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0, which accompanies this distribution + * and is available at http://www.eclipse.org/legal/epl-v10.html. + * + * Contributors: + * Oracle - initial API and implementation + ******************************************************************************/ package org.eclipse.jpt.core.internal.jpa2.resource.java.source; import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jpt.core.internal.resource.java.source.SourceAnnotation; import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter; +import org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationElementAdapter; import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; import org.eclipse.jpt.core.jpa2.resource.java.JPA2_0; import org.eclipse.jpt.core.jpa2.resource.java.MapsId2_0Annotation; @@ -27,15 +26,13 @@ import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; /** * javax.persistence.MapsId */ -public class SourceMapsId2_0Annotation +public final class SourceMapsId2_0Annotation extends SourceAnnotation<Attribute> implements MapsId2_0Annotation { - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER - = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); + private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - private static final DeclarationAnnotationElementAdapter<String> VALUE_ADAPTER - = buildValueAdapter(); + private static final DeclarationAnnotationElementAdapter<String> VALUE_ADAPTER = buildValueAdapter(); private final AnnotationElementAdapter<String> valueAdapter; @@ -45,7 +42,7 @@ public class SourceMapsId2_0Annotation public SourceMapsId2_0Annotation(JavaResourcePersistentAttribute parent, Attribute attribute) { super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); - this.valueAdapter = new ShortCircuitAnnotationElementAdapter<String>(attribute, VALUE_ADAPTER); + this.valueAdapter = new MemberAnnotationElementAdapter<String>(attribute, VALUE_ADAPTER); } @@ -57,8 +54,8 @@ public class SourceMapsId2_0Annotation this.value = this.buildValue(astRoot); } - public void update(CompilationUnit astRoot) { - this.setValue(this.buildValue(astRoot)); + public void synchronizeWith(CompilationUnit astRoot) { + this.syncValue(this.buildValue(astRoot)); } @Override @@ -73,16 +70,19 @@ public class SourceMapsId2_0Annotation return this.value; } - public void setValue(String newValue) { - if (this.attributeValueHasNotChanged(this.value, newValue)) { - return; + public void setValue(String value) { + if (this.attributeValueHasChanged(this.value, value)) { + this.value = value; + this.valueAdapter.setValue(value); } - String oldValue = this.value; - this.value = newValue; - this.valueAdapter.setValue(newValue); - this.firePropertyChanged(VALUE_PROPERTY, oldValue, newValue); } - + + private void syncValue(String astValue) { + String old = this.value; + this.value = astValue; + this.firePropertyChanged(VALUE_PROPERTY, old, astValue); + } + private String buildValue(CompilationUnit astRoot) { return this.valueAdapter.getValue(astRoot); } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceNamedQueries2_0Annotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceNamedQueries2_0Annotation.java index 82f15d31a9..1e86f39717 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceNamedQueries2_0Annotation.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceNamedQueries2_0Annotation.java @@ -1,5 +1,5 @@ /******************************************************************************* -* Copyright (c) 2009 Oracle. All rights reserved. +* Copyright (c) 2009, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -15,14 +15,16 @@ import org.eclipse.jpt.core.resource.java.NestableNamedQueryAnnotation; import org.eclipse.jpt.core.utility.jdt.Type; /** - * SourceNamedQueries2_0Annotation + * javax.persistence.NamedQueries */ -public class SourceNamedQueries2_0Annotation extends SourceNamedQueriesAnnotation +public final class SourceNamedQueries2_0Annotation + extends SourceNamedQueriesAnnotation { public SourceNamedQueries2_0Annotation(JavaResourceNode parent, Type type) { super(parent, type); } + @Override protected NestableNamedQueryAnnotation buildNamedQuery(int index) { return SourceNamedQuery2_0Annotation.createNestedNamedQuery(this, member, index, this.daa); } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceNamedQuery2_0Annotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceNamedQuery2_0Annotation.java index e554df0082..abc4264e2c 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceNamedQuery2_0Annotation.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceNamedQuery2_0Annotation.java @@ -1,5 +1,5 @@ /******************************************************************************* -* Copyright (c) 2009 Oracle. All rights reserved. +* Copyright (c) 2009, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -13,9 +13,9 @@ import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jpt.core.internal.resource.java.source.SourceNamedQueryAnnotation; import org.eclipse.jpt.core.internal.utility.jdt.EnumDeclarationAnnotationElementAdapter; import org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationAdapter; +import org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationElementAdapter; import org.eclipse.jpt.core.internal.utility.jdt.MemberIndexedAnnotationAdapter; import org.eclipse.jpt.core.internal.utility.jdt.NestedIndexedDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter; import org.eclipse.jpt.core.jpa2.resource.java.JPA2_0; import org.eclipse.jpt.core.jpa2.resource.java.LockModeType_2_0; import org.eclipse.jpt.core.jpa2.resource.java.NamedQuery2_0Annotation; @@ -32,7 +32,7 @@ import org.eclipse.jpt.core.utility.jdt.IndexedDeclarationAnnotationAdapter; import org.eclipse.jpt.core.utility.jdt.Type; /** - * SourceNamedQuery2_0Annotation + * javax.persistence.NamedQuery */ public final class SourceNamedQuery2_0Annotation extends SourceNamedQueryAnnotation @@ -46,15 +46,15 @@ public final class SourceNamedQuery2_0Annotation public SourceNamedQuery2_0Annotation(JavaResourceNode parent, Type type, DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) { super(parent, type, daa, annotationAdapter); this.lockModeDeclarationAdapter = this.buildLockModeTypeAdapter(daa); - this.lockModeAdapter = new ShortCircuitAnnotationElementAdapter<String>(type, this.lockModeDeclarationAdapter); + this.lockModeAdapter = new MemberAnnotationElementAdapter<String>(type, this.lockModeDeclarationAdapter); } public SourceNamedQuery2_0Annotation(JavaResourceNode parent, Type type) { this(parent, type, DECLARATION_ANNOTATION_ADAPTER, new MemberAnnotationAdapter(type, DECLARATION_ANNOTATION_ADAPTER)); } - private DeclarationAnnotationElementAdapter<String> buildLockModeTypeAdapter(DeclarationAnnotationAdapter daa) { - return new EnumDeclarationAnnotationElementAdapter(daa, this.getLockModeElementName()); + private DeclarationAnnotationElementAdapter<String> buildLockModeTypeAdapter(DeclarationAnnotationAdapter daAdapter) { + return new EnumDeclarationAnnotationElementAdapter(daAdapter, this.getLockModeElementName()); } private String getLockModeElementName() { @@ -77,9 +77,9 @@ public final class SourceNamedQuery2_0Annotation } @Override - public void update(CompilationUnit astRoot) { - super.update(astRoot); - this.setLockMode(this.buildLockMode(astRoot)); + public void synchronizeWith(CompilationUnit astRoot) { + super.synchronizeWith(astRoot); + this.syncLockMode(this.buildLockMode(astRoot)); } @Override @@ -94,13 +94,16 @@ public final class SourceNamedQuery2_0Annotation } public void setLockMode(LockModeType_2_0 lockMode) { - if (this.attributeValueHasNotChanged(this.lockMode, lockMode)) { - return; + if (this.attributeValueHasChanged(this.lockMode, lockMode)) { + this.lockMode = lockMode; + this.lockModeAdapter.setValue(LockModeType_2_0.toJavaAnnotationValue(lockMode)); } + } + + private void syncLockMode(LockModeType_2_0 astLockMode) { LockModeType_2_0 old = this.lockMode; - this.lockMode = lockMode; - this.lockModeAdapter.setValue(LockModeType_2_0.toJavaAnnotationValue(lockMode)); - this.firePropertyChanged(LOCK_MODE_PROPERTY, old, lockMode); + this.lockMode = astLockMode; + this.firePropertyChanged(LOCK_MODE_PROPERTY, old, astLockMode); } private LockModeType_2_0 buildLockMode(CompilationUnit astRoot) { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceOneToMany2_0Annotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceOneToMany2_0Annotation.java index 57c49026ab..bdeafe20de 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceOneToMany2_0Annotation.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceOneToMany2_0Annotation.java @@ -1,5 +1,5 @@ /******************************************************************************* -* Copyright (c) 2009 Oracle. All rights reserved. +* Copyright (c) 2009, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -46,9 +46,9 @@ public final class SourceOneToMany2_0Annotation } @Override - public void update(CompilationUnit astRoot) { - super.update(astRoot); - this.setOrphanRemoval(this.buildOrphanRemoval(astRoot)); + public void synchronizeWith(CompilationUnit astRoot) { + super.synchronizeWith(astRoot); + this.syncOrphanRemoval(this.buildOrphanRemoval(astRoot)); } // ********** OneToMany2_0Annotation implementation ********** @@ -58,13 +58,16 @@ public final class SourceOneToMany2_0Annotation } public void setOrphanRemoval(Boolean orphanRemoval) { - if (this.attributeValueHasNotChanged(this.orphanRemoval, orphanRemoval)) { - return; + if (this.attributeValueHasChanged(this.orphanRemoval, orphanRemoval)) { + this.orphanRemoval = orphanRemoval; + this.orphanRemovalAdapter.setValue(orphanRemoval); } + } + + private void syncOrphanRemoval(Boolean astOrphanRemoval) { Boolean old = this.orphanRemoval; - this.orphanRemoval = orphanRemoval; - this.orphanRemovalAdapter.setValue(orphanRemoval); - this.firePropertyChanged(ORPHAN_REMOVAL_PROPERTY, old, orphanRemoval); + this.orphanRemoval = astOrphanRemoval; + this.firePropertyChanged(ORPHAN_REMOVAL_PROPERTY, old, astOrphanRemoval); } public TextRange getOrphanRemovalTextRange(CompilationUnit astRoot) { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceOneToOne2_0Annotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceOneToOne2_0Annotation.java index 11ce5d7fe1..14f1553784 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceOneToOne2_0Annotation.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceOneToOne2_0Annotation.java @@ -1,5 +1,5 @@ /******************************************************************************* -* Copyright (c) 2009 Oracle. All rights reserved. +* Copyright (c) 2009, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -46,9 +46,9 @@ public final class SourceOneToOne2_0Annotation } @Override - public void update(CompilationUnit astRoot) { - super.update(astRoot); - this.setOrphanRemoval(this.buildOrphanRemoval(astRoot)); + public void synchronizeWith(CompilationUnit astRoot) { + super.synchronizeWith(astRoot); + this.syncOrphanRemoval(this.buildOrphanRemoval(astRoot)); } // ********** OneToOne2_0Annotation implementation ********** @@ -58,13 +58,16 @@ public final class SourceOneToOne2_0Annotation } public void setOrphanRemoval(Boolean orphanRemoval) { - if (this.attributeValueHasNotChanged(this.orphanRemoval, orphanRemoval)) { - return; + if (this.attributeValueHasChanged(this.orphanRemoval, orphanRemoval)) { + this.orphanRemoval = orphanRemoval; + this.orphanRemovalAdapter.setValue(orphanRemoval); } + } + + private void syncOrphanRemoval(Boolean astOrphanRemoval) { Boolean old = this.orphanRemoval; - this.orphanRemoval = orphanRemoval; - this.orphanRemovalAdapter.setValue(orphanRemoval); - this.firePropertyChanged(ORPHAN_REMOVAL_PROPERTY, old, orphanRemoval); + this.orphanRemoval = astOrphanRemoval; + this.firePropertyChanged(ORPHAN_REMOVAL_PROPERTY, old, astOrphanRemoval); } public TextRange getOrphanRemovalTextRange(CompilationUnit astRoot) { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceOrderColumn2_0Annotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceOrderColumn2_0Annotation.java index da51338491..177665cde2 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceOrderColumn2_0Annotation.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceOrderColumn2_0Annotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -26,7 +26,7 @@ import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; /** * javax.persistence.OrderColumn */ -public class SourceOrderColumn2_0Annotation +public final class SourceOrderColumn2_0Annotation extends SourceNamedColumnAnnotation implements OrderColumn2_0Annotation { @@ -63,11 +63,11 @@ public class SourceOrderColumn2_0Annotation } @Override - public void update(CompilationUnit astRoot) { - super.update(astRoot); - this.setNullable(this.buildNullable(astRoot)); - this.setInsertable(this.buildInsertable(astRoot)); - this.setUpdatable(this.buildUpdatable(astRoot)); + public void synchronizeWith(CompilationUnit astRoot) { + super.synchronizeWith(astRoot); + this.syncNullable(this.buildNullable(astRoot)); + this.syncInsertable(this.buildInsertable(astRoot)); + this.syncUpdatable(this.buildUpdatable(astRoot)); } @Override @@ -101,13 +101,16 @@ public class SourceOrderColumn2_0Annotation } public void setNullable(Boolean nullable) { - if (this.attributeValueHasNotChanged(this.nullable, nullable)) { - return; + if (this.attributeValueHasChanged(this.nullable, nullable)) { + this.nullable = nullable; + this.nullableAdapter.setValue(nullable); } + } + + private void syncNullable(Boolean astNullable) { Boolean old = this.nullable; - this.nullable = nullable; - this.nullableAdapter.setValue(nullable); - this.firePropertyChanged(NULLABLE_PROPERTY, old, nullable); + this.nullable = astNullable; + this.firePropertyChanged(NULLABLE_PROPERTY, old, astNullable); } private Boolean buildNullable(CompilationUnit astRoot) { @@ -128,13 +131,16 @@ public class SourceOrderColumn2_0Annotation } public void setInsertable(Boolean insertable) { - if (this.attributeValueHasNotChanged(this.insertable, insertable)) { - return; + if (this.attributeValueHasChanged(this.insertable, insertable)) { + this.insertable = insertable; + this.insertableAdapter.setValue(insertable); } + } + + private void syncInsertable(Boolean astInsertable) { Boolean old = this.insertable; - this.insertable = insertable; - this.insertableAdapter.setValue(insertable); - this.firePropertyChanged(INSERTABLE_PROPERTY, old, insertable); + this.insertable = astInsertable; + this.firePropertyChanged(INSERTABLE_PROPERTY, old, astInsertable); } private Boolean buildInsertable(CompilationUnit astRoot) { @@ -155,13 +161,16 @@ public class SourceOrderColumn2_0Annotation } public void setUpdatable(Boolean updatable) { - if (this.attributeValueHasNotChanged(this.updatable, updatable)) { - return; + if (this.attributeValueHasChanged(this.updatable, updatable)) { + this.updatable = updatable; + this.updatableAdapter.setValue(updatable); } + } + + private void syncUpdatable(Boolean astUpdatable) { Boolean old = this.updatable; - this.updatable = updatable; - this.updatableAdapter.setValue(updatable); - this.firePropertyChanged(UPDATABLE_PROPERTY, old, updatable); + this.updatable = astUpdatable; + this.firePropertyChanged(UPDATABLE_PROPERTY, old, astUpdatable); } private Boolean buildUpdatable(CompilationUnit astRoot) { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceSequenceGenerator2_0Annotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceSequenceGenerator2_0Annotation.java index f1c09d3aa0..1fa27a74f9 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceSequenceGenerator2_0Annotation.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceSequenceGenerator2_0Annotation.java @@ -1,5 +1,5 @@ /******************************************************************************* -* Copyright (c) 2009 Oracle. All rights reserved. +* Copyright (c) 2009, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -38,7 +38,6 @@ public final class SourceSequenceGenerator2_0Annotation // ********** constructor ********** public SourceSequenceGenerator2_0Annotation(JavaResourceNode parent, Member member) { super(parent, member); - this.catalogAdapter = this.buildAdapter(CATALOG_ADAPTER); this.schemaAdapter = this.buildAdapter(SCHEMA_ADAPTER); } @@ -46,18 +45,15 @@ public final class SourceSequenceGenerator2_0Annotation @Override public void initialize(CompilationUnit astRoot) { super.initialize(astRoot); - this.catalog = this.buildCatalog(astRoot); this.schema = this.buildSchema(astRoot); - } @Override - public void update(CompilationUnit astRoot) { - super.update(astRoot); - - this.setCatalog(this.buildCatalog(astRoot)); - this.setSchema(this.buildSchema(astRoot)); + public void synchronizeWith(CompilationUnit astRoot) { + super.synchronizeWith(astRoot); + this.syncCatalog(this.buildCatalog(astRoot)); + this.syncSchema(this.buildSchema(astRoot)); } // ********** catalog ********** @@ -66,13 +62,16 @@ public final class SourceSequenceGenerator2_0Annotation } public void setCatalog(String catalog) { - if (this.attributeValueHasNotChanged(this.catalog, catalog)) { - return; + if (this.attributeValueHasChanged(this.catalog, catalog)) { + this.catalog = catalog; + this.catalogAdapter.setValue(catalog); } + } + + private void syncCatalog(String astCatalog) { String old = this.catalog; - this.catalog = catalog; - this.catalogAdapter.setValue(catalog); - this.firePropertyChanged(CATALOG_PROPERTY, old, catalog); + this.catalog = astCatalog; + this.firePropertyChanged(CATALOG_PROPERTY, old, astCatalog); } private String buildCatalog(CompilationUnit astRoot) { @@ -93,13 +92,16 @@ public final class SourceSequenceGenerator2_0Annotation } public void setSchema(String schema) { - if (this.attributeValueHasNotChanged(this.schema, schema)) { - return; + if (this.attributeValueHasChanged(this.schema, schema)) { + this.schema = schema; + this.schemaAdapter.setValue(schema); } + } + + private void syncSchema(String astSchema) { String old = this.schema; - this.schema = schema; - this.schemaAdapter.setValue(schema); - this.firePropertyChanged(SCHEMA_PROPERTY, old, schema); + this.schema = astSchema; + this.firePropertyChanged(SCHEMA_PROPERTY, old, astSchema); } private String buildSchema(CompilationUnit astRoot) { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceStaticMetamodelAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceStaticMetamodelAnnotation.java index bab8473fef..8bef8f45a9 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceStaticMetamodelAnnotation.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceStaticMetamodelAnnotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. + * Copyright (c) 2009, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -13,7 +13,7 @@ import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jpt.core.internal.resource.java.source.SourceAnnotation; import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; import org.eclipse.jpt.core.internal.utility.jdt.JDTTools; -import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter; +import org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationElementAdapter; import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; import org.eclipse.jpt.core.internal.utility.jdt.SimpleTypeStringExpressionConverter; import org.eclipse.jpt.core.jpa2.resource.java.JPA2_0; @@ -42,7 +42,7 @@ public final class SourceStaticMetamodelAnnotation public SourceStaticMetamodelAnnotation(JavaResourcePersistentType parent, Type type) { super(parent, type, DECLARATION_ANNOTATION_ADAPTER); - this.valueAdapter = new ShortCircuitAnnotationElementAdapter<String>(type, VALUE_ADAPTER); + this.valueAdapter = new MemberAnnotationElementAdapter<String>(type, VALUE_ADAPTER); } public String getAnnotationName() { @@ -54,9 +54,9 @@ public final class SourceStaticMetamodelAnnotation this.fullyQualifiedClassName = this.buildFullyQualifiedClassName(astRoot); } - public void update(CompilationUnit astRoot) { - this.setValue(this.buildValue(astRoot)); - this.setFullyQualifiedClassName(this.buildFullyQualifiedClassName(astRoot)); + public void synchronizeWith(CompilationUnit astRoot) { + this.syncValue(this.buildValue(astRoot)); + this.syncFullyQualifiedClassName(this.buildFullyQualifiedClassName(astRoot)); } @Override @@ -73,13 +73,16 @@ public final class SourceStaticMetamodelAnnotation } public void setValue(String value) { - if (this.attributeValueHasNotChanged(this.value, value)) { - return; + if (this.attributeValueHasChanged(this.value, value)) { + this.value = value; + this.valueAdapter.setValue(value); } + } + + private void syncValue(String astValue) { String old = this.value; - this.value = value; - this.valueAdapter.setValue(value); - this.firePropertyChanged(VALUE_PROPERTY, old, value); + this.value = astValue; + this.firePropertyChanged(VALUE_PROPERTY, old, astValue); } private String buildValue(CompilationUnit astRoot) { @@ -91,10 +94,10 @@ public final class SourceStaticMetamodelAnnotation return this.fullyQualifiedClassName; } - private void setFullyQualifiedClassName(String fullyQualifiedClassName) { + private void syncFullyQualifiedClassName(String astfullyQualifiedClassName) { String old = this.fullyQualifiedClassName; - this.fullyQualifiedClassName = fullyQualifiedClassName; - this.firePropertyChanged(FULLY_QUALIFIED_CLASS_NAME_PROPERTY, old, fullyQualifiedClassName); + this.fullyQualifiedClassName = astfullyQualifiedClassName; + this.firePropertyChanged(FULLY_QUALIFIED_CLASS_NAME_PROPERTY, old, astfullyQualifiedClassName); } private String buildFullyQualifiedClassName(CompilationUnit astRoot) { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NamedQueriesAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NamedQueriesAnnotationDefinition.java index e560b3e62d..ef71eec403 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NamedQueriesAnnotationDefinition.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NamedQueriesAnnotationDefinition.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. + * Copyright (c) 2009, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -11,7 +11,7 @@ package org.eclipse.jpt.core.internal.resource.java; import org.eclipse.jdt.core.IAnnotation; import org.eclipse.jpt.core.internal.jpa1.resource.java.binary.BinaryNamedQueries1_0Annotation; -import org.eclipse.jpt.core.internal.resource.java.source.SourceNamedQueriesAnnotation; +import org.eclipse.jpt.core.internal.resource.java.source.SourceNamedQueries1_0Annotation; import org.eclipse.jpt.core.resource.java.Annotation; import org.eclipse.jpt.core.resource.java.AnnotationDefinition; import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; @@ -43,7 +43,7 @@ public final class NamedQueriesAnnotationDefinition } public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { - return new SourceNamedQueriesAnnotation(parent, (Type) member); + return new SourceNamedQueries1_0Annotation(parent, (Type) member); } public Annotation buildNullAnnotation(JavaResourcePersistentMember parent) { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullAnnotation.java index 3fc989ff90..049ef35f11 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullAnnotation.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullAnnotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. + * Copyright (c) 2009, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -32,7 +32,7 @@ public abstract class NullAnnotation // do nothing } - public org.eclipse.jdt.core.dom.Annotation getJdtAnnotation(CompilationUnit astRoot) { + public org.eclipse.jdt.core.dom.Annotation getAstAnnotation(CompilationUnit astRoot) { return null; } @@ -52,7 +52,7 @@ public abstract class NullAnnotation return null; } - public void update(CompilationUnit astRoot) { + public void synchronizeWith(CompilationUnit astRoot) { throw new UnsupportedOperationException(); } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryAnnotation.java index 7d5b6bf1ec..db134fd8b8 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryAnnotation.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryAnnotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. + * Copyright (c) 2009, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -76,7 +76,7 @@ public abstract class BinaryAnnotation // ********** Annotation implementation ********** - public org.eclipse.jdt.core.dom.Annotation getJdtAnnotation(CompilationUnit astRoot) { + public org.eclipse.jdt.core.dom.Annotation getAstAnnotation(CompilationUnit astRoot) { throw new UnsupportedOperationException(); } public void newAnnotation() { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryContainerAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryContainerAnnotation.java index 1133431dab..29c0215586 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryContainerAnnotation.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryContainerAnnotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. + * Copyright (c) 2009, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -32,7 +32,7 @@ public abstract class BinaryContainerAnnotation<T extends NestableAnnotation> throw new UnsupportedOperationException(); } - public Annotation getContainerJdtAnnotation(CompilationUnit astRoot) { + public Annotation getContainerAstAnnotation(CompilationUnit astRoot) { throw new UnsupportedOperationException(); } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryNode.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryNode.java index 07a15f79a1..8f01e8d048 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryNode.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryNode.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. + * Copyright (c) 2009, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -55,7 +55,7 @@ public abstract class BinaryNode throw new UnsupportedOperationException(); } - public void update(CompilationUnit astRoot) { + public void synchronizeWith(CompilationUnit astRoot) { throw new UnsupportedOperationException(); } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/RootBinaryNode.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/RootBinaryNode.java index 7caa4969cd..fa78848df6 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/RootBinaryNode.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/RootBinaryNode.java @@ -60,7 +60,7 @@ abstract class RootBinaryNode public void resourceModelChanged() { for (JpaResourceModelListener listener : this.resourceModelListenerList.getListeners()) { - listener.resourceModelChanged(); + listener.resourceModelChanged(this); } } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/AnnotationContainerTools.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/AnnotationContainerTools.java index 97446b9da0..949dff37af 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/AnnotationContainerTools.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/AnnotationContainerTools.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -35,7 +35,7 @@ public final class AnnotationContainerTools { * Add a nested annotation to the specified annotation container * at the specified index. * This method modifies both the model annotation container and the - * AST; with the appropriate change notification occurring afterwards. + * AST; with <em>no</em> change notification. */ public static <T extends NestableAnnotation> NestableAnnotation addNestedAnnotation(int index, AnnotationContainer<T> annotationContainer) { // add a new annotation to the end of the list... @@ -44,9 +44,7 @@ public final class AnnotationContainerTools { nestedAnnotation.newAnnotation(); // ...then move it to the specified index... annotationContainer.moveNestedAnnotationInternal(index, sourceIndex); - synchJavaAnnotationsAfterMove(index, sourceIndex, annotationContainer, nestedAnnotation); - // ...then, when all is settled, tell the container to fire change notification - annotationContainer.nestedAnnotationAdded(index, nestedAnnotation); + syncAstAnnotationsAfterMove(index, sourceIndex, annotationContainer, nestedAnnotation); return nestedAnnotation; } @@ -54,12 +52,11 @@ public final class AnnotationContainerTools { * Move the nested annotation at the specified source index in the * specified annotation container to the specified target index. * This method modifies both the model annotation container and the - * AST; with the appropriate change notification occurring afterwards. + * AST; with <em>no</em> change notification. */ public static <T extends NestableAnnotation> void moveNestedAnnotation(int targetIndex, int sourceIndex, AnnotationContainer<T> annotationContainer) { NestableAnnotation nestedAnnotation = annotationContainer.moveNestedAnnotationInternal(targetIndex, sourceIndex); - synchJavaAnnotationsAfterMove(targetIndex, sourceIndex, annotationContainer, nestedAnnotation); - annotationContainer.nestedAnnotationMoved(targetIndex, sourceIndex); + syncAstAnnotationsAfterMove(targetIndex, sourceIndex, annotationContainer, nestedAnnotation); } /** @@ -68,10 +65,10 @@ public final class AnnotationContainerTools { * Synchronize the AST annotations with the model annotation container, * starting with the lower index to prevent overlap. */ - private static <T extends NestableAnnotation> void synchJavaAnnotationsAfterMove(int targetIndex, int sourceIndex, AnnotationContainer<T> annotationContainer, NestableAnnotation nestedAnnotationAnnotation) { + private static <T extends NestableAnnotation> void syncAstAnnotationsAfterMove(int targetIndex, int sourceIndex, AnnotationContainer<T> annotationContainer, NestableAnnotation nestedAnnotation) { // move the Java annotation to the end of the list... - nestedAnnotationAnnotation.moveAnnotation(annotationContainer.nestedAnnotationsSize()); - // ...then shift the other Java annotations over one slot... + nestedAnnotation.moveAnnotation(annotationContainer.nestedAnnotationsSize()); + // ...then shift the other AST annotations over one slot... List<T> nestableAnnotations = CollectionTools.list(annotationContainer.nestedAnnotations()); if (sourceIndex < targetIndex) { for (int i = sourceIndex; i < targetIndex; i++) { @@ -82,21 +79,20 @@ public final class AnnotationContainerTools { nestableAnnotations.get(i).moveAnnotation(i); } } - // ...then move the Java annotation to the now empty slot at the target index - nestedAnnotationAnnotation.moveAnnotation(targetIndex); + // ...then move the AST annotation to the now empty slot at the target index + nestedAnnotation.moveAnnotation(targetIndex); } /** * Remove the nested annotation at the specified index in the * specified annotation container. * This method modifies both the model annotation container and the - * AST; with the appropriate change notification occurring afterwards. + * AST; with <em>no</em> change notification. */ public static <T extends NestableAnnotation> void removeNestedAnnotation(int index, AnnotationContainer<T> annotationContainer) { T nestedAnnotation = annotationContainer.removeNestedAnnotationInternal(index); nestedAnnotation.removeAnnotation(); - synchJavaAnnotationsAfterRemove(index, annotationContainer); - annotationContainer.nestedAnnotationRemoved(index, nestedAnnotation); + syncAstAnnotationsAfterRemove(index, annotationContainer); } /** @@ -105,11 +101,11 @@ public final class AnnotationContainerTools { * Synchronize the AST annotations with the model annotation container, * starting at the specified index to prevent overlap. */ - private static <T extends NestableAnnotation> void synchJavaAnnotationsAfterRemove(int index, AnnotationContainer<T> annotationContainer) { + private static <T extends NestableAnnotation> void syncAstAnnotationsAfterRemove(int index, AnnotationContainer<T> annotationContainer) { List<T> nestableAnnotations = CollectionTools.list(annotationContainer.nestedAnnotations()); for (int i = index; i < nestableAnnotations.size(); i++) { // the indices are the same because the model annotations are - // already in the proper locations - it's the Java annotations that + // already in the proper locations - it's the AST annotations that // need to be moved to the same location nestableAnnotations.get(i).moveAnnotation(i); } @@ -134,7 +130,7 @@ public final class AnnotationContainerTools { */ private static <T extends NestableAnnotation> ArrayList<Annotation> getNestedAstAnnotations(CompilationUnit astRoot, AnnotationContainer<T> annotationContainer) { ArrayList<Annotation> result = new ArrayList<Annotation>(); - Annotation containerAstAnnotation = annotationContainer.getContainerJdtAnnotation(astRoot); + Annotation containerAstAnnotation = annotationContainer.getContainerAstAnnotation(astRoot); if (containerAstAnnotation.isMarkerAnnotation()) { // no nested annotations } @@ -231,11 +227,11 @@ public final class AnnotationContainerTools { } /** - * Update the annotations in the specified annotation container to be in - * synch with those in the specified AST. The appropriate change - * notification will occur. + * Synchronize the annotations in the specified annotation container + * with those in the specified AST. Trigger the appropriate change + * notification. */ - public static <T extends NestableAnnotation> void update(AnnotationContainer<T> annotationContainer, CompilationUnit astRoot) { + public static <T extends NestableAnnotation> void synchronize(AnnotationContainer<T> annotationContainer, CompilationUnit astRoot) { ListIterator<Annotation> astAnnotations = getNestedAstAnnotations(astRoot, annotationContainer).listIterator(); for (ListIterator<T> nestedAnnotations = annotationContainer.nestedAnnotations(); nestedAnnotations.hasNext(); ) { @@ -243,7 +239,7 @@ public final class AnnotationContainerTools { if (astAnnotations.hasNext()) { // matching AST annotation is present - update the nested annotation astAnnotations.next(); // maybe someday we can pass this to the update - nestedAnnotation.update(astRoot); + nestedAnnotation.synchronizeWith(astRoot); } else { // no more AST annotations - remove the nested annotation at the end of the container's list int last = annotationContainer.nestedAnnotationsSize() - 1; diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceAnnotation.java index 78e6e5ba82..27e8e8c4e9 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceAnnotation.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceAnnotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -64,7 +64,7 @@ public abstract class SourceAnnotation<M extends Member> // ********** Annotation implementation ********** - public org.eclipse.jdt.core.dom.Annotation getJdtAnnotation(CompilationUnit astRoot) { + public org.eclipse.jdt.core.dom.Annotation getAstAnnotation(CompilationUnit astRoot) { return this.annotationAdapter.getAnnotation(astRoot); } @@ -84,7 +84,7 @@ public abstract class SourceAnnotation<M extends Member> * If the annotation is missing, return null. */ protected TextRange getAnnotationTextRange(CompilationUnit astRoot) { - return this.getTextRange(this.getJdtAnnotation(astRoot)); + return this.getTextRange(this.getAstAnnotation(astRoot)); } /** diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceAssociationOverrideAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceAssociationOverrideAnnotation.java index 9f2ccc4032..aa51c60ca0 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceAssociationOverrideAnnotation.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceAssociationOverrideAnnotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -59,9 +59,9 @@ public abstract class SourceAssociationOverrideAnnotation } @Override - public void update(CompilationUnit astRoot) { - super.update(astRoot); - AnnotationContainerTools.update(this.joinColumnsContainer, astRoot); + public void synchronizeWith(CompilationUnit astRoot) { + super.synchronizeWith(astRoot); + AnnotationContainerTools.synchronize(this.joinColumnsContainer, astRoot); } @@ -163,8 +163,8 @@ public abstract class SourceAssociationOverrideAnnotation return SourceAssociationOverrideAnnotation.this.getAnnotationName(); } - public org.eclipse.jdt.core.dom.Annotation getContainerJdtAnnotation(CompilationUnit astRoot) { - return SourceAssociationOverrideAnnotation.this.getJdtAnnotation(astRoot); + public org.eclipse.jdt.core.dom.Annotation getContainerAstAnnotation(CompilationUnit astRoot) { + return SourceAssociationOverrideAnnotation.this.getAstAnnotation(astRoot); } public String getElementName() { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceAssociationOverridesAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceAssociationOverridesAnnotation.java index 65acf31d66..4dccf5cafc 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceAssociationOverridesAnnotation.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceAssociationOverridesAnnotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -48,8 +48,8 @@ public abstract class SourceAssociationOverridesAnnotation AnnotationContainerTools.initialize(this, astRoot); } - public void update(CompilationUnit astRoot) { - AnnotationContainerTools.update(this, astRoot); + public void synchronizeWith(CompilationUnit astRoot) { + AnnotationContainerTools.synchronize(this, astRoot); } @Override @@ -64,8 +64,8 @@ public abstract class SourceAssociationOverridesAnnotation return this.getAnnotationName(); } - public org.eclipse.jdt.core.dom.Annotation getContainerJdtAnnotation(CompilationUnit astRoot) { - return this.getJdtAnnotation(astRoot); + public org.eclipse.jdt.core.dom.Annotation getContainerAstAnnotation(CompilationUnit astRoot) { + return this.getAstAnnotation(astRoot); } public String getElementName() { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceAttributeOverrideAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceAttributeOverrideAnnotation.java index 5f7fdb2d8e..f3f8f3b3c3 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceAttributeOverrideAnnotation.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceAttributeOverrideAnnotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -62,9 +62,9 @@ public final class SourceAttributeOverrideAnnotation } @Override - public void update(CompilationUnit astRoot) { - super.update(astRoot); - this.updateColumn(astRoot); + public void synchronizeWith(CompilationUnit astRoot) { + super.synchronizeWith(astRoot); + this.syncColumn(astRoot); } @@ -83,42 +83,47 @@ public final class SourceAttributeOverrideAnnotation return this.column; } + public ColumnAnnotation getNonNullColumn() { + return (this.column != null) ? this.column : new NullAttributeOverrideColumnAnnotation(this); + } + public NestableColumnAnnotation addColumn() { - NestableColumnAnnotation col = SourceColumnAnnotation.createAttributeOverrideColumn(this, this.member, this.daa); - col.newAnnotation(); - this.setColumn(col); - return col; + if (this.column != null) { + throw new IllegalStateException("'column' element already exists: " + this.column); //$NON-NLS-1$ + } + this.column = SourceColumnAnnotation.createAttributeOverrideColumn(this, this.member, this.daa); + this.column.newAnnotation(); + return this.column; } public void removeColumn() { + if (this.column == null) { + throw new IllegalStateException("'column' element does not exist"); //$NON-NLS-1$ + } this.column.removeAnnotation(); - setColumn(null); + this.column = null; } - private void setColumn(NestableColumnAnnotation column) { - ColumnAnnotation old = this.column; - this.column = column; - this.firePropertyChanged(COLUMN_PROPERTY, old, column); - } - - public ColumnAnnotation getNonNullColumn() { - return (this.column != null) ? this.column : new NullAttributeOverrideColumnAnnotation(this); - } - - private void updateColumn(CompilationUnit astRoot) { + private void syncColumn(CompilationUnit astRoot) { if (this.columnAdapter.getAnnotation(astRoot) == null) { - this.setColumn(null); + this.syncColumn_(null); } else { if (this.column == null) { NestableColumnAnnotation col = SourceColumnAnnotation.createAttributeOverrideColumn(this, this.member, this.daa); col.initialize(astRoot); - this.setColumn(col); + this.syncColumn_(col); } else { - this.column.update(astRoot); + this.column.synchronizeWith(astRoot); } } } + private void syncColumn_(NestableColumnAnnotation astColumn) { + ColumnAnnotation old = this.column; + this.column = astColumn; + this.firePropertyChanged(COLUMN_PROPERTY, old, astColumn); + } + // ********** NestableAnnotation implementation ********** diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceAttributeOverridesAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceAttributeOverridesAnnotation.java index 8d41766fe8..eb0f103439 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceAttributeOverridesAnnotation.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceAttributeOverridesAnnotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -48,8 +48,8 @@ public final class SourceAttributeOverridesAnnotation AnnotationContainerTools.initialize(this, astRoot); } - public void update(CompilationUnit astRoot) { - AnnotationContainerTools.update(this, astRoot); + public void synchronizeWith(CompilationUnit astRoot) { + AnnotationContainerTools.synchronize(this, astRoot); } @Override @@ -64,8 +64,8 @@ public final class SourceAttributeOverridesAnnotation return this.getAnnotationName(); } - public org.eclipse.jdt.core.dom.Annotation getContainerJdtAnnotation(CompilationUnit astRoot) { - return this.getJdtAnnotation(astRoot); + public org.eclipse.jdt.core.dom.Annotation getContainerAstAnnotation(CompilationUnit astRoot) { + return this.getAstAnnotation(astRoot); } public String getElementName() { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceBaseColumnAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceBaseColumnAnnotation.java index b6b233ddf3..2dab34af2d 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceBaseColumnAnnotation.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceBaseColumnAnnotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -79,13 +79,13 @@ public abstract class SourceBaseColumnAnnotation } @Override - public void update(CompilationUnit astRoot) { - super.update(astRoot); - this.setTable(this.buildTable(astRoot)); - this.setUnique(this.buildUnique(astRoot)); - this.setNullable(this.buildNullable(astRoot)); - this.setInsertable(this.buildInsertable(astRoot)); - this.setUpdatable(this.buildUpdatable(astRoot)); + public void synchronizeWith(CompilationUnit astRoot) { + super.synchronizeWith(astRoot); + this.syncTable(this.buildTable(astRoot)); + this.syncUnique(this.buildUnique(astRoot)); + this.syncNullable(this.buildNullable(astRoot)); + this.syncInsertable(this.buildInsertable(astRoot)); + this.syncUpdatable(this.buildUpdatable(astRoot)); } @@ -97,13 +97,16 @@ public abstract class SourceBaseColumnAnnotation } public void setTable(String table) { - if (this.attributeValueHasNotChanged(this.table, table)) { - return; + if (this.attributeValueHasChanged(this.table, table)) { + this.table = table; + this.tableAdapter.setValue(table); } + } + + private void syncTable(String astTable) { String old = this.table; - this.table = table; - this.tableAdapter.setValue(table); - this.firePropertyChanged(TABLE_PROPERTY, old, table); + this.table = astTable; + this.firePropertyChanged(TABLE_PROPERTY, old, astTable); } private String buildTable(CompilationUnit astRoot) { @@ -126,13 +129,16 @@ public abstract class SourceBaseColumnAnnotation } public void setUnique(Boolean unique) { - if (this.attributeValueHasNotChanged(this.unique, unique)) { - return; + if (this.attributeValueHasChanged(this.unique, unique)) { + this.unique = unique; + this.uniqueAdapter.setValue(unique); } + } + + private void syncUnique(Boolean astUnique) { Boolean old = this.unique; - this.unique = unique; - this.uniqueAdapter.setValue(unique); - this.firePropertyChanged(UNIQUE_PROPERTY, old, unique); + this.unique = astUnique; + this.firePropertyChanged(UNIQUE_PROPERTY, old, astUnique); } private Boolean buildUnique(CompilationUnit astRoot) { @@ -151,13 +157,16 @@ public abstract class SourceBaseColumnAnnotation } public void setNullable(Boolean nullable) { - if (this.attributeValueHasNotChanged(this.nullable, nullable)) { - return; + if (this.attributeValueHasChanged(this.nullable, nullable)) { + this.nullable = nullable; + this.nullableAdapter.setValue(nullable); } + } + + private void syncNullable(Boolean astNullable) { Boolean old = this.nullable; - this.nullable = nullable; - this.nullableAdapter.setValue(nullable); - this.firePropertyChanged(NULLABLE_PROPERTY, old, nullable); + this.nullable = astNullable; + this.firePropertyChanged(NULLABLE_PROPERTY, old, astNullable); } private Boolean buildNullable(CompilationUnit astRoot) { @@ -176,13 +185,16 @@ public abstract class SourceBaseColumnAnnotation } public void setInsertable(Boolean insertable) { - if (this.attributeValueHasNotChanged(this.insertable, insertable)) { - return; + if (this.attributeValueHasChanged(this.insertable, insertable)) { + this.insertable = insertable; + this.insertableAdapter.setValue(insertable); } + } + + private void syncInsertable(Boolean astInsertable) { Boolean old = this.insertable; - this.insertable = insertable; - this.insertableAdapter.setValue(insertable); - this.firePropertyChanged(INSERTABLE_PROPERTY, old, insertable); + this.insertable = astInsertable; + this.firePropertyChanged(INSERTABLE_PROPERTY, old, astInsertable); } private Boolean buildInsertable(CompilationUnit astRoot) { @@ -201,13 +213,16 @@ public abstract class SourceBaseColumnAnnotation } public void setUpdatable(Boolean updatable) { - if (this.attributeValueHasNotChanged(this.updatable, updatable)) { - return; + if (this.attributeValueHasChanged(this.updatable, updatable)) { + this.updatable = updatable; + this.updatableAdapter.setValue(updatable); } + } + + private void syncUpdatable(Boolean astUpdatable) { Boolean old = this.updatable; - this.updatable = updatable; - this.updatableAdapter.setValue(updatable); - this.firePropertyChanged(UPDATABLE_PROPERTY, old, updatable); + this.updatable = astUpdatable; + this.firePropertyChanged(UPDATABLE_PROPERTY, old, astUpdatable); } private Boolean buildUpdatable(CompilationUnit astRoot) { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceBaseEnumeratedAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceBaseEnumeratedAnnotation.java index 9f3360aa86..cd14ba5636 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceBaseEnumeratedAnnotation.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceBaseEnumeratedAnnotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -11,7 +11,7 @@ package org.eclipse.jpt.core.internal.resource.java.source; import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jpt.core.internal.utility.jdt.EnumDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter; +import org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationElementAdapter; import org.eclipse.jpt.core.resource.java.EnumType; import org.eclipse.jpt.core.resource.java.EnumeratedAnnotation; import org.eclipse.jpt.core.resource.java.JavaResourceNode; @@ -37,15 +37,15 @@ public abstract class SourceBaseEnumeratedAnnotation protected SourceBaseEnumeratedAnnotation(JavaResourceNode parent, Attribute attribute, DeclarationAnnotationAdapter daa) { super(parent, attribute, daa); this.valueDeclarationAdapter = new EnumDeclarationAnnotationElementAdapter(daa, getValueElementName(), false); - this.valueAdapter = new ShortCircuitAnnotationElementAdapter<String>(attribute, this.valueDeclarationAdapter); + this.valueAdapter = new MemberAnnotationElementAdapter<String>(attribute, this.valueDeclarationAdapter); } public void initialize(CompilationUnit astRoot) { this.value = this.buildValue(astRoot); } - public void update(CompilationUnit astRoot) { - this.setValue(this.buildValue(astRoot)); + public void synchronizeWith(CompilationUnit astRoot) { + this.syncValue(this.buildValue(astRoot)); } @Override @@ -62,13 +62,16 @@ public abstract class SourceBaseEnumeratedAnnotation } public void setValue(EnumType value) { - if (this.attributeValueHasNotChanged(this.value, value)) { - return; + if (this.attributeValueHasChanged(this.value, value)) { + this.value = value; + this.valueAdapter.setValue(EnumType.toJavaAnnotationValue(value)); } + } + + private void syncValue(EnumType astValue) { EnumType old = this.value; - this.value = value; - this.valueAdapter.setValue(EnumType.toJavaAnnotationValue(value)); - this.firePropertyChanged(VALUE_PROPERTY, old, value); + this.value = astValue; + this.firePropertyChanged(VALUE_PROPERTY, old, astValue); } private EnumType buildValue(CompilationUnit astRoot) { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceBaseJoinColumnAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceBaseJoinColumnAnnotation.java index 7b8552030d..63e1dc52b4 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceBaseJoinColumnAnnotation.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceBaseJoinColumnAnnotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -58,9 +58,9 @@ public abstract class SourceBaseJoinColumnAnnotation } @Override - public void update(CompilationUnit astRoot) { - super.update(astRoot); - this.setReferencedColumnName(this.buildReferencedColumnName(astRoot)); + public void synchronizeWith(CompilationUnit astRoot) { + super.synchronizeWith(astRoot); + this.syncReferencedColumnName(this.buildReferencedColumnName(astRoot)); } protected abstract String getReferencedColumnNameElementName(); @@ -74,13 +74,16 @@ public abstract class SourceBaseJoinColumnAnnotation } public void setReferencedColumnName(String referencedColumnName) { - if (this.attributeValueHasNotChanged(this.referencedColumnName, referencedColumnName)) { - return; + if (this.attributeValueHasChanged(this.referencedColumnName, referencedColumnName)) { + this.referencedColumnName = referencedColumnName; + this.referencedColumnNameAdapter.setValue(referencedColumnName); } + } + + private void syncReferencedColumnName(String astReferencedColumnName) { String old = this.referencedColumnName; - this.referencedColumnName = referencedColumnName; - this.referencedColumnNameAdapter.setValue(referencedColumnName); - this.firePropertyChanged(REFERENCED_COLUMN_NAME_PROPERTY, old, referencedColumnName); + this.referencedColumnName = astReferencedColumnName; + this.firePropertyChanged(REFERENCED_COLUMN_NAME_PROPERTY, old, astReferencedColumnName); } private String buildReferencedColumnName(CompilationUnit astRoot) { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceBaseNamedQueryAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceBaseNamedQueryAnnotation.java index 530bcbcfe6..af425a45db 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceBaseNamedQueryAnnotation.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceBaseNamedQueryAnnotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -15,7 +15,7 @@ import java.util.Vector; import org.eclipse.jdt.core.dom.Annotation; import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter; +import org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationElementAdapter; import org.eclipse.jpt.core.resource.java.AnnotationContainer; import org.eclipse.jpt.core.resource.java.BaseNamedQueryAnnotation; import org.eclipse.jpt.core.resource.java.JavaResourceNode; @@ -67,17 +67,17 @@ abstract class SourceBaseNamedQueryAnnotation AnnotationContainerTools.initialize(this.hintsContainer, astRoot); } - public void update(CompilationUnit astRoot) { - this.setName(this.buildName(astRoot)); - this.setQuery(this.buildQuery(astRoot)); - AnnotationContainerTools.update(this.hintsContainer, astRoot); + public void synchronizeWith(CompilationUnit astRoot) { + this.syncName(this.buildName(astRoot)); + this.syncQuery(this.buildQuery(astRoot)); + AnnotationContainerTools.synchronize(this.hintsContainer, astRoot); } /** * convenience method */ protected AnnotationElementAdapter<String> buildAdapter(DeclarationAnnotationElementAdapter<String> daea) { - return new ShortCircuitAnnotationElementAdapter<String>(this.member, daea); + return new MemberAnnotationElementAdapter<String>(this.member, daea); } @Override @@ -94,13 +94,16 @@ abstract class SourceBaseNamedQueryAnnotation } public void setName(String name) { - if (this.attributeValueHasNotChanged(this.name, name)) { - return; + if (this.attributeValueHasChanged(this.name, name)) { + this.name = name; + this.nameAdapter.setValue(name); } + } + + private void syncName(String astName) { String old = this.name; - this.name = name; - this.nameAdapter.setValue(name); - this.firePropertyChanged(NAME_PROPERTY, old, name); + this.name = astName; + this.firePropertyChanged(NAME_PROPERTY, old, astName); } private String buildName(CompilationUnit astRoot) { @@ -123,13 +126,16 @@ abstract class SourceBaseNamedQueryAnnotation } public void setQuery(String query) { - if (this.attributeValueHasNotChanged(this.query, query)) { - return; + if (this.attributeValueHasChanged(this.query, query)) { + this.query = query; + this.queryAdapter.setValue(query); } + } + + private void syncQuery(String annotationQuery) { String old = this.query; - this.query = query; - this.queryAdapter.setValue(query); - this.firePropertyChanged(QUERY_PROPERTY, old, query); + this.query = annotationQuery; + this.firePropertyChanged(QUERY_PROPERTY, old, annotationQuery); } private String buildQuery(CompilationUnit astRoot) { @@ -251,8 +257,8 @@ abstract class SourceBaseNamedQueryAnnotation return SourceBaseNamedQueryAnnotation.this.getAnnotationName(); } - public Annotation getContainerJdtAnnotation(CompilationUnit astRoot) { - return SourceBaseNamedQueryAnnotation.this.getJdtAnnotation(astRoot); + public Annotation getContainerAstAnnotation(CompilationUnit astRoot) { + return SourceBaseNamedQueryAnnotation.this.getAstAnnotation(astRoot); } public String getElementName() { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceBaseTableAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceBaseTableAnnotation.java index bb3513ad99..c64738a83c 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceBaseTableAnnotation.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceBaseTableAnnotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -15,8 +15,8 @@ import java.util.Vector; import org.eclipse.jdt.core.dom.Annotation; import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationAdapter; +import org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationElementAdapter; import org.eclipse.jpt.core.internal.utility.jdt.NestedIndexedDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter; import org.eclipse.jpt.core.resource.java.AnnotationContainer; import org.eclipse.jpt.core.resource.java.BaseTableAnnotation; import org.eclipse.jpt.core.resource.java.JPA; @@ -76,7 +76,7 @@ public abstract class SourceBaseTableAnnotation } private AnnotationElementAdapter<String> buildAnnotationElementAdapter(DeclarationAnnotationElementAdapter<String> daea) { - return new ShortCircuitAnnotationElementAdapter<String>(this.member, daea); + return new MemberAnnotationElementAdapter<String>(this.member, daea); } public void initialize(CompilationUnit astRoot) { @@ -86,11 +86,11 @@ public abstract class SourceBaseTableAnnotation AnnotationContainerTools.initialize(this.uniqueConstraintsContainer, astRoot); } - public void update(CompilationUnit astRoot) { - this.setName(this.buildName(astRoot)); - this.setSchema(this.buildSchema(astRoot)); - this.setCatalog(this.buildCatalog(astRoot)); - AnnotationContainerTools.update(this.uniqueConstraintsContainer, astRoot); + public void synchronizeWith(CompilationUnit astRoot) { + this.syncName(this.buildName(astRoot)); + this.syncSchema(this.buildSchema(astRoot)); + this.syncCatalog(this.buildCatalog(astRoot)); + AnnotationContainerTools.synchronize(this.uniqueConstraintsContainer, astRoot); } /** @@ -116,13 +116,16 @@ public abstract class SourceBaseTableAnnotation } public void setName(String name) { - if (this.attributeValueHasNotChanged(this.name, name)) { - return; + if (this.attributeValueHasChanged(this.name, name)) { + this.name = name; + this.nameAdapter.setValue(name); } + } + + private void syncName(String astName) { String old = this.name; - this.name = name; - this.nameAdapter.setValue(name); - this.firePropertyChanged(NAME_PROPERTY, old, name); + this.name = astName; + this.firePropertyChanged(NAME_PROPERTY, old, astName); } private String buildName(CompilationUnit astRoot) { @@ -148,13 +151,16 @@ public abstract class SourceBaseTableAnnotation } public void setSchema(String schema) { - if (this.attributeValueHasNotChanged(this.schema, schema)) { - return; + if (this.attributeValueHasChanged(this.schema, schema)) { + this.schema = schema; + this.schemaAdapter.setValue(schema); } + } + + private void syncSchema(String astSchema) { String old = this.schema; - this.schema = schema; - this.schemaAdapter.setValue(schema); - this.firePropertyChanged(SCHEMA_PROPERTY, old, schema); + this.schema = astSchema; + this.firePropertyChanged(SCHEMA_PROPERTY, old, astSchema); } private String buildSchema(CompilationUnit astRoot) { @@ -180,13 +186,16 @@ public abstract class SourceBaseTableAnnotation } public void setCatalog(String catalog) { - if (this.attributeValueHasNotChanged(this.catalog, catalog)) { - return; + if (this.attributeValueHasChanged(this.catalog, catalog)) { + this.catalog = catalog; + this.catalogAdapter.setValue(catalog); } + } + + private void syncCatalog(String astCatalog) { String old = this.catalog; - this.catalog = catalog; - this.catalogAdapter.setValue(catalog); - this.firePropertyChanged(CATALOG_PROPERTY, old, catalog); + this.catalog = astCatalog; + this.firePropertyChanged(CATALOG_PROPERTY, old, astCatalog); } private String buildCatalog(CompilationUnit astRoot) { @@ -299,8 +308,8 @@ public abstract class SourceBaseTableAnnotation return SourceBaseTableAnnotation.this.getAnnotationName(); } - public Annotation getContainerJdtAnnotation(CompilationUnit astRoot) { - return SourceBaseTableAnnotation.this.getJdtAnnotation(astRoot); + public Annotation getContainerAstAnnotation(CompilationUnit astRoot) { + return SourceBaseTableAnnotation.this.getAstAnnotation(astRoot); } public String getElementName() { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceBaseTemporalAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceBaseTemporalAnnotation.java index a30b7cbe15..4845d65307 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceBaseTemporalAnnotation.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceBaseTemporalAnnotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -11,7 +11,7 @@ package org.eclipse.jpt.core.internal.resource.java.source; import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jpt.core.internal.utility.jdt.EnumDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter; +import org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationElementAdapter; import org.eclipse.jpt.core.resource.java.JavaResourceNode; import org.eclipse.jpt.core.resource.java.TemporalAnnotation; import org.eclipse.jpt.core.resource.java.TemporalType; @@ -38,15 +38,15 @@ public abstract class SourceBaseTemporalAnnotation protected SourceBaseTemporalAnnotation(JavaResourceNode parent, Attribute attribute, DeclarationAnnotationAdapter daa) { super(parent, attribute, daa); this.valueDeclarationAdapter = new EnumDeclarationAnnotationElementAdapter(daa, getValueElementName()); - this.valueAdapter = new ShortCircuitAnnotationElementAdapter<String>(attribute, this.valueDeclarationAdapter); + this.valueAdapter = new MemberAnnotationElementAdapter<String>(attribute, this.valueDeclarationAdapter); } public void initialize(CompilationUnit astRoot) { this.value = this.buildValue(astRoot); } - public void update(CompilationUnit astRoot) { - this.setValue(this.buildValue(astRoot)); + public void synchronizeWith(CompilationUnit astRoot) { + this.syncValue(this.buildValue(astRoot)); } @Override @@ -63,13 +63,16 @@ public abstract class SourceBaseTemporalAnnotation } public void setValue(TemporalType value) { - if (this.attributeValueHasNotChanged(this.value, value)) { - return; + if (this.attributeValueHasChanged(this.value, value)) { + this.value = value; + this.valueAdapter.setValue(TemporalType.toJavaAnnotationValue(value)); } + } + + private void syncValue(TemporalType astValue) { TemporalType old = this.value; - this.value = value; - this.valueAdapter.setValue(TemporalType.toJavaAnnotationValue(value)); - this.firePropertyChanged(VALUE_PROPERTY, old, value); + this.value = astValue; + this.firePropertyChanged(VALUE_PROPERTY, old, astValue); } private TemporalType buildValue(CompilationUnit astRoot) { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceBasicAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceBasicAnnotation.java index c9d4466863..fe6151673c 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceBasicAnnotation.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceBasicAnnotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -13,7 +13,7 @@ import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jpt.core.internal.utility.jdt.BooleanExpressionConverter; import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; import org.eclipse.jpt.core.internal.utility.jdt.EnumDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter; +import org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationElementAdapter; import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; import org.eclipse.jpt.core.resource.java.BasicAnnotation; import org.eclipse.jpt.core.resource.java.FetchType; @@ -45,8 +45,8 @@ public final class SourceBasicAnnotation public SourceBasicAnnotation(JavaResourcePersistentAttribute parent, Attribute attribute) { super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); - this.optionalAdapter = new ShortCircuitAnnotationElementAdapter<Boolean>(attribute, OPTIONAL_ADAPTER); - this.fetchAdapter = new ShortCircuitAnnotationElementAdapter<String>(attribute, FETCH_ADAPTER); + this.optionalAdapter = new MemberAnnotationElementAdapter<Boolean>(attribute, OPTIONAL_ADAPTER); + this.fetchAdapter = new MemberAnnotationElementAdapter<String>(attribute, FETCH_ADAPTER); } public String getAnnotationName() { @@ -58,9 +58,9 @@ public final class SourceBasicAnnotation this.fetch = this.buildFetch(astRoot); } - public void update(CompilationUnit astRoot) { - this.setOptional(this.buildOptional(astRoot)); - this.setFetch(this.buildFetch(astRoot)); + public void synchronizeWith(CompilationUnit astRoot) { + this.syncOptional(this.buildOptional(astRoot)); + this.syncFetch(this.buildFetch(astRoot)); } @Override @@ -77,16 +77,19 @@ public final class SourceBasicAnnotation } public void setOptional(Boolean optional) { - if (this.attributeValueHasNotChanged(this.optional, optional)) { - return; + if (this.attributeValueHasChanged(this.optional, optional)) { + this.optional = optional; + this.optionalAdapter.setValue(optional); } + } + + private void syncOptional(Boolean astOptional) { Boolean old = this.optional; - this.optional = optional; - this.optionalAdapter.setValue(optional); - this.firePropertyChanged(OPTIONAL_PROPERTY, old, optional); + this.optional = astOptional; + this.firePropertyChanged(OPTIONAL_PROPERTY, old, astOptional); } - protected Boolean buildOptional(CompilationUnit astRoot) { + private Boolean buildOptional(CompilationUnit astRoot) { return this.optionalAdapter.getValue(astRoot); } @@ -100,16 +103,19 @@ public final class SourceBasicAnnotation } public void setFetch(FetchType fetch) { - if (this.attributeValueHasNotChanged(this.fetch, fetch)) { - return; + if (this.attributeValueHasChanged(this.fetch, fetch)) { + this.fetch = fetch; + this.fetchAdapter.setValue(FetchType.toJavaAnnotationValue(fetch)); } + } + + private void syncFetch(FetchType astFetch) { FetchType old = this.fetch; - this.fetch = fetch; - this.fetchAdapter.setValue(FetchType.toJavaAnnotationValue(fetch)); - this.firePropertyChanged(FETCH_PROPERTY, old, fetch); + this.fetch = astFetch; + this.firePropertyChanged(FETCH_PROPERTY, old, astFetch); } - protected FetchType buildFetch(CompilationUnit astRoot) { + private FetchType buildFetch(CompilationUnit astRoot) { return FetchType.fromJavaAnnotationValue(this.fetchAdapter.getValue(astRoot)); } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceCompilationUnit.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceCompilationUnit.java index 38cc87c241..4905198e18 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceCompilationUnit.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceCompilationUnit.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -60,7 +60,7 @@ public final class SourceCompilationUnit * the constructor in a package class (which is what all top-level, * non-primary classes must be). */ - protected JavaResourcePersistentType persistentType; + private JavaResourcePersistentType persistentType; // ********** construction ********** @@ -79,14 +79,18 @@ public final class SourceCompilationUnit this.persistentType = this.buildPersistentType(); } - protected JavaResourcePersistentType buildPersistentType() { + public void initialize(CompilationUnit astRoot) { + // never called? + } + + private JavaResourcePersistentType buildPersistentType() { this.openCompilationUnit(); CompilationUnit astRoot = this.buildASTRoot(); this.closeCompilationUnit(); return this.buildPersistentType(astRoot); } - protected void openCompilationUnit() { + private void openCompilationUnit() { try { this.compilationUnit.open(null); } catch (JavaModelException ex) { @@ -94,7 +98,7 @@ public final class SourceCompilationUnit } } - protected void closeCompilationUnit() { + private void closeCompilationUnit() { try { this.compilationUnit.close(); } catch (JavaModelException ex) { @@ -102,30 +106,14 @@ public final class SourceCompilationUnit } } - protected JavaResourcePersistentType buildPersistentType(CompilationUnit astRoot) { - TypeDeclaration td = this.getPrimaryType(astRoot); - return (td == null) ? null : this.buildPersistentType(astRoot, td); - } - - private void setPersistentType(JavaResourcePersistentType newPersistentType) { - JavaResourcePersistentType old = this.persistentType; - this.persistentType = newPersistentType; - this.firePropertyChanged(PERSISTENT_TYPES_COLLECTION, old, newPersistentType); - } + // ********** AbstractJavaResourceNode overrides ********** @Override protected boolean requiresParent() { return false; } - public void initialize(CompilationUnit astRoot) { - // never called? - } - - - // ********** AbstractJavaResourceNode overrides ********** - @Override public JavaResourceCompilationUnit getRoot() { return this; @@ -144,17 +132,8 @@ public final class SourceCompilationUnit // ********** JavaResourceNode implementation ********** - public void update(CompilationUnit astRoot) { - TypeDeclaration td = this.getPrimaryType(astRoot); - if (td == null) { - this.setPersistentType(null); - } else { - if (this.persistentType == null) { - this.setPersistentType(this.buildPersistentType(astRoot, td)); - } else { - this.persistentType.update(astRoot); - } - } + public void synchronizeWith(CompilationUnit astRoot) { + this.syncPersistentType(astRoot); } public TextRange getTextRange(CompilationUnit astRoot) { @@ -175,7 +154,7 @@ public final class SourceCompilationUnit public void resourceModelChanged() { for (JpaResourceModelListener listener : this.resourceModelListenerList.getListeners()) { - listener.resourceModelChanged(); + listener.resourceModelChanged(this); } } @@ -205,6 +184,34 @@ public final class SourceCompilationUnit } + // ********** persistent type ********** + + private JavaResourcePersistentType buildPersistentType(CompilationUnit astRoot) { + TypeDeclaration td = this.getPrimaryTypeDeclaration(astRoot); + return (td == null) ? null : this.buildPersistentType(astRoot, td); + } + + + private void syncPersistentType(CompilationUnit astRoot) { + TypeDeclaration td = this.getPrimaryTypeDeclaration(astRoot); + if (td == null) { + this.syncPersistentType_(null); + } else { + if (this.persistentType == null) { + this.syncPersistentType_(this.buildPersistentType(astRoot, td)); + } else { + this.persistentType.synchronizeWith(astRoot); + } + } + } + + private void syncPersistentType_(JavaResourcePersistentType astPersistentType) { + JavaResourcePersistentType old = this.persistentType; + this.persistentType = astPersistentType; + this.firePropertyChanged(PERSISTENT_TYPES_COLLECTION, old, astPersistentType); + } + + // ********** JpaResourceModel implementation ********** public JpaResourceType getResourceType() { @@ -222,14 +229,14 @@ public final class SourceCompilationUnit // ********** Java changes ********** - public void update() { - this.update(this.buildASTRoot()); + public void synchronizeWithJavaSource() { + this.synchronizeWith(this.buildASTRoot()); } // ********** internal ********** - protected JavaResourcePersistentType buildPersistentType(CompilationUnit astRoot, TypeDeclaration typeDeclaration) { + private JavaResourcePersistentType buildPersistentType(CompilationUnit astRoot, TypeDeclaration typeDeclaration) { return SourcePersistentType.newInstance(this, typeDeclaration, astRoot); } @@ -243,31 +250,35 @@ public final class SourceCompilationUnit * Return null if the parser did not resolve the type declaration's binding. * This can occur if the project JRE is removed (bug 225332). */ - protected TypeDeclaration getPrimaryType(CompilationUnit astRoot) { + private TypeDeclaration getPrimaryTypeDeclaration(CompilationUnit astRoot) { String primaryTypeName = this.getPrimaryTypeName(); - for (AbstractTypeDeclaration atd : types(astRoot)) { - if ((atd.getNodeType() == ASTNode.TYPE_DECLARATION) - && atd.getName().getFullyQualifiedName().equals(primaryTypeName)) { + for (AbstractTypeDeclaration atd : this.types(astRoot)) { + if (this.nodeIsPrimaryTypeDeclaration(atd, primaryTypeName)) { return (atd.resolveBinding() == null) ? null : (TypeDeclaration) atd; } } return null; } + private boolean nodeIsPrimaryTypeDeclaration(AbstractTypeDeclaration atd, String primaryTypeName) { + return (atd.getNodeType() == ASTNode.TYPE_DECLARATION) && + atd.getName().getFullyQualifiedName().equals(primaryTypeName); + } + // minimize scope of suppressed warnings @SuppressWarnings("unchecked") - protected static List<AbstractTypeDeclaration> types(CompilationUnit astRoot) { + private List<AbstractTypeDeclaration> types(CompilationUnit astRoot) { return astRoot.types(); } /** * i.e. the name of the compilation unit */ - protected String getPrimaryTypeName() { - return removeJavaExtension(this.compilationUnit.getElementName()); + private String getPrimaryTypeName() { + return this.removeJavaExtension(this.compilationUnit.getElementName()); } - protected static String removeJavaExtension(String fileName) { + private String removeJavaExtension(String fileName) { int index = fileName.lastIndexOf(".java"); //$NON-NLS-1$ return (index == -1) ? fileName : fileName.substring(0, index); } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceCompleteColumnAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceCompleteColumnAnnotation.java index 7a3e94f5a8..766c351580 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceCompleteColumnAnnotation.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceCompleteColumnAnnotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -59,11 +59,11 @@ public abstract class SourceCompleteColumnAnnotation } @Override - public void update(CompilationUnit astRoot) { - super.update(astRoot); - this.setLength(this.buildLength(astRoot)); - this.setPrecision(this.buildPrecision(astRoot)); - this.setScale(this.buildScale(astRoot)); + public void synchronizeWith(CompilationUnit astRoot) { + super.synchronizeWith(astRoot); + this.syncLength(this.buildLength(astRoot)); + this.syncPrecision(this.buildPrecision(astRoot)); + this.syncScale(this.buildScale(astRoot)); } @@ -75,13 +75,16 @@ public abstract class SourceCompleteColumnAnnotation } public void setLength(Integer length) { - if (this.attributeValueHasNotChanged(this.length, length)) { - return; + if (this.attributeValueHasChanged(this.length, length)) { + this.length = length; + this.lengthAdapter.setValue(length); } + } + + private void syncLength(Integer astLength) { Integer old = this.length; - this.length = length; - this.lengthAdapter.setValue(length); - this.firePropertyChanged(LENGTH_PROPERTY, old, length); + this.length = astLength; + this.firePropertyChanged(LENGTH_PROPERTY, old, astLength); } private Integer buildLength(CompilationUnit astRoot) { @@ -100,13 +103,16 @@ public abstract class SourceCompleteColumnAnnotation } public void setPrecision(Integer precision) { - if (this.attributeValueHasNotChanged(this.precision, precision)) { - return; + if (this.attributeValueHasChanged(this.precision, precision)) { + this.precision = precision; + this.precisionAdapter.setValue(precision); } + } + + private void syncPrecision(Integer astPrecision) { Integer old = this.precision; - this.precision = precision; - this.precisionAdapter.setValue(precision); - this.firePropertyChanged(PRECISION_PROPERTY, old, precision); + this.precision = astPrecision; + this.firePropertyChanged(PRECISION_PROPERTY, old, astPrecision); } private Integer buildPrecision(CompilationUnit astRoot) { @@ -125,13 +131,16 @@ public abstract class SourceCompleteColumnAnnotation } public void setScale(Integer scale) { - if (this.attributeValueHasNotChanged(this.scale, scale)) { - return; + if (this.attributeValueHasChanged(this.scale, scale)) { + this.scale = scale; + this.scaleAdapter.setValue(scale); } + } + + private void syncScale(Integer astScale) { Integer old = this.scale; - this.scale = scale; - this.scaleAdapter.setValue(scale); - this.firePropertyChanged(SCALE_PROPERTY, old, scale); + this.scale = astScale; + this.firePropertyChanged(SCALE_PROPERTY, old, astScale); } private Integer buildScale(CompilationUnit astRoot) { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceDiscriminatorColumnAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceDiscriminatorColumnAnnotation.java index e22a024bfc..e600666f3e 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceDiscriminatorColumnAnnotation.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceDiscriminatorColumnAnnotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -11,7 +11,7 @@ package org.eclipse.jpt.core.internal.resource.java.source; import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jpt.core.internal.utility.jdt.EnumDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter; +import org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationElementAdapter; import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; import org.eclipse.jpt.core.resource.java.DiscriminatorColumnAnnotation; import org.eclipse.jpt.core.resource.java.DiscriminatorType; @@ -43,7 +43,7 @@ public final class SourceDiscriminatorColumnAnnotation public SourceDiscriminatorColumnAnnotation(JavaResourcePersistentType parent, Type type) { super(parent, type, DECLARATION_ANNOTATION_ADAPTER); - this.discriminatorTypeAdapter = new ShortCircuitAnnotationElementAdapter<String>(type, DISCRIMINATOR_TYPE_ADAPTER); + this.discriminatorTypeAdapter = new MemberAnnotationElementAdapter<String>(type, DISCRIMINATOR_TYPE_ADAPTER); this.lengthDeclarationAdapter = this.buildIntegerElementAdapter(JPA.DISCRIMINATOR_COLUMN__LENGTH); this.lengthAdapter = this.buildShortCircuitIntegerElementAdapter(this.lengthDeclarationAdapter); } @@ -60,10 +60,10 @@ public final class SourceDiscriminatorColumnAnnotation } @Override - public void update(CompilationUnit astRoot) { - super.update(astRoot); - this.setLength(this.buildLength(astRoot)); - this.setDiscriminatorType(this.buildDiscriminatorType(astRoot)); + public void synchronizeWith(CompilationUnit astRoot) { + super.synchronizeWith(astRoot); + this.syncLength(this.buildLength(astRoot)); + this.syncDiscriminatorType(this.buildDiscriminatorType(astRoot)); } @@ -88,13 +88,16 @@ public final class SourceDiscriminatorColumnAnnotation } public void setDiscriminatorType(DiscriminatorType discriminatorType) { - if (this.attributeValueHasNotChanged(this.discriminatorType, discriminatorType)) { - return; + if (this.attributeValueHasChanged(this.discriminatorType, discriminatorType)) { + this.discriminatorType = discriminatorType; + this.discriminatorTypeAdapter.setValue(DiscriminatorType.toJavaAnnotationValue(discriminatorType)); } + } + + private void syncDiscriminatorType(DiscriminatorType astDiscriminatorType) { DiscriminatorType old = this.discriminatorType; - this.discriminatorType = discriminatorType; - this.discriminatorTypeAdapter.setValue(DiscriminatorType.toJavaAnnotationValue(discriminatorType)); - this.firePropertyChanged(DISCRIMINATOR_TYPE_PROPERTY, old, discriminatorType); + this.discriminatorType = astDiscriminatorType; + this.firePropertyChanged(DISCRIMINATOR_TYPE_PROPERTY, old, astDiscriminatorType); } private DiscriminatorType buildDiscriminatorType(CompilationUnit astRoot) { @@ -107,13 +110,16 @@ public final class SourceDiscriminatorColumnAnnotation } public void setLength(Integer length) { - if (this.attributeValueHasNotChanged(this.length, length)) { - return; + if (this.attributeValueHasChanged(this.length, length)) { + this.length = length; + this.lengthAdapter.setValue(length); } + } + + private void syncLength(Integer astLength) { Integer old = this.length; - this.length = length; - this.lengthAdapter.setValue(length); - this.firePropertyChanged(LENGTH_PROPERTY, old, length); + this.length = astLength; + this.firePropertyChanged(LENGTH_PROPERTY, old, astLength); } private Integer buildLength(CompilationUnit astRoot) { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceDiscriminatorValueAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceDiscriminatorValueAnnotation.java index 9a890f94ee..17f63b8238 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceDiscriminatorValueAnnotation.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceDiscriminatorValueAnnotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -11,7 +11,7 @@ package org.eclipse.jpt.core.internal.resource.java.source; import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter; +import org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationElementAdapter; import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; import org.eclipse.jpt.core.resource.java.DiscriminatorValueAnnotation; import org.eclipse.jpt.core.resource.java.JPA; @@ -38,7 +38,7 @@ public final class SourceDiscriminatorValueAnnotation public SourceDiscriminatorValueAnnotation(JavaResourcePersistentType parent, Type type) { super(parent, type, DECLARATION_ANNOTATION_ADAPTER); - this.valueAdapter = new ShortCircuitAnnotationElementAdapter<String>(type, VALUE_ADAPTER); + this.valueAdapter = new MemberAnnotationElementAdapter<String>(type, VALUE_ADAPTER); } public String getAnnotationName() { @@ -49,8 +49,8 @@ public final class SourceDiscriminatorValueAnnotation this.value = this.buildValue(astRoot); } - public void update(CompilationUnit astRoot) { - this.setValue(this.buildValue(astRoot)); + public void synchronizeWith(CompilationUnit astRoot) { + this.syncValue(this.buildValue(astRoot)); } @Override @@ -67,13 +67,16 @@ public final class SourceDiscriminatorValueAnnotation } public void setValue(String value) { - if (this.attributeValueHasNotChanged(this.value, value)) { - return; + if (this.attributeValueHasChanged(this.value, value)) { + this.value = value; + this.valueAdapter.setValue(value); } + } + + private void syncValue(String astValue) { String old = this.value; - this.value = value; - this.valueAdapter.setValue(value); - this.firePropertyChanged(VALUE_PROPERTY, old, value); + this.value = astValue; + this.firePropertyChanged(VALUE_PROPERTY, old, astValue); } private String buildValue(CompilationUnit astRoot) { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceEmbeddableAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceEmbeddableAnnotation.java index 787e136a18..a336c4466f 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceEmbeddableAnnotation.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceEmbeddableAnnotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -38,7 +38,7 @@ public final class SourceEmbeddableAnnotation // nothing to initialize } - public void update(CompilationUnit astRoot) { + public void synchronizeWith(CompilationUnit astRoot) { // nothing to update } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceEmbeddedAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceEmbeddedAnnotation.java index 723086ad8a..2e29565656 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceEmbeddedAnnotation.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceEmbeddedAnnotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -38,7 +38,7 @@ public final class SourceEmbeddedAnnotation // nothing to initialize } - public void update(CompilationUnit astRoot) { + public void synchronizeWith(CompilationUnit astRoot) { // nothing to update } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceEmbeddedIdAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceEmbeddedIdAnnotation.java index c35382bb7d..17901e5a7b 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceEmbeddedIdAnnotation.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceEmbeddedIdAnnotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -38,7 +38,7 @@ public final class SourceEmbeddedIdAnnotation // nothing to initialize } - public void update(CompilationUnit astRoot) { + public void synchronizeWith(CompilationUnit astRoot) { // nothing to update } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceEntityAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceEntityAnnotation.java index 55662448e9..8aa53f278a 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceEntityAnnotation.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceEntityAnnotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -11,7 +11,7 @@ package org.eclipse.jpt.core.internal.resource.java.source; import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter; +import org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationElementAdapter; import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; import org.eclipse.jpt.core.resource.java.EntityAnnotation; import org.eclipse.jpt.core.resource.java.JPA; @@ -38,7 +38,7 @@ public final class SourceEntityAnnotation public SourceEntityAnnotation(JavaResourcePersistentType parent, Type type) { super(parent, type, DECLARATION_ANNOTATION_ADAPTER); - this.nameAdapter = new ShortCircuitAnnotationElementAdapter<String>(this.member, NAME_ADAPTER); + this.nameAdapter = new MemberAnnotationElementAdapter<String>(this.member, NAME_ADAPTER); } public String getAnnotationName() { @@ -49,8 +49,8 @@ public final class SourceEntityAnnotation this.name = this.buildName(astRoot); } - public void update(CompilationUnit astRoot) { - this.setName(this.buildName(astRoot)); + public void synchronizeWith(CompilationUnit astRoot) { + this.syncName(this.buildName(astRoot)); } @Override @@ -67,13 +67,16 @@ public final class SourceEntityAnnotation } public void setName(String name) { - if (this.attributeValueHasNotChanged(this.name, name)) { - return; + if (this.attributeValueHasChanged(this.name, name)) { + this.name = name; + this.nameAdapter.setValue(name); } + } + + private void syncName(String astName) { String old = this.name; - this.name = name; - this.nameAdapter.setValue(name); - this.firePropertyChanged(NAME_PROPERTY, old, name); + this.name = astName; + this.firePropertyChanged(NAME_PROPERTY, old, astName); } private String buildName(CompilationUnit astRoot) { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceEnumeratedAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceEnumeratedAnnotation.java index c04439818c..031706d84c 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceEnumeratedAnnotation.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceEnumeratedAnnotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceGeneratedValueAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceGeneratedValueAnnotation.java index 3be7bd4040..75b8b9fe5f 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceGeneratedValueAnnotation.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceGeneratedValueAnnotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -12,7 +12,7 @@ package org.eclipse.jpt.core.internal.resource.java.source; import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; import org.eclipse.jpt.core.internal.utility.jdt.EnumDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter; +import org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationElementAdapter; import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; import org.eclipse.jpt.core.resource.java.GeneratedValueAnnotation; import org.eclipse.jpt.core.resource.java.GenerationType; @@ -45,8 +45,8 @@ public final class SourceGeneratedValueAnnotation public SourceGeneratedValueAnnotation(JavaResourcePersistentAttribute parent, Attribute attribute) { super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); - this.strategyAdapter = new ShortCircuitAnnotationElementAdapter<String>(attribute, STRATEGY_ADAPTER); - this.generatorAdapter = new ShortCircuitAnnotationElementAdapter<String>(attribute, GENERATOR_ADAPTER); + this.strategyAdapter = new MemberAnnotationElementAdapter<String>(attribute, STRATEGY_ADAPTER); + this.generatorAdapter = new MemberAnnotationElementAdapter<String>(attribute, GENERATOR_ADAPTER); } public String getAnnotationName() { @@ -58,9 +58,9 @@ public final class SourceGeneratedValueAnnotation this.generator = this.buildGenerator(astRoot); } - public void update(CompilationUnit astRoot) { - this.setStrategy(this.buildStrategy(astRoot)); - this.setGenerator(this.buildGenerator(astRoot)); + public void synchronizeWith(CompilationUnit astRoot) { + this.syncStrategy(this.buildStrategy(astRoot)); + this.syncGenerator(this.buildGenerator(astRoot)); } @Override @@ -77,13 +77,16 @@ public final class SourceGeneratedValueAnnotation } public void setStrategy(GenerationType strategy) { - if (this.attributeValueHasNotChanged(this.strategy, strategy)) { - return; + if (this.attributeValueHasChanged(this.strategy, strategy)) { + this.strategy = strategy; + this.strategyAdapter.setValue(GenerationType.toJavaAnnotationValue(strategy)); } + } + + private void syncStrategy(GenerationType astStrategy) { GenerationType old = this.strategy; - this.strategy = strategy; - this.strategyAdapter.setValue(GenerationType.toJavaAnnotationValue(strategy)); - this.firePropertyChanged(STRATEGY_PROPERTY, old, strategy); + this.strategy = astStrategy; + this.firePropertyChanged(STRATEGY_PROPERTY, old, astStrategy); } private GenerationType buildStrategy(CompilationUnit astRoot) { @@ -100,13 +103,16 @@ public final class SourceGeneratedValueAnnotation } public void setGenerator(String generator) { - if (this.attributeValueHasNotChanged(this.generator, generator)) { - return; + if (this.attributeValueHasChanged(this.generator, generator)) { + this.generator = generator; + this.generatorAdapter.setValue(generator); } + } + + private void syncGenerator(String astGenerator) { String old = this.generator; - this.generator = generator; - this.generatorAdapter.setValue(generator); - this.firePropertyChanged(GENERATOR_PROPERTY, old, generator); + this.generator = astGenerator; + this.firePropertyChanged(GENERATOR_PROPERTY, old, astGenerator); } private String buildGenerator(CompilationUnit astRoot) { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceGeneratorAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceGeneratorAnnotation.java index fd6d68a5ed..7e2d84fe78 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceGeneratorAnnotation.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceGeneratorAnnotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -11,8 +11,8 @@ package org.eclipse.jpt.core.internal.resource.java.source; import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; +import org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationElementAdapter; import org.eclipse.jpt.core.internal.utility.jdt.NumberIntegerExpressionConverter; -import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter; import org.eclipse.jpt.core.resource.java.GeneratorAnnotation; import org.eclipse.jpt.core.resource.java.JavaResourceNode; import org.eclipse.jpt.core.utility.TextRange; @@ -53,11 +53,11 @@ abstract class SourceGeneratorAnnotation } protected AnnotationElementAdapter<String> buildAdapter(DeclarationAnnotationElementAdapter<String> daea) { - return new ShortCircuitAnnotationElementAdapter<String>(this.member, daea); + return new MemberAnnotationElementAdapter<String>(this.member, daea); } protected AnnotationElementAdapter<Integer> buildIntegerAdapter(DeclarationAnnotationElementAdapter<Integer> daea) { - return new ShortCircuitAnnotationElementAdapter<Integer>(this.member, daea); + return new MemberAnnotationElementAdapter<Integer>(this.member, daea); } public void initialize(CompilationUnit astRoot) { @@ -66,10 +66,10 @@ abstract class SourceGeneratorAnnotation this.allocationSize = this.buildAllocationSize(astRoot); } - public void update(CompilationUnit astRoot) { - this.setName(this.buildName(astRoot)); - this.setInitialValue(this.buildInitialValue(astRoot)); - this.setAllocationSize(this.buildAllocationSize(astRoot)); + public void synchronizeWith(CompilationUnit astRoot) { + this.syncName(this.buildName(astRoot)); + this.syncInitialValue(this.buildInitialValue(astRoot)); + this.syncAllocationSize(this.buildAllocationSize(astRoot)); } @Override @@ -86,13 +86,16 @@ abstract class SourceGeneratorAnnotation } public void setName(String name) { - if (this.attributeValueHasNotChanged(this.name, name)) { - return; + if (this.attributeValueHasChanged(this.name, name)) { + this.name = name; + this.nameAdapter.setValue(name); } + } + + private void syncName(String astName) { String old = this.name; - this.name = name; - this.nameAdapter.setValue(name); - this.firePropertyChanged(NAME_PROPERTY, old, name); + this.name = astName; + this.firePropertyChanged(NAME_PROPERTY, old, astName); } private String buildName(CompilationUnit astRoot) { @@ -111,13 +114,16 @@ abstract class SourceGeneratorAnnotation } public void setInitialValue(Integer initialValue) { - if (this.attributeValueHasNotChanged(this.initialValue, initialValue)) { - return; + if (this.attributeValueHasChanged(this.initialValue, initialValue)) { + this.initialValue = initialValue; + this.initialValueAdapter.setValue(initialValue); } + } + + private void syncInitialValue(Integer astIinitialValue) { Integer old = this.initialValue; - this.initialValue = initialValue; - this.initialValueAdapter.setValue(initialValue); - this.firePropertyChanged(INITIAL_VALUE_PROPERTY, old, initialValue); + this.initialValue = astIinitialValue; + this.firePropertyChanged(INITIAL_VALUE_PROPERTY, old, astIinitialValue); } private Integer buildInitialValue(CompilationUnit astRoot) { @@ -136,13 +142,16 @@ abstract class SourceGeneratorAnnotation } public void setAllocationSize(Integer allocationSize) { - if (this.attributeValueHasNotChanged(this.allocationSize, allocationSize)) { - return; + if (this.attributeValueHasChanged(this.allocationSize, allocationSize)) { + this.allocationSize = allocationSize; + this.allocationSizeAdapter.setValue(allocationSize); } + } + + private void syncAllocationSize(Integer astAllocationSize) { Integer old = this.allocationSize; - this.allocationSize = allocationSize; - this.allocationSizeAdapter.setValue(allocationSize); - this.firePropertyChanged(ALLOCATION_SIZE_PROPERTY, old, allocationSize); + this.allocationSize = astAllocationSize; + this.firePropertyChanged(ALLOCATION_SIZE_PROPERTY, old, astAllocationSize); } private Integer buildAllocationSize(CompilationUnit astRoot) { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceIdAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceIdAnnotation.java index 224785258d..63cbbd11d9 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceIdAnnotation.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceIdAnnotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -38,7 +38,7 @@ public final class SourceIdAnnotation // nothing to initialize } - public void update(CompilationUnit astRoot) { + public void synchronizeWith(CompilationUnit astRoot) { // nothing to update } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceIdClassAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceIdClassAnnotation.java index 84842a898d..dc8d773eac 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceIdClassAnnotation.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceIdClassAnnotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -12,7 +12,7 @@ package org.eclipse.jpt.core.internal.resource.java.source; import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; import org.eclipse.jpt.core.internal.utility.jdt.JDTTools; -import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter; +import org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationElementAdapter; import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; import org.eclipse.jpt.core.internal.utility.jdt.SimpleTypeStringExpressionConverter; import org.eclipse.jpt.core.resource.java.IdClassAnnotation; @@ -42,7 +42,7 @@ public final class SourceIdClassAnnotation public SourceIdClassAnnotation(JavaResourcePersistentType parent, Type type) { super(parent, type, DECLARATION_ANNOTATION_ADAPTER); - this.valueAdapter = new ShortCircuitAnnotationElementAdapter<String>(type, VALUE_ADAPTER); + this.valueAdapter = new MemberAnnotationElementAdapter<String>(type, VALUE_ADAPTER); } public String getAnnotationName() { @@ -54,9 +54,9 @@ public final class SourceIdClassAnnotation this.fullyQualifiedClassName = this.buildFullyQualifiedClassName(astRoot); } - public void update(CompilationUnit astRoot) { - this.setValue(this.buildValue(astRoot)); - this.setFullyQualifiedClassName(this.buildFullyQualifiedClassName(astRoot)); + public void synchronizeWith(CompilationUnit astRoot) { + this.syncValue(this.buildValue(astRoot)); + this.syncFullyQualifiedClassName(this.buildFullyQualifiedClassName(astRoot)); } @Override @@ -73,13 +73,16 @@ public final class SourceIdClassAnnotation } public void setValue(String value) { - if (this.attributeValueHasNotChanged(this.value, value)) { - return; + if (this.attributeValueHasChanged(this.value, value)) { + this.value = value; + this.valueAdapter.setValue(value); } + } + + private void syncValue(String astValue) { String old = this.value; - this.value = value; - this.valueAdapter.setValue(value); - this.firePropertyChanged(VALUE_PROPERTY, old, value); + this.value = astValue; + this.firePropertyChanged(VALUE_PROPERTY, old, astValue); } private String buildValue(CompilationUnit astRoot) { @@ -95,10 +98,10 @@ public final class SourceIdClassAnnotation return this.fullyQualifiedClassName; } - private void setFullyQualifiedClassName(String fullyQualifiedClassName) { + private void syncFullyQualifiedClassName(String astFullyQualifiedClassName) { String old = this.fullyQualifiedClassName; - this.fullyQualifiedClassName = fullyQualifiedClassName; - this.firePropertyChanged(FULLY_QUALIFIED_CLASS_NAME_PROPERTY, old, fullyQualifiedClassName); + this.fullyQualifiedClassName = astFullyQualifiedClassName; + this.firePropertyChanged(FULLY_QUALIFIED_CLASS_NAME_PROPERTY, old, astFullyQualifiedClassName); } private String buildFullyQualifiedClassName(CompilationUnit astRoot) { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceInheritanceAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceInheritanceAnnotation.java index 12957ce4b5..e08d9abdd4 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceInheritanceAnnotation.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceInheritanceAnnotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -11,7 +11,7 @@ package org.eclipse.jpt.core.internal.resource.java.source; import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jpt.core.internal.utility.jdt.EnumDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter; +import org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationElementAdapter; import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; import org.eclipse.jpt.core.resource.java.InheritanceAnnotation; import org.eclipse.jpt.core.resource.java.InheritanceType; @@ -39,7 +39,7 @@ public final class SourceInheritanceAnnotation public SourceInheritanceAnnotation(JavaResourcePersistentType parent, Type type) { super(parent, type, DECLARATION_ANNOTATION_ADAPTER); - this.strategyAdapter = new ShortCircuitAnnotationElementAdapter<String>(type, STRATEGY_ADAPTER); + this.strategyAdapter = new MemberAnnotationElementAdapter<String>(type, STRATEGY_ADAPTER); } public String getAnnotationName() { @@ -50,8 +50,8 @@ public final class SourceInheritanceAnnotation this.strategy = this.buildStrategy(astRoot); } - public void update(CompilationUnit astRoot) { - this.setStrategy(this.buildStrategy(astRoot)); + public void synchronizeWith(CompilationUnit astRoot) { + this.syncStrategy(this.buildStrategy(astRoot)); } @Override @@ -68,13 +68,16 @@ public final class SourceInheritanceAnnotation } public void setStrategy(InheritanceType strategy) { - if (this.attributeValueHasNotChanged(this.strategy, strategy)) { - return; + if (this.attributeValueHasChanged(this.strategy, strategy)) { + this.strategy = strategy; + this.strategyAdapter.setValue(InheritanceType.toJavaAnnotationValue(strategy)); } + } + + private void syncStrategy(InheritanceType astStrategy) { InheritanceType old = this.strategy; - this.strategy = strategy; - this.strategyAdapter.setValue(InheritanceType.toJavaAnnotationValue(strategy)); - this.firePropertyChanged(STRATEGY_PROPERTY, old, strategy); + this.strategy = astStrategy; + this.firePropertyChanged(STRATEGY_PROPERTY, old, astStrategy); } private InheritanceType buildStrategy(CompilationUnit astRoot) { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceJoinColumnsAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceJoinColumnsAnnotation.java index 30f633fd88..cfde87e2dd 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceJoinColumnsAnnotation.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceJoinColumnsAnnotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -48,8 +48,8 @@ public final class SourceJoinColumnsAnnotation AnnotationContainerTools.initialize(this, astRoot); } - public void update(CompilationUnit astRoot) { - AnnotationContainerTools.update(this, astRoot); + public void synchronizeWith(CompilationUnit astRoot) { + AnnotationContainerTools.synchronize(this, astRoot); } @Override @@ -64,8 +64,8 @@ public final class SourceJoinColumnsAnnotation return this.getAnnotationName(); } - public org.eclipse.jdt.core.dom.Annotation getContainerJdtAnnotation(CompilationUnit astRoot) { - return this.getJdtAnnotation(astRoot); + public org.eclipse.jdt.core.dom.Annotation getContainerAstAnnotation(CompilationUnit astRoot) { + return this.getAstAnnotation(astRoot); } public String getElementName() { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceJoinTableAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceJoinTableAnnotation.java index 82b56ca468..d24bee01f2 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceJoinTableAnnotation.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceJoinTableAnnotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -35,7 +35,7 @@ import org.eclipse.jpt.utility.internal.iterators.CloneListIterator; /** * javax.persistence.JoinTable */ -public class SourceJoinTableAnnotation +public final class SourceJoinTableAnnotation extends SourceBaseTableAnnotation implements NestableJoinTableAnnotation { @@ -69,10 +69,10 @@ public class SourceJoinTableAnnotation } @Override - public void update(CompilationUnit astRoot) { - super.update(astRoot); - AnnotationContainerTools.update(this.joinColumnsContainer, astRoot); - AnnotationContainerTools.update(this.inverseJoinColumnsContainer, astRoot); + public void synchronizeWith(CompilationUnit astRoot) { + super.synchronizeWith(astRoot); + AnnotationContainerTools.synchronize(this.joinColumnsContainer, astRoot); + AnnotationContainerTools.synchronize(this.inverseJoinColumnsContainer, astRoot); } @@ -276,8 +276,8 @@ public class SourceJoinTableAnnotation return SourceJoinTableAnnotation.this.getAnnotationName(); } - public org.eclipse.jdt.core.dom.Annotation getContainerJdtAnnotation(CompilationUnit astRoot) { - return SourceJoinTableAnnotation.this.getJdtAnnotation(astRoot); + public org.eclipse.jdt.core.dom.Annotation getContainerAstAnnotation(CompilationUnit astRoot) { + return SourceJoinTableAnnotation.this.getAstAnnotation(astRoot); } public String getNestableAnnotationName() { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceLobAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceLobAnnotation.java index 781d9e3e0f..103b3bc40a 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceLobAnnotation.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceLobAnnotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -38,7 +38,7 @@ public final class SourceLobAnnotation // nothing to initialize } - public void update(CompilationUnit astRoot) { + public void synchronizeWith(CompilationUnit astRoot) { // nothing to update } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceManyToManyAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceManyToManyAnnotation.java index 73d8ef8db2..fd81b634d7 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceManyToManyAnnotation.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceManyToManyAnnotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -57,9 +57,9 @@ public final class SourceManyToManyAnnotation } @Override - public void update(CompilationUnit astRoot) { - super.update(astRoot); - this.setMappedBy(this.buildMappedBy(astRoot)); + public void synchronizeWith(CompilationUnit astRoot) { + super.synchronizeWith(astRoot); + this.syncMappedBy(this.buildMappedBy(astRoot)); } @@ -89,13 +89,16 @@ public final class SourceManyToManyAnnotation } public void setMappedBy(String mappedBy) { - if (this.attributeValueHasNotChanged(this.mappedBy, mappedBy)) { - return; + if (this.attributeValueHasChanged(this.mappedBy, mappedBy)) { + this.mappedBy = mappedBy; + this.mappedByAdapter.setValue(mappedBy); } + } + + private void syncMappedBy(String astMappedBy) { String old = this.mappedBy; - this.mappedBy = mappedBy; - this.mappedByAdapter.setValue(mappedBy); - this.firePropertyChanged(MAPPED_BY_PROPERTY, old, mappedBy); + this.mappedBy = astMappedBy; + this.firePropertyChanged(MAPPED_BY_PROPERTY, old, astMappedBy); } private String buildMappedBy(CompilationUnit astRoot) { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceManyToOneAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceManyToOneAnnotation.java index 6883f3d1c6..05384884d0 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceManyToOneAnnotation.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceManyToOneAnnotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -58,9 +58,9 @@ public final class SourceManyToOneAnnotation } @Override - public void update(CompilationUnit astRoot) { - super.update(astRoot); - this.setOptional(this.buildOptional(astRoot)); + public void synchronizeWith(CompilationUnit astRoot) { + super.synchronizeWith(astRoot); + this.syncOptional(this.buildOptional(astRoot)); } @@ -90,13 +90,16 @@ public final class SourceManyToOneAnnotation } public void setOptional(Boolean optional) { - if (this.attributeValueHasNotChanged(this.optional, optional)) { - return; + if (this.attributeValueHasChanged(this.optional, optional)) { + this.optional = optional; + this.optionalAdapter.setValue(optional); } + } + + private void syncOptional(Boolean astOptional) { Boolean old = this.optional; - this.optional = optional; - this.optionalAdapter.setValue(optional); - this.firePropertyChanged(OPTIONAL_PROPERTY, old, optional); + this.optional = astOptional; + this.firePropertyChanged(OPTIONAL_PROPERTY, old, astOptional); } private Boolean buildOptional(CompilationUnit astRoot) { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceMapKeyAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceMapKeyAnnotation.java index c6361ccdbf..24a3087ad8 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceMapKeyAnnotation.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceMapKeyAnnotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -11,7 +11,7 @@ package org.eclipse.jpt.core.internal.resource.java.source; import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter; +import org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationElementAdapter; import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; import org.eclipse.jpt.core.resource.java.JPA; import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; @@ -38,7 +38,7 @@ public final class SourceMapKeyAnnotation public SourceMapKeyAnnotation(JavaResourcePersistentAttribute parent, Attribute attribute) { super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); - this.nameAdapter = new ShortCircuitAnnotationElementAdapter<String>(attribute, NAME_ADAPTER); + this.nameAdapter = new MemberAnnotationElementAdapter<String>(attribute, NAME_ADAPTER); } public String getAnnotationName() { @@ -49,8 +49,8 @@ public final class SourceMapKeyAnnotation this.name = this.buildName(astRoot); } - public void update(CompilationUnit astRoot) { - this.setName(this.buildName(astRoot)); + public void synchronizeWith(CompilationUnit astRoot) { + this.syncName(this.buildName(astRoot)); } @Override @@ -67,13 +67,16 @@ public final class SourceMapKeyAnnotation } public void setName(String name) { - if (this.attributeValueHasNotChanged(this.name, name)) { - return; + if (this.attributeValueHasChanged(this.name, name)) { + this.name = name; + this.nameAdapter.setValue(name); } + } + + private void syncName(String astName) { String old = this.name; - this.name = name; - this.nameAdapter.setValue(name); - this.firePropertyChanged(NAME_PROPERTY, old, name); + this.name = astName; + this.firePropertyChanged(NAME_PROPERTY, old, astName); } private String buildName(CompilationUnit astRoot) { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceMappedSuperclassAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceMappedSuperclassAnnotation.java index 3703e3ab2e..75f8cc48e1 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceMappedSuperclassAnnotation.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceMappedSuperclassAnnotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -38,7 +38,7 @@ public final class SourceMappedSuperclassAnnotation // nothing to initialize } - public void update(CompilationUnit astRoot) { + public void synchronizeWith(CompilationUnit astRoot) { // nothing to update } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedColumnAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedColumnAnnotation.java index 2a8670c14d..b168201eae 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedColumnAnnotation.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedColumnAnnotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -13,8 +13,8 @@ import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jpt.core.internal.utility.jdt.BooleanExpressionConverter; import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; import org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationAdapter; +import org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationElementAdapter; import org.eclipse.jpt.core.internal.utility.jdt.NumberIntegerExpressionConverter; -import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter; import org.eclipse.jpt.core.resource.java.JavaResourceNode; import org.eclipse.jpt.core.resource.java.NamedColumnAnnotation; import org.eclipse.jpt.core.resource.java.NestableAnnotation; @@ -69,15 +69,15 @@ public abstract class SourceNamedColumnAnnotation } AnnotationElementAdapter<String> buildShortCircuitElementAdapter(DeclarationAnnotationElementAdapter<String> daea) { - return new ShortCircuitAnnotationElementAdapter<String>(this.member, daea); + return new MemberAnnotationElementAdapter<String>(this.member, daea); } protected AnnotationElementAdapter<Boolean> buildShortCircuitBooleanElementAdapter(DeclarationAnnotationElementAdapter<Boolean> daea) { - return new ShortCircuitAnnotationElementAdapter<Boolean>(this.member, daea); + return new MemberAnnotationElementAdapter<Boolean>(this.member, daea); } protected AnnotationElementAdapter<Integer> buildShortCircuitIntegerElementAdapter(DeclarationAnnotationElementAdapter<Integer> daea) { - return new ShortCircuitAnnotationElementAdapter<Integer>(this.member, daea); + return new MemberAnnotationElementAdapter<Integer>(this.member, daea); } AnnotationElementAdapter<String> buildShortCircuitStringElementAdapter(String elementName) { @@ -89,9 +89,9 @@ public abstract class SourceNamedColumnAnnotation this.columnDefinition = this.buildColumnDefinition(astRoot); } - public void update(CompilationUnit astRoot) { - this.setName(this.buildName(astRoot)); - this.setColumnDefinition(this.buildColumnDefinition(astRoot)); + public void synchronizeWith(CompilationUnit astRoot) { + this.syncName(this.buildName(astRoot)); + this.syncColumnDefinition(this.buildColumnDefinition(astRoot)); } @Override @@ -112,13 +112,16 @@ public abstract class SourceNamedColumnAnnotation } public void setName(String name) { - if (this.attributeValueHasNotChanged(this.name, name)) { - return; + if (this.attributeValueHasChanged(this.name, name)) { + this.name = name; + this.nameAdapter.setValue(name); } + } + + private void syncName(String astName) { String old = this.name; - this.name = name; - this.nameAdapter.setValue(name); - this.firePropertyChanged(NAME_PROPERTY, old, name); + this.name = astName; + this.firePropertyChanged(NAME_PROPERTY, old, astName); } private String buildName(CompilationUnit astRoot) { @@ -141,13 +144,16 @@ public abstract class SourceNamedColumnAnnotation } public void setColumnDefinition(String columnDefinition) { - if (this.attributeValueHasNotChanged(this.columnDefinition, columnDefinition)) { - return; + if (this.attributeValueHasChanged(this.columnDefinition, columnDefinition)) { + this.columnDefinition = columnDefinition; + this.columnDefinitionAdapter.setValue(columnDefinition); } + } + + private void syncColumnDefinition(String astColumnDefinition) { String old = this.columnDefinition; - this.columnDefinition = columnDefinition; - this.columnDefinitionAdapter.setValue(columnDefinition); - this.firePropertyChanged(COLUMN_DEFINITION_PROPERTY, old, columnDefinition); + this.columnDefinition = astColumnDefinition; + this.firePropertyChanged(COLUMN_DEFINITION_PROPERTY, old, astColumnDefinition); } private String buildColumnDefinition(CompilationUnit astRoot) { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedNativeQueriesAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedNativeQueriesAnnotation.java index 966e3506d3..46f6e73e09 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedNativeQueriesAnnotation.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedNativeQueriesAnnotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -48,8 +48,8 @@ public final class SourceNamedNativeQueriesAnnotation AnnotationContainerTools.initialize(this, astRoot); } - public void update(CompilationUnit astRoot) { - AnnotationContainerTools.update(this, astRoot); + public void synchronizeWith(CompilationUnit astRoot) { + AnnotationContainerTools.synchronize(this, astRoot); } @Override @@ -64,8 +64,8 @@ public final class SourceNamedNativeQueriesAnnotation return this.getAnnotationName(); } - public org.eclipse.jdt.core.dom.Annotation getContainerJdtAnnotation(CompilationUnit astRoot) { - return this.getJdtAnnotation(astRoot); + public org.eclipse.jdt.core.dom.Annotation getContainerAstAnnotation(CompilationUnit astRoot) { + return this.getAstAnnotation(astRoot); } public String getElementName() { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedNativeQueryAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedNativeQueryAnnotation.java index 0c5cadde71..c8f64f776e 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedNativeQueryAnnotation.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedNativeQueryAnnotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -73,11 +73,11 @@ public final class SourceNamedNativeQueryAnnotation } @Override - public void update(CompilationUnit astRoot) { - super.update(astRoot); - this.setResultClass(this.buildResultClass(astRoot)); - this.setFullyQualifiedResultClassName(this.buildFullyQualifiedResultClassName(astRoot)); - this.setResultSetMapping(this.buildResultSetMapping(astRoot)); + public void synchronizeWith(CompilationUnit astRoot) { + super.synchronizeWith(astRoot); + this.syncResultClass(this.buildResultClass(astRoot)); + this.syncFullyQualifiedResultClassName(this.buildFullyQualifiedResultClassName(astRoot)); + this.syncResultSetMapping(this.buildResultSetMapping(astRoot)); } @@ -112,13 +112,16 @@ public final class SourceNamedNativeQueryAnnotation } public void setResultClass(String resultClass) { - if (this.attributeValueHasNotChanged(this.resultClass, resultClass)) { - return; + if (this.attributeValueHasChanged(this.resultClass, resultClass)) { + this.resultClass = resultClass; + this.resultClassAdapter.setValue(resultClass); } + } + + private void syncResultClass(String astResultClass) { String old = this.resultClass; - this.resultClass = resultClass; - this.resultClassAdapter.setValue(resultClass); - this.firePropertyChanged(RESULT_CLASS_PROPERTY, old, resultClass); + this.resultClass = astResultClass; + this.firePropertyChanged(RESULT_CLASS_PROPERTY, old, astResultClass); } private String buildResultClass(CompilationUnit astRoot) { @@ -138,10 +141,10 @@ public final class SourceNamedNativeQueryAnnotation return this.fullyQualifiedResultClassName; } - private void setFullyQualifiedResultClassName(String name) { + private void syncFullyQualifiedResultClassName(String astName) { String old = this.fullyQualifiedResultClassName; - this.fullyQualifiedResultClassName = name; - this.firePropertyChanged(FULLY_QUALIFIED_RESULT_CLASS_NAME_PROPERTY, old, name); + this.fullyQualifiedResultClassName = astName; + this.firePropertyChanged(FULLY_QUALIFIED_RESULT_CLASS_NAME_PROPERTY, old, astName); } private String buildFullyQualifiedResultClassName(CompilationUnit astRoot) { @@ -154,13 +157,16 @@ public final class SourceNamedNativeQueryAnnotation } public void setResultSetMapping(String resultSetMapping) { - if (this.attributeValueHasNotChanged(this.resultSetMapping, resultSetMapping)) { - return; + if (this.attributeValueHasChanged(this.resultSetMapping, resultSetMapping)) { + this.resultSetMapping = resultSetMapping; + this.resultSetMappingAdapter.setValue(resultSetMapping); } + } + + private void syncResultSetMapping(String astResultSetMapping) { String old = this.resultSetMapping; - this.resultSetMapping = resultSetMapping; - this.resultSetMappingAdapter.setValue(resultSetMapping); - this.firePropertyChanged(RESULT_SET_MAPPING_PROPERTY, old, resultSetMapping); + this.resultSetMapping = astResultSetMapping; + this.firePropertyChanged(RESULT_SET_MAPPING_PROPERTY, old, astResultSetMapping); } private String buildResultSetMapping(CompilationUnit astRoot) { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedQueries1_0Annotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedQueries1_0Annotation.java new file mode 100644 index 0000000000..451da89edd --- /dev/null +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedQueries1_0Annotation.java @@ -0,0 +1,30 @@ +/******************************************************************************* + * Copyright (c) 2007, 2010 Oracle. All rights reserved. + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0, which accompanies this distribution + * and is available at http://www.eclipse.org/legal/epl-v10.html. + * + * Contributors: + * Oracle - initial API and implementation + ******************************************************************************/ +package org.eclipse.jpt.core.internal.resource.java.source; + +import org.eclipse.jpt.core.resource.java.JavaResourceNode; +import org.eclipse.jpt.core.resource.java.NestableNamedQueryAnnotation; +import org.eclipse.jpt.core.utility.jdt.Type; + +/** + * javax.persistence.NamedQueries + */ +public final class SourceNamedQueries1_0Annotation + extends SourceNamedQueriesAnnotation +{ + public SourceNamedQueries1_0Annotation(JavaResourceNode parent, Type type) { + super(parent, type); + } + + @Override + protected NestableNamedQueryAnnotation buildNamedQuery(int index) { + return SourceNamedQueryAnnotation.createNestedNamedQuery(this, member, index, this.daa); + } +} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedQueriesAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedQueriesAnnotation.java index 334e628a28..e85dab7769 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedQueriesAnnotation.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedQueriesAnnotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -27,7 +27,7 @@ import org.eclipse.jpt.utility.internal.iterators.CloneListIterator; /** * javax.persistence.NamedQueries */ -public class SourceNamedQueriesAnnotation +public abstract class SourceNamedQueriesAnnotation extends SourceAnnotation<Type> implements NamedQueriesAnnotation { @@ -48,8 +48,8 @@ public class SourceNamedQueriesAnnotation AnnotationContainerTools.initialize(this, astRoot); } - public void update(CompilationUnit astRoot) { - AnnotationContainerTools.update(this, astRoot); + public void synchronizeWith(CompilationUnit astRoot) { + AnnotationContainerTools.synchronize(this, astRoot); } @Override @@ -64,8 +64,8 @@ public class SourceNamedQueriesAnnotation return this.getAnnotationName(); } - public org.eclipse.jdt.core.dom.Annotation getContainerJdtAnnotation(CompilationUnit astRoot) { - return this.getJdtAnnotation(astRoot); + public org.eclipse.jdt.core.dom.Annotation getContainerAstAnnotation(CompilationUnit astRoot) { + return this.getAstAnnotation(astRoot); } public String getElementName() { @@ -90,9 +90,7 @@ public class SourceNamedQueriesAnnotation return namedQuery; } - protected NestableNamedQueryAnnotation buildNamedQuery(int index) { - return SourceNamedQueryAnnotation.createNestedNamedQuery(this, member, index, this.daa); - } + protected abstract NestableNamedQueryAnnotation buildNamedQuery(int index); public void nestedAnnotationAdded(int index, NestableNamedQueryAnnotation nestedAnnotation) { this.fireItemAdded(NAMED_QUERIES_LIST, index, nestedAnnotation); diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceOneToManyAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceOneToManyAnnotation.java index 8e379f9923..2cf406da51 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceOneToManyAnnotation.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceOneToManyAnnotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -57,9 +57,9 @@ public abstract class SourceOneToManyAnnotation } @Override - public void update(CompilationUnit astRoot) { - super.update(astRoot); - this.setMappedBy(this.buildMappedBy(astRoot)); + public void synchronizeWith(CompilationUnit astRoot) { + super.synchronizeWith(astRoot); + this.syncMappedBy(this.buildMappedBy(astRoot)); } @@ -88,13 +88,16 @@ public abstract class SourceOneToManyAnnotation } public void setMappedBy(String mappedBy) { - if (this.attributeValueHasNotChanged(this.mappedBy, mappedBy)) { - return; + if (this.attributeValueHasChanged(this.mappedBy, mappedBy)) { + this.mappedBy = mappedBy; + this.mappedByAdapter.setValue(mappedBy); } + } + + private void syncMappedBy(String astMappedBy) { String old = this.mappedBy; - this.mappedBy = mappedBy; - this.mappedByAdapter.setValue(mappedBy); - this.firePropertyChanged(MAPPED_BY_PROPERTY, old, mappedBy); + this.mappedBy = astMappedBy; + this.firePropertyChanged(MAPPED_BY_PROPERTY, old, astMappedBy); } private String buildMappedBy(CompilationUnit astRoot) { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceOneToOneAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceOneToOneAnnotation.java index cf1d474d64..de71ab77e0 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceOneToOneAnnotation.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceOneToOneAnnotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -64,10 +64,10 @@ public abstract class SourceOneToOneAnnotation } @Override - public void update(CompilationUnit astRoot) { - super.update(astRoot); - this.setMappedBy(this.buildMappedBy(astRoot)); - this.setOptional(this.buildOptional(astRoot)); + public void synchronizeWith(CompilationUnit astRoot) { + super.synchronizeWith(astRoot); + this.syncMappedBy(this.buildMappedBy(astRoot)); + this.syncOptional(this.buildOptional(astRoot)); } @@ -97,13 +97,16 @@ public abstract class SourceOneToOneAnnotation } public void setMappedBy(String mappedBy) { - if (this.attributeValueHasNotChanged(this.mappedBy, mappedBy)) { - return; + if (this.attributeValueHasChanged(this.mappedBy, mappedBy)) { + this.mappedBy = mappedBy; + this.mappedByAdapter.setValue(mappedBy); } + } + + private void syncMappedBy(String astMappedBy) { String old = this.mappedBy; - this.mappedBy = mappedBy; - this.mappedByAdapter.setValue(mappedBy); - this.firePropertyChanged(MAPPED_BY_PROPERTY, old, mappedBy); + this.mappedBy = astMappedBy; + this.firePropertyChanged(MAPPED_BY_PROPERTY, old, astMappedBy); } private String buildMappedBy(CompilationUnit astRoot) { @@ -124,13 +127,16 @@ public abstract class SourceOneToOneAnnotation } public void setOptional(Boolean optional) { - if (this.attributeValueHasNotChanged(this.optional, optional)) { - return; + if (this.attributeValueHasChanged(this.optional, optional)) { + this.optional = optional; + this.optionalAdapter.setValue(optional); } + } + + private void syncOptional(Boolean astOptional) { Boolean old = this.optional; - this.optional = optional; - this.optionalAdapter.setValue(optional); - this.firePropertyChanged(OPTIONAL_PROPERTY, old, optional); + this.optional = astOptional; + this.firePropertyChanged(OPTIONAL_PROPERTY, old, astOptional); } private Boolean buildOptional(CompilationUnit astRoot) { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceOrderByAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceOrderByAnnotation.java index 85a7b0e7cc..08c060a41d 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceOrderByAnnotation.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceOrderByAnnotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -11,7 +11,7 @@ package org.eclipse.jpt.core.internal.resource.java.source; import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter; +import org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationElementAdapter; import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; import org.eclipse.jpt.core.resource.java.JPA; import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; @@ -38,7 +38,7 @@ public final class SourceOrderByAnnotation public SourceOrderByAnnotation(JavaResourcePersistentAttribute parent, Attribute attribute) { super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); - this.valueAdapter = new ShortCircuitAnnotationElementAdapter<String>(attribute, VALUE_ADAPTER); + this.valueAdapter = new MemberAnnotationElementAdapter<String>(attribute, VALUE_ADAPTER); } public String getAnnotationName() { @@ -49,8 +49,8 @@ public final class SourceOrderByAnnotation this.value = this.buildValue(astRoot); } - public void update(CompilationUnit astRoot) { - this.setValue(this.buildValue(astRoot)); + public void synchronizeWith(CompilationUnit astRoot) { + this.syncValue(this.buildValue(astRoot)); } @Override @@ -66,13 +66,16 @@ public final class SourceOrderByAnnotation } public void setValue(String value) { - if (this.attributeValueHasNotChanged(this.value, value)) { - return; + if (this.attributeValueHasChanged(this.value, value)) { + this.value = value; + this.valueAdapter.setValue(value); } + } + + private void syncValue(String astValue) { String old = this.value; - this.value = value; - this.valueAdapter.setValue(value); - this.firePropertyChanged(VALUE_PROPERTY, old, value); + this.value = astValue; + this.firePropertyChanged(VALUE_PROPERTY, old, astValue); } public TextRange getValueTextRange(CompilationUnit astRoot) { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceOverrideAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceOverrideAnnotation.java index 8d0758b647..dbb5b89a7c 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceOverrideAnnotation.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceOverrideAnnotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -11,7 +11,7 @@ package org.eclipse.jpt.core.internal.resource.java.source; import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter; +import org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationElementAdapter; import org.eclipse.jpt.core.resource.java.JavaResourceNode; import org.eclipse.jpt.core.resource.java.NestableAnnotation; import org.eclipse.jpt.core.resource.java.OverrideAnnotation; @@ -42,15 +42,15 @@ abstract class SourceOverrideAnnotation SourceOverrideAnnotation(JavaResourceNode parent, Member member, DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) { super(parent, member, daa, annotationAdapter); this.nameDeclarationAdapter = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, this.getNameElementName(), false); // false = do not remove annotation when empty - this.nameAdapter = new ShortCircuitAnnotationElementAdapter<String>(this.member, this.nameDeclarationAdapter); + this.nameAdapter = new MemberAnnotationElementAdapter<String>(this.member, this.nameDeclarationAdapter); } public void initialize(CompilationUnit astRoot) { this.name = this.buildName(astRoot); } - public void update(CompilationUnit astRoot) { - this.setName(this.buildName(astRoot)); + public void synchronizeWith(CompilationUnit astRoot) { + this.syncName(this.buildName(astRoot)); } @Override @@ -67,13 +67,16 @@ abstract class SourceOverrideAnnotation } public void setName(String name) { - if (this.attributeValueHasNotChanged(this.name, name)) { - return; + if (this.attributeValueHasChanged(this.name, name)) { + this.name = name; + this.nameAdapter.setValue(name); } + } + + private void syncName(String astName) { String old = this.name; - this.name = name; - this.nameAdapter.setValue(name); - this.firePropertyChanged(OverrideAnnotation.NAME_PROPERTY, old, name); + this.name = astName; + this.firePropertyChanged(NAME_PROPERTY, old, astName); } private String buildName(CompilationUnit astRoot) { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourcePersistentAttribute.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourcePersistentAttribute.java index 35b2ce4a73..c864ae94de 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourcePersistentAttribute.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourcePersistentAttribute.java @@ -3,7 +3,7 @@ * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. - * + * * Contributors: * Oracle - initial API and implementation ******************************************************************************/ @@ -125,22 +125,22 @@ final class SourcePersistentAttribute @Override public void resolveTypes(CompilationUnit astRoot) { super.resolveTypes(astRoot); - this.setTypeName(this.buildTypeName(astRoot)); - this.setTypeSuperclassNames(this.buildTypeSuperclassNames(astRoot)); - this.setTypeInterfaceNames(this.buildTypeInterfaceNames(astRoot)); - this.setTypeTypeArgumentNames(this.buildTypeTypeArgumentNames(astRoot)); + this.syncTypeName(this.buildTypeName(astRoot)); + this.syncTypeSuperclassNames(this.buildTypeSuperclassNames(astRoot)); + this.syncTypeInterfaceNames(this.buildTypeInterfaceNames(astRoot)); + this.syncTypeTypeArgumentNames(this.buildTypeTypeArgumentNames(astRoot)); } @Override - public void update(CompilationUnit astRoot) { - super.update(astRoot); - this.setModifiers(this.buildModifiers(astRoot)); - this.setTypeName(this.buildTypeName(astRoot)); - this.setTypeIsInterface(this.buildTypeIsInterface(astRoot)); - this.setTypeIsEnum(this.buildTypeIsEnum(astRoot)); - this.setTypeSuperclassNames(this.buildTypeSuperclassNames(astRoot)); - this.setTypeInterfaceNames(this.buildTypeInterfaceNames(astRoot)); - this.setTypeTypeArgumentNames(this.buildTypeTypeArgumentNames(astRoot)); + public void synchronizeWith(CompilationUnit astRoot) { + super.synchronizeWith(astRoot); + this.syncModifiers(this.buildModifiers(astRoot)); + this.syncTypeName(this.buildTypeName(astRoot)); + this.syncTypeIsInterface(this.buildTypeIsInterface(astRoot)); + this.syncTypeIsEnum(this.buildTypeIsEnum(astRoot)); + this.syncTypeSuperclassNames(this.buildTypeSuperclassNames(astRoot)); + this.syncTypeInterfaceNames(this.buildTypeInterfaceNames(astRoot)); + this.syncTypeTypeArgumentNames(this.buildTypeTypeArgumentNames(astRoot)); } @Override @@ -150,54 +150,54 @@ final class SourcePersistentAttribute // ******** AbstractJavaResourcePersistentMember implementation ******** - + @Override Iterator<String> validAnnotationNames() { return this.getAnnotationProvider().attributeAnnotationNames(); } - + @Override Annotation buildAnnotation(String annotationName) { return this.getAnnotationProvider().buildAttributeAnnotation(this, this.member, annotationName); } - + Annotation buildNullAnnotation_(String annotationName) { return this.getAnnotationProvider().buildNullAttributeAnnotation(this, annotationName); } - + public boolean isFor(MethodSignature signature, int occurrence) { return ((MethodAttribute) this.member).matches(signature, occurrence); } - - + + // ******** JavaResourcePersistentAttribute implementation ******** - + public String getName() { return this.member.getAttributeName(); } - + @Override public Annotation buildNullAnnotation(String annotationName) { return (annotationName == null) ? null : this.buildNullAnnotation_(annotationName); } - + public boolean isField() { return this.member.isField(); } - + public boolean isProperty() { return ! this.isField(); } - + public AccessType getSpecifiedAccess() { Access2_0Annotation accessAnnotation = this.getAccessAnnotation(); return (accessAnnotation == null) ? null : accessAnnotation.getValue(); } - + private Access2_0Annotation getAccessAnnotation() { return (Access2_0Annotation) this.getAnnotation(Access2_0Annotation.ANNOTATION_NAME); } - + public boolean typeIsSubTypeOf(String tn) { if (this.typeName == null) { return false; @@ -206,25 +206,25 @@ final class SourcePersistentAttribute || this.typeInterfaceNames.contains(tn) || this.typeSuperclassNames.contains(tn); } - + public boolean typeIsVariablePrimitive() { return (this.typeName != null) && ClassName.isVariablePrimitive(this.typeName); } - + private ITypeBinding getTypeBinding(CompilationUnit astRoot) { return this.member.getTypeBinding(astRoot); } - - + + // ***** modifiers public int getModifiers() { return this.modifiers; } - private void setModifiers(int modifiers) { + private void syncModifiers(int astModifiers) { int old = this.modifiers; - this.modifiers = modifiers; - this.firePropertyChanged(MODIFIERS_PROPERTY, old, modifiers); + this.modifiers = astModifiers; + this.firePropertyChanged(MODIFIERS_PROPERTY, old, astModifiers); } /** @@ -240,10 +240,10 @@ final class SourcePersistentAttribute return this.typeName; } - private void setTypeName(String typeName) { + private void syncTypeName(String astTypeName) { String old = this.typeName; - this.typeName = typeName; - this.firePropertyChanged(TYPE_NAME_PROPERTY, old, typeName); + this.typeName = astTypeName; + this.firePropertyChanged(TYPE_NAME_PROPERTY, old, astTypeName); } /** @@ -260,10 +260,10 @@ final class SourcePersistentAttribute return this.typeIsInterface; } - private void setTypeIsInterface(boolean typeIsInterface) { + private void syncTypeIsInterface(boolean astTypeIsInterface) { boolean old = this.typeIsInterface; - this.typeIsInterface = typeIsInterface; - this.firePropertyChanged(TYPE_IS_INTERFACE_PROPERTY, old, typeIsInterface); + this.typeIsInterface = astTypeIsInterface; + this.firePropertyChanged(TYPE_IS_INTERFACE_PROPERTY, old, astTypeIsInterface); } private boolean buildTypeIsInterface(CompilationUnit astRoot) { @@ -276,10 +276,10 @@ final class SourcePersistentAttribute return this.typeIsEnum; } - private void setTypeIsEnum(boolean typeIsEnum) { + private void syncTypeIsEnum(boolean astTypeIsEnum) { boolean old = this.typeIsEnum; - this.typeIsEnum = typeIsEnum; - this.firePropertyChanged(TYPE_IS_ENUM_PROPERTY, old, typeIsEnum); + this.typeIsEnum = astTypeIsEnum; + this.firePropertyChanged(TYPE_IS_ENUM_PROPERTY, old, astTypeIsEnum); } private boolean buildTypeIsEnum(CompilationUnit astRoot) { @@ -292,8 +292,8 @@ final class SourcePersistentAttribute return new CloneListIterator<String>(this.typeSuperclassNames); } - private void setTypeSuperclassNames(List<String> typeSuperclassNames) { - this.synchronizeList(typeSuperclassNames, this.typeSuperclassNames, TYPE_SUPERCLASS_NAMES_LIST); + private void syncTypeSuperclassNames(List<String> astTypeSuperclassNames) { + this.synchronizeList(astTypeSuperclassNames, this.typeSuperclassNames, TYPE_SUPERCLASS_NAMES_LIST); } private List<String> buildTypeSuperclassNames(CompilationUnit astRoot) { @@ -319,8 +319,8 @@ final class SourcePersistentAttribute // return this.typeInterfaceNames.contains(interfaceName); // } // - private void setTypeInterfaceNames(Collection<String> typeInterfaceNames) { - this.synchronizeCollection(typeInterfaceNames, this.typeInterfaceNames, TYPE_INTERFACE_NAMES_COLLECTION); + private void syncTypeInterfaceNames(Collection<String> astTypeInterfaceNames) { + this.synchronizeCollection(astTypeInterfaceNames, this.typeInterfaceNames, TYPE_INTERFACE_NAMES_COLLECTION); } private Collection<String> buildTypeInterfaceNames(CompilationUnit astRoot) { @@ -356,8 +356,8 @@ final class SourcePersistentAttribute return this.typeTypeArgumentNames.get(index); } - private void setTypeTypeArgumentNames(List<String> typeTypeArgumentNames) { - this.synchronizeList(typeTypeArgumentNames, this.typeTypeArgumentNames, TYPE_TYPE_ARGUMENT_NAMES_LIST); + private void syncTypeTypeArgumentNames(List<String> astTypeTypeArgumentNames) { + this.synchronizeList(astTypeTypeArgumentNames, this.typeTypeArgumentNames, TYPE_TYPE_ARGUMENT_NAMES_LIST); } /** diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourcePersistentMember.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourcePersistentMember.java index 443539d0f2..ba39efa9a2 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourcePersistentMember.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourcePersistentMember.java @@ -3,7 +3,7 @@ * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. - * + * * Contributors: * Oracle - initial API and implementation ******************************************************************************/ @@ -45,31 +45,31 @@ abstract class SourcePersistentMember<E extends Member> implements JavaResourcePersistentMember { final E member; - + /** * annotations; no duplicates (java compiler has an error for duplicates) */ final Vector<Annotation> annotations = new Vector<Annotation>(); - + boolean persistable; - - + + // ********** construction/initialization ********** - + SourcePersistentMember(JavaResourceNode parent, E member) { super(parent); this.member = member; } - + public void initialize(CompilationUnit astRoot) { this.member.getBodyDeclaration(astRoot).accept(this.buildInitialAnnotationVisitor(astRoot)); this.persistable = this.buildPersistable(astRoot); } - + private ASTVisitor buildInitialAnnotationVisitor(CompilationUnit astRoot) { return new InitialAnnotationVisitor(astRoot, this.member.getBodyDeclaration(astRoot)); } - + /** * called from {@link InitialAnnotationVisitor} */ @@ -92,31 +92,36 @@ abstract class SourcePersistentMember<E extends Member> } } } - - + + public void synchronizeWith(CompilationUnit astRoot) { + this.syncAnnotations(astRoot); + this.syncPersistable(this.buildPersistable(astRoot)); + } + + // ********** annotations ********** - + public Iterator<Annotation> annotations() { return this.getAnnotations().iterator(); } - + Iterable<Annotation> getAnnotations() { return new LiveCloneIterable<Annotation>(this.annotations); } - + public int annotationsSize() { return this.annotations.size(); } - + public Annotation getAnnotation(String annotationName) { return this.selectAnnotationNamed(this.getAnnotations(), annotationName); } - + public Annotation getNonNullAnnotation(String annotationName) { Annotation annotation = this.getAnnotation(annotationName); return (annotation != null) ? annotation : this.buildNullAnnotation(annotationName); } - + public Iterator<NestableAnnotation> annotations(String nestableAnnotationName, String containerAnnotationName) { ContainerAnnotation<NestableAnnotation> containerAnnotation = this.getContainerAnnotation(containerAnnotationName); if (containerAnnotation != null) { @@ -128,35 +133,33 @@ abstract class SourcePersistentMember<E extends Member> } return EmptyIterator.instance(); } - + // minimize scope of suppressed warnings @SuppressWarnings("unchecked") private ContainerAnnotation<NestableAnnotation> getContainerAnnotation(String annotationName) { return (ContainerAnnotation<NestableAnnotation>) this.getAnnotation(annotationName); } - + private NestableAnnotation getNestableAnnotation(String annotationName) { return (NestableAnnotation) this.getAnnotation(annotationName); } - + public Annotation addAnnotation(String annotationName) { Annotation annotation = this.buildAnnotation(annotationName); this.annotations.add(annotation); annotation.newAnnotation(); - this.fireItemAdded(ANNOTATIONS_COLLECTION, annotation); return annotation; } - + public Annotation addAnnotation(String annotationName, AnnotationInitializer annotationInitializer) { Annotation annotation = this.buildAnnotation(annotationName); this.annotations.add(annotation); annotation.newAnnotation(); Annotation nestedAnnotation = annotationInitializer.initializeAnnotation(annotation); nestedAnnotation.newAnnotation(); - this.fireItemAdded(ANNOTATIONS_COLLECTION, annotation); return nestedAnnotation; } - + /** * 1. check for a container annotation; * if it is present, add a nested annotation to it @@ -184,24 +187,18 @@ abstract class SourcePersistentMember<E extends Member> /** * "move" the existing nestable annotation to a new container annotation and * add a new nestable annotation at the specified index (which should be 0 or 1) - * - * NB: we make all the necessary changes to the resource model and the - * Java source code *before* we fire any events; so that everything is in - * place when the context model gets an "update" and looks at the resource - * model to determine what has changed */ private NestableAnnotation addSecondNestedAnnotation(int index, String containerAnnotationName, NestableAnnotation standAloneAnnotation) { ContainerAnnotation<NestableAnnotation> containerAnnotation = this.buildContainerAnnotation(containerAnnotationName); this.annotations.add(containerAnnotation); containerAnnotation.newAnnotation(); - + NestableAnnotation nestedAnnotation0 = containerAnnotation.addNestedAnnotationInternal(); nestedAnnotation0.newAnnotation(); NestableAnnotation nestedAnnotation1 = containerAnnotation.addNestedAnnotationInternal(); nestedAnnotation1.newAnnotation(); this.removeAnnotation(standAloneAnnotation); - this.fireItemAdded(ANNOTATIONS_COLLECTION, containerAnnotation); - + if (index == 0) { // adding new annotation at 0, so stand-alone is "copied" to slot 1 nestedAnnotation1.initializeFrom(standAloneAnnotation); @@ -209,14 +206,14 @@ abstract class SourcePersistentMember<E extends Member> // adding new annotation at 1, so stand-alone is "copied" to slot 0 nestedAnnotation0.initializeFrom(standAloneAnnotation); } - + return (index == 0) ? nestedAnnotation0 : nestedAnnotation1; } - + public void moveAnnotation(int targetIndex, int sourceIndex, String containerAnnotationName) { this.moveAnnotation(targetIndex, sourceIndex, this.getContainerAnnotation(containerAnnotationName)); } - + private void moveAnnotation(int targetIndex, int sourceIndex, ContainerAnnotation<NestableAnnotation> containerAnnotation) { AnnotationContainerTools.moveNestedAnnotation(targetIndex, sourceIndex, containerAnnotation); } @@ -227,13 +224,12 @@ abstract class SourcePersistentMember<E extends Member> this.removeAnnotation(annotation); } } - + private void removeAnnotation(Annotation annotation) { this.annotations.remove(annotation); annotation.removeAnnotation(); - this.fireItemRemoved(ANNOTATIONS_COLLECTION, annotation); } - + public void removeAnnotation(int index, String nestableAnnotationName, String containerAnnotationName) { ContainerAnnotation<NestableAnnotation> containerAnnotation = this.getContainerAnnotation(containerAnnotationName); if (containerAnnotation == null) { // assume the index is 0 @@ -242,7 +238,7 @@ abstract class SourcePersistentMember<E extends Member> this.removeAnnotation(index, containerAnnotation); } } - + /** * after we remove the nested annotation, check to see whether we need to * either remove the container (if it is empty) or convert the last nested @@ -265,25 +261,18 @@ abstract class SourcePersistentMember<E extends Member> /** * convert the last nested annotation in the container to a stand-alone * annotation - * - * NB: we make all the necessary changes to the resource model and the - * Java source code *before* we fire any events; so that everything is in - * place when the context model gets an "update" and looks at the resource - * model to determine what has changed */ private void convertLastNestedAnnotation(ContainerAnnotation<NestableAnnotation> containerAnnotation) { NestableAnnotation lastNestedAnnotation = containerAnnotation.nestedAnnotations().next(); - annotations.remove(containerAnnotation); + this.annotations.remove(containerAnnotation); containerAnnotation.removeAnnotation(); - + NestableAnnotation standAloneAnnotation = this.buildNestableAnnotation(lastNestedAnnotation.getAnnotationName()); this.annotations.add(standAloneAnnotation); standAloneAnnotation.newAnnotation(); - this.fireItemRemoved(ANNOTATIONS_COLLECTION, containerAnnotation); - this.fireItemAdded(ANNOTATIONS_COLLECTION, standAloneAnnotation); standAloneAnnotation.initializeFrom(lastNestedAnnotation); } - + public Annotation setPrimaryAnnotation(String primaryAnnotationName, Iterable<String> supportingAnnotationNames) { ArrayList<String> annotationNames = new ArrayList<String>(); CollectionTools.addAll(annotationNames, supportingAnnotationNames); @@ -306,112 +295,67 @@ abstract class SourcePersistentMember<E extends Member> this.fireCollectionChanged(ANNOTATIONS_COLLECTION, this.annotations); return newPrimaryAnnotation; } - + private boolean annotationIsValid(String annotationName) { return CollectionTools.contains(this.validAnnotationNames(), annotationName); } - + abstract Iterator<String> validAnnotationNames(); - + abstract Annotation buildAnnotation(String mappingAnnotationName); - + abstract Annotation buildNullAnnotation(String annotationName); - + // minimize scope of suppressed warnings @SuppressWarnings("unchecked") private ContainerAnnotation<NestableAnnotation> buildContainerAnnotation(String annotationName) { return (ContainerAnnotation<NestableAnnotation>) this.buildAnnotation(annotationName); } - + private NestableAnnotation buildNestableAnnotation(String annotationName) { return (NestableAnnotation) this.buildAnnotation(annotationName); } - - - // ********** simple state ********** - - public boolean isPersistable() { - return this.persistable; - } - - private void setPersistable(boolean persistable) { - boolean old = this.persistable; - this.persistable = persistable; - this.firePropertyChanged(PERSISTABLE_PROPERTY, old, persistable); - } - - private boolean buildPersistable(CompilationUnit astRoot) { - return this.member.isPersistable(astRoot); - } - - public boolean isAnnotated() { - return ! this.annotations.isEmpty(); - } - - public boolean isFor(String memberName, int occurrence) { - return this.member.matches(memberName, occurrence); - } - - public TextRange getTextRange(CompilationUnit astRoot) { - return this.fullTextRange(astRoot); - } - - private TextRange fullTextRange(CompilationUnit astRoot) { - return this.buildTextRange(this.member.getBodyDeclaration(astRoot)); - } - - public TextRange getNameTextRange(CompilationUnit astRoot) { - return this.member.getNameTextRange(astRoot); - } - - - // ********** update ********** - - public void update(CompilationUnit astRoot) { - this.updateAnnotations(astRoot); - this.setPersistable(this.buildPersistable(astRoot)); - } - - private void updateAnnotations(CompilationUnit astRoot) { + + private void syncAnnotations(CompilationUnit astRoot) { HashSet<Annotation> annotationsToRemove = new HashSet<Annotation>(this.annotations); - - this.member.getBodyDeclaration(astRoot).accept(this.buildUpdateAnnotationVisitor(astRoot, annotationsToRemove)); - + + this.member.getBodyDeclaration(astRoot).accept(this.buildSynchronizeAnnotationVisitor(astRoot, annotationsToRemove)); + for (Annotation annotation : annotationsToRemove) { this.removeItemFromCollection(annotation, this.annotations, ANNOTATIONS_COLLECTION); } } - - private ASTVisitor buildUpdateAnnotationVisitor(CompilationUnit astRoot, Set<Annotation> annotationsToRemove) { - return new UpdateAnnotationVisitor(astRoot, this.member.getBodyDeclaration(astRoot), annotationsToRemove); + + private ASTVisitor buildSynchronizeAnnotationVisitor(CompilationUnit astRoot, Set<Annotation> annotationsToRemove) { + return new SynchronizeAnnotationVisitor(astRoot, this.member.getBodyDeclaration(astRoot), annotationsToRemove); } - + /** - * called from {@link UpdateAnnotationVisitor} + * called from {@link SynchronizeAnnotationVisitor} */ - /* private */ void addOrUpdateAnnotation(org.eclipse.jdt.core.dom.Annotation node, CompilationUnit astRoot, Set<Annotation> annotationsToRemove) { + /* private */ void addOrSyncAnnotation(org.eclipse.jdt.core.dom.Annotation node, CompilationUnit astRoot, Set<Annotation> annotationsToRemove) { String jdtAnnotationName = JDTTools.resolveAnnotation(node); if (jdtAnnotationName != null) { - this.addOrUpdateAnnotation(jdtAnnotationName, astRoot, annotationsToRemove); + this.addOrSyncAnnotation(jdtAnnotationName, astRoot, annotationsToRemove); } } /** * pre-condition: jdtAnnotationName is not null */ - void addOrUpdateAnnotation(String jdtAnnotationName, CompilationUnit astRoot, Set<Annotation> annotationsToRemove) { + void addOrSyncAnnotation(String jdtAnnotationName, CompilationUnit astRoot, Set<Annotation> annotationsToRemove) { if (this.annotationIsValid(jdtAnnotationName)) { - this.addOrUpdateAnnotation_(jdtAnnotationName, astRoot, annotationsToRemove); + this.addOrSyncAnnotation_(jdtAnnotationName, astRoot, annotationsToRemove); } } - + /** * pre-condition: jdtAnnotationName is valid */ - private void addOrUpdateAnnotation_(String jdtAnnotationName, CompilationUnit astRoot, Set<Annotation> annotationsToRemove) { + private void addOrSyncAnnotation_(String jdtAnnotationName, CompilationUnit astRoot, Set<Annotation> annotationsToRemove) { Annotation annotation = this.selectAnnotationNamed(annotationsToRemove, jdtAnnotationName); if (annotation != null) { - annotation.update(astRoot); + annotation.synchronizeWith(astRoot); annotationsToRemove.remove(annotation); } else { annotation = this.buildAnnotation(jdtAnnotationName); @@ -419,14 +363,51 @@ abstract class SourcePersistentMember<E extends Member> this.addItemToCollection(annotation, this.annotations, ANNOTATIONS_COLLECTION); } } - - + + + // ********** persistable ********** + + public boolean isPersistable() { + return this.persistable; + } + + private void syncPersistable(boolean astPersistable) { + boolean old = this.persistable; + this.persistable = astPersistable; + this.firePropertyChanged(PERSISTABLE_PROPERTY, old, astPersistable); + } + + private boolean buildPersistable(CompilationUnit astRoot) { + return this.member.isPersistable(astRoot); + } + + // ********** miscellaneous ********** - + + public boolean isAnnotated() { + return ! this.annotations.isEmpty(); + } + + public boolean isFor(String memberName, int occurrence) { + return this.member.matches(memberName, occurrence); + } + + public TextRange getTextRange(CompilationUnit astRoot) { + return this.fullTextRange(astRoot); + } + + private TextRange fullTextRange(CompilationUnit astRoot) { + return this.buildTextRange(this.member.getBodyDeclaration(astRoot)); + } + + public TextRange getNameTextRange(CompilationUnit astRoot) { + return this.member.getNameTextRange(astRoot); + } + public void resolveTypes(CompilationUnit astRoot) { - this.setPersistable(this.buildPersistable(astRoot)); + this.syncPersistable(this.buildPersistable(astRoot)); } - + private Annotation selectAnnotationNamed(Iterable<Annotation> list, String annotationName) { for (Annotation annotation : list) { if (annotation.getAnnotationName().equals(annotationName)) { @@ -435,11 +416,11 @@ abstract class SourcePersistentMember<E extends Member> } return null; } - + private TextRange buildTextRange(ASTNode astNode) { return (astNode == null) ? null : new ASTNodeTextRange(astNode); } - + /** * convenience method */ @@ -451,40 +432,40 @@ abstract class SourcePersistentMember<E extends Member> } }; } - - + + // ********** AST visitors ********** - + /** * annotation visitor */ - protected static abstract class AnnotationVisitor - extends ASTVisitor + protected static abstract class AnnotationVisitor + extends ASTVisitor { protected final CompilationUnit astRoot; protected final BodyDeclaration bodyDeclaration; - + protected AnnotationVisitor(CompilationUnit astRoot, BodyDeclaration bodyDeclaration) { super(); this.astRoot = astRoot; this.bodyDeclaration = bodyDeclaration; } - + @Override public boolean visit(SingleMemberAnnotation node) { - return visit_(node); + return this.visit_(node); } - + @Override public boolean visit(NormalAnnotation node) { - return visit_(node); + return this.visit_(node); } - + @Override public boolean visit(MarkerAnnotation node) { - return visit_(node); + return this.visit_(node); } - + protected boolean visit_(org.eclipse.jdt.core.dom.Annotation node) { // ignore annotations for child members, only this member if (node.getParent() == this.bodyDeclaration) { @@ -492,44 +473,44 @@ abstract class SourcePersistentMember<E extends Member> } return false; } - + protected abstract void visitChildAnnotation(org.eclipse.jdt.core.dom.Annotation node); } - - + + /** * initial annotation visitor */ - protected class InitialAnnotationVisitor - extends AnnotationVisitor + protected class InitialAnnotationVisitor + extends AnnotationVisitor { protected InitialAnnotationVisitor(CompilationUnit astRoot, BodyDeclaration bodyDeclaration) { super(astRoot, bodyDeclaration); } - + @Override protected void visitChildAnnotation(org.eclipse.jdt.core.dom.Annotation node) { SourcePersistentMember.this.addInitialAnnotation(node, this.astRoot); } } - - + + /** - * update annotation visitor + * synchronize annotation visitor */ - protected class UpdateAnnotationVisitor - extends AnnotationVisitor + protected class SynchronizeAnnotationVisitor + extends AnnotationVisitor { protected final Set<Annotation> annotationsToRemove; - - protected UpdateAnnotationVisitor(CompilationUnit astRoot, BodyDeclaration bodyDeclaration, Set<Annotation> annotationsToRemove) { + + protected SynchronizeAnnotationVisitor(CompilationUnit astRoot, BodyDeclaration bodyDeclaration, Set<Annotation> annotationsToRemove) { super(astRoot, bodyDeclaration); this.annotationsToRemove = annotationsToRemove; } - + @Override protected void visitChildAnnotation(org.eclipse.jdt.core.dom.Annotation node) { - SourcePersistentMember.this.addOrUpdateAnnotation(node, this.astRoot, this.annotationsToRemove); - } + SourcePersistentMember.this.addOrSyncAnnotation(node, this.astRoot, this.annotationsToRemove); + } } } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourcePersistentType.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourcePersistentType.java index 92c06f41e7..394d2560fa 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourcePersistentType.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourcePersistentType.java @@ -3,7 +3,7 @@ * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. - * + * * Contributors: * Oracle - initial API and implementation ******************************************************************************/ @@ -97,7 +97,7 @@ final class SourcePersistentType javaResourceCompilationUnit.getAnnotationEditFormatter()); JavaResourcePersistentType jrpt = new SourcePersistentType(javaResourceCompilationUnit, type); jrpt.initialize(astRoot); - return jrpt; + return jrpt; } /** @@ -118,12 +118,12 @@ final class SourcePersistentType javaResourceCompilationUnit.getAnnotationEditFormatter()); JavaResourcePersistentType jrpt = new SourcePersistentType(javaResourceCompilationUnit, type); jrpt.initialize(astRoot); - return jrpt; + return jrpt; } private SourcePersistentType(JavaResourceCompilationUnit javaResourceCompilationUnit, Type type) { super(javaResourceCompilationUnit, type); - this.types = new Vector<JavaResourcePersistentType>(); + this.types = new Vector<JavaResourcePersistentType>(); this.fields = new Vector<JavaResourcePersistentAttribute>(); this.methods = new Vector<JavaResourcePersistentAttribute>(); } @@ -166,19 +166,19 @@ final class SourcePersistentType // ********** update ********** - + @Override - public void update(CompilationUnit astRoot) { - super.update(astRoot); - this.setName(this.buildName(astRoot)); - this.setQualifiedName(this.buildQualifiedName(astRoot)); - this.setSuperclassQualifiedName(this.buildSuperclassQualifiedName(astRoot)); - this.setAbstract(this.buildAbstract(astRoot)); - this.updateTypes(astRoot); - this.updateFields(astRoot); - this.updateMethods(astRoot); + public void synchronizeWith(CompilationUnit astRoot) { + super.synchronizeWith(astRoot); + this.syncName(this.buildName(astRoot)); + this.syncQualifiedName(this.buildQualifiedName(astRoot)); + this.syncSuperclassQualifiedName(this.buildSuperclassQualifiedName(astRoot)); + this.syncAbstract(this.buildAbstract(astRoot)); + this.syncTypes(astRoot); + this.syncFields(astRoot); + this.syncMethods(astRoot); // need to wait until everything is built to calculate 'access' - this.setAccess(this.buildAccess()); + this.syncAccess(this.buildAccess()); } /** @@ -187,60 +187,60 @@ final class SourcePersistentType * annotations.... */ @Override - void addOrUpdateAnnotation(String jdtAnnotationName, CompilationUnit astRoot, Set<Annotation> annotationsToRemove) { + void addOrSyncAnnotation(String jdtAnnotationName, CompilationUnit astRoot, Set<Annotation> annotationsToRemove) { if (jdtAnnotationName.equals(STATIC_METAMODEL_ANNOTATION_DEFINITION.getAnnotationName())) { if (this.staticMetamodelAnnotation != null) { - this.staticMetamodelAnnotation.update(astRoot); + this.staticMetamodelAnnotation.synchronizeWith(astRoot); } else { this.staticMetamodelAnnotation = STATIC_METAMODEL_ANNOTATION_DEFINITION.buildAnnotation(this, this.member); this.staticMetamodelAnnotation.initialize(astRoot); } } else if (jdtAnnotationName.equals(GENERATED_ANNOTATION_DEFINITION.getAnnotationName())) { if (this.generatedAnnotation != null) { - this.generatedAnnotation.update(astRoot); + this.generatedAnnotation.synchronizeWith(astRoot); } else { this.generatedAnnotation = GENERATED_ANNOTATION_DEFINITION.buildAnnotation(this, this.member); this.generatedAnnotation.initialize(astRoot); } } else { - super.addOrUpdateAnnotation(jdtAnnotationName, astRoot, annotationsToRemove); + super.addOrSyncAnnotation(jdtAnnotationName, astRoot, annotationsToRemove); } } // ********** SourcePersistentMember implementation ********** - + @Override Iterator<String> validAnnotationNames() { return this.getAnnotationProvider().typeAnnotationNames(); } - + @Override Annotation buildAnnotation(String mappingAnnotationName) { return this.getAnnotationProvider().buildTypeAnnotation(this, this.member, mappingAnnotationName); } - + @Override Annotation buildNullAnnotation(String annotationName) { return this.getAnnotationProvider().buildNullTypeAnnotation(this, annotationName); } - + @Override public void resolveTypes(CompilationUnit astRoot) { super.resolveTypes(astRoot); - - this.setSuperclassQualifiedName(this.buildSuperclassQualifiedName(astRoot)); - + + this.syncSuperclassQualifiedName(this.buildSuperclassQualifiedName(astRoot)); + for (JavaResourcePersistentAttribute field : this.getFields()) { field.resolveTypes(astRoot); } - + // a new type can trigger a method parameter type to be a resolved, // fully-qualified name, so we need to rebuild our list of methods: // "setFoo(Foo)" is not the same as "setFoo(com.bar.Foo)" // and, vice-versa, a removed type can "unresolve" a parameter type - this.updateMethods(astRoot); - + this.syncMethods(astRoot); + for (JavaResourcePersistentAttribute method : this.getMethods()) { method.resolveTypes(astRoot); } @@ -248,13 +248,13 @@ final class SourcePersistentType type.resolveTypes(astRoot); } } - + @Override public void toString(StringBuilder sb) { sb.append(this.name); } - - + + // ******** JavaResourcePersistentType implementation ******** // ***** name @@ -262,10 +262,10 @@ final class SourcePersistentType return this.name; } - private void setName(String name) { + private void syncName(String astName) { String old = this.name; - this.name = name; - this.firePropertyChanged(NAME_PROPERTY, old, name); + this.name = astName; + this.firePropertyChanged(NAME_PROPERTY, old, astName); } private String buildName(CompilationUnit astRoot) { @@ -278,10 +278,10 @@ final class SourcePersistentType return this.qualifiedName; } - private void setQualifiedName(String qualifiedName) { + private void syncQualifiedName(String astQualifiedName) { String old = this.qualifiedName; - this.qualifiedName = qualifiedName; - this.firePropertyChanged(QUALIFIED_NAME_PROPERTY, old, qualifiedName); + this.qualifiedName = astQualifiedName; + this.firePropertyChanged(QUALIFIED_NAME_PROPERTY, old, astQualifiedName); } private String buildQualifiedName(CompilationUnit astRoot) { @@ -294,10 +294,10 @@ final class SourcePersistentType return this.superclassQualifiedName; } - private void setSuperclassQualifiedName(String superclassQualifiedName) { + private void syncSuperclassQualifiedName(String astSuperclassQualifiedName) { String old = this.superclassQualifiedName; - this.superclassQualifiedName = superclassQualifiedName; - this.firePropertyChanged(SUPERCLASS_QUALIFIED_NAME_PROPERTY, old, superclassQualifiedName); + this.superclassQualifiedName = astSuperclassQualifiedName; + this.firePropertyChanged(SUPERCLASS_QUALIFIED_NAME_PROPERTY, old, astSuperclassQualifiedName); } private String buildSuperclassQualifiedName(CompilationUnit astRoot) { @@ -314,15 +314,15 @@ final class SourcePersistentType return this.abstract_; } - private void setAbstract(boolean abstract_) { + private void syncAbstract(boolean astAbstract) { boolean old = this.abstract_; - this.abstract_ = abstract_; - this.firePropertyChanged(ABSTRACT_PROPERTY, old, abstract_); + this.abstract_ = astAbstract; + this.firePropertyChanged(ABSTRACT_PROPERTY, old, astAbstract); } private boolean buildAbstract(CompilationUnit astRoot) { ITypeBinding binding = this.member.getBinding(astRoot); - return (binding == null) ? false : Modifier.isAbstract(binding.getModifiers()); + return (binding == null) ? false : Modifier.isAbstract(binding.getModifiers()); } // ***** access @@ -337,16 +337,16 @@ final class SourcePersistentType //corresponding field/method does not exist? //making this internal since it should only be set based on changes in the source, the //context model should not need to set this - private void setAccess(AccessType access) { + private void syncAccess(AccessType astAccess) { AccessType old = this.access; - this.access = access; - this.firePropertyChanged(ACCESS_PROPERTY, old, access); + this.access = astAccess; + this.firePropertyChanged(ACCESS_PROPERTY, old, astAccess); } private AccessType buildAccess() { return JPTTools.buildAccess(this); } - + public boolean isMapped() { for (Annotation each : this.getAnnotations()) { if (this.annotationIsMappingAnnotation(each)) { @@ -363,7 +363,7 @@ final class SourcePersistentType private Iterator<String> mappingAnnotationNames() { return this.getAnnotationProvider().typeMappingAnnotationNames(); } - + /** * check only persistable attributes */ @@ -427,7 +427,7 @@ final class SourcePersistentType } } - private void updateTypes(CompilationUnit astRoot) { + private void syncTypes(CompilationUnit astRoot) { TypeDeclaration[] typeDeclarations = this.member.getTypes(astRoot); CounterMap counters = new CounterMap(typeDeclarations.length); HashSet<JavaResourcePersistentType> typesToRemove = new HashSet<JavaResourcePersistentType>(this.types); @@ -440,7 +440,7 @@ final class SourcePersistentType this.addType(this.buildType(typeDeclaration, occurrence, astRoot)); } else { typesToRemove.remove(type); - type.update(astRoot); + type.synchronizeWith(astRoot); } } this.removeTypes(typesToRemove); @@ -464,7 +464,7 @@ final class SourcePersistentType public Iterator<JavaResourcePersistentAttribute> persistableFields() { return this.persistableMembers(this.fields()); } - + public Iterator<JavaResourcePersistentAttribute> persistableFieldsWithSpecifiedFieldAccess() { return new FilteringIterator<JavaResourcePersistentAttribute>(this.persistableFields()) { @Override @@ -473,7 +473,7 @@ final class SourcePersistentType } }; } - + private void addField(JavaResourcePersistentAttribute field) { this.addItemToCollection(field, this.fields, FIELDS_COLLECTION); } @@ -503,7 +503,7 @@ final class SourcePersistentType } } - private void updateFields(CompilationUnit astRoot) { + private void syncFields(CompilationUnit astRoot) { FieldDeclaration[] fieldDeclarations = this.member.getFields(astRoot); CounterMap counters = new CounterMap(fieldDeclarations.length); HashSet<JavaResourcePersistentAttribute> fieldsToRemove = new HashSet<JavaResourcePersistentAttribute>(this.fields); @@ -517,7 +517,7 @@ final class SourcePersistentType this.addField(this.buildField(fieldName, occurrence, astRoot)); } else { fieldsToRemove.remove(field); - field.update(astRoot); + field.synchronizeWith(astRoot); } } } @@ -548,7 +548,7 @@ final class SourcePersistentType public Iterator<JavaResourcePersistentAttribute> persistableProperties() { return this.persistableMembers(this.methods()); } - + public Iterator<JavaResourcePersistentAttribute> persistablePropertiesWithSpecifiedPropertyAccess() { return new FilteringIterator<JavaResourcePersistentAttribute>(this.persistableProperties()) { @Override @@ -585,7 +585,7 @@ final class SourcePersistentType } } - private void updateMethods(CompilationUnit astRoot) { + private void syncMethods(CompilationUnit astRoot) { MethodDeclaration[] methodDeclarations = this.member.getMethods(astRoot); CounterMap counters = new CounterMap(methodDeclarations.length); HashSet<JavaResourcePersistentAttribute> methodsToRemove = new HashSet<JavaResourcePersistentAttribute>(this.methods); @@ -598,7 +598,7 @@ final class SourcePersistentType this.addMethod(this.buildMethod(signature, occurrence, astRoot)); } else { methodsToRemove.remove(method); - method.update(astRoot); + method.synchronizeWith(astRoot); } } this.removeMethods(methodsToRemove); @@ -618,7 +618,7 @@ final class SourcePersistentType this.persistableProperties() ); } - + public Iterator<JavaResourcePersistentAttribute> persistableAttributes(AccessType specifiedAccess) { if (specifiedAccess == null) { throw new IllegalArgumentException("specified access is null"); //$NON-NLS-1$ @@ -627,7 +627,7 @@ final class SourcePersistentType this.persistableAttributesForFieldAccessType() : this.persistableAttributesForPropertyAccessType(); } - + @SuppressWarnings("unchecked") private Iterator<JavaResourcePersistentAttribute> persistableAttributesForFieldAccessType() { return new CompositeIterator<JavaResourcePersistentAttribute>( @@ -635,7 +635,7 @@ final class SourcePersistentType this.persistablePropertiesWithSpecifiedPropertyAccess() ); } - + @SuppressWarnings("unchecked") private Iterator<JavaResourcePersistentAttribute> persistableAttributesForPropertyAccessType() { return new CompositeIterator<JavaResourcePersistentAttribute>( @@ -643,7 +643,7 @@ final class SourcePersistentType this.persistableFieldsWithSpecifiedFieldAccess() ); } - + // ********** metamodel ********** diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourcePrimaryKeyJoinColumnAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourcePrimaryKeyJoinColumnAnnotation.java index 1b190855fd..65c7b71eca 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourcePrimaryKeyJoinColumnAnnotation.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourcePrimaryKeyJoinColumnAnnotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -67,9 +67,9 @@ public final class SourcePrimaryKeyJoinColumnAnnotation } @Override - public void update(CompilationUnit astRoot) { - super.update(astRoot); - this.setReferencedColumnName(this.buildReferencedColumnName(astRoot)); + public void synchronizeWith(CompilationUnit astRoot) { + super.synchronizeWith(astRoot); + this.syncReferencedColumnName(this.buildReferencedColumnName(astRoot)); } @@ -94,13 +94,16 @@ public final class SourcePrimaryKeyJoinColumnAnnotation } public void setReferencedColumnName(String referencedColumnName) { - if (this.attributeValueHasNotChanged(this.referencedColumnName, referencedColumnName)) { - return; + if (this.attributeValueHasChanged(this.referencedColumnName, referencedColumnName)) { + this.referencedColumnName = referencedColumnName; + this.referencedColumnNameAdapter.setValue(referencedColumnName); } + } + + private void syncReferencedColumnName(String astReferencedColumnName) { String old = this.referencedColumnName; - this.referencedColumnName = referencedColumnName; - this.referencedColumnNameAdapter.setValue(referencedColumnName); - this.firePropertyChanged(REFERENCED_COLUMN_NAME_PROPERTY, old, referencedColumnName); + this.referencedColumnName = astReferencedColumnName; + this.firePropertyChanged(REFERENCED_COLUMN_NAME_PROPERTY, old, astReferencedColumnName); } private String buildReferencedColumnName(CompilationUnit astRoot) { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourcePrimaryKeyJoinColumnsAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourcePrimaryKeyJoinColumnsAnnotation.java index 0a3ea82674..6b0c573bbc 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourcePrimaryKeyJoinColumnsAnnotation.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourcePrimaryKeyJoinColumnsAnnotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -48,8 +48,8 @@ public final class SourcePrimaryKeyJoinColumnsAnnotation AnnotationContainerTools.initialize(this, astRoot); } - public void update(CompilationUnit astRoot) { - AnnotationContainerTools.update(this, astRoot); + public void synchronizeWith(CompilationUnit astRoot) { + AnnotationContainerTools.synchronize(this, astRoot); } @Override @@ -64,8 +64,8 @@ public final class SourcePrimaryKeyJoinColumnsAnnotation return this.getAnnotationName(); } - public org.eclipse.jdt.core.dom.Annotation getContainerJdtAnnotation(CompilationUnit astRoot) { - return this.getJdtAnnotation(astRoot); + public org.eclipse.jdt.core.dom.Annotation getContainerAstAnnotation(CompilationUnit astRoot) { + return this.getAstAnnotation(astRoot); } public String getElementName() { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceQueryHintAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceQueryHintAnnotation.java index 23484c15f1..4b5718b105 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceQueryHintAnnotation.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceQueryHintAnnotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -11,9 +11,9 @@ package org.eclipse.jpt.core.internal.resource.java.source; import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; +import org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationElementAdapter; import org.eclipse.jpt.core.internal.utility.jdt.MemberIndexedAnnotationAdapter; import org.eclipse.jpt.core.internal.utility.jdt.NestedIndexedDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter; import org.eclipse.jpt.core.resource.java.JPA; import org.eclipse.jpt.core.resource.java.JavaResourceNode; import org.eclipse.jpt.core.resource.java.NestableAnnotation; @@ -56,7 +56,7 @@ public final class SourceQueryHintAnnotation } private AnnotationElementAdapter<String> buildAdapter(DeclarationAnnotationElementAdapter<String> daea) { - return new ShortCircuitAnnotationElementAdapter<String>(this.member, daea); + return new MemberAnnotationElementAdapter<String>(this.member, daea); } private DeclarationAnnotationElementAdapter<String> buildNameAdapter(DeclarationAnnotationAdapter adapter) { @@ -72,9 +72,9 @@ public final class SourceQueryHintAnnotation this.value = this.buildValue(astRoot); } - public void update(CompilationUnit astRoot) { - this.setName(this.buildName(astRoot)); - this.setValue(this.buildValue(astRoot)); + public void synchronizeWith(CompilationUnit astRoot) { + this.syncName(this.buildName(astRoot)); + this.syncValue(this.buildValue(astRoot)); } public IndexedAnnotationAdapter getIndexedAnnotationAdapter() { @@ -95,13 +95,16 @@ public final class SourceQueryHintAnnotation } public void setName(String name) { - if (this.attributeValueHasNotChanged(this.name, name)) { - return; + if (this.attributeValueHasChanged(this.name, name)) { + this.name = name; + this.nameAdapter.setValue(name); } + } + + private void syncName(String astName) { String old = this.name; - this.name = name; - this.nameAdapter.setValue(name); - this.firePropertyChanged(NAME_PROPERTY, old, name); + this.name = astName; + this.firePropertyChanged(NAME_PROPERTY, old, astName); } private String buildName(CompilationUnit astRoot) { @@ -118,13 +121,16 @@ public final class SourceQueryHintAnnotation } public void setValue(String value) { - if (this.attributeValueHasNotChanged(this.value, value)) { - return; + if (this.attributeValueHasChanged(this.value, value)) { + this.value = value; + this.valueAdapter.setValue(value); } + } + + private void syncValue(String astValue) { String old = this.value; - this.value = value; - this.valueAdapter.setValue(value); - this.firePropertyChanged(VALUE_PROPERTY, old, value); + this.value = astValue; + this.firePropertyChanged(VALUE_PROPERTY, old, astValue); } private String buildValue(CompilationUnit astRoot) { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceRelationshipMappingAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceRelationshipMappingAnnotation.java index db7f070ea9..bb4a93af2b 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceRelationshipMappingAnnotation.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceRelationshipMappingAnnotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -14,8 +14,7 @@ import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotation import org.eclipse.jpt.core.internal.utility.jdt.EnumArrayDeclarationAnnotationElementAdapter; import org.eclipse.jpt.core.internal.utility.jdt.EnumDeclarationAnnotationElementAdapter; import org.eclipse.jpt.core.internal.utility.jdt.JDTTools; -import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitArrayAnnotationElementAdapter; +import org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationElementAdapter; import org.eclipse.jpt.core.internal.utility.jdt.SimpleTypeStringExpressionConverter; import org.eclipse.jpt.core.resource.java.CascadeType; import org.eclipse.jpt.core.resource.java.FetchType; @@ -51,11 +50,7 @@ abstract class SourceRelationshipMappingAnnotation final DeclarationAnnotationElementAdapter<String[]> cascadeDeclarationAdapter; final AnnotationElementAdapter<String[]> cascadeAdapter; - boolean cascadeAll; - boolean cascadePersist; - boolean cascadeMerge; - boolean cascadeRemove; - boolean cascadeRefresh; + CascadeType[] cascadeTypes; SourceRelationshipMappingAnnotation(JavaResourcePersistentAttribute parent, Attribute attribute, DeclarationAnnotationAdapter daa) { @@ -65,47 +60,29 @@ abstract class SourceRelationshipMappingAnnotation this.fetchDeclarationAdapter = this.getFetchAdapter(); this.fetchAdapter = this.buildAnnotationElementAdapter(this.fetchDeclarationAdapter); this.cascadeDeclarationAdapter = this.getCascadeAdapter(); - this.cascadeAdapter = new ShortCircuitArrayAnnotationElementAdapter<String>(attribute, this.cascadeDeclarationAdapter); + this.cascadeAdapter = new MemberAnnotationElementAdapter<String[]>(attribute, this.cascadeDeclarationAdapter); } protected AnnotationElementAdapter<String> buildAnnotationElementAdapter(DeclarationAnnotationElementAdapter<String> daea) { - return new ShortCircuitAnnotationElementAdapter<String>(this.member, daea); + return new MemberAnnotationElementAdapter<String>(this.member, daea); } protected AnnotationElementAdapter<Boolean> buildBooleanAnnotationElementAdapter(DeclarationAnnotationElementAdapter<Boolean> daea) { - return new ShortCircuitAnnotationElementAdapter<Boolean>(this.member, daea); + return new MemberAnnotationElementAdapter<Boolean>(this.member, daea); } public void initialize(CompilationUnit astRoot) { this.targetEntity = this.buildTargetEntity(astRoot); this.fullyQualifiedTargetEntityClassName = this.buildFullyQualifiedTargetEntityClassName(astRoot); this.fetch = this.buildFetch(astRoot); - this.initializeCascadeTypes(astRoot); + this.cascadeTypes = this.buildCascadeTypes(astRoot); } - private void initializeCascadeTypes(CompilationUnit astRoot) { - CascadeType[] cascadeTypes = CascadeType.fromJavaAnnotationValues(this.cascadeAdapter.getValue(astRoot)); - this.cascadeAll = ArrayTools.contains(cascadeTypes, CascadeType.ALL); - this.cascadeMerge = ArrayTools.contains(cascadeTypes, CascadeType.MERGE); - this.cascadePersist = ArrayTools.contains(cascadeTypes, CascadeType.PERSIST); - this.cascadeRefresh = ArrayTools.contains(cascadeTypes, CascadeType.REFRESH); - this.cascadeRemove = ArrayTools.contains(cascadeTypes, CascadeType.REMOVE); - } - - public void update(CompilationUnit astRoot) { - this.setFetch(this.buildFetch(astRoot)); - this.setTargetEntity(this.buildTargetEntity(astRoot)); - this.setFullyQualifiedTargetEntityClassName(this.buildFullyQualifiedTargetEntityClassName(astRoot)); - this.updateCascade(astRoot); - } - - private void updateCascade(CompilationUnit astRoot) { - CascadeType[] cascadeTypes = CascadeType.fromJavaAnnotationValues(this.cascadeAdapter.getValue(astRoot)); - this.setCascadeAll(ArrayTools.contains(cascadeTypes, CascadeType.ALL)); - this.setCascadeMerge(ArrayTools.contains(cascadeTypes, CascadeType.MERGE)); - this.setCascadePersist(ArrayTools.contains(cascadeTypes, CascadeType.PERSIST)); - this.setCascadeRefresh(ArrayTools.contains(cascadeTypes, CascadeType.REFRESH)); - this.setCascadeRemove(ArrayTools.contains(cascadeTypes, CascadeType.REMOVE)); + public void synchronizeWith(CompilationUnit astRoot) { + this.syncFetch(this.buildFetch(astRoot)); + this.syncTargetEntity(this.buildTargetEntity(astRoot)); + this.syncFullyQualifiedTargetEntityClassName(this.buildFullyQualifiedTargetEntityClassName(astRoot)); + this.syncCascadeTypes(this.buildCascadeTypes(astRoot)); } @Override @@ -122,13 +99,16 @@ abstract class SourceRelationshipMappingAnnotation } public void setTargetEntity(String targetEntity) { - if (this.attributeValueHasNotChanged(this.targetEntity, targetEntity)) { - return; + if (this.attributeValueHasChanged(this.targetEntity, targetEntity)) { + this.targetEntity = targetEntity; + this.targetEntityAdapter.setValue(targetEntity); } + } + + private void syncTargetEntity(String astTargetEntity) { String old = this.targetEntity; - this.targetEntity = targetEntity; - this.targetEntityAdapter.setValue(targetEntity); - this.firePropertyChanged(TARGET_ENTITY_PROPERTY, old, targetEntity); + this.targetEntity = astTargetEntity; + this.firePropertyChanged(TARGET_ENTITY_PROPERTY, old, astTargetEntity); } private String buildTargetEntity(CompilationUnit astRoot) { @@ -149,7 +129,7 @@ abstract class SourceRelationshipMappingAnnotation return this.fullyQualifiedTargetEntityClassName; } - private void setFullyQualifiedTargetEntityClassName(String name) { + private void syncFullyQualifiedTargetEntityClassName(String name) { String old = this.fullyQualifiedTargetEntityClassName; this.fullyQualifiedTargetEntityClassName = name; this.firePropertyChanged(FULLY_QUALIFIED_TARGET_ENTITY_CLASS_NAME_PROPERTY, old, name); @@ -165,13 +145,16 @@ abstract class SourceRelationshipMappingAnnotation } public void setFetch(FetchType fetch) { - if (this.attributeValueHasNotChanged(this.fetch, fetch)) { - return; + if (this.attributeValueHasChanged(this.fetch, fetch)) { + this.fetch = fetch; + this.fetchAdapter.setValue(FetchType.toJavaAnnotationValue(fetch)); } + } + + private void syncFetch(FetchType astFetch) { FetchType old = this.fetch; - this.fetch = fetch; - this.fetchAdapter.setValue(FetchType.toJavaAnnotationValue(fetch)); - this.firePropertyChanged(FETCH_PROPERTY, old, fetch); + this.fetch = astFetch; + this.firePropertyChanged(FETCH_PROPERTY, old, astFetch); } private FetchType buildFetch(CompilationUnit astRoot) { @@ -187,25 +170,37 @@ abstract class SourceRelationshipMappingAnnotation */ abstract DeclarationAnnotationElementAdapter<String> getFetchAdapter(); - // ***** cascade + // ***** cascade types + /** + * pre-condition: state of 'cascadeTypes' is to change + */ + private void setCascadeType(CascadeType cascadeType, boolean set) { + this.setCascadeTypes(set ? + ArrayTools.add(this.cascadeTypes, cascadeType) : + ArrayTools.remove(this.cascadeTypes, cascadeType) + ); + } + + /** + * pre-condition: state of 'cascadeTypes' is to change + */ private void setCascadeTypes(CascadeType[] cascadeTypes) { + this.cascadeTypes = cascadeTypes; this.cascadeAdapter.setValue(CascadeType.toJavaAnnotationValues(cascadeTypes)); } - private void setCascade(CascadeType cascadeType, boolean set) { - String[] javaValues = this.cascadeAdapter.getValue(); - CascadeType[] cascadeTypes = CascadeType.fromJavaAnnotationValues(javaValues); + private void syncCascadeTypes(CascadeType[] astCascadeTypes) { + CascadeType[] old = this.cascadeTypes; + this.cascadeTypes = astCascadeTypes; + this.syncCascadeAll(old); + this.syncCascadeMerge(old); + this.syncCascadePersist(old); + this.syncCascadeRefresh(old); + this.syncCascadeRemove(old); + } - boolean present = ArrayTools.contains(cascadeTypes, cascadeType); - if (set) { - if ( ! present) { - this.setCascadeTypes(ArrayTools.add(cascadeTypes, cascadeType)); - } - } else { - if (present) { - this.setCascadeTypes(ArrayTools.remove(cascadeTypes, cascadeType)); - } - } + private CascadeType[] buildCascadeTypes(CompilationUnit astRoot) { + return CascadeType.fromJavaAnnotationValues(this.cascadeAdapter.getValue(astRoot)); } public TextRange getCascadeTextRange(CompilationUnit astRoot) { @@ -219,77 +214,82 @@ abstract class SourceRelationshipMappingAnnotation // ***** cascade all public boolean isCascadeAll() { - return this.cascadeAll; + return ArrayTools.contains(this.cascadeTypes, CascadeType.ALL); } public void setCascadeAll(boolean cascadeAll) { - if (this.cascadeAll == cascadeAll) { - return; + if (this.isCascadeAll() != cascadeAll) { + this.setCascadeType(CascadeType.ALL, cascadeAll); } - boolean old = this.cascadeAll; - this.cascadeAll = cascadeAll; - this.setCascade(CascadeType.ALL, cascadeAll); - this.firePropertyChanged(CASCADE_ALL_PROPERTY, old, cascadeAll); + } + + private void syncCascadeAll(CascadeType[] oldCascadeTypes) { + boolean old = ArrayTools.contains(oldCascadeTypes, CascadeType.ALL); + this.firePropertyChanged(CASCADE_ALL_PROPERTY, old, this.isCascadeAll()); } // ***** cascade persist public boolean isCascadePersist() { - return this.cascadePersist; + return ArrayTools.contains(this.cascadeTypes, CascadeType.PERSIST); } public void setCascadePersist(boolean cascadePersist) { - if (this.cascadePersist == cascadePersist) { - return; + if (this.isCascadePersist() != cascadePersist) { + this.setCascadeType(CascadeType.PERSIST, cascadePersist); } - boolean old = this.cascadePersist; - this.cascadePersist = cascadePersist; - this.setCascade(CascadeType.PERSIST, cascadePersist); - this.firePropertyChanged(CASCADE_PERSIST_PROPERTY, old, cascadePersist); + } + + private void syncCascadePersist(CascadeType[] oldCascadeTypes) { + boolean old = ArrayTools.contains(oldCascadeTypes, CascadeType.PERSIST); + this.firePropertyChanged(CASCADE_PERSIST_PROPERTY, old, this.isCascadePersist()); } // ***** cascade merge public boolean isCascadeMerge() { - return this.cascadeMerge; + return ArrayTools.contains(this.cascadeTypes, CascadeType.MERGE); } public void setCascadeMerge(boolean cascadeMerge) { - if (this.cascadeMerge == cascadeMerge) { - return; + if (this.isCascadeMerge() != cascadeMerge) { + this.setCascadeType(CascadeType.MERGE, cascadeMerge); } - boolean old = this.cascadeMerge; - this.cascadeMerge = cascadeMerge; - this.setCascade(CascadeType.MERGE, cascadeMerge); - this.firePropertyChanged(CASCADE_MERGE_PROPERTY, old, cascadeMerge); + } + + private void syncCascadeMerge(CascadeType[] oldCascadeTypes) { + boolean old = ArrayTools.contains(oldCascadeTypes, CascadeType.MERGE); + this.firePropertyChanged(CASCADE_MERGE_PROPERTY, old, this.isCascadeMerge()); } // ***** cascade remove public boolean isCascadeRemove() { - return this.cascadeRemove; + return ArrayTools.contains(this.cascadeTypes, CascadeType.REMOVE); } public void setCascadeRemove(boolean cascadeRemove) { - if (this.cascadeRemove == cascadeRemove) { - return; + if (this.isCascadeRemove() != cascadeRemove) { + this.setCascadeType(CascadeType.REMOVE, cascadeRemove); } - boolean old = this.cascadeRemove; - this.cascadeRemove = cascadeRemove; - this.setCascade(CascadeType.REMOVE, cascadeRemove); - this.firePropertyChanged(CASCADE_REMOVE_PROPERTY, old, cascadeRemove); + } + + private void syncCascadeRemove(CascadeType[] oldCascadeTypes) { + boolean old = ArrayTools.contains(oldCascadeTypes, CascadeType.REMOVE); + this.firePropertyChanged(CASCADE_REMOVE_PROPERTY, old, this.isCascadeRemove()); } // ***** cascade refresh public boolean isCascadeRefresh() { - return this.cascadeRefresh; + return ArrayTools.contains(this.cascadeTypes, CascadeType.REFRESH); } public void setCascadeRefresh(boolean cascadeRefresh) { - if (this.cascadeRefresh == cascadeRefresh) { - return; + if (this.isCascadeRefresh() != cascadeRefresh) { + this.setCascadeType(CascadeType.REFRESH, cascadeRefresh); } - boolean old = this.cascadeRefresh; - this.cascadeRefresh = cascadeRefresh; - this.setCascade(CascadeType.REFRESH, cascadeRefresh); - this.firePropertyChanged(CASCADE_REFRESH_PROPERTY, old, cascadeRefresh); + } + + private void syncCascadeRefresh(CascadeType[] oldCascadeTypes) { + boolean old = ArrayTools.contains(oldCascadeTypes, CascadeType.REFRESH); + this.firePropertyChanged(CASCADE_REFRESH_PROPERTY, old, this.isCascadeRefresh()); } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceSecondaryTableAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceSecondaryTableAnnotation.java index 0a56feec54..d0aaf911a8 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceSecondaryTableAnnotation.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceSecondaryTableAnnotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -64,9 +64,9 @@ public final class SourceSecondaryTableAnnotation } @Override - public void update(CompilationUnit astRoot) { - super.update(astRoot); - AnnotationContainerTools.update(this.pkJoinColumnsContainer, astRoot); + public void synchronizeWith(CompilationUnit astRoot) { + super.synchronizeWith(astRoot); + AnnotationContainerTools.synchronize(this.pkJoinColumnsContainer, astRoot); } @@ -210,8 +210,8 @@ public final class SourceSecondaryTableAnnotation return SourceSecondaryTableAnnotation.this.getAnnotationName(); } - public org.eclipse.jdt.core.dom.Annotation getContainerJdtAnnotation(CompilationUnit astRoot) { - return SourceSecondaryTableAnnotation.this.getJdtAnnotation(astRoot); + public org.eclipse.jdt.core.dom.Annotation getContainerAstAnnotation(CompilationUnit astRoot) { + return SourceSecondaryTableAnnotation.this.getAstAnnotation(astRoot); } public String getElementName() { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceSecondaryTablesAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceSecondaryTablesAnnotation.java index bf37125772..a34b50db6d 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceSecondaryTablesAnnotation.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceSecondaryTablesAnnotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -48,8 +48,8 @@ public final class SourceSecondaryTablesAnnotation AnnotationContainerTools.initialize(this, astRoot); } - public void update(CompilationUnit astRoot) { - AnnotationContainerTools.update(this, astRoot); + public void synchronizeWith(CompilationUnit astRoot) { + AnnotationContainerTools.synchronize(this, astRoot); } @Override @@ -64,8 +64,8 @@ public final class SourceSecondaryTablesAnnotation return this.getAnnotationName(); } - public org.eclipse.jdt.core.dom.Annotation getContainerJdtAnnotation(CompilationUnit astRoot) { - return this.getJdtAnnotation(astRoot); + public org.eclipse.jdt.core.dom.Annotation getContainerAstAnnotation(CompilationUnit astRoot) { + return this.getAstAnnotation(astRoot); } public String getElementName() { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceSequenceGeneratorAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceSequenceGeneratorAnnotation.java index 90387e4bf8..b1894b7eb9 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceSequenceGeneratorAnnotation.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceSequenceGeneratorAnnotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -56,9 +56,9 @@ public abstract class SourceSequenceGeneratorAnnotation } @Override - public void update(CompilationUnit astRoot) { - super.update(astRoot); - this.setSequenceName(this.buildSequenceName(astRoot)); + public void synchronizeWith(CompilationUnit astRoot) { + super.synchronizeWith(astRoot); + this.syncSequenceName(this.buildSequenceName(astRoot)); } @@ -88,13 +88,16 @@ public abstract class SourceSequenceGeneratorAnnotation } public void setSequenceName(String sequenceName) { - if (this.attributeValueHasNotChanged(this.sequenceName, sequenceName)) { - return; + if (this.attributeValueHasChanged(this.sequenceName, sequenceName)) { + this.sequenceName = sequenceName; + this.sequenceNameAdapter.setValue(sequenceName); } + } + + public void syncSequenceName(String astSequenceName) { String old = this.sequenceName; - this.sequenceName = sequenceName; - this.sequenceNameAdapter.setValue(sequenceName); - this.firePropertyChanged(SEQUENCE_NAME_PROPERTY, old, sequenceName); + this.sequenceName = astSequenceName; + this.firePropertyChanged(SEQUENCE_NAME_PROPERTY, old, astSequenceName); } private String buildSequenceName(CompilationUnit astRoot) { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceTableGeneratorAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceTableGeneratorAnnotation.java index 328cdf6727..64558eed0a 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceTableGeneratorAnnotation.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceTableGeneratorAnnotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -101,15 +101,15 @@ public final class SourceTableGeneratorAnnotation } @Override - public void update(CompilationUnit astRoot) { - super.update(astRoot); - this.setTable(this.buildTable(astRoot)); - this.setSchema(this.buildSchema(astRoot)); - this.setCatalog(this.buildCatalog(astRoot)); - this.setPkColumnName(this.buildPkColumnName(astRoot)); - this.setValueColumnName(this.buildValueColumnName(astRoot)); - this.setPkColumnValue(this.buildPkColumnValue(astRoot)); - AnnotationContainerTools.update(this.uniqueConstraintsContainer, astRoot); + public void synchronizeWith(CompilationUnit astRoot) { + super.synchronizeWith(astRoot); + this.syncTable(this.buildTable(astRoot)); + this.syncSchema(this.buildSchema(astRoot)); + this.syncCatalog(this.buildCatalog(astRoot)); + this.syncPkColumnName(this.buildPkColumnName(astRoot)); + this.syncValueColumnName(this.buildValueColumnName(astRoot)); + this.syncPkColumnValue(this.buildPkColumnValue(astRoot)); + AnnotationContainerTools.synchronize(this.uniqueConstraintsContainer, astRoot); } @@ -139,13 +139,16 @@ public final class SourceTableGeneratorAnnotation } public void setTable(String table) { - if (this.attributeValueHasNotChanged(this.table, table)) { - return; + if (this.attributeValueHasChanged(this.table, table)) { + this.table = table; + this.tableAdapter.setValue(table); } + } + + private void syncTable(String astTable) { String old = this.table; - this.table = table; - this.tableAdapter.setValue(table); - this.firePropertyChanged(TABLE_PROPERTY, old, table); + this.table = astTable; + this.firePropertyChanged(TABLE_PROPERTY, old, astTable); } private String buildTable(CompilationUnit astRoot) { @@ -166,13 +169,16 @@ public final class SourceTableGeneratorAnnotation } public void setSchema(String schema) { - if (this.attributeValueHasNotChanged(this.schema, schema)) { - return; + if (this.attributeValueHasChanged(this.schema, schema)) { + this.schema = schema; + this.schemaAdapter.setValue(schema); } + } + + private void syncSchema(String astSchema) { String old = this.schema; - this.schema = schema; - this.schemaAdapter.setValue(schema); - this.firePropertyChanged(SCHEMA_PROPERTY, old, schema); + this.schema = astSchema; + this.firePropertyChanged(SCHEMA_PROPERTY, old, astSchema); } private String buildSchema(CompilationUnit astRoot) { @@ -193,13 +199,16 @@ public final class SourceTableGeneratorAnnotation } public void setCatalog(String catalog) { - if (this.attributeValueHasNotChanged(this.catalog, catalog)) { - return; + if (this.attributeValueHasChanged(this.catalog, catalog)) { + this.catalog = catalog; + this.catalogAdapter.setValue(catalog); } + } + + private void syncCatalog(String astCatalog) { String old = this.catalog; - this.catalog = catalog; - this.catalogAdapter.setValue(catalog); - this.firePropertyChanged(CATALOG_PROPERTY, old, catalog); + this.catalog = astCatalog; + this.firePropertyChanged(CATALOG_PROPERTY, old, astCatalog); } private String buildCatalog(CompilationUnit astRoot) { @@ -220,13 +229,16 @@ public final class SourceTableGeneratorAnnotation } public void setPkColumnName(String pkColumnName) { - if (this.attributeValueHasNotChanged(this.pkColumnName, pkColumnName)) { - return; + if (this.attributeValueHasChanged(this.pkColumnName, pkColumnName)) { + this.pkColumnName = pkColumnName; + this.pkColumnNameAdapter.setValue(pkColumnName); } + } + + private void syncPkColumnName(String astPkColumnName) { String old = this.pkColumnName; - this.pkColumnName = pkColumnName; - this.pkColumnNameAdapter.setValue(pkColumnName); - this.firePropertyChanged(PK_COLUMN_NAME_PROPERTY, old, pkColumnName); + this.pkColumnName = astPkColumnName; + this.firePropertyChanged(PK_COLUMN_NAME_PROPERTY, old, astPkColumnName); } private String buildPkColumnName(CompilationUnit astRoot) { @@ -247,13 +259,16 @@ public final class SourceTableGeneratorAnnotation } public void setValueColumnName(String valueColumnName) { - if (this.attributeValueHasNotChanged(this.valueColumnName, valueColumnName)) { - return; + if (this.attributeValueHasChanged(this.valueColumnName, valueColumnName)) { + this.valueColumnName = valueColumnName; + this.valueColumnNameAdapter.setValue(valueColumnName); } + } + + private void syncValueColumnName(String astValueColumnName) { String old = this.valueColumnName; - this.valueColumnName = valueColumnName; - this.valueColumnNameAdapter.setValue(valueColumnName); - this.firePropertyChanged(VALUE_COLUMN_NAME_PROPERTY, old, valueColumnName); + this.valueColumnName = astValueColumnName; + this.firePropertyChanged(VALUE_COLUMN_NAME_PROPERTY, old, astValueColumnName); } private String buildValueColumnName(CompilationUnit astRoot) { @@ -274,13 +289,16 @@ public final class SourceTableGeneratorAnnotation } public void setPkColumnValue(String pkColumnValue) { - if (this.attributeValueHasNotChanged(this.pkColumnValue, pkColumnValue)) { - return; + if (this.attributeValueHasChanged(this.pkColumnValue, pkColumnValue)) { + this.pkColumnValue = pkColumnValue; + this.pkColumnValueAdapter.setValue(pkColumnValue); } + } + + private void syncPkColumnValue(String astPkColumnValue) { String old = this.pkColumnValue; - this.pkColumnValue = pkColumnValue; - this.pkColumnValueAdapter.setValue(pkColumnValue); - this.firePropertyChanged(PK_COLUMN_VALUE_PROPERTY, old, pkColumnValue); + this.pkColumnValue = astPkColumnValue; + this.firePropertyChanged(PK_COLUMN_VALUE_PROPERTY, old, astPkColumnValue); } private String buildPkColumnValue(CompilationUnit astRoot) { @@ -386,8 +404,8 @@ public final class SourceTableGeneratorAnnotation return SourceTableGeneratorAnnotation.this.getAnnotationName(); } - public org.eclipse.jdt.core.dom.Annotation getContainerJdtAnnotation(CompilationUnit astRoot) { - return SourceTableGeneratorAnnotation.this.getJdtAnnotation(astRoot); + public org.eclipse.jdt.core.dom.Annotation getContainerAstAnnotation(CompilationUnit astRoot) { + return SourceTableGeneratorAnnotation.this.getAstAnnotation(astRoot); } public String getElementName() { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceTransientAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceTransientAnnotation.java index b41ff19a6e..fe3c171d89 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceTransientAnnotation.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceTransientAnnotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -38,7 +38,7 @@ public final class SourceTransientAnnotation // nothing to initialize } - public void update(CompilationUnit astRoot) { + public void synchronizeWith(CompilationUnit astRoot) { // nothing to update } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceUniqueConstraintAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceUniqueConstraintAnnotation.java index 6240b36fa4..474d351479 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceUniqueConstraintAnnotation.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceUniqueConstraintAnnotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -16,8 +16,8 @@ import java.util.Vector; import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jpt.core.internal.utility.jdt.AnnotationStringArrayExpressionConverter; import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; +import org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationElementAdapter; import org.eclipse.jpt.core.internal.utility.jdt.MemberIndexedAnnotationAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitArrayAnnotationElementAdapter; import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; import org.eclipse.jpt.core.resource.java.JPA; import org.eclipse.jpt.core.resource.java.JavaResourceNode; @@ -59,7 +59,7 @@ public final class SourceUniqueConstraintAnnotation } private AnnotationElementAdapter<String[]> buildAnnotationElementAdapter(DeclarationAnnotationElementAdapter<String[]> daea) { - return new ShortCircuitArrayAnnotationElementAdapter<String>(this.member, daea); + return new MemberAnnotationElementAdapter<String[]>(this.member, daea); } private static DeclarationAnnotationElementAdapter<String[]> buildArrayAnnotationElementAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName) { @@ -71,19 +71,11 @@ public final class SourceUniqueConstraintAnnotation } public void initialize(CompilationUnit astRoot) { - String[] javaColumnNames = this.columnNamesAdapter.getValue(astRoot); - for (int i = 0; i < javaColumnNames.length; i++) { - this.columnNames.add(javaColumnNames[i]); - } + this.initializeColumnNames(astRoot); } - public void update(CompilationUnit astRoot) { - this.updateColumnNames(astRoot); - } - - private void updateColumnNames(CompilationUnit astRoot) { - String[] javaColumnNames = this.columnNamesAdapter.getValue(astRoot); - this.synchronizeList(Arrays.asList(javaColumnNames), this.columnNames, COLUMN_NAMES_LIST); + public void synchronizeWith(CompilationUnit astRoot) { + this.syncColumnNames(astRoot); } public IndexedAnnotationAdapter getIndexedAnnotationAdapter() { @@ -112,31 +104,43 @@ public final class SourceUniqueConstraintAnnotation } public void addColumnName(int index, String columnName) { - this.addColumnName_(index, columnName); - this.columnNamesAdapter.setValue(this.columnNames.toArray(new String[this.columnNames.size()])); + this.columnNames.add(index, columnName); + this.writeColumnNames(); } - private void addColumnName_(int index, String columnName) { - this.addItemToList(index, columnName, this.columnNames, COLUMN_NAMES_LIST); + public void moveColumnName(int targetIndex, int sourceIndex) { + CollectionTools.move(this.columnNames, targetIndex, sourceIndex); + this.writeColumnNames(); } - public void moveColumnName(int targetIndex, int sourceIndex) { - this.moveItemInList(targetIndex, sourceIndex, this.columnNames, COLUMN_NAMES_LIST); - this.columnNamesAdapter.setValue(this.columnNames.toArray(new String[this.columnNames.size()])); + public void removeColumnName(String columnName) { + this.columnNames.remove(columnName); + this.writeColumnNames(); } - public boolean columnNamesTouches(int pos, CompilationUnit astRoot) { - return this.elementTouches(this.columnNamesDeclarationAdapter, pos, astRoot); + public void removeColumnName(int index) { + this.columnNames.remove(index); + this.writeColumnNames(); } - public void removeColumnName(String columnName) { - this.removeItemFromList(columnName, this.columnNames, COLUMN_NAMES_LIST); + private void writeColumnNames() { this.columnNamesAdapter.setValue(this.columnNames.toArray(new String[this.columnNames.size()])); } - public void removeColumnName(int index) { - this.removeItemFromList(index, this.columnNames, COLUMN_NAMES_LIST); - this.columnNamesAdapter.setValue(this.columnNames.toArray(new String[this.columnNames.size()])); + private void initializeColumnNames(CompilationUnit astRoot) { + String[] astColumnNames = this.columnNamesAdapter.getValue(astRoot); + for (int i = 0; i < astColumnNames.length; i++) { + this.columnNames.add(astColumnNames[i]); + } + } + + private void syncColumnNames(CompilationUnit astRoot) { + String[] javaColumnNames = this.columnNamesAdapter.getValue(astRoot); + this.synchronizeList(Arrays.asList(javaColumnNames), this.columnNames, COLUMN_NAMES_LIST); + } + + public boolean columnNamesTouches(int pos, CompilationUnit astRoot) { + return this.elementTouches(this.columnNamesDeclarationAdapter, pos, astRoot); } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceVersionAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceVersionAnnotation.java index 2b27d2c6c4..7e1e448cd7 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceVersionAnnotation.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceVersionAnnotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -38,7 +38,7 @@ public final class SourceVersionAnnotation // nothing to initialize } - public void update(CompilationUnit astRoot) { + public void synchronizeWith(CompilationUnit astRoot) { // nothing to update } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/Annotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/Annotation.java index ff1779a29c..376673b27a 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/Annotation.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/Annotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -37,7 +37,7 @@ public interface Annotation * Return the corresponding JDT DOM annotation from the specified * AST compilation unit. */ - org.eclipse.jdt.core.dom.Annotation getJdtAnnotation(CompilationUnit astRoot); + org.eclipse.jdt.core.dom.Annotation getAstAnnotation(CompilationUnit astRoot); /** * Create and add the corresponding Java annotation to the JDT DOM. diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/AnnotationContainer.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/AnnotationContainer.java index 51bb19c52c..57eb479c36 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/AnnotationContainer.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/AnnotationContainer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. + * Copyright (c) 2009, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -15,7 +15,7 @@ import org.eclipse.jdt.core.dom.CompilationUnit; /** * Common behavior for all annotation "containers". - * + * <p> * 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 @@ -34,7 +34,7 @@ public interface AnnotationContainer<T extends NestableAnnotation> * Return the corresponding JDT DOM annotation from the specified * AST compilation unit. Used as a starting point when traversing the AST. */ - org.eclipse.jdt.core.dom.Annotation getContainerJdtAnnotation(CompilationUnit astRoot); + org.eclipse.jdt.core.dom.Annotation getContainerAstAnnotation(CompilationUnit astRoot); /** * Return the name of the container annotation's element that is used @@ -83,6 +83,7 @@ public interface AnnotationContainer<T extends NestableAnnotation> * specified source index to the specified target index; notify interested * parties. */ + // TODO vestigial, now that we only fire events during updates... void nestedAnnotationMoved(int targetIndex, int sourceIndex); /** diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/JavaResourceCompilationUnit.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/JavaResourceCompilationUnit.java index 8513fb58ff..fada118c57 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/JavaResourceCompilationUnit.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/JavaResourceCompilationUnit.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. + * Copyright (c) 2009, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -52,10 +52,10 @@ public interface JavaResourceCompilationUnit /** * Something in Java has changed (typically either the compilation unit's - * source code or the Java classpath); update the JPA compilation unit's - * state to be in synch with the source code etc. + * source code or the Java classpath); synchronize the compilation unit's + * state with the Java source code etc. */ - void update(); + void synchronizeWithJavaSource(); /** * Build an AST for the compilation unit with its bindings resolved. diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/JavaResourceNode.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/JavaResourceNode.java index ecfadb041b..e67628deda 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/JavaResourceNode.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/JavaResourceNode.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -20,7 +20,7 @@ import org.eclipse.jpt.utility.model.Model; /** * Common interface for Java resource nodes (source code or binary). - * + * <p> * 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 @@ -46,6 +46,7 @@ public interface JavaResourceNode /** * Return the [source] node's root (the compilation unit). */ + // TODO get rid of this method...? JavaResourceCompilationUnit getJavaResourceCompilationUnit(); /** @@ -54,18 +55,18 @@ public interface JavaResourceNode TextRange getTextRange(CompilationUnit astRoot); /** - * Initialize the [source] with the specified AST. + * Initialize the [source] node from the specified AST. */ void initialize(CompilationUnit astRoot); /** - * Update the [source] with the specified AST. + * Synchronize the [source] node with the specified AST. */ - void update(CompilationUnit astRoot); + void synchronizeWith(CompilationUnit astRoot); /** - * root of Java resource containment hierarchy + * Root of Java resource model containment hierarchy. */ interface Root extends JavaResourceNode, JpaResourceModel { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/xml/JpaXmlResource.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/xml/JpaXmlResource.java index 245e8b5318..87e4af9f39 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/xml/JpaXmlResource.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/xml/JpaXmlResource.java @@ -92,12 +92,13 @@ public class JpaXmlResource // ********** BasicNotifierImpl override ********** /** - * override to fire notification only when - * - the resource's state has actually changed; and - * - the resource is loaded; and - * - the resource's resource set is still present (EMF will fire an + * Override to fire notification only when:<ul> + * <li>the resource's state has actually changed; and + * <li>the resource is loaded; and + * <li>the resource's resource set is still present (EMF will fire an * notification when the resource set is set to 'null', just before * the resource is "unloaded" - we want to swallow this notification) + * </ul> */ @Override public void eNotify(Notification notification) { @@ -242,7 +243,7 @@ public class JpaXmlResource protected void resourceModelChanged() { for (JpaResourceModelListener listener : this.resourceModelListenerList.getListeners()) { - listener.resourceModelChanged(); + listener.resourceModelChanged(this); } } diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceBaseEclipseLinkTypeConverterAnnotation.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceBaseEclipseLinkTypeConverterAnnotation.java index 03151ed322..8ff0eb5032 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceBaseEclipseLinkTypeConverterAnnotation.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceBaseEclipseLinkTypeConverterAnnotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 Oracle. All rights reserved. + * Copyright (c) 2008, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -11,7 +11,7 @@ package org.eclipse.jpt.eclipselink.core.internal.resource.java.source; import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter; +import org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationElementAdapter; import org.eclipse.jpt.core.internal.utility.jdt.TypeStringExpressionConverter; import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; import org.eclipse.jpt.core.utility.TextRange; @@ -41,10 +41,10 @@ abstract class SourceBaseEclipseLinkTypeConverterAnnotation SourceBaseEclipseLinkTypeConverterAnnotation(JavaResourcePersistentMember parent, Member member, DeclarationAnnotationAdapter daa) { super(parent, member, daa); this.dataTypeDeclarationAdapter = this.buildTypeAdapter(this.getDataTypeElementName()); - this.dataTypeAdapter = new ShortCircuitAnnotationElementAdapter<String>(this.member, this.dataTypeDeclarationAdapter); + this.dataTypeAdapter = new MemberAnnotationElementAdapter<String>(this.member, this.dataTypeDeclarationAdapter); this.objectTypeDeclarationAdapter = this.buildTypeAdapter(this.getObjectTypeElementName()); - this.objectTypeAdapter = new ShortCircuitAnnotationElementAdapter<String>(this.member, this.objectTypeDeclarationAdapter); + this.objectTypeAdapter = new MemberAnnotationElementAdapter<String>(this.member, this.objectTypeDeclarationAdapter); } private DeclarationAnnotationElementAdapter<String> buildTypeAdapter(String elementName) { @@ -60,10 +60,10 @@ abstract class SourceBaseEclipseLinkTypeConverterAnnotation } @Override - public void update(CompilationUnit astRoot) { - super.update(astRoot); - this.setDataType(this.buildDataType(astRoot)); - this.setObjectType(this.buildObjectType(astRoot)); + public void synchronizeWith(CompilationUnit astRoot) { + super.synchronizeWith(astRoot); + this.syncDataType(this.buildDataType(astRoot)); + this.syncObjectType(this.buildObjectType(astRoot)); } @@ -75,13 +75,16 @@ abstract class SourceBaseEclipseLinkTypeConverterAnnotation } public void setDataType(String dataType) { - if (this.attributeValueHasNotChanged(this.dataType, dataType)) { - return; + if (this.attributeValueHasChanged(this.dataType, dataType)) { + this.dataType = dataType; + this.dataTypeAdapter.setValue(dataType); } + } + + private void syncDataType(String astDataType) { String old = this.dataType; - this.dataType = dataType; - this.dataTypeAdapter.setValue(dataType); - this.firePropertyChanged(DATA_TYPE_PROPERTY, old, dataType); + this.dataType = astDataType; + this.firePropertyChanged(DATA_TYPE_PROPERTY, old, astDataType); } private String buildDataType(CompilationUnit astRoot) { @@ -100,23 +103,26 @@ abstract class SourceBaseEclipseLinkTypeConverterAnnotation } public void setObjectType(String objectType) { - if (this.attributeValueHasNotChanged(this.objectType, objectType)) { - return; + if (this.attributeValueHasChanged(this.objectType, objectType)) { + this.objectType = objectType; + this.objectTypeAdapter.setValue(objectType); } - String old = this.objectType; - this.objectType = objectType; - this.objectTypeAdapter.setValue(objectType); - this.firePropertyChanged(OBJECT_TYPE_PROPERTY, old, objectType); } - public TextRange getObjectTypeTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.objectTypeDeclarationAdapter, astRoot); + private void syncObjectType(String astObjectType) { + String old = this.objectType; + this.objectType = astObjectType; + this.firePropertyChanged(OBJECT_TYPE_PROPERTY, old, astObjectType); } private String buildObjectType(CompilationUnit astRoot) { return this.objectTypeAdapter.getValue(astRoot); } + public TextRange getObjectTypeTextRange(CompilationUnit astRoot) { + return this.getElementTextRange(this.objectTypeDeclarationAdapter, astRoot); + } + abstract String getObjectTypeElementName(); } diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkBasicCollectionAnnotation.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkBasicCollectionAnnotation.java index 9e3642c5a8..efe884329a 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkBasicCollectionAnnotation.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkBasicCollectionAnnotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 Oracle. All rights reserved. + * Copyright (c) 2008, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -39,7 +39,7 @@ public final class SourceEclipseLinkBasicCollectionAnnotation // do nothing } - public void update(CompilationUnit astRoot) { + public void synchronizeWith(CompilationUnit astRoot) { // do nothing } diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkBasicMapAnnotation.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkBasicMapAnnotation.java index 10dcfd80d9..307855c110 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkBasicMapAnnotation.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkBasicMapAnnotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 Oracle. All rights reserved. + * Copyright (c) 2008, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -39,7 +39,7 @@ public final class SourceEclipseLinkBasicMapAnnotation // do nothing } - public void update(CompilationUnit astRoot) { + public void synchronizeWith(CompilationUnit astRoot) { // do nothing } diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkCacheAnnotation.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkCacheAnnotation.java index a2c9163dba..1e553f4b02 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkCacheAnnotation.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkCacheAnnotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 Oracle. All rights reserved. + * Copyright (c) 2008, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -15,9 +15,9 @@ import org.eclipse.jpt.core.internal.utility.jdt.BooleanExpressionConverter; import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; import org.eclipse.jpt.core.internal.utility.jdt.EnumDeclarationAnnotationElementAdapter; import org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationAdapter; +import org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationElementAdapter; import org.eclipse.jpt.core.internal.utility.jdt.NestedDeclarationAnnotationAdapter; import org.eclipse.jpt.core.internal.utility.jdt.NumberIntegerExpressionConverter; -import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter; import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; import org.eclipse.jpt.core.utility.TextRange; @@ -25,10 +25,10 @@ import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; import org.eclipse.jpt.core.utility.jdt.Type; -import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLinkCacheAnnotation; import org.eclipse.jpt.eclipselink.core.resource.java.CacheCoordinationType; import org.eclipse.jpt.eclipselink.core.resource.java.CacheType; import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLink; +import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLinkCacheAnnotation; import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLinkTimeOfDayAnnotation; /** @@ -79,14 +79,14 @@ public final class SourceEclipseLinkCacheAnnotation public SourceEclipseLinkCacheAnnotation(JavaResourcePersistentType parent, Type type) { super(parent, type, DECLARATION_ANNOTATION_ADAPTER); - this.typeAdapter = new ShortCircuitAnnotationElementAdapter<String>(type, TYPE_ADAPTER); - this.sizeAdapter = new ShortCircuitAnnotationElementAdapter<Integer>(type, SIZE_ADAPTER); - this.sharedAdapter = new ShortCircuitAnnotationElementAdapter<Boolean>(type, SHARED_ADAPTER); - this.expiryAdapter = new ShortCircuitAnnotationElementAdapter<Integer>(type, EXPIRY_ADAPTER); - this.alwaysRefreshAdapter = new ShortCircuitAnnotationElementAdapter<Boolean>(type, ALWAYS_REFRESH_ADAPTER); - this.refreshOnlyIfNewerAdapter = new ShortCircuitAnnotationElementAdapter<Boolean>(type, REFRESH_ONLY_IF_NEWER_ADAPTER); - this.disableHitsAdapter = new ShortCircuitAnnotationElementAdapter<Boolean>(type, DISABLE_HITS_ADAPTER); - this.coordinationTypeAdapter = new ShortCircuitAnnotationElementAdapter<String>(type, COORDINATION_TYPE_ADAPTER); + this.typeAdapter = new MemberAnnotationElementAdapter<String>(type, TYPE_ADAPTER); + this.sizeAdapter = new MemberAnnotationElementAdapter<Integer>(type, SIZE_ADAPTER); + this.sharedAdapter = new MemberAnnotationElementAdapter<Boolean>(type, SHARED_ADAPTER); + this.expiryAdapter = new MemberAnnotationElementAdapter<Integer>(type, EXPIRY_ADAPTER); + this.alwaysRefreshAdapter = new MemberAnnotationElementAdapter<Boolean>(type, ALWAYS_REFRESH_ADAPTER); + this.refreshOnlyIfNewerAdapter = new MemberAnnotationElementAdapter<Boolean>(type, REFRESH_ONLY_IF_NEWER_ADAPTER); + this.disableHitsAdapter = new MemberAnnotationElementAdapter<Boolean>(type, DISABLE_HITS_ADAPTER); + this.coordinationTypeAdapter = new MemberAnnotationElementAdapter<String>(type, COORDINATION_TYPE_ADAPTER); this.expiryTimeOfDayAdapter = new MemberAnnotationAdapter(type, EXPIRY_TIME_OF_DAY_ADAPTER); } @@ -113,30 +113,16 @@ public final class SourceEclipseLinkCacheAnnotation } } - public void update(CompilationUnit astRoot) { - this.setType(this.buildType(astRoot)); - this.setSize(this.buildSize(astRoot)); - this.setShared(this.buildShared(astRoot)); - this.setExpiry(this.buildExpiry(astRoot)); - this.updateExpiryTimeOfDay(astRoot); - this.setAlwaysRefresh(this.buildAlwaysRefresh(astRoot)); - this.setRefreshOnlyIfNewer(this.buildRefreshOnlyIfNewer(astRoot)); - this.setDisableHits(this.buildDisableHits(astRoot)); - this.setCoordinationType(this.buildCoordinationType(astRoot)); - } - - private void updateExpiryTimeOfDay(CompilationUnit astRoot) { - if (this.expiryTimeOfDayAdapter.getAnnotation(astRoot) == null) { - this.setExpiryTimeOfDay(null); - } else { - if (this.getExpiryTimeOfDay() == null) { - EclipseLinkTimeOfDayAnnotation etod = this.buildExpiryTimeOfDay(); - etod.initialize(astRoot); - this.setExpiryTimeOfDay(etod); - } else { - this.getExpiryTimeOfDay().update(astRoot); - } - } + public void synchronizeWith(CompilationUnit astRoot) { + this.syncType(this.buildType(astRoot)); + this.syncSize(this.buildSize(astRoot)); + this.syncShared(this.buildShared(astRoot)); + this.syncExpiry(this.buildExpiry(astRoot)); + this.syncExpiryTimeOfDay(astRoot); + this.syncAlwaysRefresh(this.buildAlwaysRefresh(astRoot)); + this.syncRefreshOnlyIfNewer(this.buildRefreshOnlyIfNewer(astRoot)); + this.syncDisableHits(this.buildDisableHits(astRoot)); + this.syncCoordinationType(this.buildCoordinationType(astRoot)); } @Override @@ -153,13 +139,16 @@ public final class SourceEclipseLinkCacheAnnotation } public void setType(CacheType type) { - if (this.attributeValueHasNotChanged(this.type, type)) { - return; + if (this.attributeValueHasChanged(this.type, type)) { + this.type = type; + this.typeAdapter.setValue(CacheType.toJavaAnnotationValue(type)); } + } + + private void syncType(CacheType astType) { CacheType old = this.type; - this.type = type; - this.typeAdapter.setValue(CacheType.toJavaAnnotationValue(type)); - this.firePropertyChanged(TYPE_PROPERTY, old, type); + this.type = astType; + this.firePropertyChanged(TYPE_PROPERTY, old, astType); } private CacheType buildType(CompilationUnit astRoot) { @@ -176,13 +165,16 @@ public final class SourceEclipseLinkCacheAnnotation } public void setSize(Integer size) { - if (this.attributeValueHasNotChanged(this.size, size)) { - return; + if (this.attributeValueHasChanged(this.size, size)) { + this.size = size; + this.sizeAdapter.setValue(size); } + } + + private void syncSize(Integer astSize) { Integer old = this.size; - this.size = size; - this.sizeAdapter.setValue(size); - this.firePropertyChanged(SIZE_PROPERTY, old, size); + this.size = astSize; + this.firePropertyChanged(SIZE_PROPERTY, old, astSize); } private Integer buildSize(CompilationUnit astRoot) { @@ -199,13 +191,16 @@ public final class SourceEclipseLinkCacheAnnotation } public void setShared(Boolean shared) { - if (this.attributeValueHasNotChanged(this.shared, shared)) { - return; + if (this.attributeValueHasChanged(this.shared, shared)) { + this.shared = shared; + this.sharedAdapter.setValue(shared); } + } + + private void syncShared(Boolean astShared) { Boolean old = this.shared; - this.shared = shared; - this.sharedAdapter.setValue(shared); - this.firePropertyChanged(SHARED_PROPERTY, old, shared); + this.shared = astShared; + this.firePropertyChanged(SHARED_PROPERTY, old, astShared); } private Boolean buildShared(CompilationUnit astRoot) { @@ -222,13 +217,16 @@ public final class SourceEclipseLinkCacheAnnotation } public void setExpiry(Integer expiry) { - if (this.attributeValueHasNotChanged(this.expiry, expiry)) { - return; + if (this.attributeValueHasChanged(this.expiry, expiry)) { + this.expiry = expiry; + this.expiryAdapter.setValue(expiry); } + } + + private void syncExpiry(Integer astExpiry) { Integer old = this.expiry; - this.expiry = expiry; - this.expiryAdapter.setValue(expiry); - this.firePropertyChanged(EXPIRY_PROPERTY, old, expiry); + this.expiry = astExpiry; + this.firePropertyChanged(EXPIRY_PROPERTY, old, astExpiry); } private Integer buildExpiry(CompilationUnit astRoot) { @@ -246,33 +244,45 @@ public final class SourceEclipseLinkCacheAnnotation public EclipseLinkTimeOfDayAnnotation addExpiryTimeOfDay() { if (this.expiryTimeOfDay != null) { - throw new IllegalStateException("'expiryTimeOfDay' element already exists"); //$NON-NLS-1$ + throw new IllegalStateException("'expiryTimeOfDay' element already exists: " + this.expiryTimeOfDay); //$NON-NLS-1$ } this.expiryTimeOfDay = this.buildExpiryTimeOfDay(); - this.expiryTimeOfDayAdapter.newMarkerAnnotation(); - this.firePropertyChanged(EXPIRY_TIME_OF_DAY_PROPERTY, null, this.expiryTimeOfDay); + this.expiryTimeOfDay.newAnnotation(); return this.expiryTimeOfDay; } public void removeExpiryTimeOfDay() { if (this.expiryTimeOfDay == null) { - throw new IllegalStateException("No expiryTimeOfDay element exists"); //$NON-NLS-1$ + throw new IllegalStateException("'expiryTimeOfDay' element does not exist"); //$NON-NLS-1$ } + this.expiryTimeOfDay.removeAnnotation(); this.expiryTimeOfDay = null; - this.expiryTimeOfDayAdapter.removeAnnotation(); - this.firePropertyChanged(EXPIRY_TIME_OF_DAY_PROPERTY, this.expiryTimeOfDay, null); - } - - private void setExpiryTimeOfDay(EclipseLinkTimeOfDayAnnotation expiryTimeOfDay) { - EclipseLinkTimeOfDayAnnotation old = this.expiryTimeOfDay; - this.expiryTimeOfDay = expiryTimeOfDay; - this.firePropertyChanged(EXPIRY_TIME_OF_DAY_PROPERTY, old, expiryTimeOfDay); } private EclipseLinkTimeOfDayAnnotation buildExpiryTimeOfDay() { return new SourceEclipseLinkTimeOfDayAnnotation(this, this.member, EXPIRY_TIME_OF_DAY_ADAPTER); } + private void syncExpiryTimeOfDay(CompilationUnit astRoot) { + if (this.expiryTimeOfDayAdapter.getAnnotation(astRoot) == null) { + this.syncExpiryTimeOfDay_(null); + } else { + if (this.expiryTimeOfDay == null) { + EclipseLinkTimeOfDayAnnotation tod = this.buildExpiryTimeOfDay(); + tod.initialize(astRoot); + this.syncExpiryTimeOfDay_(tod); + } else { + this.expiryTimeOfDay.synchronizeWith(astRoot); + } + } + } + + private void syncExpiryTimeOfDay_(EclipseLinkTimeOfDayAnnotation astExpiryTimeOfDay) { + EclipseLinkTimeOfDayAnnotation old = this.expiryTimeOfDay; + this.expiryTimeOfDay = astExpiryTimeOfDay; + this.firePropertyChanged(EXPIRY_TIME_OF_DAY_PROPERTY, old, astExpiryTimeOfDay); + } + public TextRange getExpiryTimeOfDayTextRange(CompilationUnit astRoot) { return null;//TODO return this.getElementTextRange(EXPIRY_TIME_OF_DAY_ADAPTER, astRoot); } @@ -283,13 +293,16 @@ public final class SourceEclipseLinkCacheAnnotation } public void setAlwaysRefresh(Boolean alwaysRefresh) { - if (this.attributeValueHasNotChanged(this.alwaysRefresh, alwaysRefresh)) { - return; + if (this.attributeValueHasChanged(this.alwaysRefresh, alwaysRefresh)) { + this.alwaysRefresh = alwaysRefresh; + this.alwaysRefreshAdapter.setValue(alwaysRefresh); } + } + + private void syncAlwaysRefresh(Boolean astAlwaysRefresh) { Boolean old = this.alwaysRefresh; - this.alwaysRefresh = alwaysRefresh; - this.alwaysRefreshAdapter.setValue(alwaysRefresh); - this.firePropertyChanged(ALWAYS_REFRESH_PROPERTY, old, alwaysRefresh); + this.alwaysRefresh = astAlwaysRefresh; + this.firePropertyChanged(ALWAYS_REFRESH_PROPERTY, old, astAlwaysRefresh); } private Boolean buildAlwaysRefresh(CompilationUnit astRoot) { @@ -306,13 +319,16 @@ public final class SourceEclipseLinkCacheAnnotation } public void setRefreshOnlyIfNewer(Boolean refreshOnlyIfNewer) { - if (this.attributeValueHasNotChanged(this.refreshOnlyIfNewer, refreshOnlyIfNewer)) { - return; + if (this.attributeValueHasChanged(this.refreshOnlyIfNewer, refreshOnlyIfNewer)) { + this.refreshOnlyIfNewer = refreshOnlyIfNewer; + this.refreshOnlyIfNewerAdapter.setValue(refreshOnlyIfNewer); } + } + + private void syncRefreshOnlyIfNewer(Boolean astRefreshOnlyIfNewer) { Boolean old = this.refreshOnlyIfNewer; - this.refreshOnlyIfNewer = refreshOnlyIfNewer; - this.refreshOnlyIfNewerAdapter.setValue(refreshOnlyIfNewer); - this.firePropertyChanged(REFRESH_ONLY_IF_NEWER_PROPERTY, old, refreshOnlyIfNewer); + this.refreshOnlyIfNewer = astRefreshOnlyIfNewer; + this.firePropertyChanged(REFRESH_ONLY_IF_NEWER_PROPERTY, old, astRefreshOnlyIfNewer); } private Boolean buildRefreshOnlyIfNewer(CompilationUnit astRoot) { @@ -329,13 +345,16 @@ public final class SourceEclipseLinkCacheAnnotation } public void setDisableHits(Boolean disableHits) { - if (this.attributeValueHasNotChanged(this.disableHits, disableHits)) { - return; + if (this.attributeValueHasChanged(this.disableHits, disableHits)) { + this.disableHits = disableHits; + this.disableHitsAdapter.setValue(disableHits); } + } + + private void syncDisableHits(Boolean astDisableHits) { Boolean old = this.disableHits; - this.disableHits = disableHits; - this.disableHitsAdapter.setValue(disableHits); - this.firePropertyChanged(DISABLE_HITS_PROPERTY, old, disableHits); + this.disableHits = astDisableHits; + this.firePropertyChanged(DISABLE_HITS_PROPERTY, old, astDisableHits); } private Boolean buildDisableHits(CompilationUnit astRoot) { @@ -352,13 +371,16 @@ public final class SourceEclipseLinkCacheAnnotation } public void setCoordinationType(CacheCoordinationType coordinationType) { - if (this.attributeValueHasNotChanged(this.coordinationType, coordinationType)) { - return; + if (this.attributeValueHasChanged(this.coordinationType, coordinationType)) { + this.coordinationType = coordinationType; + this.coordinationTypeAdapter.setValue(CacheCoordinationType.toJavaAnnotationValue(coordinationType)); } + } + + private void syncCoordinationType(CacheCoordinationType astCoordinationType) { CacheCoordinationType old = this.coordinationType; - this.coordinationType = coordinationType; - this.coordinationTypeAdapter.setValue(CacheCoordinationType.toJavaAnnotationValue(coordinationType)); - this.firePropertyChanged(TYPE_PROPERTY, old, coordinationType); + this.coordinationType = astCoordinationType; + this.firePropertyChanged(TYPE_PROPERTY, old, astCoordinationType); } private CacheCoordinationType buildCoordinationType(CompilationUnit astRoot) { diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkChangeTrackingAnnotation.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkChangeTrackingAnnotation.java index 270bc9a78b..575ed10b48 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkChangeTrackingAnnotation.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkChangeTrackingAnnotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 Oracle. All rights reserved. + * Copyright (c) 2008, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -12,7 +12,7 @@ package org.eclipse.jpt.eclipselink.core.internal.resource.java.source; import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jpt.core.internal.resource.java.source.SourceAnnotation; import org.eclipse.jpt.core.internal.utility.jdt.EnumDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter; +import org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationElementAdapter; import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; import org.eclipse.jpt.core.utility.TextRange; @@ -20,9 +20,9 @@ import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; import org.eclipse.jpt.core.utility.jdt.Type; -import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLinkChangeTrackingAnnotation; import org.eclipse.jpt.eclipselink.core.resource.java.ChangeTrackingType; import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLink; +import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLinkChangeTrackingAnnotation; /** * org.eclipse.persistence.annotations.ChangeTracking @@ -40,7 +40,7 @@ public final class SourceEclipseLinkChangeTrackingAnnotation public SourceEclipseLinkChangeTrackingAnnotation(JavaResourcePersistentType parent, Type type) { super(parent, type, DECLARATION_ANNOTATION_ADAPTER); - this.valueAdapter = new ShortCircuitAnnotationElementAdapter<String>(type, VALUE_ADAPTER); + this.valueAdapter = new MemberAnnotationElementAdapter<String>(type, VALUE_ADAPTER); } public String getAnnotationName() { @@ -51,8 +51,8 @@ public final class SourceEclipseLinkChangeTrackingAnnotation this.value = this.buildValue(astRoot); } - public void update(CompilationUnit astRoot) { - this.setValue(this.buildValue(astRoot)); + public void synchronizeWith(CompilationUnit astRoot) { + this.syncValue(this.buildValue(astRoot)); } @Override @@ -69,13 +69,16 @@ public final class SourceEclipseLinkChangeTrackingAnnotation } public void setValue(ChangeTrackingType value) { - if (this.attributeValueHasNotChanged(this.value, value)) { - return; + if (this.attributeValueHasChanged(this.value, value)) { + this.value = value; + this.valueAdapter.setValue(ChangeTrackingType.toJavaAnnotationValue(value)); } + } + + private void syncValue(ChangeTrackingType astValue) { ChangeTrackingType old = this.value; - this.value = value; - this.valueAdapter.setValue(ChangeTrackingType.toJavaAnnotationValue(value)); - this.firePropertyChanged(VALUE_PROPERTY, old, value); + this.value = astValue; + this.firePropertyChanged(VALUE_PROPERTY, old, astValue); } private ChangeTrackingType buildValue(CompilationUnit astRoot) { diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkConversionValueAnnotation.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkConversionValueAnnotation.java index 7833912a1c..f1b803486a 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkConversionValueAnnotation.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkConversionValueAnnotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 Oracle. All rights reserved. + * Copyright (c) 2008, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -12,9 +12,9 @@ package org.eclipse.jpt.eclipselink.core.internal.resource.java.source; import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jpt.core.internal.resource.java.source.SourceAnnotation; import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; +import org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationElementAdapter; import org.eclipse.jpt.core.internal.utility.jdt.MemberIndexedAnnotationAdapter; import org.eclipse.jpt.core.internal.utility.jdt.NestedIndexedDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter; import org.eclipse.jpt.core.resource.java.NestableAnnotation; import org.eclipse.jpt.core.utility.TextRange; import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; @@ -23,10 +23,10 @@ import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; import org.eclipse.jpt.core.utility.jdt.IndexedAnnotationAdapter; import org.eclipse.jpt.core.utility.jdt.IndexedDeclarationAnnotationAdapter; import org.eclipse.jpt.core.utility.jdt.Member; -import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLinkConversionValueAnnotation; import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLink; -import org.eclipse.jpt.eclipselink.core.resource.java.NestableEclipseLinkConversionValueAnnotation; +import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLinkConversionValueAnnotation; import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLinkObjectTypeConverterAnnotation; +import org.eclipse.jpt.eclipselink.core.resource.java.NestableEclipseLinkConversionValueAnnotation; /** * org.eclipse.persistence.annotations.ConversionValue @@ -53,7 +53,7 @@ final class SourceEclipseLinkConversionValueAnnotation } private AnnotationElementAdapter<String> buildAdapter(DeclarationAnnotationElementAdapter<String> daea) { - return new ShortCircuitAnnotationElementAdapter<String>(this.member, daea); + return new MemberAnnotationElementAdapter<String>(this.member, daea); } private DeclarationAnnotationElementAdapter<String> buildDataValueAdapter(DeclarationAnnotationAdapter declarationAnnotationAdapter) { @@ -73,9 +73,9 @@ final class SourceEclipseLinkConversionValueAnnotation this.objectValue = this.buildObjectValue(astRoot); } - public void update(CompilationUnit astRoot) { - this.setDataValue(this.buildDataValue(astRoot)); - this.setObjectValue(this.buildObjectValue(astRoot)); + public void synchronizeWith(CompilationUnit astRoot) { + this.syncDataValue(this.buildDataValue(astRoot)); + this.syncObjectValue(this.buildObjectValue(astRoot)); } public IndexedAnnotationAdapter getIndexedAnnotationAdapter() { @@ -98,13 +98,16 @@ final class SourceEclipseLinkConversionValueAnnotation } public void setDataValue(String dataValue) { - if (this.attributeValueHasNotChanged(this.dataValue, dataValue)) { - return; + if (this.attributeValueHasChanged(this.dataValue, dataValue)) { + this.dataValue = dataValue; + this.dataValueAdapter.setValue(dataValue); } + } + + private void syncDataValue(String astDataValue) { String old = this.dataValue; - this.dataValue = dataValue; - this.dataValueAdapter.setValue(dataValue); - this.firePropertyChanged(DATA_VALUE_PROPERTY, old, dataValue); + this.dataValue = astDataValue; + this.firePropertyChanged(DATA_VALUE_PROPERTY, old, astDataValue); } private String buildDataValue(CompilationUnit astRoot) { @@ -121,13 +124,16 @@ final class SourceEclipseLinkConversionValueAnnotation } public void setObjectValue(String objectValue) { - if (this.attributeValueHasNotChanged(this.objectValue, objectValue)) { - return; + if (this.attributeValueHasChanged(this.objectValue, objectValue)) { + this.objectValue = objectValue; + this.objectValueAdapter.setValue(objectValue); } + } + + private void syncObjectValue(String astObjectValue) { String old = this.objectValue; - this.objectValue = objectValue; - this.objectValueAdapter.setValue(objectValue); - this.firePropertyChanged(OBJECT_VALUE_PROPERTY, old, objectValue); + this.objectValue = astObjectValue; + this.firePropertyChanged(OBJECT_VALUE_PROPERTY, old, astObjectValue); } private String buildObjectValue(CompilationUnit astRoot) { diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkConvertAnnotation.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkConvertAnnotation.java index 05665f1c3f..68deb5fe47 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkConvertAnnotation.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkConvertAnnotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 Oracle. All rights reserved. + * Copyright (c) 2008, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -12,7 +12,7 @@ package org.eclipse.jpt.eclipselink.core.internal.resource.java.source; import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jpt.core.internal.resource.java.source.SourceAnnotation; import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter; +import org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationElementAdapter; import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; import org.eclipse.jpt.core.internal.utility.jdt.StringExpressionConverter; import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; @@ -21,8 +21,8 @@ import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; import org.eclipse.jpt.core.utility.jdt.Attribute; import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; -import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLinkConvertAnnotation; import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLink; +import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLinkConvertAnnotation; /** * org.eclipse.persistence.annotations.Convert @@ -40,7 +40,7 @@ public final class SourceEclipseLinkConvertAnnotation public SourceEclipseLinkConvertAnnotation(JavaResourcePersistentAttribute parent, Attribute attribute) { super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); - this.valueAdapter = new ShortCircuitAnnotationElementAdapter<String>(attribute, VALUE_ADAPTER); + this.valueAdapter = new MemberAnnotationElementAdapter<String>(attribute, VALUE_ADAPTER); } public String getAnnotationName() { @@ -51,8 +51,8 @@ public final class SourceEclipseLinkConvertAnnotation this.value = this.buildValue(astRoot); } - public void update(CompilationUnit astRoot) { - this.setValue(this.buildValue(astRoot)); + public void synchronizeWith(CompilationUnit astRoot) { + this.syncValue(this.buildValue(astRoot)); } @Override @@ -69,13 +69,16 @@ public final class SourceEclipseLinkConvertAnnotation } public void setValue(String value) { - if (this.attributeValueHasNotChanged(this.value, value)) { - return; + if (this.attributeValueHasChanged(this.value, value)) { + this.value = value; + this.valueAdapter.setValue(value); } + } + + private void syncValue(String astValue) { String old = this.value; - this.value = value; - this.valueAdapter.setValue(value); - this.firePropertyChanged(VALUE_PROPERTY, old, value); + this.value = astValue; + this.firePropertyChanged(VALUE_PROPERTY, old, astValue); } private String buildValue(CompilationUnit astRoot) { diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkConverterAnnotation.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkConverterAnnotation.java index ba69e17342..1d5e085ddf 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkConverterAnnotation.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkConverterAnnotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 Oracle. All rights reserved. + * Copyright (c) 2008, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -12,7 +12,7 @@ package org.eclipse.jpt.eclipselink.core.internal.resource.java.source; import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; import org.eclipse.jpt.core.internal.utility.jdt.JDTTools; -import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter; +import org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationElementAdapter; import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; import org.eclipse.jpt.core.internal.utility.jdt.SimpleTypeStringExpressionConverter; import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; @@ -21,8 +21,8 @@ import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; import org.eclipse.jpt.core.utility.jdt.Member; -import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLinkConverterAnnotation; import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLink; +import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLinkConverterAnnotation; /** * org.eclipse.persistence.annotations.Converter @@ -40,7 +40,7 @@ public final class SourceEclipseLinkConverterAnnotation public SourceEclipseLinkConverterAnnotation(JavaResourcePersistentMember parent, Member member) { super(parent, member, DECLARATION_ANNOTATION_ADAPTER); - this.converterClassAdapter = new ShortCircuitAnnotationElementAdapter<String>(member, CONVERTER_CLASS_ADAPTER); + this.converterClassAdapter = new MemberAnnotationElementAdapter<String>(member, CONVERTER_CLASS_ADAPTER); } public String getAnnotationName() { @@ -54,9 +54,9 @@ public final class SourceEclipseLinkConverterAnnotation } @Override - public void update(CompilationUnit astRoot) { - super.update(astRoot); - this.setConverterClass(this.buildConverterClass(astRoot)); + public void synchronizeWith(CompilationUnit astRoot) { + super.synchronizeWith(astRoot); + this.syncConverterClass(this.buildConverterClass(astRoot)); } @@ -76,13 +76,16 @@ public final class SourceEclipseLinkConverterAnnotation } public void setConverterClass(String converterClass) { - if (this.attributeValueHasNotChanged(this.converterClass, converterClass)) { - return; + if (this.attributeValueHasChanged(this.converterClass, converterClass)) { + this.converterClass = converterClass; + this.converterClassAdapter.setValue(converterClass); } + } + + private void syncConverterClass(String astConverterClass) { String old = this.converterClass; - this.converterClass = converterClass; - this.converterClassAdapter.setValue(converterClass); - this.firePropertyChanged(CONVERTER_CLASS_PROPERTY, old, converterClass); + this.converterClass = astConverterClass; + this.firePropertyChanged(CONVERTER_CLASS_PROPERTY, old, astConverterClass); } private String buildConverterClass(CompilationUnit astRoot) { diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkCustomizerAnnotation.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkCustomizerAnnotation.java index 037d4f2aed..d51af412f7 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkCustomizerAnnotation.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkCustomizerAnnotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 Oracle. All rights reserved. + * Copyright (c) 2008, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -13,7 +13,7 @@ import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jpt.core.internal.resource.java.source.SourceAnnotation; import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; import org.eclipse.jpt.core.internal.utility.jdt.JDTTools; -import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter; +import org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationElementAdapter; import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; import org.eclipse.jpt.core.internal.utility.jdt.SimpleTypeStringExpressionConverter; import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; @@ -22,8 +22,8 @@ import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; import org.eclipse.jpt.core.utility.jdt.Type; -import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLinkCustomizerAnnotation; import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLink; +import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLinkCustomizerAnnotation; /** * org.eclipse.persistence.annotations.Customizer @@ -41,7 +41,7 @@ public final class SourceEclipseLinkCustomizerAnnotation public SourceEclipseLinkCustomizerAnnotation(JavaResourcePersistentType parent, Type type) { super(parent, type, DECLARATION_ANNOTATION_ADAPTER); - this.valueAdapter = new ShortCircuitAnnotationElementAdapter<String>(type, VALUE_ADAPTER); + this.valueAdapter = new MemberAnnotationElementAdapter<String>(type, VALUE_ADAPTER); } public String getAnnotationName() { @@ -52,8 +52,8 @@ public final class SourceEclipseLinkCustomizerAnnotation this.value = this.buildValue(astRoot); } - public void update(CompilationUnit astRoot) { - this.setValue(this.buildValue(astRoot)); + public void synchronizeWith(CompilationUnit astRoot) { + this.syncValue(this.buildValue(astRoot)); } @Override @@ -70,13 +70,16 @@ public final class SourceEclipseLinkCustomizerAnnotation } public void setValue(String value) { - if (this.attributeValueHasNotChanged(this.value, value)) { - return; + if (this.attributeValueHasChanged(this.value, value)) { + this.value = value; + this.valueAdapter.setValue(value); } + } + + private void syncValue(String astValue) { String old = this.value; - this.value = value; - this.valueAdapter.setValue(value); - this.firePropertyChanged(VALUE_PROPERTY, old, value); + this.value = astValue; + this.firePropertyChanged(VALUE_PROPERTY, old, astValue); } private String buildValue(CompilationUnit astRoot) { diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkExistenceCheckingAnnotation.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkExistenceCheckingAnnotation.java index 1b56da9366..bae9012793 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkExistenceCheckingAnnotation.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkExistenceCheckingAnnotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 Oracle. All rights reserved. + * Copyright (c) 2008, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -12,7 +12,7 @@ package org.eclipse.jpt.eclipselink.core.internal.resource.java.source; import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jpt.core.internal.resource.java.source.SourceAnnotation; import org.eclipse.jpt.core.internal.utility.jdt.EnumDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter; +import org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationElementAdapter; import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; import org.eclipse.jpt.core.utility.TextRange; @@ -40,7 +40,7 @@ public final class SourceEclipseLinkExistenceCheckingAnnotation public SourceEclipseLinkExistenceCheckingAnnotation(JavaResourcePersistentType parent, Type type) { super(parent, type, DECLARATION_ANNOTATION_ADAPTER); - this.valueAdapter = new ShortCircuitAnnotationElementAdapter<String>(type, VALUE_ADAPTER); + this.valueAdapter = new MemberAnnotationElementAdapter<String>(type, VALUE_ADAPTER); } public String getAnnotationName() { @@ -51,8 +51,8 @@ public final class SourceEclipseLinkExistenceCheckingAnnotation this.value = this.buildValue(astRoot); } - public void update(CompilationUnit astRoot) { - this.setValue(this.buildValue(astRoot)); + public void synchronizeWith(CompilationUnit astRoot) { + this.syncValue(this.buildValue(astRoot)); } @Override @@ -69,13 +69,16 @@ public final class SourceEclipseLinkExistenceCheckingAnnotation } public void setValue(ExistenceType value) { - if (this.attributeValueHasNotChanged(this.value, value)) { - return; + if (this.attributeValueHasChanged(this.value, value)) { + this.value = value; + this.valueAdapter.setValue(ExistenceType.toJavaAnnotationValue(value)); } + } + + private void syncValue(ExistenceType astValue) { ExistenceType old = this.value; - this.value = value; - this.valueAdapter.setValue(ExistenceType.toJavaAnnotationValue(value)); - this.firePropertyChanged(VALUE_PROPERTY, old, value); + this.value = astValue; + this.firePropertyChanged(VALUE_PROPERTY, old, astValue); } private ExistenceType buildValue(CompilationUnit astRoot) { diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkJoinFetchAnnotation.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkJoinFetchAnnotation.java index 54be00aed4..604a9af93b 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkJoinFetchAnnotation.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkJoinFetchAnnotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 Oracle. All rights reserved. + * Copyright (c) 2008, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -12,7 +12,7 @@ package org.eclipse.jpt.eclipselink.core.internal.resource.java.source; import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jpt.core.internal.resource.java.source.SourceAnnotation; import org.eclipse.jpt.core.internal.utility.jdt.EnumDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter; +import org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationElementAdapter; import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; import org.eclipse.jpt.core.utility.TextRange; @@ -40,7 +40,7 @@ public final class SourceEclipseLinkJoinFetchAnnotation public SourceEclipseLinkJoinFetchAnnotation(JavaResourcePersistentAttribute parent, Attribute attribute) { super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); - this.valueAdapter = new ShortCircuitAnnotationElementAdapter<String>(attribute, VALUE_ADAPTER); + this.valueAdapter = new MemberAnnotationElementAdapter<String>(attribute, VALUE_ADAPTER); } public String getAnnotationName() { @@ -51,8 +51,8 @@ public final class SourceEclipseLinkJoinFetchAnnotation this.value = this.buildValue(astRoot); } - public void update(CompilationUnit astRoot) { - this.setValue(this.buildValue(astRoot)); + public void synchronizeWith(CompilationUnit astRoot) { + this.syncValue(this.buildValue(astRoot)); } @Override @@ -69,13 +69,16 @@ public final class SourceEclipseLinkJoinFetchAnnotation } public void setValue(JoinFetchType value) { - if (this.attributeValueHasNotChanged(this.value, value)) { - return; + if (this.attributeValueHasChanged(this.value, value)) { + this.value = value; + this.valueAdapter.setValue(JoinFetchType.toJavaAnnotationValue(value)); } + } + + private void syncValue(JoinFetchType astValue) { JoinFetchType old = this.value; - this.value = value; - this.valueAdapter.setValue(JoinFetchType.toJavaAnnotationValue(value)); - this.firePropertyChanged(VALUE_PROPERTY, old, value); + this.value = astValue; + this.firePropertyChanged(VALUE_PROPERTY, old, astValue); } private JoinFetchType buildValue(CompilationUnit astRoot) { diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkMutableAnnotation.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkMutableAnnotation.java index 1b258d84cd..62832e81ee 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkMutableAnnotation.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkMutableAnnotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 Oracle. All rights reserved. + * Copyright (c) 2008, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -13,7 +13,7 @@ import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jpt.core.internal.resource.java.source.SourceAnnotation; import org.eclipse.jpt.core.internal.utility.jdt.BooleanExpressionConverter; import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter; +import org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationElementAdapter; import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; import org.eclipse.jpt.core.utility.TextRange; @@ -40,7 +40,7 @@ public final class SourceEclipseLinkMutableAnnotation public SourceEclipseLinkMutableAnnotation(JavaResourcePersistentAttribute parent, Attribute attribute) { super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); - this.valueAdapter = new ShortCircuitAnnotationElementAdapter<Boolean>(attribute, VALUE_ADAPTER); + this.valueAdapter = new MemberAnnotationElementAdapter<Boolean>(attribute, VALUE_ADAPTER); } public String getAnnotationName() { @@ -51,8 +51,8 @@ public final class SourceEclipseLinkMutableAnnotation this.value = this.buildValue(astRoot); } - public void update(CompilationUnit astRoot) { - this.setValue(this.buildValue(astRoot)); + public void synchronizeWith(CompilationUnit astRoot) { + this.syncValue(this.buildValue(astRoot)); } @Override @@ -69,13 +69,16 @@ public final class SourceEclipseLinkMutableAnnotation } public void setValue(Boolean value) { - if (this.attributeValueHasNotChanged(this.value, value)) { - return; + if (this.attributeValueHasChanged(this.value, value)) { + this.value = value; + this.valueAdapter.setValue(value); } + } + + private void syncValue(Boolean astValue) { Boolean old = this.value; - this.value = value; - this.valueAdapter.setValue(value); - this.firePropertyChanged(VALUE_PROPERTY, old, value); + this.value = astValue; + this.firePropertyChanged(VALUE_PROPERTY, old, astValue); } private Boolean buildValue(CompilationUnit astRoot) { diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkNamedConverterAnnotation.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkNamedConverterAnnotation.java index fda7787b0a..244d24f4b5 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkNamedConverterAnnotation.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkNamedConverterAnnotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. + * Copyright (c) 2009, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -12,7 +12,7 @@ package org.eclipse.jpt.eclipselink.core.internal.resource.java.source; import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jpt.core.internal.resource.java.source.SourceAnnotation; import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter; +import org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationElementAdapter; import org.eclipse.jpt.core.resource.java.JavaResourceNode; import org.eclipse.jpt.core.resource.java.OverrideAnnotation; import org.eclipse.jpt.core.utility.TextRange; @@ -42,15 +42,15 @@ abstract class SourceEclipseLinkNamedConverterAnnotation SourceEclipseLinkNamedConverterAnnotation(JavaResourceNode parent, Member member, DeclarationAnnotationAdapter daa) { super(parent, member, daa); this.nameDeclarationAdapter = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, this.getNameElementName(), false); // false = do not remove annotation when empty - this.nameAdapter = new ShortCircuitAnnotationElementAdapter<String>(this.member, this.nameDeclarationAdapter); + this.nameAdapter = new MemberAnnotationElementAdapter<String>(this.member, this.nameDeclarationAdapter); } public void initialize(CompilationUnit astRoot) { this.name = this.buildName(astRoot); } - public void update(CompilationUnit astRoot) { - this.setName(this.buildName(astRoot)); + public void synchronizeWith(CompilationUnit astRoot) { + this.syncName(this.buildName(astRoot)); } @Override @@ -67,13 +67,16 @@ abstract class SourceEclipseLinkNamedConverterAnnotation } public void setName(String name) { - if (this.attributeValueHasNotChanged(this.name, name)) { - return; + if (this.attributeValueHasChanged(this.name, name)) { + this.name = name; + this.nameAdapter.setValue(name); } + } + + private void syncName(String astName) { String old = this.name; - this.name = name; - this.nameAdapter.setValue(name); - this.firePropertyChanged(OverrideAnnotation.NAME_PROPERTY, old, name); + this.name = astName; + this.firePropertyChanged(OverrideAnnotation.NAME_PROPERTY, old, astName); } private String buildName(CompilationUnit astRoot) { diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkObjectTypeConverterAnnotation.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkObjectTypeConverterAnnotation.java index ef9c5c7546..2697b3de84 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkObjectTypeConverterAnnotation.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkObjectTypeConverterAnnotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 Oracle. All rights reserved. + * Copyright (c) 2008, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -15,7 +15,7 @@ import java.util.Vector; import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jpt.core.internal.resource.java.source.AnnotationContainerTools; import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter; +import org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationElementAdapter; import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; import org.eclipse.jpt.core.internal.utility.jdt.StringExpressionConverter; import org.eclipse.jpt.core.resource.java.AnnotationContainer; @@ -25,10 +25,10 @@ import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; import org.eclipse.jpt.core.utility.jdt.Member; -import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLinkConversionValueAnnotation; import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLink; -import org.eclipse.jpt.eclipselink.core.resource.java.NestableEclipseLinkConversionValueAnnotation; +import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLinkConversionValueAnnotation; import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLinkObjectTypeConverterAnnotation; +import org.eclipse.jpt.eclipselink.core.resource.java.NestableEclipseLinkConversionValueAnnotation; import org.eclipse.jpt.utility.internal.CollectionTools; import org.eclipse.jpt.utility.internal.StringTools; import org.eclipse.jpt.utility.internal.iterators.CloneListIterator; @@ -52,7 +52,7 @@ public final class SourceEclipseLinkObjectTypeConverterAnnotation public SourceEclipseLinkObjectTypeConverterAnnotation(JavaResourcePersistentMember parent, Member member) { super(parent, member, DECLARATION_ANNOTATION_ADAPTER); - this.defaultObjectValueAdapter = new ShortCircuitAnnotationElementAdapter<String>(member, DEFAULT_OBJECT_VALUE_ADAPTER); + this.defaultObjectValueAdapter = new MemberAnnotationElementAdapter<String>(member, DEFAULT_OBJECT_VALUE_ADAPTER); } public String getAnnotationName() { @@ -67,10 +67,10 @@ public final class SourceEclipseLinkObjectTypeConverterAnnotation } @Override - public void update(CompilationUnit astRoot) { - super.update(astRoot); - this.setDefaultObjectValue(this.buildDefaultObjectValue(astRoot)); - AnnotationContainerTools.update(this.conversionValuesContainer, astRoot); + public void synchronizeWith(CompilationUnit astRoot) { + super.synchronizeWith(astRoot); + this.syncDefaultObjectValue(this.buildDefaultObjectValue(astRoot)); + AnnotationContainerTools.synchronize(this.conversionValuesContainer, astRoot); } @@ -103,13 +103,16 @@ public final class SourceEclipseLinkObjectTypeConverterAnnotation } public void setDefaultObjectValue(String defaultObjectValue) { - if (this.attributeValueHasNotChanged(this.defaultObjectValue, defaultObjectValue)) { - return; + if (this.attributeValueHasChanged(this.defaultObjectValue, defaultObjectValue)) { + this.defaultObjectValue = defaultObjectValue; + this.defaultObjectValueAdapter.setValue(defaultObjectValue); } + } + + private void syncDefaultObjectValue(String astDefaultObjectValue) { String old = this.defaultObjectValue; - this.defaultObjectValue = defaultObjectValue; - this.defaultObjectValueAdapter.setValue(defaultObjectValue); - this.firePropertyChanged(DEFAULT_OBJECT_VALUE_PROPERTY, old, defaultObjectValue); + this.defaultObjectValue = astDefaultObjectValue; + this.firePropertyChanged(DEFAULT_OBJECT_VALUE_PROPERTY, old, astDefaultObjectValue); } private String buildDefaultObjectValue(CompilationUnit astRoot) { @@ -204,8 +207,8 @@ public final class SourceEclipseLinkObjectTypeConverterAnnotation return SourceEclipseLinkObjectTypeConverterAnnotation.this.getAnnotationName(); } - public org.eclipse.jdt.core.dom.Annotation getContainerJdtAnnotation(CompilationUnit astRoot) { - return SourceEclipseLinkObjectTypeConverterAnnotation.this.getJdtAnnotation(astRoot); + public org.eclipse.jdt.core.dom.Annotation getContainerAstAnnotation(CompilationUnit astRoot) { + return SourceEclipseLinkObjectTypeConverterAnnotation.this.getAstAnnotation(astRoot); } public String getElementName() { diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkPrivateOwnedAnnotation.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkPrivateOwnedAnnotation.java index 43c191c9b2..d6446f9519 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkPrivateOwnedAnnotation.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkPrivateOwnedAnnotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 Oracle. All rights reserved. + * Copyright (c) 2008, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -39,8 +39,8 @@ public final class SourceEclipseLinkPrivateOwnedAnnotation // nothing to initialize } - public void update(CompilationUnit astRoot) { - // nothing to update + public void synchronizeWith(CompilationUnit astRoot) { + // nothing to sync } } diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkReadOnlyAnnotation.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkReadOnlyAnnotation.java index ff138fbc76..112039d734 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkReadOnlyAnnotation.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkReadOnlyAnnotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 Oracle. All rights reserved. + * Copyright (c) 2008, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -39,8 +39,8 @@ public final class SourceEclipseLinkReadOnlyAnnotation // nothing to initialize } - public void update(CompilationUnit astRoot) { - // nothing to update + public void synchronizeWith(CompilationUnit astRoot) { + // nothing to sync } } diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkStructConverterAnnotation.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkStructConverterAnnotation.java index 6b14438286..f2fabfae0e 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkStructConverterAnnotation.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkStructConverterAnnotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 Oracle. All rights reserved. + * Copyright (c) 2008, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -11,7 +11,7 @@ package org.eclipse.jpt.eclipselink.core.internal.resource.java.source; import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter; +import org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationElementAdapter; import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; import org.eclipse.jpt.core.internal.utility.jdt.StringExpressionConverter; import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; @@ -39,7 +39,7 @@ public final class SourceEclipseLinkStructConverterAnnotation public SourceEclipseLinkStructConverterAnnotation(JavaResourcePersistentMember parent, Member member) { super(parent, member, DECLARATION_ANNOTATION_ADAPTER); - this.converterAdapter = new ShortCircuitAnnotationElementAdapter<String>(member, CONVERTER_ADAPTER); + this.converterAdapter = new MemberAnnotationElementAdapter<String>(member, CONVERTER_ADAPTER); } public String getAnnotationName() { @@ -53,9 +53,9 @@ public final class SourceEclipseLinkStructConverterAnnotation } @Override - public void update(CompilationUnit astRoot) { - super.update(astRoot); - this.setConverter(this.buildConverter(astRoot)); + public void synchronizeWith(CompilationUnit astRoot) { + super.synchronizeWith(astRoot); + this.syncConverter(this.buildConverter(astRoot)); } @@ -75,13 +75,16 @@ public final class SourceEclipseLinkStructConverterAnnotation } public void setConverter(String converter) { - if (this.attributeValueHasNotChanged(this.converter, converter)) { - return; + if (this.attributeValueHasChanged(this.converter, converter)) { + this.converter = converter; + this.converterAdapter.setValue(converter); } + } + + private void syncConverter(String astConverter) { String old = this.converter; - this.converter = converter; - this.converterAdapter.setValue(converter); - this.firePropertyChanged(CONVERTER_PROPERTY, old, converter); + this.converter = astConverter; + this.firePropertyChanged(CONVERTER_PROPERTY, old, astConverter); } private String buildConverter(CompilationUnit astRoot) { diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkTimeOfDayAnnotation.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkTimeOfDayAnnotation.java index b3e36bb6ea..d9a563b267 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkTimeOfDayAnnotation.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkTimeOfDayAnnotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 Oracle. All rights reserved. + * Copyright (c) 2008, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -12,8 +12,8 @@ package org.eclipse.jpt.eclipselink.core.internal.resource.java.source; import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jpt.core.internal.resource.java.source.SourceAnnotation; import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; +import org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationElementAdapter; import org.eclipse.jpt.core.internal.utility.jdt.NumberIntegerExpressionConverter; -import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter; import org.eclipse.jpt.core.resource.java.JavaResourceNode; import org.eclipse.jpt.core.utility.TextRange; import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; @@ -50,13 +50,13 @@ public final class SourceEclipseLinkTimeOfDayAnnotation public SourceEclipseLinkTimeOfDayAnnotation(JavaResourceNode parent, Type type, DeclarationAnnotationAdapter daa) { super(parent, type, daa); this.hourDeclarationAdapter = buildHourAdapter(daa); - this.hourAdapter = new ShortCircuitAnnotationElementAdapter<Integer>(type, this.hourDeclarationAdapter); + this.hourAdapter = new MemberAnnotationElementAdapter<Integer>(type, this.hourDeclarationAdapter); this.minuteDeclarationAdapter = buildMinuteAdapter(daa); - this.minuteAdapter = new ShortCircuitAnnotationElementAdapter<Integer>(type, this.minuteDeclarationAdapter); + this.minuteAdapter = new MemberAnnotationElementAdapter<Integer>(type, this.minuteDeclarationAdapter); this.secondDeclarationAdapter = buildSecondAdapter(daa); - this.secondAdapter = new ShortCircuitAnnotationElementAdapter<Integer>(type, this.secondDeclarationAdapter); + this.secondAdapter = new MemberAnnotationElementAdapter<Integer>(type, this.secondDeclarationAdapter); this.millisecondDeclarationAdapter = buildMillisecondAdapter(daa); - this.millisecondAdapter = new ShortCircuitAnnotationElementAdapter<Integer>(type, this.millisecondDeclarationAdapter); + this.millisecondAdapter = new MemberAnnotationElementAdapter<Integer>(type, this.millisecondDeclarationAdapter); } public String getAnnotationName() { @@ -70,11 +70,11 @@ public final class SourceEclipseLinkTimeOfDayAnnotation this.millisecond = this.buildMillisecond(astRoot); } - public void update(CompilationUnit astRoot) { - this.setHour(this.buildHour(astRoot)); - this.setMinute(this.buildMinute(astRoot)); - this.setSecond(this.buildSecond(astRoot)); - this.setMillisecond(this.buildMillisecond(astRoot)); + public void synchronizeWith(CompilationUnit astRoot) { + this.syncHour(this.buildHour(astRoot)); + this.syncMinute(this.buildMinute(astRoot)); + this.syncSecond(this.buildSecond(astRoot)); + this.syncMillisecond(this.buildMillisecond(astRoot)); } @@ -86,13 +86,16 @@ public final class SourceEclipseLinkTimeOfDayAnnotation } public void setHour(Integer hour) { - if (this.attributeValueHasNotChanged(this.hour, hour)) { - return; + if (this.attributeValueHasChanged(this.hour, hour)) { + this.hour = hour; + this.hourAdapter.setValue(hour); } + } + + private void syncHour(Integer astHour) { Integer old = this.hour; - this.hour = hour; - this.hourAdapter.setValue(hour); - this.firePropertyChanged(HOUR_PROPERTY, old, hour); + this.hour = astHour; + this.firePropertyChanged(HOUR_PROPERTY, old, astHour); } private Integer buildHour(CompilationUnit astRoot) { @@ -108,14 +111,17 @@ public final class SourceEclipseLinkTimeOfDayAnnotation return this.minute; } - public void setMinute(Integer newMinute) { - if (attributeValueHasNotChanged(this.minute, newMinute)) { - return; + public void setMinute(Integer minute) { + if (this.attributeValueHasChanged(this.minute, minute)) { + this.minute = minute; + this.minuteAdapter.setValue(minute); } - Integer oldMinute = this.minute; - this.minute = newMinute; - this.minuteAdapter.setValue(newMinute); - firePropertyChanged(MINUTE_PROPERTY, oldMinute, newMinute); + } + + private void syncMinute(Integer astMinute) { + Integer old = this.minute; + this.minute = astMinute; + this.firePropertyChanged(MINUTE_PROPERTY, old, astMinute); } private Integer buildMinute(CompilationUnit astRoot) { @@ -132,13 +138,16 @@ public final class SourceEclipseLinkTimeOfDayAnnotation } public void setSecond(Integer newSecond) { - if (attributeValueHasNotChanged(this.second, newSecond)) { - return; + if (this.attributeValueHasChanged(this.second, newSecond)) { + this.second = newSecond; + this.secondAdapter.setValue(newSecond); } - Integer oldSecond = this.second; - this.second = newSecond; - this.secondAdapter.setValue(newSecond); - firePropertyChanged(SECOND_PROPERTY, oldSecond, newSecond); + } + + private void syncSecond(Integer astSecond) { + Integer old = this.second; + this.second = astSecond; + this.firePropertyChanged(SECOND_PROPERTY, old, astSecond); } private Integer buildSecond(CompilationUnit astRoot) { @@ -154,14 +163,17 @@ public final class SourceEclipseLinkTimeOfDayAnnotation return this.millisecond; } - public void setMillisecond(Integer newMillisecond) { - if (attributeValueHasNotChanged(this.millisecond, newMillisecond)) { - return; + public void setMillisecond(Integer millisecond) { + if (this.attributeValueHasChanged(this.millisecond, millisecond)) { + this.millisecond = millisecond; + this.millisecondAdapter.setValue(millisecond); } + } + + private void syncMillisecond(Integer astMillisecond) { Integer oldMillisecond = this.millisecond; - this.millisecond = newMillisecond; - this.millisecondAdapter.setValue(newMillisecond); - firePropertyChanged(MILLISECOND_PROPERTY, oldMillisecond, newMillisecond); + this.millisecond = astMillisecond; + this.firePropertyChanged(MILLISECOND_PROPERTY, oldMillisecond, astMillisecond); } private Integer buildMillisecond(CompilationUnit astRoot) { diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkTransformationAnnotation.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkTransformationAnnotation.java index 1b4e6e6227..2927b6f3db 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkTransformationAnnotation.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkTransformationAnnotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 Oracle. All rights reserved. + * Copyright (c) 2008, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -14,7 +14,7 @@ import org.eclipse.jpt.core.internal.resource.java.source.SourceAnnotation; import org.eclipse.jpt.core.internal.utility.jdt.BooleanExpressionConverter; import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; import org.eclipse.jpt.core.internal.utility.jdt.EnumDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter; +import org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationElementAdapter; import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; import org.eclipse.jpt.core.resource.java.FetchType; import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; @@ -46,8 +46,8 @@ public final class SourceEclipseLinkTransformationAnnotation public SourceEclipseLinkTransformationAnnotation(JavaResourcePersistentAttribute parent, Attribute attribute) { super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); - this.fetchAdapter = new ShortCircuitAnnotationElementAdapter<String>(attribute, FETCH_ADAPTER); - this.optionalAdapter = new ShortCircuitAnnotationElementAdapter<Boolean>(attribute, OPTIONAL_ADAPTER); + this.fetchAdapter = new MemberAnnotationElementAdapter<String>(attribute, FETCH_ADAPTER); + this.optionalAdapter = new MemberAnnotationElementAdapter<Boolean>(attribute, OPTIONAL_ADAPTER); } public String getAnnotationName() { @@ -59,9 +59,9 @@ public final class SourceEclipseLinkTransformationAnnotation this.fetch = this.buildFetch(astRoot); } - public void update(CompilationUnit astRoot) { - this.setOptional(this.buildOptional(astRoot)); - this.setFetch(this.buildFetch(astRoot)); + public void synchronizeWith(CompilationUnit astRoot) { + this.syncOptional(this.buildOptional(astRoot)); + this.syncFetch(this.buildFetch(astRoot)); } @Override @@ -78,13 +78,16 @@ public final class SourceEclipseLinkTransformationAnnotation } public void setFetch(FetchType fetch) { - if (this.attributeValueHasNotChanged(this.fetch, fetch)) { - return; + if (this.attributeValueHasChanged(this.fetch, fetch)) { + this.fetch = fetch; + this.fetchAdapter.setValue(FetchType.toJavaAnnotationValue(fetch)); } + } + + private void syncFetch(FetchType astFetch) { FetchType old = this.fetch; - this.fetch = fetch; - this.fetchAdapter.setValue(FetchType.toJavaAnnotationValue(fetch)); - this.firePropertyChanged(FETCH_PROPERTY, old, fetch); + this.fetch = astFetch; + this.firePropertyChanged(FETCH_PROPERTY, old, astFetch); } private FetchType buildFetch(CompilationUnit astRoot) { @@ -101,13 +104,16 @@ public final class SourceEclipseLinkTransformationAnnotation } public void setOptional(Boolean optional) { - if (this.attributeValueHasNotChanged(this.optional, optional)) { - return; + if (this.attributeValueHasChanged(this.optional, optional)) { + this.optional = optional; + this.optionalAdapter.setValue(optional); } + } + + private void syncOptional(Boolean astOptional) { Boolean old = this.optional; - this.optional = optional; - this.optionalAdapter.setValue(optional); - this.firePropertyChanged(OPTIONAL_PROPERTY, old, optional); + this.optional = astOptional; + this.firePropertyChanged(OPTIONAL_PROPERTY, old, astOptional); } private Boolean buildOptional(CompilationUnit astRoot) { diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkTransformerAnnotation.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkTransformerAnnotation.java index 86eace3576..e50c25eb6c 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkTransformerAnnotation.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkTransformerAnnotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 Oracle. All rights reserved. + * Copyright (c) 2008, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -12,7 +12,7 @@ package org.eclipse.jpt.eclipselink.core.internal.resource.java.source; import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jpt.core.internal.resource.java.source.SourceAnnotation; import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter; +import org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationElementAdapter; import org.eclipse.jpt.core.internal.utility.jdt.SimpleTypeStringExpressionConverter; import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; import org.eclipse.jpt.core.utility.TextRange; @@ -42,10 +42,10 @@ abstract class SourceEclipseLinkTransformerAnnotation SourceEclipseLinkTransformerAnnotation(JavaResourcePersistentAttribute parent, Attribute attribute, DeclarationAnnotationAdapter daa) { super(parent, attribute, daa); this.transformerClassDeclarationAdapter = new ConversionDeclarationAnnotationElementAdapter<String>(daa, this.getTransformerClassElementName(), false, SimpleTypeStringExpressionConverter.instance()); - this.transformerClassAdapter = new ShortCircuitAnnotationElementAdapter<String>(attribute, this.transformerClassDeclarationAdapter); + this.transformerClassAdapter = new MemberAnnotationElementAdapter<String>(attribute, this.transformerClassDeclarationAdapter); this.methodDeclarationAdapter = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, this.getMethodElementName(), false); - this.methodAdapter = new ShortCircuitAnnotationElementAdapter<String>(attribute, this.methodDeclarationAdapter); + this.methodAdapter = new MemberAnnotationElementAdapter<String>(attribute, this.methodDeclarationAdapter); } public void initialize(CompilationUnit astRoot) { @@ -53,9 +53,9 @@ abstract class SourceEclipseLinkTransformerAnnotation this.method = this.buildMethod(astRoot); } - public void update(CompilationUnit astRoot) { - this.setTransformerClass(this.buildTransformerClass(astRoot)); - this.setMethod(this.buildMethod(astRoot)); + public void synchronizeWith(CompilationUnit astRoot) { + this.syncTransformerClass(this.buildTransformerClass(astRoot)); + this.syncMethod(this.buildMethod(astRoot)); } @Override @@ -72,13 +72,16 @@ abstract class SourceEclipseLinkTransformerAnnotation } public void setTransformerClass(String transformerClass) { - if (this.attributeValueHasNotChanged(this.transformerClass, transformerClass)) { - return; + if (this.attributeValueHasChanged(this.transformerClass, transformerClass)) { + this.transformerClass = transformerClass; + this.transformerClassAdapter.setValue(transformerClass); } + } + + private void syncTransformerClass(String astTransformerClass) { String old = this.transformerClass; - this.transformerClass = transformerClass; - this.transformerClassAdapter.setValue(transformerClass); - this.firePropertyChanged(TRANSFORMER_CLASS_PROPERTY, old, transformerClass); + this.transformerClass = astTransformerClass; + this.firePropertyChanged(TRANSFORMER_CLASS_PROPERTY, old, astTransformerClass); } private String buildTransformerClass(CompilationUnit astRoot) { @@ -97,13 +100,16 @@ abstract class SourceEclipseLinkTransformerAnnotation } public void setMethod(String method) { - if (this.attributeValueHasNotChanged(this.method, method)) { - return; + if (this.attributeValueHasChanged(this.method, method)) { + this.method = method; + this.methodAdapter.setValue(method); } + } + + private void syncMethod(String astMethod) { String old = this.method; - this.method = method; - this.methodAdapter.setValue(method); - this.firePropertyChanged(METHOD_PROPERTY, old, method); + this.method = astMethod; + this.firePropertyChanged(METHOD_PROPERTY, old, astMethod); } private String buildMethod(CompilationUnit astRoot) { diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkVariableOneToOneAnnotation.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkVariableOneToOneAnnotation.java index 268190206f..5b542e2cbc 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkVariableOneToOneAnnotation.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkVariableOneToOneAnnotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. + * Copyright (c) 2009, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -39,7 +39,7 @@ public final class SourceEclipseLinkVariableOneToOneAnnotation // nothing to initialize } - public void update(CompilationUnit astRoot) { + public void synchronizeWith(CompilationUnit astRoot) { // nothing to update } diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkWriteTransformerAnnotation.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkWriteTransformerAnnotation.java index 7026f15b44..cc71ce6b66 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkWriteTransformerAnnotation.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceEclipseLinkWriteTransformerAnnotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 Oracle. All rights reserved. + * Copyright (c) 2008, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -58,19 +58,9 @@ public final class SourceEclipseLinkWriteTransformerAnnotation } @Override - public void update(CompilationUnit astRoot) { - super.update(astRoot); - if (this.columnAdapter.getAnnotation(astRoot) == null) { - this.setColumn(null); - } else { - if (this.column == null) { - ColumnAnnotation col = createColumn(this, this.member, this.daa); - col.initialize(astRoot); - this.setColumn(col); - } else { - this.column.update(astRoot); - } - } + public void synchronizeWith(CompilationUnit astRoot) { + super.synchronizeWith(astRoot); + this.syncColumn(astRoot); } @@ -99,21 +89,40 @@ public final class SourceEclipseLinkWriteTransformerAnnotation } public ColumnAnnotation addColumn() { - ColumnAnnotation col = createColumn(this, this.member, this.daa); - col.newAnnotation(); - this.setColumn(col); - return col; + if (this.column != null) { + throw new IllegalStateException("'column' element already exists: " + this.column); //$NON-NLS-1$ + } + this.column = createColumn(this, this.member, this.daa); + this.column.newAnnotation(); + return this.column; } public void removeColumn() { + if (this.column == null) { + throw new IllegalStateException("'column' element does not exist"); //$NON-NLS-1$ + } this.column.removeAnnotation(); - this.setColumn(null); + this.column = null; + } + + private void syncColumn(CompilationUnit astRoot) { + if (this.columnAdapter.getAnnotation(astRoot) == null) { + this.syncColumn_(null); + } else { + if (this.column == null) { + ColumnAnnotation col = createColumn(this, this.member, this.daa); + col.initialize(astRoot); + this.syncColumn_(col); + } else { + this.column.synchronizeWith(astRoot); + } + } } - private void setColumn(ColumnAnnotation newColumn) { + private void syncColumn_(ColumnAnnotation astColumn) { ColumnAnnotation old = this.column; - this.column = newColumn; - this.firePropertyChanged(COLUMN_PROPERTY, old, newColumn); + this.column = astColumn; + this.firePropertyChanged(COLUMN_PROPERTY, old, astColumn); } public TextRange getColumnTextRange(CompilationUnit astRoot) { diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/views/structure/JpaStructurePage.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/views/structure/JpaStructurePage.java index fa578bf0b5..51d2b55626 100644 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/views/structure/JpaStructurePage.java +++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/views/structure/JpaStructurePage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -27,7 +27,7 @@ import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.jpt.core.JpaFile; -import org.eclipse.jpt.core.JpaModel; +import org.eclipse.jpt.core.JpaProjectManager; import org.eclipse.jpt.core.JpaProject; import org.eclipse.jpt.core.JpaStructureNode; import org.eclipse.jpt.core.JptCorePlugin; @@ -255,7 +255,7 @@ public class JpaStructurePage this.viewer.addSelectionChangedListener(this.treeSelectionListener); this.viewer.addPostSelectionChangedListener(this.treePostSelectionListener); this.jpaProject.addCollectionChangeListener(JpaProject.JPA_FILES_COLLECTION, this.jpaFilesListener); - JptCorePlugin.getJpaModel().addCollectionChangeListener(JpaModel.JPA_PROJECTS_COLLECTION, this.projectsListener); + JptCorePlugin.getJpaProjectManager().addCollectionChangeListener(JpaProjectManager.JPA_PROJECTS_COLLECTION, this.projectsListener); } @Override @@ -265,7 +265,7 @@ public class JpaStructurePage } protected void disengageListeners() { - JptCorePlugin.getJpaModel().removeCollectionChangeListener(JpaModel.JPA_PROJECTS_COLLECTION, this.projectsListener); + JptCorePlugin.getJpaProjectManager().removeCollectionChangeListener(JpaProjectManager.JPA_PROJECTS_COLLECTION, this.projectsListener); if (this.jpaProject != null) { this.jpaProject.removeCollectionChangeListener(JpaProject.JPA_FILES_COLLECTION, this.jpaFilesListener); } diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/JptCoreTestsPlugin.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/JptCoreTestsPlugin.java index 4374e5d207..4d6ed067f6 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/JptCoreTestsPlugin.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/JptCoreTestsPlugin.java @@ -10,7 +10,7 @@ package org.eclipse.jpt.core.tests; import org.eclipse.core.runtime.Plugin; -import org.eclipse.jpt.core.JpaModel; +import org.eclipse.jpt.core.JpaProjectManager; import org.eclipse.jpt.core.JptCorePlugin; import org.eclipse.jpt.utility.internal.ReflectionTools; import org.osgi.framework.BundleContext; @@ -44,8 +44,8 @@ public class JptCoreTestsPlugin extends Plugin { @Override public void start(BundleContext context) throws Exception { super.start(context); - JpaModel jpaModel = JptCorePlugin.getJpaModel(); - ReflectionTools.executeMethod(jpaModel, "handleEventsSynchronously"); + JpaProjectManager jpaProjectManager = JptCorePlugin.getJpaProjectManager(); + ReflectionTools.executeMethod(jpaProjectManager, "handleEventsSynchronously"); ReflectionTools.executeStaticMethod(JptCorePlugin.class, "doNotFlushPreferences"); } diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaAssociationOverrideTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaAssociationOverrideTests.java index ee94ec1195..d3b8ad97cb 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaAssociationOverrideTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaAssociationOverrideTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 Oracle. All rights reserved. + * Copyright (c) 2008, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -115,19 +115,23 @@ public class JavaAssociationOverrideTests extends ContextModelTestCase //set name in the resource model, verify context model updated associationOverrideResource.setName("FOO"); + getJpaProject().synchronizeContextModel(); assertEquals("FOO", javaAssociationOverride.getName()); assertEquals("FOO", associationOverrideResource.getName()); //set name to null in the resource model associationOverrideResource.setName(null); + getJpaProject().synchronizeContextModel(); assertNull(javaAssociationOverride.getName()); assertNull(associationOverrideResource.getName()); associationOverrideResource.setName("FOO"); + getJpaProject().synchronizeContextModel(); assertEquals("FOO", javaAssociationOverride.getName()); assertEquals("FOO", associationOverrideResource.getName()); typeResource.removeAnnotation(0, JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES); + getJpaProject().synchronizeContextModel(); assertFalse(overrideContainer.specifiedAssociationOverrides().hasNext()); assertFalse(typeResource.annotations(JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES).hasNext()); } @@ -318,6 +322,7 @@ public class JavaAssociationOverrideTests extends ContextModelTestCase associationOverrideResource.joinColumnAt(0).setName("FOO"); associationOverrideResource.joinColumnAt(1).setName("BAR"); associationOverrideResource.joinColumnAt(2).setName("BAZ"); + getJpaProject().synchronizeContextModel(); joinColumns = joiningStrategy.specifiedJoinColumns(); assertEquals("FOO", joinColumns.next().getName()); @@ -327,6 +332,7 @@ public class JavaAssociationOverrideTests extends ContextModelTestCase assertFalse(joinColumns.hasNext()); associationOverrideResource.moveJoinColumn(2, 0); + getJpaProject().synchronizeContextModel(); joinColumns = joiningStrategy.specifiedJoinColumns(); assertEquals("BAR", joinColumns.next().getName()); assertEquals("BAZ", joinColumns.next().getName()); @@ -335,6 +341,7 @@ public class JavaAssociationOverrideTests extends ContextModelTestCase assertFalse(joinColumns.hasNext()); associationOverrideResource.moveJoinColumn(0, 1); + getJpaProject().synchronizeContextModel(); joinColumns = joiningStrategy.specifiedJoinColumns(); assertEquals("BAZ", joinColumns.next().getName()); assertEquals("BAR", joinColumns.next().getName()); @@ -343,6 +350,7 @@ public class JavaAssociationOverrideTests extends ContextModelTestCase assertFalse(joinColumns.hasNext()); associationOverrideResource.removeJoinColumn(1); + getJpaProject().synchronizeContextModel(); joinColumns = joiningStrategy.specifiedJoinColumns(); assertEquals("BAZ", joinColumns.next().getName()); assertEquals("FOO", joinColumns.next().getName()); @@ -350,16 +358,19 @@ public class JavaAssociationOverrideTests extends ContextModelTestCase assertFalse(joinColumns.hasNext()); associationOverrideResource.removeJoinColumn(1); + getJpaProject().synchronizeContextModel(); joinColumns = joiningStrategy.specifiedJoinColumns(); assertEquals("BAZ", joinColumns.next().getName()); assertEquals("address_id", joinColumns.next().getName()); assertFalse(joinColumns.hasNext()); associationOverrideResource.removeJoinColumn(0); + getJpaProject().synchronizeContextModel(); joinColumns = joiningStrategy.specifiedJoinColumns(); assertEquals("address_id", joinColumns.next().getName()); associationOverrideResource.removeJoinColumn(0); + getJpaProject().synchronizeContextModel(); assertFalse(joiningStrategy.specifiedJoinColumns().hasNext()); } @@ -376,6 +387,7 @@ public class JavaAssociationOverrideTests extends ContextModelTestCase AssociationOverrideAnnotation associationOverrideResource = (AssociationOverrideAnnotation) typeResource.getAnnotation(JPA.ASSOCIATION_OVERRIDE); associationOverrideResource.setName("FOO"); + getJpaProject().synchronizeContextModel(); specifiedAssociationOverride = overrideContainer.specifiedAssociationOverrides().next(); assertEquals("FOO", specifiedAssociationOverride.getName()); } diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaAttributeOverrideTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaAttributeOverrideTests.java index 1ae40d7379..33922cda5c 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaAttributeOverrideTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaAttributeOverrideTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -96,6 +96,7 @@ public class JavaAttributeOverrideTests extends ContextModelTestCase AttributeOverrideAnnotation attributeOverrideResource = (AttributeOverrideAnnotation) typeResource.getAnnotation(JPA.ATTRIBUTE_OVERRIDE); attributeOverrideResource.setName("FOO"); + getJpaProject().synchronizeContextModel(); specifiedAttributeOverride = overrideContainer.specifiedAttributeOverrides().next(); assertEquals("FOO", specifiedAttributeOverride.getName()); } @@ -130,6 +131,7 @@ public class JavaAttributeOverrideTests extends ContextModelTestCase AttributeOverrideAnnotation attributeOverrideResource = (AttributeOverrideAnnotation) typeResource.getAnnotation(JPA.ATTRIBUTE_OVERRIDE); ColumnAnnotation columnResource = attributeOverrideResource.getColumn(); columnResource.setName("FOO"); + getJpaProject().synchronizeContextModel(); column = overrideContainer.specifiedAttributeOverrides().next().getColumn(); diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaBasicMappingTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaBasicMappingTests.java index 7df463ad86..5554e65e83 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaBasicMappingTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaBasicMappingTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -207,6 +207,7 @@ public class JavaBasicMappingTests extends ContextModelTestCase JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next(); BasicAnnotation basic = (BasicAnnotation) attributeResource.getAnnotation(JPA.BASIC); basic.setFetch(org.eclipse.jpt.core.resource.java.FetchType.LAZY); + getJpaProject().synchronizeContextModel(); assertEquals(FetchType.LAZY, basicMapping.getSpecifiedFetch()); } @@ -639,6 +640,7 @@ public class JavaBasicMappingTests extends ContextModelTestCase JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next(); BasicAnnotation basic = (BasicAnnotation) attributeResource.getAnnotation(JPA.BASIC); basic.setOptional(Boolean.FALSE); + getJpaProject().synchronizeContextModel(); assertEquals(Boolean.FALSE, basicMapping.getSpecifiedOptional()); } @@ -716,16 +718,19 @@ public class JavaBasicMappingTests extends ContextModelTestCase JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next(); BasicAnnotation basic = (BasicAnnotation) attributeResource.getAnnotation(JPA.BASIC); basic.setOptional(Boolean.FALSE); + getJpaProject().synchronizeContextModel(); assertEquals(Boolean.FALSE, basicMapping.getSpecifiedOptional()); basic.setOptional(null); + getJpaProject().synchronizeContextModel(); assertNull(basicMapping.getSpecifiedOptional()); assertFalse(basicMapping.isDefault()); assertSame(basicMapping, persistentAttribute.getSpecifiedMapping()); basic.setOptional(Boolean.FALSE); attributeResource.setPrimaryAnnotation(null, EmptyIterable.<String>instance()); + getJpaProject().synchronizeContextModel(); assertNull(persistentAttribute.getSpecifiedMapping()); assertEquals(true, ((BasicMapping) persistentAttribute.getMapping()).isOptional()); @@ -781,10 +786,12 @@ public class JavaBasicMappingTests extends ContextModelTestCase JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME); JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next(); attributeResource.addAnnotation(LobAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertTrue(basicMapping.getConverter().getType() == Converter.LOB_CONVERTER); attributeResource.removeAnnotation(LobAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertFalse(basicMapping.getConverter().getType() == Converter.LOB_CONVERTER); } @@ -819,9 +826,11 @@ public class JavaBasicMappingTests extends ContextModelTestCase JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME); JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next(); EnumeratedAnnotation enumeratedAnnotation = (EnumeratedAnnotation) attributeResource.addAnnotation(EnumeratedAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertEquals(EnumType.ORDINAL, ((EnumeratedConverter) basicMapping.getConverter()).getDefaultEnumType()); enumeratedAnnotation.setValue(org.eclipse.jpt.core.resource.java.EnumType.STRING); + getJpaProject().synchronizeContextModel(); assertEquals(EnumType.STRING, ((EnumeratedConverter) basicMapping.getConverter()).getSpecifiedEnumType()); } @@ -877,10 +886,12 @@ public class JavaBasicMappingTests extends ContextModelTestCase JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next(); EnumeratedAnnotation enumerated = (EnumeratedAnnotation) attributeResource.addAnnotation(EnumeratedAnnotation.ANNOTATION_NAME); enumerated.setValue(org.eclipse.jpt.core.resource.java.EnumType.STRING); + getJpaProject().synchronizeContextModel(); assertEquals(EnumType.STRING, ((EnumeratedConverter) basicMapping.getConverter()).getSpecifiedEnumType()); enumerated.setValue(null); + getJpaProject().synchronizeContextModel(); assertNotNull(attributeResource.getAnnotation(EnumeratedAnnotation.ANNOTATION_NAME)); assertNull(((EnumeratedConverter) basicMapping.getConverter()).getSpecifiedEnumType()); assertFalse(basicMapping.isDefault()); @@ -894,6 +905,7 @@ public class JavaBasicMappingTests extends ContextModelTestCase JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME); JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next(); attributeResource.addAnnotation(TemporalAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next(); BasicMapping basicMapping = (BasicMapping) persistentAttribute.getSpecifiedMapping(); @@ -947,11 +959,13 @@ public class JavaBasicMappingTests extends ContextModelTestCase JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next(); TemporalAnnotation temporal = (TemporalAnnotation) attributeResource.addAnnotation(TemporalAnnotation.ANNOTATION_NAME); temporal.setValue(org.eclipse.jpt.core.resource.java.TemporalType.DATE); + getJpaProject().synchronizeContextModel(); assertEquals(Converter.TEMPORAL_CONVERTER, basicMapping.getConverter().getType()); assertEquals(TemporalType.DATE, ((TemporalConverter) basicMapping.getConverter()).getTemporalType()); attributeResource.removeAnnotation(TemporalAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertEquals(Converter.NO_CONVERTER, basicMapping.getConverter().getType()); assertFalse(basicMapping.isDefault()); @@ -972,6 +986,7 @@ public class JavaBasicMappingTests extends ContextModelTestCase JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next(); ColumnAnnotation column = (ColumnAnnotation) attributeResource.addAnnotation(JPA.COLUMN); column.setName("foo"); + getJpaProject().synchronizeContextModel(); assertEquals("foo", basicMapping.getColumn().getSpecifiedName()); assertEquals("foo", basicMapping.getColumn().getName()); diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaColumnTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaColumnTests.java index 8edb76390d..78d419cdd1 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaColumnTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaColumnTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -200,10 +200,12 @@ public class JavaColumnTests extends ContextModelTestCase ColumnAnnotation column = (ColumnAnnotation) attributeResource.addAnnotation(JPA.COLUMN); column.setName("foo"); + getJpaProject().synchronizeContextModel(); assertEquals("foo", basicMapping.getColumn().getSpecifiedName()); assertEquals("foo", basicMapping.getColumn().getName()); column.setName(null); + getJpaProject().synchronizeContextModel(); assertNull(basicMapping.getColumn().getSpecifiedName()); } @@ -308,10 +310,12 @@ public class JavaColumnTests extends ContextModelTestCase ColumnAnnotation column = (ColumnAnnotation) attributeResource.addAnnotation(JPA.COLUMN); column.setTable("foo"); + getJpaProject().synchronizeContextModel(); assertEquals("foo", basicMapping.getColumn().getSpecifiedTable()); assertEquals("foo", basicMapping.getColumn().getTable()); column.setTable(null); + getJpaProject().synchronizeContextModel(); assertNull(basicMapping.getColumn().getSpecifiedTable()); } @@ -352,9 +356,11 @@ public class JavaColumnTests extends ContextModelTestCase ColumnAnnotation column = (ColumnAnnotation) attributeResource.addAnnotation(JPA.COLUMN); column.setColumnDefinition("foo"); + getJpaProject().synchronizeContextModel(); assertEquals("foo", basicMapping.getColumn().getColumnDefinition()); column.setColumnDefinition(null); + getJpaProject().synchronizeContextModel(); assertNull(basicMapping.getColumn().getColumnDefinition()); } @@ -393,11 +399,13 @@ public class JavaColumnTests extends ContextModelTestCase JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next(); ColumnAnnotation column = (ColumnAnnotation) attributeResource.addAnnotation(JPA.COLUMN); column.setLength(Integer.valueOf(66)); + getJpaProject().synchronizeContextModel(); assertEquals(Integer.valueOf(66), basicMapping.getColumn().getSpecifiedLength()); assertEquals(66, basicMapping.getColumn().getLength()); column.setLength(null); + getJpaProject().synchronizeContextModel(); assertNull(attributeResource.getAnnotation(JPA.COLUMN)); assertNull(basicMapping.getColumn().getSpecifiedLength()); @@ -458,11 +466,13 @@ public class JavaColumnTests extends ContextModelTestCase JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next(); ColumnAnnotation column = (ColumnAnnotation) attributeResource.addAnnotation(JPA.COLUMN); column.setPrecision(Integer.valueOf(66)); + getJpaProject().synchronizeContextModel(); assertEquals(Integer.valueOf(66), basicMapping.getColumn().getSpecifiedPrecision()); assertEquals(66, basicMapping.getColumn().getPrecision()); column.setPrecision(null); + getJpaProject().synchronizeContextModel(); assertNull(attributeResource.getAnnotation(JPA.COLUMN)); assertNull(basicMapping.getColumn().getSpecifiedPrecision()); @@ -523,11 +533,13 @@ public class JavaColumnTests extends ContextModelTestCase JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next(); ColumnAnnotation column = (ColumnAnnotation) attributeResource.addAnnotation(JPA.COLUMN); column.setScale(Integer.valueOf(66)); + getJpaProject().synchronizeContextModel(); assertEquals(Integer.valueOf(66), basicMapping.getColumn().getSpecifiedScale()); assertEquals(66, basicMapping.getColumn().getScale()); column.setScale(null); + getJpaProject().synchronizeContextModel(); assertNull(attributeResource.getAnnotation(JPA.COLUMN)); assertNull(basicMapping.getColumn().getSpecifiedScale()); @@ -588,11 +600,13 @@ public class JavaColumnTests extends ContextModelTestCase JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next(); ColumnAnnotation column = (ColumnAnnotation) attributeResource.addAnnotation(JPA.COLUMN); column.setUnique(Boolean.TRUE); + getJpaProject().synchronizeContextModel(); assertEquals(Boolean.TRUE, basicMapping.getColumn().getSpecifiedUnique()); assertEquals(true, basicMapping.getColumn().isUnique()); column.setUnique(null); + getJpaProject().synchronizeContextModel(); assertNull(attributeResource.getAnnotation(JPA.COLUMN)); assertNull(basicMapping.getColumn().getSpecifiedUnique()); @@ -653,11 +667,13 @@ public class JavaColumnTests extends ContextModelTestCase JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next(); ColumnAnnotation column = (ColumnAnnotation) attributeResource.addAnnotation(JPA.COLUMN); column.setInsertable(Boolean.TRUE); + getJpaProject().synchronizeContextModel(); assertEquals(Boolean.TRUE, basicMapping.getColumn().getSpecifiedInsertable()); assertEquals(true, basicMapping.getColumn().isInsertable()); column.setInsertable(null); + getJpaProject().synchronizeContextModel(); assertNull(attributeResource.getAnnotation(JPA.COLUMN)); assertNull(basicMapping.getColumn().getSpecifiedInsertable()); @@ -718,11 +734,13 @@ public class JavaColumnTests extends ContextModelTestCase JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next(); ColumnAnnotation column = (ColumnAnnotation) attributeResource.addAnnotation(JPA.COLUMN); column.setNullable(Boolean.TRUE); + getJpaProject().synchronizeContextModel(); assertEquals(Boolean.TRUE, basicMapping.getColumn().getSpecifiedNullable()); assertEquals(true, basicMapping.getColumn().isNullable()); column.setNullable(null); + getJpaProject().synchronizeContextModel(); assertNull(attributeResource.getAnnotation(JPA.COLUMN)); assertNull(basicMapping.getColumn().getSpecifiedNullable()); @@ -783,11 +801,13 @@ public class JavaColumnTests extends ContextModelTestCase JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next(); ColumnAnnotation column = (ColumnAnnotation) attributeResource.addAnnotation(JPA.COLUMN); column.setUpdatable(Boolean.TRUE); + getJpaProject().synchronizeContextModel(); assertEquals(Boolean.TRUE, basicMapping.getColumn().getSpecifiedUpdatable()); assertEquals(true, basicMapping.getColumn().isUpdatable()); column.setUpdatable(null); + getJpaProject().synchronizeContextModel(); assertNull(attributeResource.getAnnotation(JPA.COLUMN)); assertNull(basicMapping.getColumn().getSpecifiedUpdatable()); diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaDiscriminatorColumnTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaDiscriminatorColumnTests.java index a007aee983..686a032f63 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaDiscriminatorColumnTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaDiscriminatorColumnTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -219,6 +219,7 @@ public class JavaDiscriminatorColumnTests extends ContextModelTestCase JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME); DiscriminatorColumnAnnotation discriminatorColumn = (DiscriminatorColumnAnnotation) typeResource.getAnnotation(JPA.DISCRIMINATOR_COLUMN); discriminatorColumn.setDiscriminatorType(org.eclipse.jpt.core.resource.java.DiscriminatorType.CHAR); + getJpaProject().synchronizeContextModel(); assertEquals(DiscriminatorType.CHAR, getJavaEntity().getDiscriminatorColumn().getSpecifiedDiscriminatorType()); } @@ -251,10 +252,12 @@ public class JavaDiscriminatorColumnTests extends ContextModelTestCase DiscriminatorColumnAnnotation column = (DiscriminatorColumnAnnotation) typeResource.addAnnotation(JPA.DISCRIMINATOR_COLUMN); column.setDiscriminatorType(org.eclipse.jpt.core.resource.java.DiscriminatorType.INTEGER); + getJpaProject().synchronizeContextModel(); assertEquals(DiscriminatorType.INTEGER, getJavaEntity().getDiscriminatorColumn().getSpecifiedDiscriminatorType()); assertEquals(DiscriminatorType.INTEGER, getJavaEntity().getDiscriminatorColumn().getDiscriminatorType()); column.setDiscriminatorType(null); + getJpaProject().synchronizeContextModel(); assertNull(getJavaEntity().getDiscriminatorColumn().getSpecifiedDiscriminatorType()); assertEquals(null, getJavaEntity().getDiscriminatorColumn().getDiscriminatorType()); @@ -301,11 +304,13 @@ public class JavaDiscriminatorColumnTests extends ContextModelTestCase JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME); DiscriminatorColumnAnnotation discriminatorColumn = (DiscriminatorColumnAnnotation) typeResource.getAnnotation(JPA.DISCRIMINATOR_COLUMN); discriminatorColumn.setLength(Integer.valueOf(66)); + getJpaProject().synchronizeContextModel(); assertEquals(Integer.valueOf(66), getJavaEntity().getDiscriminatorColumn().getSpecifiedLength()); assertEquals(66, getJavaEntity().getDiscriminatorColumn().getLength()); discriminatorColumn.setName(null); discriminatorColumn.setLength(null); + getJpaProject().synchronizeContextModel(); assertNull(typeResource.getAnnotation(JPA.DISCRIMINATOR_COLUMN)); assertNull(getJavaEntity().getDiscriminatorColumn().getSpecifiedLength()); @@ -339,10 +344,12 @@ public class JavaDiscriminatorColumnTests extends ContextModelTestCase DiscriminatorColumnAnnotation column = (DiscriminatorColumnAnnotation) typeResource.addAnnotation(JPA.DISCRIMINATOR_COLUMN); column.setLength(Integer.valueOf(78)); + getJpaProject().synchronizeContextModel(); assertEquals(Integer.valueOf(78), getJavaEntity().getDiscriminatorColumn().getSpecifiedLength()); assertEquals(78, getJavaEntity().getDiscriminatorColumn().getLength()); column.setLength(null); + getJpaProject().synchronizeContextModel(); assertNull(getJavaEntity().getDiscriminatorColumn().getSpecifiedLength()); assertEquals(0, getJavaEntity().getDiscriminatorColumn().getLength()); @@ -361,10 +368,12 @@ public class JavaDiscriminatorColumnTests extends ContextModelTestCase JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME); DiscriminatorColumnAnnotation column = (DiscriminatorColumnAnnotation) typeResource.getAnnotation(JPA.DISCRIMINATOR_COLUMN); column.setColumnDefinition(COLUMN_DEFINITION); + getJpaProject().synchronizeContextModel(); assertEquals(COLUMN_DEFINITION, getJavaEntity().getDiscriminatorColumn().getColumnDefinition()); column.setColumnDefinition(null); + getJpaProject().synchronizeContextModel(); assertNull(getJavaEntity().getDiscriminatorColumn().getColumnDefinition()); diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaEmbeddedIdMappingTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaEmbeddedIdMappingTests.java index 9d6acb89d2..8618c20fa5 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaEmbeddedIdMappingTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaEmbeddedIdMappingTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -347,12 +347,14 @@ public class JavaEmbeddedIdMappingTests extends ContextModelTestCase //add an annotation to the resource model and verify the context model is updated AttributeOverrideAnnotation attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES); attributeOverride.setName("FOO"); + getJpaProject().synchronizeContextModel(); specifiedAttributeOverrides = attributeOverrideContainer.specifiedAttributeOverrides(); assertEquals("FOO", specifiedAttributeOverrides.next().getName()); assertFalse(specifiedAttributeOverrides.hasNext()); attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(1, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES); attributeOverride.setName("BAR"); + getJpaProject().synchronizeContextModel(); specifiedAttributeOverrides = attributeOverrideContainer.specifiedAttributeOverrides(); assertEquals("FOO", specifiedAttributeOverrides.next().getName()); assertEquals("BAR", specifiedAttributeOverrides.next().getName()); @@ -361,6 +363,7 @@ public class JavaEmbeddedIdMappingTests extends ContextModelTestCase attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES); attributeOverride.setName("BAZ"); + getJpaProject().synchronizeContextModel(); specifiedAttributeOverrides = attributeOverrideContainer.specifiedAttributeOverrides(); assertEquals("BAZ", specifiedAttributeOverrides.next().getName()); assertEquals("FOO", specifiedAttributeOverrides.next().getName()); @@ -369,6 +372,7 @@ public class JavaEmbeddedIdMappingTests extends ContextModelTestCase //move an annotation to the resource model and verify the context model is updated attributeResource.moveAnnotation(1, 0, JPA.ATTRIBUTE_OVERRIDES); + getJpaProject().synchronizeContextModel(); specifiedAttributeOverrides = attributeOverrideContainer.specifiedAttributeOverrides(); assertEquals("FOO", specifiedAttributeOverrides.next().getName()); assertEquals("BAZ", specifiedAttributeOverrides.next().getName()); @@ -376,18 +380,21 @@ public class JavaEmbeddedIdMappingTests extends ContextModelTestCase assertFalse(specifiedAttributeOverrides.hasNext()); attributeResource.removeAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES); + getJpaProject().synchronizeContextModel(); specifiedAttributeOverrides = attributeOverrideContainer.specifiedAttributeOverrides(); assertEquals("BAZ", specifiedAttributeOverrides.next().getName()); assertEquals("BAR", specifiedAttributeOverrides.next().getName()); assertFalse(specifiedAttributeOverrides.hasNext()); attributeResource.removeAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES); + getJpaProject().synchronizeContextModel(); specifiedAttributeOverrides = attributeOverrideContainer.specifiedAttributeOverrides(); assertEquals("BAR", specifiedAttributeOverrides.next().getName()); assertFalse(specifiedAttributeOverrides.hasNext()); attributeResource.removeAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES); + getJpaProject().synchronizeContextModel(); specifiedAttributeOverrides = attributeOverrideContainer.specifiedAttributeOverrides(); assertFalse(specifiedAttributeOverrides.hasNext()); } @@ -481,6 +488,7 @@ public class JavaEmbeddedIdMappingTests extends ContextModelTestCase AttributeOverrideAnnotation annotation = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES); annotation.setName("city"); + getJpaProject().synchronizeContextModel(); assertEquals(1, attributeOverrideContainer.virtualAttributeOverridesSize()); } @@ -502,6 +510,7 @@ public class JavaEmbeddedIdMappingTests extends ContextModelTestCase attributeOverride.setName("FOO"); attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES); attributeOverride.setName("BAR"); + getJpaProject().synchronizeContextModel(); assertEquals(2, attributeOverrideContainer.specifiedAttributeOverridesSize()); } @@ -524,11 +533,13 @@ public class JavaEmbeddedIdMappingTests extends ContextModelTestCase attributeOverride.setName("FOO"); attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES); attributeOverride.setName("BAR"); + getJpaProject().synchronizeContextModel(); assertEquals(4, attributeOverrideContainer.attributeOverridesSize()); attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES); attributeOverride.setName("city"); + getJpaProject().synchronizeContextModel(); assertEquals(4, attributeOverrideContainer.attributeOverridesSize()); } @@ -553,10 +564,12 @@ public class JavaEmbeddedIdMappingTests extends ContextModelTestCase attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES); attributeOverride.setName("city"); + getJpaProject().synchronizeContextModel(); assertEquals(1, attributeOverrideContainer.virtualAttributeOverridesSize()); attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES); attributeOverride.setName("state"); + getJpaProject().synchronizeContextModel(); assertEquals(0, attributeOverrideContainer.virtualAttributeOverridesSize()); } diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaEmbeddedMappingTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaEmbeddedMappingTests.java index 93338e31df..e3bcea7e01 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaEmbeddedMappingTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaEmbeddedMappingTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -485,12 +485,14 @@ public class JavaEmbeddedMappingTests extends ContextModelTestCase //add an annotation to the resource model and verify the context model is updated AttributeOverrideAnnotation attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES); attributeOverride.setName("FOO"); + getJpaProject().synchronizeContextModel(); specifiedAttributeOverrides = attributeOverrideContainer.specifiedAttributeOverrides(); assertEquals("FOO", specifiedAttributeOverrides.next().getName()); assertFalse(specifiedAttributeOverrides.hasNext()); attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(1, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES); attributeOverride.setName("BAR"); + getJpaProject().synchronizeContextModel(); specifiedAttributeOverrides = attributeOverrideContainer.specifiedAttributeOverrides(); assertEquals("FOO", specifiedAttributeOverrides.next().getName()); assertEquals("BAR", specifiedAttributeOverrides.next().getName()); @@ -500,6 +502,7 @@ public class JavaEmbeddedMappingTests extends ContextModelTestCase attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES); attributeOverride.setName("BAZ"); specifiedAttributeOverrides = attributeOverrideContainer.specifiedAttributeOverrides(); + getJpaProject().synchronizeContextModel(); assertEquals("BAZ", specifiedAttributeOverrides.next().getName()); assertEquals("FOO", specifiedAttributeOverrides.next().getName()); assertEquals("BAR", specifiedAttributeOverrides.next().getName()); @@ -508,6 +511,7 @@ public class JavaEmbeddedMappingTests extends ContextModelTestCase //move an annotation to the resource model and verify the context model is updated attributeResource.moveAnnotation(1, 0, JPA.ATTRIBUTE_OVERRIDES); specifiedAttributeOverrides = attributeOverrideContainer.specifiedAttributeOverrides(); + getJpaProject().synchronizeContextModel(); assertEquals("FOO", specifiedAttributeOverrides.next().getName()); assertEquals("BAZ", specifiedAttributeOverrides.next().getName()); assertEquals("BAR", specifiedAttributeOverrides.next().getName()); @@ -515,17 +519,20 @@ public class JavaEmbeddedMappingTests extends ContextModelTestCase attributeResource.removeAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES); specifiedAttributeOverrides = attributeOverrideContainer.specifiedAttributeOverrides(); + getJpaProject().synchronizeContextModel(); assertEquals("BAZ", specifiedAttributeOverrides.next().getName()); assertEquals("BAR", specifiedAttributeOverrides.next().getName()); assertFalse(specifiedAttributeOverrides.hasNext()); attributeResource.removeAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES); + getJpaProject().synchronizeContextModel(); specifiedAttributeOverrides = attributeOverrideContainer.specifiedAttributeOverrides(); assertEquals("BAR", specifiedAttributeOverrides.next().getName()); assertFalse(specifiedAttributeOverrides.hasNext()); attributeResource.removeAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES); + getJpaProject().synchronizeContextModel(); specifiedAttributeOverrides = attributeOverrideContainer.specifiedAttributeOverrides(); assertFalse(specifiedAttributeOverrides.hasNext()); } @@ -619,6 +626,7 @@ public class JavaEmbeddedMappingTests extends ContextModelTestCase AttributeOverrideAnnotation annotation = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES); annotation.setName("city"); + getJpaProject().synchronizeContextModel(); assertEquals(1, attributeOverrideContainer.virtualAttributeOverridesSize()); } @@ -640,6 +648,7 @@ public class JavaEmbeddedMappingTests extends ContextModelTestCase attributeOverride.setName("FOO"); attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES); attributeOverride.setName("BAR"); + getJpaProject().synchronizeContextModel(); assertEquals(2, attributeOverrideContainer.specifiedAttributeOverridesSize()); } @@ -662,11 +671,13 @@ public class JavaEmbeddedMappingTests extends ContextModelTestCase attributeOverride.setName("FOO"); attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES); attributeOverride.setName("BAR"); + getJpaProject().synchronizeContextModel(); assertEquals(4, attributeOverrideContainer.attributeOverridesSize()); attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES); attributeOverride.setName("city"); + getJpaProject().synchronizeContextModel(); assertEquals(4, attributeOverrideContainer.attributeOverridesSize()); } @@ -686,15 +697,18 @@ public class JavaEmbeddedMappingTests extends ContextModelTestCase //add an annotation to the resource model and verify the context model is updated AttributeOverrideAnnotation attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES); attributeOverride.setName("FOO"); + getJpaProject().synchronizeContextModel(); assertEquals(2, attributeOverrideContainer.virtualAttributeOverridesSize()); attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES); attributeOverride.setName("city"); + getJpaProject().synchronizeContextModel(); assertEquals(1, attributeOverrideContainer.virtualAttributeOverridesSize()); attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES); attributeOverride.setName("state"); + getJpaProject().synchronizeContextModel(); assertEquals(0, attributeOverrideContainer.virtualAttributeOverridesSize()); } diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaEntityTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaEntityTests.java index 8afa665866..3b50ee56b1 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaEntityTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaEntityTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -494,6 +494,7 @@ public class JavaEntityTests extends ContextModelTestCase JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME); typeResource.persistableProperties().next().removeAnnotation(JPA.ID); + getJpaProject().synchronizeContextModel(); //no mapping(Id) annotation, but still a Column annotation, so access should still be property assertEquals(AccessType.PROPERTY, superPersistentType.getAccess()); assertEquals(AccessType.PROPERTY, childPersistentType.getAccess()); @@ -537,10 +538,12 @@ public class JavaEntityTests extends ContextModelTestCase JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME); typeResource.persistableProperties().next().removeAnnotation(JPA.ID); + getJpaProject().synchronizeContextModel(); //no mapping(Id) annotation, but still a Column annotation, so access should still be property assertEquals(AccessType.PROPERTY, getJavaPersistentType().getAccess()); ((BasicMapping) getJavaPersistentType().getAttributeNamed("id").getMapping()).getColumn().setSpecifiedName(null); + getJpaProject().synchronizeContextModel(); assertEquals(AccessType.FIELD, getJavaPersistentType().getAccess()); getEntityMappings().getPersistenceUnitDefaults().setAccess(AccessType.PROPERTY); @@ -636,6 +639,7 @@ public class JavaEntityTests extends ContextModelTestCase JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME); EntityAnnotation entity = (EntityAnnotation) typeResource.getAnnotation(EntityAnnotation.ANNOTATION_NAME); entity.setName("foo"); + getJpaProject().synchronizeContextModel(); assertEquals("foo", getJavaEntity().getSpecifiedName()); } @@ -718,10 +722,12 @@ public class JavaEntityTests extends ContextModelTestCase InheritanceAnnotation inheritance = (InheritanceAnnotation) typeResource.getAnnotation(InheritanceAnnotation.ANNOTATION_NAME); inheritance.setStrategy(org.eclipse.jpt.core.resource.java.InheritanceType.JOINED); + getJpaProject().synchronizeContextModel(); assertEquals(InheritanceType.JOINED, getJavaEntity().getSpecifiedInheritanceStrategy()); inheritance.setStrategy(null); + getJpaProject().synchronizeContextModel(); assertNull(getJavaEntity().getSpecifiedInheritanceStrategy()); } @@ -773,10 +779,12 @@ public class JavaEntityTests extends ContextModelTestCase DiscriminatorValueAnnotation discriminatorValue = (DiscriminatorValueAnnotation) typeResource.getAnnotation(DiscriminatorValueAnnotation.ANNOTATION_NAME); discriminatorValue.setValue("foo"); + getJpaProject().synchronizeContextModel(); assertEquals("foo", getJavaEntity().getSpecifiedDiscriminatorValue()); discriminatorValue.setValue(null); + getJpaProject().synchronizeContextModel(); assertNull(getJavaEntity().getSpecifiedDiscriminatorValue()); assertNull(typeResource.getAnnotation(DiscriminatorValueAnnotation.ANNOTATION_NAME)); @@ -1010,6 +1018,7 @@ public class JavaEntityTests extends ContextModelTestCase ((SecondaryTableAnnotation) typeResource.addAnnotation(0, SecondaryTableAnnotation.ANNOTATION_NAME, SecondaryTablesAnnotation.ANNOTATION_NAME)).setName("FOO"); ((SecondaryTableAnnotation) typeResource.addAnnotation(1, SecondaryTableAnnotation.ANNOTATION_NAME, SecondaryTablesAnnotation.ANNOTATION_NAME)).setName("BAR"); ((SecondaryTableAnnotation) typeResource.addAnnotation(2, SecondaryTableAnnotation.ANNOTATION_NAME, SecondaryTablesAnnotation.ANNOTATION_NAME)).setName("BAZ"); + getJpaProject().synchronizeContextModel(); ListIterator<SecondaryTable> secondaryTables = entity.specifiedSecondaryTables(); assertEquals("FOO", secondaryTables.next().getName()); @@ -1018,6 +1027,7 @@ public class JavaEntityTests extends ContextModelTestCase assertFalse(secondaryTables.hasNext()); typeResource.moveAnnotation(2, 0, SecondaryTablesAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); secondaryTables = entity.specifiedSecondaryTables(); assertEquals("BAR", secondaryTables.next().getName()); assertEquals("BAZ", secondaryTables.next().getName()); @@ -1025,6 +1035,7 @@ public class JavaEntityTests extends ContextModelTestCase assertFalse(secondaryTables.hasNext()); typeResource.moveAnnotation(0, 1, SecondaryTablesAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); secondaryTables = entity.specifiedSecondaryTables(); assertEquals("BAZ", secondaryTables.next().getName()); assertEquals("BAR", secondaryTables.next().getName()); @@ -1032,17 +1043,20 @@ public class JavaEntityTests extends ContextModelTestCase assertFalse(secondaryTables.hasNext()); typeResource.removeAnnotation(1, SecondaryTableAnnotation.ANNOTATION_NAME, SecondaryTablesAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); secondaryTables = entity.specifiedSecondaryTables(); assertEquals("BAZ", secondaryTables.next().getName()); assertEquals("FOO", secondaryTables.next().getName()); assertFalse(secondaryTables.hasNext()); typeResource.removeAnnotation(1, SecondaryTableAnnotation.ANNOTATION_NAME, SecondaryTablesAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); secondaryTables = entity.specifiedSecondaryTables(); assertEquals("BAZ", secondaryTables.next().getName()); assertFalse(secondaryTables.hasNext()); typeResource.removeAnnotation(0, SecondaryTableAnnotation.ANNOTATION_NAME, SecondaryTablesAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); secondaryTables = entity.specifiedSecondaryTables(); assertFalse(secondaryTables.hasNext()); } @@ -1116,6 +1130,7 @@ public class JavaEntityTests extends ContextModelTestCase JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME); SecondaryTableAnnotation secondaryTable = (SecondaryTableAnnotation) typeResource.addAnnotation(0, JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES); secondaryTable.setName("FOO"); + getJpaProject().synchronizeContextModel(); assertEquals(1, getJavaEntity().secondaryTablesSize()); assertEquals("FOO", getJavaEntity().secondaryTables().next().getSpecifiedName()); @@ -1123,6 +1138,7 @@ public class JavaEntityTests extends ContextModelTestCase SecondaryTableAnnotation secondaryTable2 = (SecondaryTableAnnotation) typeResource.addAnnotation(1, JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES); secondaryTable2.setName("BAR"); + getJpaProject().synchronizeContextModel(); assertEquals(2, getJavaEntity().secondaryTablesSize()); ListIterator<JavaSecondaryTable> secondaryTables = getJavaEntity().secondaryTables(); @@ -1131,6 +1147,7 @@ public class JavaEntityTests extends ContextModelTestCase SecondaryTableAnnotation secondaryTable3 = (SecondaryTableAnnotation) typeResource.addAnnotation(0, JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES); secondaryTable3.setName("BAZ"); + getJpaProject().synchronizeContextModel(); assertEquals(3, getJavaEntity().secondaryTablesSize()); secondaryTables = getJavaEntity().secondaryTables(); @@ -1167,6 +1184,7 @@ public class JavaEntityTests extends ContextModelTestCase typeResource.removeAnnotation(0, JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES); + getJpaProject().synchronizeContextModel(); secondaryTables = getJavaEntity().secondaryTables(); assertEquals(0, getJavaEntity().secondaryTablesSize()); @@ -1182,6 +1200,7 @@ public class JavaEntityTests extends ContextModelTestCase JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME); typeResource.addAnnotation(JPA.SEQUENCE_GENERATOR); + getJpaProject().synchronizeContextModel(); assertNotNull(getJavaEntity().getGeneratorContainer().getSequenceGenerator()); assertEquals(2, typeResource.annotationsSize()); @@ -1219,6 +1238,7 @@ public class JavaEntityTests extends ContextModelTestCase JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME); typeResource.addAnnotation(JPA.SEQUENCE_GENERATOR); + getJpaProject().synchronizeContextModel(); getJavaEntity().getGeneratorContainer().removeSequenceGenerator(); @@ -1243,6 +1263,7 @@ public class JavaEntityTests extends ContextModelTestCase JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME); typeResource.addAnnotation(JPA.TABLE_GENERATOR); + getJpaProject().synchronizeContextModel(); assertNotNull(getJavaEntity().getGeneratorContainer().getTableGenerator()); assertEquals(2, typeResource.annotationsSize()); @@ -1280,6 +1301,7 @@ public class JavaEntityTests extends ContextModelTestCase JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME); typeResource.addAnnotation(JPA.TABLE_GENERATOR); + getJpaProject().synchronizeContextModel(); getJavaEntity().getGeneratorContainer().removeTableGenerator(); @@ -1304,14 +1326,17 @@ public class JavaEntityTests extends ContextModelTestCase JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME); DiscriminatorColumnAnnotation column = (DiscriminatorColumnAnnotation) typeResource.addAnnotation(JPA.DISCRIMINATOR_COLUMN); column.setName("foo"); + getJpaProject().synchronizeContextModel(); assertEquals("foo", getJavaEntity().getDiscriminatorColumn().getSpecifiedName()); column.setName(null); + getJpaProject().synchronizeContextModel(); assertNull(getJavaEntity().getDiscriminatorColumn().getSpecifiedName()); typeResource.removeAnnotation(JPA.DISCRIMINATOR_COLUMN); + getJpaProject().synchronizeContextModel(); assertNotNull(getJavaEntity().getDiscriminatorColumn()); } @@ -1329,12 +1354,14 @@ public class JavaEntityTests extends ContextModelTestCase //add an annotation to the resource model and verify the context model is updated PrimaryKeyJoinColumnAnnotation pkJoinColumn = (PrimaryKeyJoinColumnAnnotation) typeResource.addAnnotation(0, JPA.PRIMARY_KEY_JOIN_COLUMN, JPA.PRIMARY_KEY_JOIN_COLUMNS); pkJoinColumn.setName("FOO"); + getJpaProject().synchronizeContextModel(); specifiedPkJoinColumns = getJavaEntity().specifiedPrimaryKeyJoinColumns(); assertEquals("FOO", specifiedPkJoinColumns.next().getName()); assertFalse(specifiedPkJoinColumns.hasNext()); pkJoinColumn = (PrimaryKeyJoinColumnAnnotation) typeResource.addAnnotation(0, JPA.PRIMARY_KEY_JOIN_COLUMN, JPA.PRIMARY_KEY_JOIN_COLUMNS); pkJoinColumn.setName("BAR"); + getJpaProject().synchronizeContextModel(); specifiedPkJoinColumns = getJavaEntity().specifiedPrimaryKeyJoinColumns(); assertEquals("BAR", specifiedPkJoinColumns.next().getName()); assertEquals("FOO", specifiedPkJoinColumns.next().getName()); @@ -1343,6 +1370,7 @@ public class JavaEntityTests extends ContextModelTestCase pkJoinColumn = (PrimaryKeyJoinColumnAnnotation) typeResource.addAnnotation(0, JPA.PRIMARY_KEY_JOIN_COLUMN, JPA.PRIMARY_KEY_JOIN_COLUMNS); pkJoinColumn.setName("BAZ"); + getJpaProject().synchronizeContextModel(); specifiedPkJoinColumns = getJavaEntity().specifiedPrimaryKeyJoinColumns(); assertEquals("BAZ", specifiedPkJoinColumns.next().getName()); assertEquals("BAR", specifiedPkJoinColumns.next().getName()); @@ -1351,6 +1379,7 @@ public class JavaEntityTests extends ContextModelTestCase //move an annotation to the resource model and verify the context model is updated typeResource.moveAnnotation(1, 0, JPA.PRIMARY_KEY_JOIN_COLUMNS); + getJpaProject().synchronizeContextModel(); specifiedPkJoinColumns = getJavaEntity().specifiedPrimaryKeyJoinColumns(); assertEquals("BAR", specifiedPkJoinColumns.next().getName()); assertEquals("BAZ", specifiedPkJoinColumns.next().getName()); @@ -1358,18 +1387,21 @@ public class JavaEntityTests extends ContextModelTestCase assertFalse(specifiedPkJoinColumns.hasNext()); typeResource.removeAnnotation(0, JPA.PRIMARY_KEY_JOIN_COLUMN, JPA.PRIMARY_KEY_JOIN_COLUMNS); + getJpaProject().synchronizeContextModel(); specifiedPkJoinColumns = getJavaEntity().specifiedPrimaryKeyJoinColumns(); assertEquals("BAZ", specifiedPkJoinColumns.next().getName()); assertEquals("FOO", specifiedPkJoinColumns.next().getName()); assertFalse(specifiedPkJoinColumns.hasNext()); typeResource.removeAnnotation(0, JPA.PRIMARY_KEY_JOIN_COLUMN, JPA.PRIMARY_KEY_JOIN_COLUMNS); + getJpaProject().synchronizeContextModel(); specifiedPkJoinColumns = getJavaEntity().specifiedPrimaryKeyJoinColumns(); assertEquals("FOO", specifiedPkJoinColumns.next().getName()); assertFalse(specifiedPkJoinColumns.hasNext()); typeResource.removeAnnotation(0, JPA.PRIMARY_KEY_JOIN_COLUMN, JPA.PRIMARY_KEY_JOIN_COLUMNS); + getJpaProject().synchronizeContextModel(); specifiedPkJoinColumns = getJavaEntity().specifiedPrimaryKeyJoinColumns(); assertFalse(specifiedPkJoinColumns.hasNext()); } @@ -1541,6 +1573,7 @@ public class JavaEntityTests extends ContextModelTestCase ((PrimaryKeyJoinColumnAnnotation) typeResource.addAnnotation(0, PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME, PrimaryKeyJoinColumnsAnnotation.ANNOTATION_NAME)).setName("FOO"); ((PrimaryKeyJoinColumnAnnotation) typeResource.addAnnotation(1, PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME, PrimaryKeyJoinColumnsAnnotation.ANNOTATION_NAME)).setName("BAR"); ((PrimaryKeyJoinColumnAnnotation) typeResource.addAnnotation(2, PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME, PrimaryKeyJoinColumnsAnnotation.ANNOTATION_NAME)).setName("BAZ"); + getJpaProject().synchronizeContextModel(); ListIterator<PrimaryKeyJoinColumn> primaryKeyJoinColumns = entity.specifiedPrimaryKeyJoinColumns(); assertEquals("FOO", primaryKeyJoinColumns.next().getName()); @@ -1549,6 +1582,7 @@ public class JavaEntityTests extends ContextModelTestCase assertFalse(primaryKeyJoinColumns.hasNext()); typeResource.moveAnnotation(2, 0, PrimaryKeyJoinColumnsAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); primaryKeyJoinColumns = entity.specifiedPrimaryKeyJoinColumns(); assertEquals("BAR", primaryKeyJoinColumns.next().getName()); assertEquals("BAZ", primaryKeyJoinColumns.next().getName()); @@ -1556,6 +1590,7 @@ public class JavaEntityTests extends ContextModelTestCase assertFalse(primaryKeyJoinColumns.hasNext()); typeResource.moveAnnotation(0, 1, PrimaryKeyJoinColumnsAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); primaryKeyJoinColumns = entity.specifiedPrimaryKeyJoinColumns(); assertEquals("BAZ", primaryKeyJoinColumns.next().getName()); assertEquals("BAR", primaryKeyJoinColumns.next().getName()); @@ -1563,17 +1598,20 @@ public class JavaEntityTests extends ContextModelTestCase assertFalse(primaryKeyJoinColumns.hasNext()); typeResource.removeAnnotation(1, PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME, PrimaryKeyJoinColumnsAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); primaryKeyJoinColumns = entity.specifiedPrimaryKeyJoinColumns(); assertEquals("BAZ", primaryKeyJoinColumns.next().getName()); assertEquals("FOO", primaryKeyJoinColumns.next().getName()); assertFalse(primaryKeyJoinColumns.hasNext()); typeResource.removeAnnotation(1, PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME, PrimaryKeyJoinColumnsAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); primaryKeyJoinColumns = entity.specifiedPrimaryKeyJoinColumns(); assertEquals("BAZ", primaryKeyJoinColumns.next().getName()); assertFalse(primaryKeyJoinColumns.hasNext()); typeResource.removeAnnotation(0, PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME, PrimaryKeyJoinColumnsAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); primaryKeyJoinColumns = entity.specifiedPrimaryKeyJoinColumns(); assertFalse(primaryKeyJoinColumns.hasNext()); } @@ -1752,12 +1790,14 @@ public class JavaEntityTests extends ContextModelTestCase //add an annotation to the resource model and verify the context model is updated AttributeOverrideAnnotation attributeOverride = (AttributeOverrideAnnotation) typeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES); attributeOverride.setName("FOO"); + getJpaProject().synchronizeContextModel(); specifiedAttributeOverrides = overrideContainer.specifiedAttributeOverrides(); assertEquals("FOO", specifiedAttributeOverrides.next().getName()); assertFalse(specifiedAttributeOverrides.hasNext()); attributeOverride = (AttributeOverrideAnnotation) typeResource.addAnnotation(1, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES); attributeOverride.setName("BAR"); + getJpaProject().synchronizeContextModel(); specifiedAttributeOverrides = overrideContainer.specifiedAttributeOverrides(); assertEquals("FOO", specifiedAttributeOverrides.next().getName()); assertEquals("BAR", specifiedAttributeOverrides.next().getName()); @@ -1766,6 +1806,7 @@ public class JavaEntityTests extends ContextModelTestCase attributeOverride = (AttributeOverrideAnnotation) typeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES); attributeOverride.setName("BAZ"); + getJpaProject().synchronizeContextModel(); specifiedAttributeOverrides = overrideContainer.specifiedAttributeOverrides(); assertEquals("BAZ", specifiedAttributeOverrides.next().getName()); assertEquals("FOO", specifiedAttributeOverrides.next().getName()); @@ -1774,6 +1815,7 @@ public class JavaEntityTests extends ContextModelTestCase //move an annotation to the resource model and verify the context model is updated typeResource.moveAnnotation(1, 0, JPA.ATTRIBUTE_OVERRIDES); + getJpaProject().synchronizeContextModel(); specifiedAttributeOverrides = overrideContainer.specifiedAttributeOverrides(); assertEquals("FOO", specifiedAttributeOverrides.next().getName()); assertEquals("BAZ", specifiedAttributeOverrides.next().getName()); @@ -1781,18 +1823,21 @@ public class JavaEntityTests extends ContextModelTestCase assertFalse(specifiedAttributeOverrides.hasNext()); typeResource.removeAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES); + getJpaProject().synchronizeContextModel(); specifiedAttributeOverrides = overrideContainer.specifiedAttributeOverrides(); assertEquals("BAZ", specifiedAttributeOverrides.next().getName()); assertEquals("BAR", specifiedAttributeOverrides.next().getName()); assertFalse(specifiedAttributeOverrides.hasNext()); typeResource.removeAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES); + getJpaProject().synchronizeContextModel(); specifiedAttributeOverrides = overrideContainer.specifiedAttributeOverrides(); assertEquals("BAR", specifiedAttributeOverrides.next().getName()); assertFalse(specifiedAttributeOverrides.hasNext()); typeResource.removeAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES); + getJpaProject().synchronizeContextModel(); specifiedAttributeOverrides = overrideContainer.specifiedAttributeOverrides(); assertFalse(specifiedAttributeOverrides.hasNext()); } @@ -1961,6 +2006,7 @@ public class JavaEntityTests extends ContextModelTestCase attributeOverride.setName("FOO"); attributeOverride = (AttributeOverrideAnnotation) typeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES); attributeOverride.setName("BAR"); + getJpaProject().synchronizeContextModel(); assertEquals(2, overrideContainer.specifiedAttributeOverridesSize()); } @@ -2153,6 +2199,7 @@ public class JavaEntityTests extends ContextModelTestCase ((AttributeOverrideAnnotation) typeResource.addAnnotation(0, AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME)).setName("FOO"); ((AttributeOverrideAnnotation) typeResource.addAnnotation(1, AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME)).setName("BAR"); ((AttributeOverrideAnnotation) typeResource.addAnnotation(2, AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME)).setName("BAZ"); + getJpaProject().synchronizeContextModel(); ListIterator<AttributeOverride> attributeOverrides = overrideContainer.specifiedAttributeOverrides(); assertEquals("FOO", attributeOverrides.next().getName()); @@ -2161,6 +2208,7 @@ public class JavaEntityTests extends ContextModelTestCase assertFalse(attributeOverrides.hasNext()); typeResource.moveAnnotation(2, 0, AttributeOverridesAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); attributeOverrides = overrideContainer.specifiedAttributeOverrides(); assertEquals("BAR", attributeOverrides.next().getName()); assertEquals("BAZ", attributeOverrides.next().getName()); @@ -2168,6 +2216,7 @@ public class JavaEntityTests extends ContextModelTestCase assertFalse(attributeOverrides.hasNext()); typeResource.moveAnnotation(0, 1, AttributeOverridesAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); attributeOverrides = overrideContainer.specifiedAttributeOverrides(); assertEquals("BAZ", attributeOverrides.next().getName()); assertEquals("BAR", attributeOverrides.next().getName()); @@ -2175,17 +2224,20 @@ public class JavaEntityTests extends ContextModelTestCase assertFalse(attributeOverrides.hasNext()); typeResource.removeAnnotation(1, AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); attributeOverrides = overrideContainer.specifiedAttributeOverrides(); assertEquals("BAZ", attributeOverrides.next().getName()); assertEquals("FOO", attributeOverrides.next().getName()); assertFalse(attributeOverrides.hasNext()); typeResource.removeAnnotation(1, AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); attributeOverrides = overrideContainer.specifiedAttributeOverrides(); assertEquals("BAZ", attributeOverrides.next().getName()); assertFalse(attributeOverrides.hasNext()); typeResource.removeAnnotation(0, AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); attributeOverrides = overrideContainer.specifiedAttributeOverrides(); assertFalse(attributeOverrides.hasNext()); } @@ -2294,12 +2346,14 @@ public class JavaEntityTests extends ContextModelTestCase //add an annotation to the resource model and verify the context model is updated AssociationOverrideAnnotation associationOverride = (AssociationOverrideAnnotation) typeResource.addAnnotation(0, JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES); associationOverride.setName("FOO"); + getJpaProject().synchronizeContextModel(); specifiedAssociationOverrides = overrideContainer.specifiedAssociationOverrides(); assertEquals("FOO", specifiedAssociationOverrides.next().getName()); assertFalse(specifiedAssociationOverrides.hasNext()); associationOverride = (AssociationOverrideAnnotation) typeResource.addAnnotation(1, JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES); associationOverride.setName("BAR"); + getJpaProject().synchronizeContextModel(); specifiedAssociationOverrides = overrideContainer.specifiedAssociationOverrides(); assertEquals("FOO", specifiedAssociationOverrides.next().getName()); assertEquals("BAR", specifiedAssociationOverrides.next().getName()); @@ -2308,6 +2362,7 @@ public class JavaEntityTests extends ContextModelTestCase associationOverride = (AssociationOverrideAnnotation) typeResource.addAnnotation(0, JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES); associationOverride.setName("BAZ"); + getJpaProject().synchronizeContextModel(); specifiedAssociationOverrides = overrideContainer.specifiedAssociationOverrides(); assertEquals("BAZ", specifiedAssociationOverrides.next().getName()); assertEquals("FOO", specifiedAssociationOverrides.next().getName()); @@ -2316,6 +2371,7 @@ public class JavaEntityTests extends ContextModelTestCase //move an annotation to the resource model and verify the context model is updated typeResource.moveAnnotation(1, 0, JPA.ASSOCIATION_OVERRIDES); + getJpaProject().synchronizeContextModel(); specifiedAssociationOverrides = overrideContainer.specifiedAssociationOverrides(); assertEquals("FOO", specifiedAssociationOverrides.next().getName()); assertEquals("BAZ", specifiedAssociationOverrides.next().getName()); @@ -2323,18 +2379,21 @@ public class JavaEntityTests extends ContextModelTestCase assertFalse(specifiedAssociationOverrides.hasNext()); typeResource.removeAnnotation(0, JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES); + getJpaProject().synchronizeContextModel(); specifiedAssociationOverrides = overrideContainer.specifiedAssociationOverrides(); assertEquals("BAZ", specifiedAssociationOverrides.next().getName()); assertEquals("BAR", specifiedAssociationOverrides.next().getName()); assertFalse(specifiedAssociationOverrides.hasNext()); typeResource.removeAnnotation(0, JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES); + getJpaProject().synchronizeContextModel(); specifiedAssociationOverrides = overrideContainer.specifiedAssociationOverrides(); assertEquals("BAR", specifiedAssociationOverrides.next().getName()); assertFalse(specifiedAssociationOverrides.hasNext()); typeResource.removeAnnotation(0, JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES); + getJpaProject().synchronizeContextModel(); specifiedAssociationOverrides = overrideContainer.specifiedAssociationOverrides(); assertFalse(specifiedAssociationOverrides.hasNext()); } @@ -2481,6 +2540,7 @@ public class JavaEntityTests extends ContextModelTestCase associationOverride.setName("FOO"); associationOverride = (AssociationOverrideAnnotation) typeResource.addAnnotation(0, JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES); associationOverride.setName("BAR"); + getJpaProject().synchronizeContextModel(); assertEquals(2, overrideContainer.specifiedAssociationOverridesSize()); } @@ -2648,6 +2708,7 @@ public class JavaEntityTests extends ContextModelTestCase ((AssociationOverrideAnnotation) typeResource.addAnnotation(0, AssociationOverrideAnnotation.ANNOTATION_NAME, AssociationOverridesAnnotation.ANNOTATION_NAME)).setName("FOO"); ((AssociationOverrideAnnotation) typeResource.addAnnotation(1, AssociationOverrideAnnotation.ANNOTATION_NAME, AssociationOverridesAnnotation.ANNOTATION_NAME)).setName("BAR"); ((AssociationOverrideAnnotation) typeResource.addAnnotation(2, AssociationOverrideAnnotation.ANNOTATION_NAME, AssociationOverridesAnnotation.ANNOTATION_NAME)).setName("BAZ"); + getJpaProject().synchronizeContextModel(); ListIterator<AssociationOverride> associationOverrides = overrideContainer.specifiedAssociationOverrides(); assertEquals("FOO", associationOverrides.next().getName()); @@ -2656,6 +2717,7 @@ public class JavaEntityTests extends ContextModelTestCase assertFalse(associationOverrides.hasNext()); typeResource.moveAnnotation(2, 0, AssociationOverridesAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); associationOverrides = overrideContainer.specifiedAssociationOverrides(); assertEquals("BAR", associationOverrides.next().getName()); assertEquals("BAZ", associationOverrides.next().getName()); @@ -2663,6 +2725,7 @@ public class JavaEntityTests extends ContextModelTestCase assertFalse(associationOverrides.hasNext()); typeResource.moveAnnotation(0, 1, AssociationOverridesAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); associationOverrides = overrideContainer.specifiedAssociationOverrides(); assertEquals("BAZ", associationOverrides.next().getName()); assertEquals("BAR", associationOverrides.next().getName()); @@ -2670,17 +2733,20 @@ public class JavaEntityTests extends ContextModelTestCase assertFalse(associationOverrides.hasNext()); typeResource.removeAnnotation(1, AssociationOverrideAnnotation.ANNOTATION_NAME, AssociationOverridesAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); associationOverrides = overrideContainer.specifiedAssociationOverrides(); assertEquals("BAZ", associationOverrides.next().getName()); assertEquals("FOO", associationOverrides.next().getName()); assertFalse(associationOverrides.hasNext()); typeResource.removeAnnotation(1, AssociationOverrideAnnotation.ANNOTATION_NAME, AssociationOverridesAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); associationOverrides = overrideContainer.specifiedAssociationOverrides(); assertEquals("BAZ", associationOverrides.next().getName()); assertFalse(associationOverrides.hasNext()); typeResource.removeAnnotation(0, AssociationOverrideAnnotation.ANNOTATION_NAME, AssociationOverridesAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); associationOverrides = overrideContainer.specifiedAssociationOverrides(); assertFalse(associationOverrides.hasNext()); } @@ -2799,6 +2865,7 @@ public class JavaEntityTests extends ContextModelTestCase NamedNativeQueryAnnotation nativeQuery = (NamedNativeQueryAnnotation) typeResource.addAnnotation(0, JPA.NAMED_NATIVE_QUERY, JPA.NAMED_NATIVE_QUERIES); nativeQuery.setName("BAR"); + getJpaProject().synchronizeContextModel(); assertEquals(1, entity.getQueryContainer().namedNativeQueriesSize()); ListIterator<JavaNamedNativeQuery> namedQueries = entity.getQueryContainer().namedNativeQueries(); @@ -2817,6 +2884,7 @@ public class JavaEntityTests extends ContextModelTestCase NamedQueryAnnotation namedQuery = (NamedQueryAnnotation) typeResource.addAnnotation(0, JPA.NAMED_QUERY, JPA.NAMED_QUERIES); namedQuery.setName("BAR"); + getJpaProject().synchronizeContextModel(); assertEquals(1, entity.getQueryContainer().namedQueriesSize()); ListIterator<JavaNamedQuery> namedQueries = entity.getQueryContainer().namedQueries(); @@ -2874,6 +2942,7 @@ public class JavaEntityTests extends ContextModelTestCase ((NamedQueryAnnotation) typeResource.addAnnotation(0, NamedQueryAnnotation.ANNOTATION_NAME, NamedQueriesAnnotation.ANNOTATION_NAME)).setName("FOO"); ((NamedQueryAnnotation) typeResource.addAnnotation(1, NamedQueryAnnotation.ANNOTATION_NAME, NamedQueriesAnnotation.ANNOTATION_NAME)).setName("BAR"); ((NamedQueryAnnotation) typeResource.addAnnotation(2, NamedQueryAnnotation.ANNOTATION_NAME, NamedQueriesAnnotation.ANNOTATION_NAME)).setName("BAZ"); + getJpaProject().synchronizeContextModel(); ListIterator<JavaNamedQuery> namedQueries = entity.getQueryContainer().namedQueries(); assertEquals("FOO", namedQueries.next().getName()); assertEquals("BAR", namedQueries.next().getName()); @@ -2882,6 +2951,7 @@ public class JavaEntityTests extends ContextModelTestCase assertEquals(3, entity.getPersistenceUnit().queriesSize()); typeResource.moveAnnotation(2, 0, NamedQueriesAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); namedQueries = entity.getQueryContainer().namedQueries(); assertEquals("BAR", namedQueries.next().getName()); assertEquals("BAZ", namedQueries.next().getName()); @@ -2889,6 +2959,7 @@ public class JavaEntityTests extends ContextModelTestCase assertFalse(namedQueries.hasNext()); typeResource.moveAnnotation(0, 1, NamedQueriesAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); namedQueries = entity.getQueryContainer().namedQueries(); assertEquals("BAZ", namedQueries.next().getName()); assertEquals("BAR", namedQueries.next().getName()); @@ -2896,6 +2967,7 @@ public class JavaEntityTests extends ContextModelTestCase assertFalse(namedQueries.hasNext()); typeResource.removeAnnotation(1, NamedQueryAnnotation.ANNOTATION_NAME, NamedQueriesAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); namedQueries = entity.getQueryContainer().namedQueries(); assertEquals("BAZ", namedQueries.next().getName()); assertEquals("FOO", namedQueries.next().getName()); @@ -2903,12 +2975,14 @@ public class JavaEntityTests extends ContextModelTestCase assertEquals(2, entity.getPersistenceUnit().queriesSize()); typeResource.removeAnnotation(1, NamedQueryAnnotation.ANNOTATION_NAME, NamedQueriesAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); namedQueries = entity.getQueryContainer().namedQueries(); assertEquals("BAZ", namedQueries.next().getName()); assertFalse(namedQueries.hasNext()); assertEquals(1, entity.getPersistenceUnit().queriesSize()); typeResource.removeAnnotation(0, NamedQueryAnnotation.ANNOTATION_NAME, NamedQueriesAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); namedQueries = entity.getQueryContainer().namedQueries(); assertFalse(namedQueries.hasNext()); assertEquals(0, entity.getPersistenceUnit().queriesSize()); @@ -3051,6 +3125,7 @@ public class JavaEntityTests extends ContextModelTestCase ((NamedNativeQueryAnnotation) typeResource.addAnnotation(0, NamedNativeQueryAnnotation.ANNOTATION_NAME, NamedNativeQueriesAnnotation.ANNOTATION_NAME)).setName("FOO"); ((NamedNativeQueryAnnotation) typeResource.addAnnotation(1, NamedNativeQueryAnnotation.ANNOTATION_NAME, NamedNativeQueriesAnnotation.ANNOTATION_NAME)).setName("BAR"); ((NamedNativeQueryAnnotation) typeResource.addAnnotation(2, NamedNativeQueryAnnotation.ANNOTATION_NAME, NamedNativeQueriesAnnotation.ANNOTATION_NAME)).setName("BAZ"); + getJpaProject().synchronizeContextModel(); ListIterator<JavaNamedNativeQuery> namedQueries = entity.getQueryContainer().namedNativeQueries(); assertEquals("FOO", namedQueries.next().getName()); assertEquals("BAR", namedQueries.next().getName()); @@ -3059,6 +3134,7 @@ public class JavaEntityTests extends ContextModelTestCase assertEquals(3, entity.getPersistenceUnit().queriesSize()); typeResource.moveAnnotation(2, 0, NamedNativeQueriesAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); namedQueries = entity.getQueryContainer().namedNativeQueries(); assertEquals("BAR", namedQueries.next().getName()); assertEquals("BAZ", namedQueries.next().getName()); @@ -3066,6 +3142,7 @@ public class JavaEntityTests extends ContextModelTestCase assertFalse(namedQueries.hasNext()); typeResource.moveAnnotation(0, 1, NamedNativeQueriesAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); namedQueries = entity.getQueryContainer().namedNativeQueries(); assertEquals("BAZ", namedQueries.next().getName()); assertEquals("BAR", namedQueries.next().getName()); @@ -3073,6 +3150,7 @@ public class JavaEntityTests extends ContextModelTestCase assertFalse(namedQueries.hasNext()); typeResource.removeAnnotation(1, NamedNativeQueryAnnotation.ANNOTATION_NAME, NamedNativeQueriesAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); namedQueries = entity.getQueryContainer().namedNativeQueries(); assertEquals("BAZ", namedQueries.next().getName()); assertEquals("FOO", namedQueries.next().getName()); @@ -3080,12 +3158,14 @@ public class JavaEntityTests extends ContextModelTestCase assertEquals(2, entity.getPersistenceUnit().queriesSize()); typeResource.removeAnnotation(1, NamedNativeQueryAnnotation.ANNOTATION_NAME, NamedNativeQueriesAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); namedQueries = entity.getQueryContainer().namedNativeQueries(); assertEquals("BAZ", namedQueries.next().getName()); assertFalse(namedQueries.hasNext()); assertEquals(1, entity.getPersistenceUnit().queriesSize()); typeResource.removeAnnotation(0, NamedNativeQueryAnnotation.ANNOTATION_NAME, NamedNativeQueriesAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); namedQueries = entity.getQueryContainer().namedNativeQueries(); assertFalse(namedQueries.hasNext()); assertEquals(0, entity.getPersistenceUnit().queriesSize()); @@ -3117,15 +3197,18 @@ public class JavaEntityTests extends ContextModelTestCase assertNull(typeResource.getAnnotation(IdClassAnnotation.ANNOTATION_NAME)); IdClassAnnotation idClass = (IdClassAnnotation) typeResource.addAnnotation(IdClassAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertNull(getJavaEntity().getIdClass()); assertNotNull(typeResource.getAnnotation(IdClassAnnotation.ANNOTATION_NAME)); idClass.setValue("model.Foo"); + getJpaProject().synchronizeContextModel(); assertEquals("model.Foo", getJavaEntity().getIdClass()); assertEquals("model.Foo", ((IdClassAnnotation) typeResource.getAnnotation(IdClassAnnotation.ANNOTATION_NAME)).getValue()); //test setting @IdClass value to null, IdClass annotation is removed idClass.setValue(null); + getJpaProject().synchronizeContextModel(); assertNull(getJavaEntity().getIdClass()); assertNull(typeResource.getAnnotation(IdClassAnnotation.ANNOTATION_NAME)); @@ -3133,6 +3216,7 @@ public class JavaEntityTests extends ContextModelTestCase idClass = (IdClassAnnotation) typeResource.addAnnotation(IdClassAnnotation.ANNOTATION_NAME); idClass.setValue("model.Foo"); typeResource.removeAnnotation(IdClassAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertNull(getJavaEntity().getIdClass()); assertNull(typeResource.getAnnotation(IdClassAnnotation.ANNOTATION_NAME)); diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaGeneratedValueTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaGeneratedValueTests.java index 74be9b8315..a198b737a1 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaGeneratedValueTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaGeneratedValueTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -62,6 +62,7 @@ public class JavaGeneratedValueTests extends ContextModelTestCase GeneratedValueAnnotation generatedValue = (GeneratedValueAnnotation) attributeResource.getAnnotation(JPA.GENERATED_VALUE); generatedValue.setGenerator("foo"); + getJpaProject().synchronizeContextModel(); assertEquals("foo", idMapping.getGeneratedValue().getGenerator()); } @@ -115,6 +116,7 @@ public class JavaGeneratedValueTests extends ContextModelTestCase GeneratedValueAnnotation generatedValue = (GeneratedValueAnnotation) attributeResource.getAnnotation(JPA.GENERATED_VALUE); generatedValue.setStrategy(org.eclipse.jpt.core.resource.java.GenerationType.IDENTITY); + getJpaProject().synchronizeContextModel(); assertEquals(GenerationType.IDENTITY, idMapping.getGeneratedValue().getStrategy()); assertEquals(GeneratedValue.DEFAULT_STRATEGY, idMapping.getGeneratedValue().getDefaultStrategy()); diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaIdMappingTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaIdMappingTests.java index 72e1139fe5..c06b8b4f93 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaIdMappingTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaIdMappingTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -448,10 +448,12 @@ public class JavaIdMappingTests extends ContextModelTestCase JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next(); TemporalAnnotation temporal = (TemporalAnnotation) attributeResource.addAnnotation(TemporalAnnotation.ANNOTATION_NAME); temporal.setValue(org.eclipse.jpt.core.resource.java.TemporalType.DATE); + getJpaProject().synchronizeContextModel(); assertEquals(TemporalType.DATE, ((TemporalConverter) idMapping.getConverter()).getTemporalType()); attributeResource.removeAnnotation(TemporalAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertEquals(Converter.NO_CONVERTER, idMapping.getConverter().getType()); assertFalse(idMapping.isDefault()); @@ -472,6 +474,7 @@ public class JavaIdMappingTests extends ContextModelTestCase JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next(); ColumnAnnotation column = (ColumnAnnotation) attributeResource.addAnnotation(JPA.COLUMN); column.setName("foo"); + getJpaProject().synchronizeContextModel(); assertEquals("foo", idMapping.getColumn().getSpecifiedName()); assertEquals("foo", idMapping.getColumn().getName()); @@ -489,12 +492,15 @@ public class JavaIdMappingTests extends ContextModelTestCase JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME); JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next(); + getJpaProject().synchronizeContextModel(); attributeResource.addAnnotation(JPA.SEQUENCE_GENERATOR); + getJpaProject().synchronizeContextModel(); assertNotNull(idMapping.getGeneratorContainer().getSequenceGenerator()); assertEquals(2, attributeResource.annotationsSize()); assertEquals(1, idMapping.getPersistenceUnit().generatorsSize()); idMapping.getGeneratorContainer().getSequenceGenerator().setName("foo"); + getJpaProject().synchronizeContextModel(); assertEquals(1, idMapping.getPersistenceUnit().generatorsSize()); } @@ -534,6 +540,7 @@ public class JavaIdMappingTests extends ContextModelTestCase JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME); JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next(); attributeResource.addAnnotation(JPA.SEQUENCE_GENERATOR); + getJpaProject().synchronizeContextModel(); idMapping.getGeneratorContainer().removeSequenceGenerator(); @@ -562,6 +569,7 @@ public class JavaIdMappingTests extends ContextModelTestCase JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME); JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next(); attributeResource.addAnnotation(JPA.TABLE_GENERATOR); + getJpaProject().synchronizeContextModel(); assertNotNull(idMapping.getGeneratorContainer().getTableGenerator()); assertEquals(2, attributeResource.annotationsSize()); assertEquals(1, idMapping.getPersistenceUnit().generatorsSize()); @@ -606,6 +614,7 @@ public class JavaIdMappingTests extends ContextModelTestCase JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME); JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next(); attributeResource.addAnnotation(JPA.TABLE_GENERATOR); + getJpaProject().synchronizeContextModel(); idMapping.getGeneratorContainer().removeTableGenerator(); @@ -634,6 +643,7 @@ public class JavaIdMappingTests extends ContextModelTestCase JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME); JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next(); attributeResource.addAnnotation(JPA.GENERATED_VALUE); + getJpaProject().synchronizeContextModel(); assertNotNull(idMapping.getGeneratedValue()); assertEquals(2, attributeResource.annotationsSize()); @@ -689,7 +699,7 @@ public class JavaIdMappingTests extends ContextModelTestCase JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME); JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next(); attributeResource.addAnnotation(JPA.GENERATED_VALUE); - + getJpaProject().synchronizeContextModel(); idMapping.removeGeneratedValue(); diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaJoinColumnTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaJoinColumnTests.java index 356a7dfaa0..b4066e977c 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaJoinColumnTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaJoinColumnTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Oracle. All rights reserved. + * Copyright (c) 2008, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -107,12 +107,14 @@ public class JavaJoinColumnTests extends ContextModelTestCase //set name in the resource model, verify context model updated javaJoinColumn = (JoinColumnAnnotation) attributeResource.addAnnotation(JoinColumnAnnotation.ANNOTATION_NAME); javaJoinColumn.setName("FOO"); + getJpaProject().synchronizeContextModel(); JavaJoinColumn joinColumn = joinColumns.specifiedJoinColumns().next(); assertEquals("FOO", joinColumn.getSpecifiedName()); assertEquals("FOO", javaJoinColumn.getName()); //set name to null in the resource model, annotation removed, specified join column removed javaJoinColumn.setName(null); + getJpaProject().synchronizeContextModel(); assertEquals(0, joinColumns.specifiedJoinColumnsSize()); assertNull(attributeResource.getAnnotation(JoinColumnAnnotation.ANNOTATION_NAME)); } @@ -206,12 +208,14 @@ public class JavaJoinColumnTests extends ContextModelTestCase javaJoinColumn = (JoinColumnAnnotation) attributeResource.addAnnotation(JoinColumnAnnotation.ANNOTATION_NAME); javaJoinColumn.setName("FOO"); javaJoinColumn.setReferencedColumnName("BAR"); + getJpaProject().synchronizeContextModel(); JavaJoinColumn joinColumn = joinColumns.specifiedJoinColumns().next(); assertEquals("BAR", joinColumn.getSpecifiedReferencedColumnName()); assertEquals("BAR", javaJoinColumn.getReferencedColumnName()); //set referenced column name to null in the resource model, javaJoinColumn.setReferencedColumnName(null); + getJpaProject().synchronizeContextModel(); assertNull(joinColumn.getSpecifiedReferencedColumnName()); assertNull("BAR", javaJoinColumn.getReferencedColumnName()); } @@ -266,12 +270,14 @@ public class JavaJoinColumnTests extends ContextModelTestCase javaJoinColumn = (JoinColumnAnnotation) attributeResource.addAnnotation(JoinColumnAnnotation.ANNOTATION_NAME); javaJoinColumn.setName("FOO"); javaJoinColumn.setTable("BAR"); + getJpaProject().synchronizeContextModel(); JavaJoinColumn joinColumn = joinColumns.specifiedJoinColumns().next(); assertEquals("BAR", joinColumn.getSpecifiedTable()); assertEquals("BAR", javaJoinColumn.getTable()); //set table to null in the resource model, javaJoinColumn.setTable(null); + getJpaProject().synchronizeContextModel(); assertNull(joinColumn.getSpecifiedTable()); assertNull("BAR", javaJoinColumn.getTable()); } @@ -327,12 +333,14 @@ public class JavaJoinColumnTests extends ContextModelTestCase javaJoinColumn = (JoinColumnAnnotation) attributeResource.addAnnotation(JoinColumnAnnotation.ANNOTATION_NAME); javaJoinColumn.setName("FOO"); javaJoinColumn.setUnique(Boolean.TRUE); + getJpaProject().synchronizeContextModel(); JavaJoinColumn joinColumn = joinColumns.specifiedJoinColumns().next(); assertEquals(Boolean.TRUE, joinColumn.getSpecifiedUnique()); assertEquals(Boolean.TRUE, javaJoinColumn.getUnique()); //set unique to null in the resource model, javaJoinColumn.setUnique(null); + getJpaProject().synchronizeContextModel(); assertNull(joinColumn.getSpecifiedUnique()); assertNull(javaJoinColumn.getUnique()); } @@ -383,12 +391,14 @@ public class JavaJoinColumnTests extends ContextModelTestCase javaJoinColumn = (JoinColumnAnnotation) attributeResource.addAnnotation(JoinColumnAnnotation.ANNOTATION_NAME); javaJoinColumn.setName("FOO"); javaJoinColumn.setNullable(Boolean.FALSE); + getJpaProject().synchronizeContextModel(); JavaJoinColumn joinColumn = joinColumns.specifiedJoinColumns().next(); assertEquals(Boolean.FALSE, joinColumn.getSpecifiedNullable()); assertEquals(Boolean.FALSE, javaJoinColumn.getNullable()); //set nullable to null in the resource model, javaJoinColumn.setNullable(null); + getJpaProject().synchronizeContextModel(); assertNull(joinColumn.getSpecifiedNullable()); assertNull(javaJoinColumn.getNullable()); } @@ -439,12 +449,14 @@ public class JavaJoinColumnTests extends ContextModelTestCase javaJoinColumn = (JoinColumnAnnotation) attributeResource.addAnnotation(JoinColumnAnnotation.ANNOTATION_NAME); javaJoinColumn.setName("FOO"); javaJoinColumn.setInsertable(Boolean.FALSE); + getJpaProject().synchronizeContextModel(); JavaJoinColumn joinColumn = joinColumns.specifiedJoinColumns().next(); assertEquals(Boolean.FALSE, joinColumn.getSpecifiedInsertable()); assertEquals(Boolean.FALSE, javaJoinColumn.getInsertable()); //set insertable to null in the resource model, javaJoinColumn.setInsertable(null); + getJpaProject().synchronizeContextModel(); assertNull(joinColumn.getSpecifiedInsertable()); assertNull(javaJoinColumn.getInsertable()); } @@ -495,12 +507,14 @@ public class JavaJoinColumnTests extends ContextModelTestCase javaJoinColumn = (JoinColumnAnnotation) attributeResource.addAnnotation(JoinColumnAnnotation.ANNOTATION_NAME); javaJoinColumn.setName("FOO"); javaJoinColumn.setUpdatable(Boolean.FALSE); + getJpaProject().synchronizeContextModel(); JavaJoinColumn joinColumn = joinColumns.specifiedJoinColumns().next(); assertEquals(Boolean.FALSE, joinColumn.getSpecifiedUpdatable()); assertEquals(Boolean.FALSE, javaJoinColumn.getUpdatable()); //set updatable to null in the resource model, javaJoinColumn.setUpdatable(null); + getJpaProject().synchronizeContextModel(); assertNull(joinColumn.getSpecifiedUpdatable()); assertNull(javaJoinColumn.getUpdatable()); } diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaJoinTableTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaJoinTableTests.java index 9665063442..0ef50c7341 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaJoinTableTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaJoinTableTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -111,19 +111,23 @@ public class JavaJoinTableTests extends ContextModelTestCase attributeResource.addAnnotation(JoinTableAnnotation.ANNOTATION_NAME); javaJoinTable = (JoinTableAnnotation) attributeResource.getAnnotation(JoinTableAnnotation.ANNOTATION_NAME); javaJoinTable.setName("FOO"); + getJpaProject().synchronizeContextModel(); assertEquals("FOO", joinTable.getSpecifiedName()); assertEquals("FOO", javaJoinTable.getName()); //set name to null in the resource model javaJoinTable.setName(null); + getJpaProject().synchronizeContextModel(); assertNull(joinTable.getSpecifiedName()); assertNull(javaJoinTable.getName()); javaJoinTable.setName("FOO"); + getJpaProject().synchronizeContextModel(); assertEquals("FOO", joinTable.getSpecifiedName()); assertEquals("FOO", javaJoinTable.getName()); attributeResource.removeAnnotation(JoinTableAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertNull(joinTable.getSpecifiedName()); assertNull(attributeResource.getAnnotation(JoinTableAnnotation.ANNOTATION_NAME)); } @@ -217,19 +221,23 @@ public class JavaJoinTableTests extends ContextModelTestCase attributeResource.addAnnotation(JoinTableAnnotation.ANNOTATION_NAME); javaJoinTable = (JoinTableAnnotation) attributeResource.getAnnotation(JoinTableAnnotation.ANNOTATION_NAME); javaJoinTable.setSchema("FOO"); + getJpaProject().synchronizeContextModel(); assertEquals("FOO", joinTable.getSpecifiedSchema()); assertEquals("FOO", javaJoinTable.getSchema()); //set schema to null in the resource model javaJoinTable.setSchema(null); + getJpaProject().synchronizeContextModel(); assertNull(joinTable.getSpecifiedSchema()); assertNull(javaJoinTable.getSchema()); javaJoinTable.setSchema("FOO"); + getJpaProject().synchronizeContextModel(); assertEquals("FOO", joinTable.getSpecifiedSchema()); assertEquals("FOO", javaJoinTable.getSchema()); attributeResource.removeAnnotation(JoinTableAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertNull(joinTable.getSpecifiedSchema()); assertNull(attributeResource.getAnnotation(JoinTableAnnotation.ANNOTATION_NAME)); } @@ -281,19 +289,23 @@ public class JavaJoinTableTests extends ContextModelTestCase attributeResource.addAnnotation(JoinTableAnnotation.ANNOTATION_NAME); javaJoinTable = (JoinTableAnnotation) attributeResource.getAnnotation(JoinTableAnnotation.ANNOTATION_NAME); javaJoinTable.setCatalog("FOO"); + getJpaProject().synchronizeContextModel(); assertEquals("FOO", joinTable.getSpecifiedCatalog()); assertEquals("FOO", javaJoinTable.getCatalog()); //set catalog to null in the resource model javaJoinTable.setCatalog(null); + getJpaProject().synchronizeContextModel(); assertNull(joinTable.getSpecifiedCatalog()); assertNull(javaJoinTable.getCatalog()); javaJoinTable.setCatalog("FOO"); + getJpaProject().synchronizeContextModel(); assertEquals("FOO", joinTable.getSpecifiedCatalog()); assertEquals("FOO", javaJoinTable.getCatalog()); attributeResource.removeAnnotation(JoinTableAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertNull(joinTable.getSpecifiedCatalog()); assertNull(attributeResource.getAnnotation(JoinTableAnnotation.ANNOTATION_NAME)); } @@ -456,6 +468,7 @@ public class JavaJoinTableTests extends ContextModelTestCase joinTableResource.joinColumnAt(0).setName("FOO"); joinTableResource.joinColumnAt(1).setName("BAR"); joinTableResource.joinColumnAt(2).setName("BAZ"); + getJpaProject().synchronizeContextModel(); ListIterator<JoinColumn> joinColumns = joinTable.specifiedJoinColumns(); assertEquals("FOO", joinColumns.next().getName()); @@ -464,6 +477,7 @@ public class JavaJoinTableTests extends ContextModelTestCase assertFalse(joinColumns.hasNext()); joinTableResource.moveJoinColumn(2, 0); + getJpaProject().synchronizeContextModel(); joinColumns = joinTable.specifiedJoinColumns(); assertEquals("BAR", joinColumns.next().getName()); assertEquals("BAZ", joinColumns.next().getName()); @@ -471,6 +485,7 @@ public class JavaJoinTableTests extends ContextModelTestCase assertFalse(joinColumns.hasNext()); joinTableResource.moveJoinColumn(0, 1); + getJpaProject().synchronizeContextModel(); joinColumns = joinTable.specifiedJoinColumns(); assertEquals("BAZ", joinColumns.next().getName()); assertEquals("BAR", joinColumns.next().getName()); @@ -478,17 +493,20 @@ public class JavaJoinTableTests extends ContextModelTestCase assertFalse(joinColumns.hasNext()); joinTableResource.removeJoinColumn(1); + getJpaProject().synchronizeContextModel(); joinColumns = joinTable.specifiedJoinColumns(); assertEquals("BAZ", joinColumns.next().getName()); assertEquals("FOO", joinColumns.next().getName()); assertFalse(joinColumns.hasNext()); joinTableResource.removeJoinColumn(1); + getJpaProject().synchronizeContextModel(); joinColumns = joinTable.specifiedJoinColumns(); assertEquals("BAZ", joinColumns.next().getName()); assertFalse(joinColumns.hasNext()); joinTableResource.removeJoinColumn(0); + getJpaProject().synchronizeContextModel(); assertFalse(joinTable.specifiedJoinColumns().hasNext()); } @@ -667,6 +685,7 @@ public class JavaJoinTableTests extends ContextModelTestCase joinTableResource.inverseJoinColumnAt(0).setName("FOO"); joinTableResource.inverseJoinColumnAt(1).setName("BAR"); joinTableResource.inverseJoinColumnAt(2).setName("BAZ"); + getJpaProject().synchronizeContextModel(); ListIterator<JoinColumn> inverseJoinColumns = joinTable.specifiedInverseJoinColumns(); assertEquals("FOO", inverseJoinColumns.next().getName()); @@ -675,6 +694,7 @@ public class JavaJoinTableTests extends ContextModelTestCase assertFalse(inverseJoinColumns.hasNext()); joinTableResource.moveInverseJoinColumn(2, 0); + getJpaProject().synchronizeContextModel(); inverseJoinColumns = joinTable.specifiedInverseJoinColumns(); assertEquals("BAR", inverseJoinColumns.next().getName()); assertEquals("BAZ", inverseJoinColumns.next().getName()); @@ -682,6 +702,7 @@ public class JavaJoinTableTests extends ContextModelTestCase assertFalse(inverseJoinColumns.hasNext()); joinTableResource.moveInverseJoinColumn(0, 1); + getJpaProject().synchronizeContextModel(); inverseJoinColumns = joinTable.specifiedInverseJoinColumns(); assertEquals("BAZ", inverseJoinColumns.next().getName()); assertEquals("BAR", inverseJoinColumns.next().getName()); @@ -689,17 +710,20 @@ public class JavaJoinTableTests extends ContextModelTestCase assertFalse(inverseJoinColumns.hasNext()); joinTableResource.removeInverseJoinColumn(1); + getJpaProject().synchronizeContextModel(); inverseJoinColumns = joinTable.specifiedInverseJoinColumns(); assertEquals("BAZ", inverseJoinColumns.next().getName()); assertEquals("FOO", inverseJoinColumns.next().getName()); assertFalse(inverseJoinColumns.hasNext()); joinTableResource.removeInverseJoinColumn(1); + getJpaProject().synchronizeContextModel(); inverseJoinColumns = joinTable.specifiedInverseJoinColumns(); assertEquals("BAZ", inverseJoinColumns.next().getName()); assertFalse(inverseJoinColumns.hasNext()); joinTableResource.removeInverseJoinColumn(0); + getJpaProject().synchronizeContextModel(); assertFalse(joinTable.specifiedInverseJoinColumns().hasNext()); } @@ -762,6 +786,7 @@ public class JavaJoinTableTests extends ContextModelTestCase JoinTableAnnotation joinTableAnnotation = (JoinTableAnnotation) attributeResource.addAnnotation(JoinTableAnnotation.ANNOTATION_NAME); joinTableAnnotation.addUniqueConstraint(0).addColumnName(0, "foo"); joinTableAnnotation.addUniqueConstraint(0).addColumnName(0, "bar"); + getJpaProject().synchronizeContextModel(); uniqueConstraints = joinTable.uniqueConstraints(); assertTrue(uniqueConstraints.hasNext()); @@ -930,7 +955,7 @@ public class JavaJoinTableTests extends ContextModelTestCase joinTableAnnotation.addUniqueConstraint(0).addColumnName("FOO"); joinTableAnnotation.addUniqueConstraint(1).addColumnName("BAR"); joinTableAnnotation.addUniqueConstraint(2).addColumnName("BAZ"); - + getJpaProject().synchronizeContextModel(); ListIterator<UniqueConstraint> uniqueConstraints = joinTable.uniqueConstraints(); assertEquals("FOO", uniqueConstraints.next().columnNames().next()); @@ -939,6 +964,7 @@ public class JavaJoinTableTests extends ContextModelTestCase assertFalse(uniqueConstraints.hasNext()); joinTableAnnotation.moveUniqueConstraint(2, 0); + getJpaProject().synchronizeContextModel(); uniqueConstraints = joinTable.uniqueConstraints(); assertEquals("BAR", uniqueConstraints.next().columnNames().next()); assertEquals("BAZ", uniqueConstraints.next().columnNames().next()); @@ -946,6 +972,7 @@ public class JavaJoinTableTests extends ContextModelTestCase assertFalse(uniqueConstraints.hasNext()); joinTableAnnotation.moveUniqueConstraint(0, 1); + getJpaProject().synchronizeContextModel(); uniqueConstraints = joinTable.uniqueConstraints(); assertEquals("BAZ", uniqueConstraints.next().columnNames().next()); assertEquals("BAR", uniqueConstraints.next().columnNames().next()); @@ -953,17 +980,20 @@ public class JavaJoinTableTests extends ContextModelTestCase assertFalse(uniqueConstraints.hasNext()); joinTableAnnotation.removeUniqueConstraint(1); + getJpaProject().synchronizeContextModel(); uniqueConstraints = joinTable.uniqueConstraints(); assertEquals("BAZ", uniqueConstraints.next().columnNames().next()); assertEquals("FOO", uniqueConstraints.next().columnNames().next()); assertFalse(uniqueConstraints.hasNext()); joinTableAnnotation.removeUniqueConstraint(1); + getJpaProject().synchronizeContextModel(); uniqueConstraints = joinTable.uniqueConstraints(); assertEquals("BAZ", uniqueConstraints.next().columnNames().next()); assertFalse(uniqueConstraints.hasNext()); joinTableAnnotation.removeUniqueConstraint(0); + getJpaProject().synchronizeContextModel(); uniqueConstraints = joinTable.uniqueConstraints(); assertFalse(uniqueConstraints.hasNext()); } diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaManyToManyMappingTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaManyToManyMappingTests.java index 66ab5a67ae..4448cea823 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaManyToManyMappingTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaManyToManyMappingTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -534,16 +534,19 @@ public class JavaManyToManyMappingTests extends ContextModelTestCase //set fetch in the resource model, verify context model updated manyToMany.setFetch(org.eclipse.jpt.core.resource.java.FetchType.EAGER); + getJpaProject().synchronizeContextModel(); assertEquals(FetchType.EAGER, manyToManyMapping.getSpecifiedFetch()); assertEquals(org.eclipse.jpt.core.resource.java.FetchType.EAGER, manyToMany.getFetch()); manyToMany.setFetch(org.eclipse.jpt.core.resource.java.FetchType.LAZY); + getJpaProject().synchronizeContextModel(); assertEquals(FetchType.LAZY, manyToManyMapping.getSpecifiedFetch()); assertEquals(org.eclipse.jpt.core.resource.java.FetchType.LAZY, manyToMany.getFetch()); //set fetch to null in the resource model manyToMany.setFetch(null); + getJpaProject().synchronizeContextModel(); assertNull(manyToManyMapping.getSpecifiedFetch()); assertNull(manyToMany.getFetch()); } @@ -593,11 +596,13 @@ public class JavaManyToManyMappingTests extends ContextModelTestCase //set mappedByJoiningStrategy in the resource model, verify context model updated manyToMany.setMappedBy("newMappedBy"); + getJpaProject().synchronizeContextModel(); assertEquals("newMappedBy", manyToManyMapping.getRelationshipReference().getMappedByJoiningStrategy().getMappedByAttribute()); assertEquals("newMappedBy", manyToMany.getMappedBy()); //set mappedByJoiningStrategy to null in the resource model manyToMany.setMappedBy(null); + getJpaProject().synchronizeContextModel(); assertNull(manyToManyMapping.getRelationshipReference().getMappedByJoiningStrategy().getMappedByAttribute()); assertNull(manyToMany.getMappedBy()); } @@ -789,16 +794,19 @@ public class JavaManyToManyMappingTests extends ContextModelTestCase //set mapKey name in the resource model, verify context model updated mapKey.setName("myMapKey"); + getJpaProject().synchronizeContextModel(); assertEquals("myMapKey", manyToManyMapping.getSpecifiedMapKey()); assertEquals("myMapKey", mapKey.getName()); //set mapKey name to null in the resource model mapKey.setName(null); + getJpaProject().synchronizeContextModel(); assertNull(manyToManyMapping.getSpecifiedMapKey()); assertNull(mapKey.getName()); mapKey.setName("myMapKey"); attributeResource.removeAnnotation(MapKeyAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertNull(manyToManyMapping.getSpecifiedMapKey()); assertNull(attributeResource.getAnnotation(MapKeyAnnotation.ANNOTATION_NAME)); } @@ -845,11 +853,13 @@ public class JavaManyToManyMappingTests extends ContextModelTestCase attributeResource.addAnnotation(OrderByAnnotation.ANNOTATION_NAME); OrderByAnnotation orderBy = (OrderByAnnotation) attributeResource.getAnnotation(OrderByAnnotation.ANNOTATION_NAME); orderBy.setValue("newOrderBy"); + getJpaProject().synchronizeContextModel(); assertEquals("newOrderBy", manyToManyMapping.getOrderable().getSpecifiedOrderBy()); assertEquals("newOrderBy", orderBy.getValue()); //set orderBy to null in the resource model attributeResource.removeAnnotation(OrderByAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertNull(manyToManyMapping.getOrderable().getSpecifiedOrderBy()); assertNull(attributeResource.getAnnotation(OrderByAnnotation.ANNOTATION_NAME)); } @@ -894,14 +904,17 @@ public class JavaManyToManyMappingTests extends ContextModelTestCase //set orderBy in the resource model, verify context model updated attributeResource.addAnnotation(OrderByAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertFalse(manyToManyMapping.getOrderable().isNoOrdering()); OrderByAnnotation orderBy = (OrderByAnnotation) attributeResource.getAnnotation(OrderByAnnotation.ANNOTATION_NAME); orderBy.setValue("newOrderBy"); + getJpaProject().synchronizeContextModel(); assertFalse(manyToManyMapping.getOrderable().isNoOrdering()); //set orderBy to null in the resource model attributeResource.removeAnnotation(OrderByAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertTrue(manyToManyMapping.getOrderable().isNoOrdering()); assertNull(attributeResource.getAnnotation(OrderByAnnotation.ANNOTATION_NAME)); } @@ -947,14 +960,17 @@ public class JavaManyToManyMappingTests extends ContextModelTestCase //set orderBy in the resource model, verify context model updated attributeResource.addAnnotation(OrderByAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertTrue(manyToManyMapping.getOrderable().isPkOrdering()); OrderByAnnotation orderBy = (OrderByAnnotation) attributeResource.getAnnotation(OrderByAnnotation.ANNOTATION_NAME); orderBy.setValue("newOrderBy"); + getJpaProject().synchronizeContextModel(); assertFalse(manyToManyMapping.getOrderable().isPkOrdering()); //set orderBy to null in the resource model attributeResource.removeAnnotation(OrderByAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertFalse(manyToManyMapping.getOrderable().isPkOrdering()); assertNull(attributeResource.getAnnotation(OrderByAnnotation.ANNOTATION_NAME)); } @@ -978,10 +994,12 @@ public class JavaManyToManyMappingTests extends ContextModelTestCase OrderByAnnotation orderBy = (OrderByAnnotation) attributeResource.getAnnotation(OrderByAnnotation.ANNOTATION_NAME); orderBy.setValue("newOrderBy"); + getJpaProject().synchronizeContextModel(); assertTrue(manyToManyMapping.getOrderable().isCustomOrdering()); //set orderBy to null in the resource model attributeResource.removeAnnotation(OrderByAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertFalse(manyToManyMapping.getOrderable().isCustomOrdering()); assertNull(attributeResource.getAnnotation(OrderByAnnotation.ANNOTATION_NAME)); } diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaManyToOneMappingTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaManyToOneMappingTests.java index ffc129348d..61a90b25ef 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaManyToOneMappingTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaManyToOneMappingTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -449,15 +449,18 @@ public class JavaManyToOneMappingTests extends ContextModelTestCase //set optional in the resource model, verify context model updated manyToOne.setOptional(Boolean.TRUE); + getJpaProject().synchronizeContextModel(); assertEquals(Boolean.TRUE, manyToOneMapping.getSpecifiedOptional()); assertEquals(Boolean.TRUE, manyToOne.getOptional()); manyToOne.setOptional(Boolean.FALSE); + getJpaProject().synchronizeContextModel(); assertEquals(Boolean.FALSE, manyToOneMapping.getSpecifiedOptional()); assertEquals(Boolean.FALSE, manyToOne.getOptional()); //set optional to null in the resource model manyToOne.setOptional(null); + getJpaProject().synchronizeContextModel(); assertNull(manyToOneMapping.getSpecifiedOptional()); assertNull(manyToOne.getOptional()); } @@ -511,12 +514,14 @@ public class JavaManyToOneMappingTests extends ContextModelTestCase //add an annotation to the resource model and verify the context model is updated JoinColumnAnnotation joinColumn = (JoinColumnAnnotation) attributeResource.addAnnotation(0, JPA.JOIN_COLUMN, JPA.JOIN_COLUMNS); joinColumn.setName("FOO"); + getJpaProject().synchronizeContextModel(); specifiedJoinColumns = joinColumns.specifiedJoinColumns(); assertEquals("FOO", specifiedJoinColumns.next().getName()); assertFalse(specifiedJoinColumns.hasNext()); joinColumn = (JoinColumnAnnotation) attributeResource.addAnnotation(0, JPA.JOIN_COLUMN, JPA.JOIN_COLUMNS); joinColumn.setName("BAR"); + getJpaProject().synchronizeContextModel(); specifiedJoinColumns = joinColumns.specifiedJoinColumns(); assertEquals("BAR", specifiedJoinColumns.next().getName()); assertEquals("FOO", specifiedJoinColumns.next().getName()); @@ -525,6 +530,7 @@ public class JavaManyToOneMappingTests extends ContextModelTestCase joinColumn = (JoinColumnAnnotation) attributeResource.addAnnotation(0, JPA.JOIN_COLUMN, JPA.JOIN_COLUMNS); joinColumn.setName("BAZ"); + getJpaProject().synchronizeContextModel(); specifiedJoinColumns = joinColumns.specifiedJoinColumns(); assertEquals("BAZ", specifiedJoinColumns.next().getName()); assertEquals("BAR", specifiedJoinColumns.next().getName()); @@ -533,6 +539,7 @@ public class JavaManyToOneMappingTests extends ContextModelTestCase //move an annotation to the resource model and verify the context model is updated attributeResource.moveAnnotation(1, 0, JPA.JOIN_COLUMNS); + getJpaProject().synchronizeContextModel(); specifiedJoinColumns = joinColumns.specifiedJoinColumns(); assertEquals("BAR", specifiedJoinColumns.next().getName()); assertEquals("BAZ", specifiedJoinColumns.next().getName()); @@ -540,18 +547,21 @@ public class JavaManyToOneMappingTests extends ContextModelTestCase assertFalse(specifiedJoinColumns.hasNext()); attributeResource.removeAnnotation(0, JPA.JOIN_COLUMN, JPA.JOIN_COLUMNS); + getJpaProject().synchronizeContextModel(); specifiedJoinColumns = joinColumns.specifiedJoinColumns(); assertEquals("BAZ", specifiedJoinColumns.next().getName()); assertEquals("FOO", specifiedJoinColumns.next().getName()); assertFalse(specifiedJoinColumns.hasNext()); attributeResource.removeAnnotation(0, JPA.JOIN_COLUMN, JPA.JOIN_COLUMNS); + getJpaProject().synchronizeContextModel(); specifiedJoinColumns = joinColumns.specifiedJoinColumns(); assertEquals("FOO", specifiedJoinColumns.next().getName()); assertFalse(specifiedJoinColumns.hasNext()); attributeResource.removeAnnotation(0, JPA.JOIN_COLUMN, JPA.JOIN_COLUMNS); + getJpaProject().synchronizeContextModel(); specifiedJoinColumns = joinColumns.specifiedJoinColumns(); assertFalse(specifiedJoinColumns.hasNext()); } @@ -743,6 +753,7 @@ public class JavaManyToOneMappingTests extends ContextModelTestCase ((JoinColumnAnnotation) attributeResource.addAnnotation(0, JoinColumnAnnotation.ANNOTATION_NAME, JoinColumnsAnnotation.ANNOTATION_NAME)).setName("FOO"); ((JoinColumnAnnotation) attributeResource.addAnnotation(1, JoinColumnAnnotation.ANNOTATION_NAME, JoinColumnsAnnotation.ANNOTATION_NAME)).setName("BAR"); ((JoinColumnAnnotation) attributeResource.addAnnotation(2, JoinColumnAnnotation.ANNOTATION_NAME, JoinColumnsAnnotation.ANNOTATION_NAME)).setName("BAZ"); + getJpaProject().synchronizeContextModel(); ListIterator<? extends JoinColumn> joinColumnsIterator = joinColumns.specifiedJoinColumns(); assertEquals("FOO", joinColumnsIterator.next().getName()); @@ -751,6 +762,7 @@ public class JavaManyToOneMappingTests extends ContextModelTestCase assertFalse(joinColumnsIterator.hasNext()); attributeResource.moveAnnotation(2, 0, JoinColumnsAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); joinColumnsIterator = joinColumns.specifiedJoinColumns(); assertEquals("BAR", joinColumnsIterator.next().getName()); assertEquals("BAZ", joinColumnsIterator.next().getName()); @@ -758,6 +770,7 @@ public class JavaManyToOneMappingTests extends ContextModelTestCase assertFalse(joinColumnsIterator.hasNext()); attributeResource.moveAnnotation(0, 1, JoinColumnsAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); joinColumnsIterator = joinColumns.specifiedJoinColumns(); assertEquals("BAZ", joinColumnsIterator.next().getName()); assertEquals("BAR", joinColumnsIterator.next().getName()); @@ -765,17 +778,20 @@ public class JavaManyToOneMappingTests extends ContextModelTestCase assertFalse(joinColumnsIterator.hasNext()); attributeResource.removeAnnotation(1, JoinColumnAnnotation.ANNOTATION_NAME, JoinColumnsAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); joinColumnsIterator = joinColumns.specifiedJoinColumns(); assertEquals("BAZ", joinColumnsIterator.next().getName()); assertEquals("FOO", joinColumnsIterator.next().getName()); assertFalse(joinColumnsIterator.hasNext()); attributeResource.removeAnnotation(1, JoinColumnAnnotation.ANNOTATION_NAME, JoinColumnsAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); joinColumnsIterator = joinColumns.specifiedJoinColumns(); assertEquals("BAZ", joinColumnsIterator.next().getName()); assertFalse(joinColumnsIterator.hasNext()); attributeResource.removeAnnotation(0, JoinColumnAnnotation.ANNOTATION_NAME, JoinColumnsAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); joinColumnsIterator = joinColumns.specifiedJoinColumns(); assertFalse(joinColumnsIterator.hasNext()); } diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaMappedSuperclassTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaMappedSuperclassTests.java index 994b7d28d3..a595c5b2f7 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaMappedSuperclassTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaMappedSuperclassTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -218,6 +218,7 @@ public class JavaMappedSuperclassTests extends ContextModelTestCase idClass = (IdClassAnnotation) typeResource.addAnnotation(IdClassAnnotation.ANNOTATION_NAME); idClass.setValue("model.Foo"); typeResource.removeAnnotation(IdClassAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertNull(mappedSuperclass.getIdClass()); assertNull(typeResource.getAnnotation(IdClassAnnotation.ANNOTATION_NAME)); diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaNamedNativeQueryTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaNamedNativeQueryTests.java index ffd53a9e3b..38a43a72e1 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaNamedNativeQueryTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaNamedNativeQueryTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -62,11 +62,13 @@ public class JavaNamedNativeQueryTests extends ContextModelTestCase //set name to null in the resource model javaNamedNativeQuery.setName(null); + getJpaProject().synchronizeContextModel(); assertNull(javaNamedNativeQuery.getName()); assertNull(namedNativeQuery.getName()); //set name in the resource model, verify context model updated javaNamedNativeQuery.setName("foo"); + getJpaProject().synchronizeContextModel(); assertEquals("foo", javaNamedNativeQuery.getName()); assertEquals("foo", namedNativeQuery.getName()); } @@ -109,11 +111,13 @@ public class JavaNamedNativeQueryTests extends ContextModelTestCase //set name to null in the resource model javaNamedNativeQuery.setQuery(null); + getJpaProject().synchronizeContextModel(); assertNull(javaNamedNativeQuery.getQuery()); assertNull(namedNativeQuery.getQuery()); //set name in the resource model, verify context model updated javaNamedNativeQuery.setQuery("foo"); + getJpaProject().synchronizeContextModel(); assertEquals("foo", javaNamedNativeQuery.getQuery()); assertEquals("foo", namedNativeQuery.getQuery()); } @@ -263,6 +267,7 @@ public class JavaNamedNativeQueryTests extends ContextModelTestCase javaNamedNativeQuery.hintAt(0).setName("FOO"); javaNamedNativeQuery.hintAt(1).setName("BAR"); javaNamedNativeQuery.hintAt(2).setName("BAZ"); + getJpaProject().synchronizeContextModel(); ListIterator<QueryHint> hints = namedNativeQuery.hints(); assertEquals("FOO", hints.next().getName()); @@ -271,6 +276,7 @@ public class JavaNamedNativeQueryTests extends ContextModelTestCase assertFalse(hints.hasNext()); javaNamedNativeQuery.moveHint(2, 0); + getJpaProject().synchronizeContextModel(); hints = namedNativeQuery.hints(); assertEquals("BAR", hints.next().getName()); assertEquals("BAZ", hints.next().getName()); @@ -278,6 +284,7 @@ public class JavaNamedNativeQueryTests extends ContextModelTestCase assertFalse(hints.hasNext()); javaNamedNativeQuery.moveHint(0, 1); + getJpaProject().synchronizeContextModel(); hints = namedNativeQuery.hints(); assertEquals("BAZ", hints.next().getName()); assertEquals("BAR", hints.next().getName()); @@ -285,17 +292,20 @@ public class JavaNamedNativeQueryTests extends ContextModelTestCase assertFalse(hints.hasNext()); javaNamedNativeQuery.removeHint(1); + getJpaProject().synchronizeContextModel(); hints = namedNativeQuery.hints(); assertEquals("BAZ", hints.next().getName()); assertEquals("FOO", hints.next().getName()); assertFalse(hints.hasNext()); javaNamedNativeQuery.removeHint(1); + getJpaProject().synchronizeContextModel(); hints = namedNativeQuery.hints(); assertEquals("BAZ", hints.next().getName()); assertFalse(hints.hasNext()); javaNamedNativeQuery.removeHint(0); + getJpaProject().synchronizeContextModel(); assertFalse(namedNativeQuery.hints().hasNext()); } @@ -312,13 +322,16 @@ public class JavaNamedNativeQueryTests extends ContextModelTestCase javaNamedNativeQuery.addHint(0); + getJpaProject().synchronizeContextModel(); assertEquals(1, namedNativeQuery.hintsSize()); javaNamedNativeQuery.addHint(0); + getJpaProject().synchronizeContextModel(); assertEquals(2, namedNativeQuery.hintsSize()); javaNamedNativeQuery.removeHint(0); javaNamedNativeQuery.removeHint(0); + getJpaProject().synchronizeContextModel(); assertEquals(0, namedNativeQuery.hintsSize()); } @@ -384,11 +397,13 @@ public class JavaNamedNativeQueryTests extends ContextModelTestCase //set name in the resource model, verify context model updated javaNamedNativeQuery.setResultSetMapping("foo"); + getJpaProject().synchronizeContextModel(); assertEquals("foo", javaNamedNativeQuery.getResultSetMapping()); assertEquals("foo", namedNativeQuery.getResultSetMapping()); //set name to null in the resource model javaNamedNativeQuery.setResultSetMapping(null); + getJpaProject().synchronizeContextModel(); assertNull(javaNamedNativeQuery.getResultSetMapping()); assertNull(namedNativeQuery.getResultSetMapping()); } diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaNamedQueryTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaNamedQueryTests.java index 84bdee49d6..56198df7db 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaNamedQueryTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaNamedQueryTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -62,11 +62,13 @@ public class JavaNamedQueryTests extends ContextModelTestCase //set name to null in the resource model javaNamedQuery.setName(null); + getJpaProject().synchronizeContextModel(); assertNull(javaNamedQuery.getName()); assertNull(namedQuery.getName()); //set name in the resource model, verify context model updated javaNamedQuery.setName("foo"); + getJpaProject().synchronizeContextModel(); assertEquals("foo", javaNamedQuery.getName()); assertEquals("foo", namedQuery.getName()); } @@ -109,11 +111,13 @@ public class JavaNamedQueryTests extends ContextModelTestCase //set name to null in the resource model javaNamedQuery.setQuery(null); + getJpaProject().synchronizeContextModel(); assertNull(javaNamedQuery.getQuery()); assertNull(namedQuery.getQuery()); //set name in the resource model, verify context model updated javaNamedQuery.setQuery("foo"); + getJpaProject().synchronizeContextModel(); assertEquals("foo", javaNamedQuery.getQuery()); assertEquals("foo", namedQuery.getQuery()); } @@ -263,7 +267,8 @@ public class JavaNamedQueryTests extends ContextModelTestCase javaNamedQuery.hintAt(0).setName("FOO"); javaNamedQuery.hintAt(1).setName("BAR"); javaNamedQuery.hintAt(2).setName("BAZ"); - + getJpaProject().synchronizeContextModel(); + ListIterator<QueryHint> hints = namedQuery.hints(); assertEquals("FOO", hints.next().getName()); assertEquals("BAR", hints.next().getName()); @@ -271,6 +276,7 @@ public class JavaNamedQueryTests extends ContextModelTestCase assertFalse(hints.hasNext()); javaNamedQuery.moveHint(2, 0); + getJpaProject().synchronizeContextModel(); hints = namedQuery.hints(); assertEquals("BAR", hints.next().getName()); assertEquals("BAZ", hints.next().getName()); @@ -278,6 +284,7 @@ public class JavaNamedQueryTests extends ContextModelTestCase assertFalse(hints.hasNext()); javaNamedQuery.moveHint(0, 1); + getJpaProject().synchronizeContextModel(); hints = namedQuery.hints(); assertEquals("BAZ", hints.next().getName()); assertEquals("BAR", hints.next().getName()); @@ -285,17 +292,20 @@ public class JavaNamedQueryTests extends ContextModelTestCase assertFalse(hints.hasNext()); javaNamedQuery.removeHint(1); + getJpaProject().synchronizeContextModel(); hints = namedQuery.hints(); assertEquals("BAZ", hints.next().getName()); assertEquals("FOO", hints.next().getName()); assertFalse(hints.hasNext()); javaNamedQuery.removeHint(1); + getJpaProject().synchronizeContextModel(); hints = namedQuery.hints(); assertEquals("BAZ", hints.next().getName()); assertFalse(hints.hasNext()); javaNamedQuery.removeHint(0); + getJpaProject().synchronizeContextModel(); assertFalse(namedQuery.hints().hasNext()); } @@ -312,13 +322,16 @@ public class JavaNamedQueryTests extends ContextModelTestCase javaNamedQuery.addHint(0); + getJpaProject().synchronizeContextModel(); assertEquals(1, namedQuery.hintsSize()); javaNamedQuery.addHint(0); + getJpaProject().synchronizeContextModel(); assertEquals(2, namedQuery.hintsSize()); javaNamedQuery.removeHint(0); javaNamedQuery.removeHint(0); + getJpaProject().synchronizeContextModel(); assertEquals(0, namedQuery.hintsSize()); } } diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaOneToManyMappingTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaOneToManyMappingTests.java index fc03be6fff..71c62d35fc 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaOneToManyMappingTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaOneToManyMappingTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -536,16 +536,19 @@ public class JavaOneToManyMappingTests extends ContextModelTestCase //set fetch in the resource model, verify context model updated oneToMany.setFetch(org.eclipse.jpt.core.resource.java.FetchType.EAGER); + getJpaProject().synchronizeContextModel(); assertEquals(FetchType.EAGER, oneToManyMapping.getSpecifiedFetch()); assertEquals(org.eclipse.jpt.core.resource.java.FetchType.EAGER, oneToMany.getFetch()); oneToMany.setFetch(org.eclipse.jpt.core.resource.java.FetchType.LAZY); + getJpaProject().synchronizeContextModel(); assertEquals(FetchType.LAZY, oneToManyMapping.getSpecifiedFetch()); assertEquals(org.eclipse.jpt.core.resource.java.FetchType.LAZY, oneToMany.getFetch()); //set fetch to null in the resource model oneToMany.setFetch(null); + getJpaProject().synchronizeContextModel(); assertNull(oneToManyMapping.getSpecifiedFetch()); assertNull(oneToMany.getFetch()); } @@ -595,11 +598,13 @@ public class JavaOneToManyMappingTests extends ContextModelTestCase //set mappedBy in the resource model, verify context model updated oneToMany.setMappedBy("newMappedBy"); + getJpaProject().synchronizeContextModel(); assertEquals("newMappedBy", oneToManyMapping.getRelationshipReference().getMappedByJoiningStrategy().getMappedByAttribute()); assertEquals("newMappedBy", oneToMany.getMappedBy()); //set mappedBy to null in the resource model oneToMany.setMappedBy(null); + getJpaProject().synchronizeContextModel(); assertNull(oneToManyMapping.getRelationshipReference().getMappedByJoiningStrategy().getMappedByAttribute()); assertNull(oneToMany.getMappedBy()); } @@ -793,16 +798,19 @@ public class JavaOneToManyMappingTests extends ContextModelTestCase //set mapKey name in the resource model, verify context model updated mapKey.setName("myMapKey"); + getJpaProject().synchronizeContextModel(); assertEquals("myMapKey", oneToManyMapping.getSpecifiedMapKey()); assertEquals("myMapKey", mapKey.getName()); //set mapKey name to null in the resource model mapKey.setName(null); + getJpaProject().synchronizeContextModel(); assertNull(oneToManyMapping.getSpecifiedMapKey()); assertNull(mapKey.getName()); mapKey.setName("myMapKey"); attributeResource.removeAnnotation(MapKeyAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertNull(oneToManyMapping.getSpecifiedMapKey()); assertNull(attributeResource.getAnnotation(MapKeyAnnotation.ANNOTATION_NAME)); } @@ -849,11 +857,13 @@ public class JavaOneToManyMappingTests extends ContextModelTestCase attributeResource.addAnnotation(OrderByAnnotation.ANNOTATION_NAME); OrderByAnnotation orderBy = (OrderByAnnotation) attributeResource.getAnnotation(OrderByAnnotation.ANNOTATION_NAME); orderBy.setValue("newOrderBy"); + getJpaProject().synchronizeContextModel(); assertEquals("newOrderBy", oneToManyMapping.getOrderable().getSpecifiedOrderBy()); assertEquals("newOrderBy", orderBy.getValue()); //set orderBy to null in the resource model attributeResource.removeAnnotation(OrderByAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertNull(oneToManyMapping.getOrderable().getSpecifiedOrderBy()); assertNull(attributeResource.getAnnotation(OrderByAnnotation.ANNOTATION_NAME)); } @@ -898,14 +908,17 @@ public class JavaOneToManyMappingTests extends ContextModelTestCase //set orderBy in the resource model, verify context model updated attributeResource.addAnnotation(OrderByAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertFalse(oneToManyMapping.getOrderable().isNoOrdering()); OrderByAnnotation orderBy = (OrderByAnnotation) attributeResource.getAnnotation(OrderByAnnotation.ANNOTATION_NAME); orderBy.setValue("newOrderBy"); + getJpaProject().synchronizeContextModel(); assertFalse(oneToManyMapping.getOrderable().isNoOrdering()); //set orderBy to null in the resource model attributeResource.removeAnnotation(OrderByAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertTrue(oneToManyMapping.getOrderable().isNoOrdering()); assertNull(attributeResource.getAnnotation(OrderByAnnotation.ANNOTATION_NAME)); } @@ -925,14 +938,17 @@ public class JavaOneToManyMappingTests extends ContextModelTestCase //set orderBy in the resource model, verify context model updated attributeResource.addAnnotation(OrderByAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertTrue(oneToManyMapping.getOrderable().isPkOrdering()); OrderByAnnotation orderBy = (OrderByAnnotation) attributeResource.getAnnotation(OrderByAnnotation.ANNOTATION_NAME); orderBy.setValue("newOrderBy"); + getJpaProject().synchronizeContextModel(); assertFalse(oneToManyMapping.getOrderable().isPkOrdering()); //set orderBy to null in the resource model attributeResource.removeAnnotation(OrderByAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertFalse(oneToManyMapping.getOrderable().isPkOrdering()); assertNull(attributeResource.getAnnotation(OrderByAnnotation.ANNOTATION_NAME)); } @@ -956,10 +972,12 @@ public class JavaOneToManyMappingTests extends ContextModelTestCase OrderByAnnotation orderBy = (OrderByAnnotation) attributeResource.getAnnotation(OrderByAnnotation.ANNOTATION_NAME); orderBy.setValue("newOrderBy"); + getJpaProject().synchronizeContextModel(); assertTrue(oneToManyMapping.getOrderable().isCustomOrdering()); //set orderBy to null in the resource model attributeResource.removeAnnotation(OrderByAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertFalse(oneToManyMapping.getOrderable().isCustomOrdering()); assertNull(attributeResource.getAnnotation(OrderByAnnotation.ANNOTATION_NAME)); } diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaOneToOneMappingTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaOneToOneMappingTests.java index 154ed6597a..18f0764263 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaOneToOneMappingTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaOneToOneMappingTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -487,11 +487,13 @@ public class JavaOneToOneMappingTests extends ContextModelTestCase //set mappedBy in the resource model, verify context model updated oneToOne.setMappedBy("newMappedBy"); + getJpaProject().synchronizeContextModel(); assertEquals("newMappedBy", mappedBy.getMappedByAttribute()); assertEquals("newMappedBy", oneToOne.getMappedBy()); //set mappedBy to null in the resource model oneToOne.setMappedBy(null); + getJpaProject().synchronizeContextModel(); assertNull(mappedBy.getMappedByAttribute()); assertNull(oneToOne.getMappedBy()); } @@ -538,16 +540,19 @@ public class JavaOneToOneMappingTests extends ContextModelTestCase //set optional in the resource model, verify context model updated oneToOne.setOptional(Boolean.TRUE); + getJpaProject().synchronizeContextModel(); assertEquals(Boolean.TRUE, oneToOneMapping.getSpecifiedOptional()); assertEquals(Boolean.TRUE, oneToOne.getOptional()); oneToOne.setOptional(Boolean.FALSE); + getJpaProject().synchronizeContextModel(); assertEquals(Boolean.FALSE, oneToOneMapping.getSpecifiedOptional()); assertEquals(Boolean.FALSE, oneToOne.getOptional()); //set optional to null in the resource model oneToOne.setOptional(null); + getJpaProject().synchronizeContextModel(); assertNull(oneToOneMapping.getSpecifiedOptional()); assertNull(oneToOne.getOptional()); } @@ -598,15 +603,18 @@ public class JavaOneToOneMappingTests extends ContextModelTestCase //set fetch in the resource model, verify context model updated oneToOne.setFetch(org.eclipse.jpt.core.resource.java.FetchType.EAGER); + getJpaProject().synchronizeContextModel(); assertEquals(FetchType.EAGER, oneToOneMapping.getSpecifiedFetch()); assertEquals(org.eclipse.jpt.core.resource.java.FetchType.EAGER, oneToOne.getFetch()); oneToOne.setFetch(org.eclipse.jpt.core.resource.java.FetchType.LAZY); + getJpaProject().synchronizeContextModel(); assertEquals(FetchType.LAZY, oneToOneMapping.getSpecifiedFetch()); assertEquals(org.eclipse.jpt.core.resource.java.FetchType.LAZY, oneToOne.getFetch()); //set fetch to null in the resource model oneToOne.setFetch(null); + getJpaProject().synchronizeContextModel(); assertNull(oneToOneMapping.getSpecifiedFetch()); assertNull(oneToOne.getFetch()); } @@ -658,12 +666,14 @@ public class JavaOneToOneMappingTests extends ContextModelTestCase //add an annotation to the resource model and verify the context model is updated JoinColumnAnnotation joinColumn = (JoinColumnAnnotation) attributeResource.addAnnotation(0, JPA.JOIN_COLUMN, JPA.JOIN_COLUMNS); joinColumn.setName("FOO"); + getJpaProject().synchronizeContextModel(); specifiedJoinColumns = joinColumns.specifiedJoinColumns(); assertEquals("FOO", specifiedJoinColumns.next().getName()); assertFalse(specifiedJoinColumns.hasNext()); joinColumn = (JoinColumnAnnotation) attributeResource.addAnnotation(0, JPA.JOIN_COLUMN, JPA.JOIN_COLUMNS); joinColumn.setName("BAR"); + getJpaProject().synchronizeContextModel(); specifiedJoinColumns = joinColumns.specifiedJoinColumns(); assertEquals("BAR", specifiedJoinColumns.next().getName()); assertEquals("FOO", specifiedJoinColumns.next().getName()); @@ -672,6 +682,7 @@ public class JavaOneToOneMappingTests extends ContextModelTestCase joinColumn = (JoinColumnAnnotation) attributeResource.addAnnotation(0, JPA.JOIN_COLUMN, JPA.JOIN_COLUMNS); joinColumn.setName("BAZ"); + getJpaProject().synchronizeContextModel(); specifiedJoinColumns = joinColumns.specifiedJoinColumns(); assertEquals("BAZ", specifiedJoinColumns.next().getName()); assertEquals("BAR", specifiedJoinColumns.next().getName()); @@ -680,6 +691,7 @@ public class JavaOneToOneMappingTests extends ContextModelTestCase //move an annotation to the resource model and verify the context model is updated attributeResource.moveAnnotation(1, 0, JPA.JOIN_COLUMNS); + getJpaProject().synchronizeContextModel(); specifiedJoinColumns = joinColumns.specifiedJoinColumns(); assertEquals("BAR", specifiedJoinColumns.next().getName()); assertEquals("BAZ", specifiedJoinColumns.next().getName()); @@ -687,18 +699,21 @@ public class JavaOneToOneMappingTests extends ContextModelTestCase assertFalse(specifiedJoinColumns.hasNext()); attributeResource.removeAnnotation(0, JPA.JOIN_COLUMN, JPA.JOIN_COLUMNS); + getJpaProject().synchronizeContextModel(); specifiedJoinColumns = joinColumns.specifiedJoinColumns(); assertEquals("BAZ", specifiedJoinColumns.next().getName()); assertEquals("FOO", specifiedJoinColumns.next().getName()); assertFalse(specifiedJoinColumns.hasNext()); attributeResource.removeAnnotation(0, JPA.JOIN_COLUMN, JPA.JOIN_COLUMNS); + getJpaProject().synchronizeContextModel(); specifiedJoinColumns = joinColumns.specifiedJoinColumns(); assertEquals("FOO", specifiedJoinColumns.next().getName()); assertFalse(specifiedJoinColumns.hasNext()); attributeResource.removeAnnotation(0, JPA.JOIN_COLUMN, JPA.JOIN_COLUMNS); + getJpaProject().synchronizeContextModel(); specifiedJoinColumns = joinColumns.specifiedJoinColumns(); assertFalse(specifiedJoinColumns.hasNext()); } @@ -897,6 +912,7 @@ public class JavaOneToOneMappingTests extends ContextModelTestCase ((JoinColumnAnnotation) attributeResource.addAnnotation(0, JoinColumnAnnotation.ANNOTATION_NAME, JoinColumnsAnnotation.ANNOTATION_NAME)).setName("FOO"); ((JoinColumnAnnotation) attributeResource.addAnnotation(1, JoinColumnAnnotation.ANNOTATION_NAME, JoinColumnsAnnotation.ANNOTATION_NAME)).setName("BAR"); ((JoinColumnAnnotation) attributeResource.addAnnotation(2, JoinColumnAnnotation.ANNOTATION_NAME, JoinColumnsAnnotation.ANNOTATION_NAME)).setName("BAZ"); + getJpaProject().synchronizeContextModel(); ListIterator<? extends JoinColumn> joinColumnsIterator = joinColumns.specifiedJoinColumns(); assertEquals("FOO", joinColumnsIterator.next().getName()); @@ -905,6 +921,7 @@ public class JavaOneToOneMappingTests extends ContextModelTestCase assertFalse(joinColumnsIterator.hasNext()); attributeResource.moveAnnotation(2, 0, JoinColumnsAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); joinColumnsIterator = joinColumns.specifiedJoinColumns(); assertEquals("BAR", joinColumnsIterator.next().getName()); assertEquals("BAZ", joinColumnsIterator.next().getName()); @@ -912,6 +929,7 @@ public class JavaOneToOneMappingTests extends ContextModelTestCase assertFalse(joinColumnsIterator.hasNext()); attributeResource.moveAnnotation(0, 1, JoinColumnsAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); joinColumnsIterator = joinColumns.specifiedJoinColumns(); assertEquals("BAZ", joinColumnsIterator.next().getName()); assertEquals("BAR", joinColumnsIterator.next().getName()); @@ -919,17 +937,20 @@ public class JavaOneToOneMappingTests extends ContextModelTestCase assertFalse(joinColumnsIterator.hasNext()); attributeResource.removeAnnotation(1, JoinColumnAnnotation.ANNOTATION_NAME, JoinColumnsAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); joinColumnsIterator = joinColumns.specifiedJoinColumns(); assertEquals("BAZ", joinColumnsIterator.next().getName()); assertEquals("FOO", joinColumnsIterator.next().getName()); assertFalse(joinColumnsIterator.hasNext()); attributeResource.removeAnnotation(1, JoinColumnAnnotation.ANNOTATION_NAME, JoinColumnsAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); joinColumnsIterator = joinColumns.specifiedJoinColumns(); assertEquals("BAZ", joinColumnsIterator.next().getName()); assertFalse(joinColumnsIterator.hasNext()); attributeResource.removeAnnotation(0, JoinColumnAnnotation.ANNOTATION_NAME, JoinColumnsAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); joinColumnsIterator = joinColumns.specifiedJoinColumns(); assertFalse(joinColumnsIterator.hasNext()); } @@ -1109,12 +1130,14 @@ public class JavaOneToOneMappingTests extends ContextModelTestCase //add an annotation to the resource model and verify the context model is updated PrimaryKeyJoinColumnAnnotation joinColumn = (PrimaryKeyJoinColumnAnnotation) attributeResource.addAnnotation(0, JPA.PRIMARY_KEY_JOIN_COLUMN, JPA.PRIMARY_KEY_JOIN_COLUMNS); joinColumn.setName("FOO"); + getJpaProject().synchronizeContextModel(); primaryKeyJoinColumns = strategy.primaryKeyJoinColumns(); assertEquals("FOO", primaryKeyJoinColumns.next().getName()); assertFalse(primaryKeyJoinColumns.hasNext()); joinColumn = (PrimaryKeyJoinColumnAnnotation) attributeResource.addAnnotation(0, JPA.PRIMARY_KEY_JOIN_COLUMN, JPA.PRIMARY_KEY_JOIN_COLUMNS); joinColumn.setName("BAR"); + getJpaProject().synchronizeContextModel(); primaryKeyJoinColumns = strategy.primaryKeyJoinColumns(); assertEquals("BAR", primaryKeyJoinColumns.next().getName()); assertEquals("FOO", primaryKeyJoinColumns.next().getName()); @@ -1123,6 +1146,7 @@ public class JavaOneToOneMappingTests extends ContextModelTestCase joinColumn = (PrimaryKeyJoinColumnAnnotation) attributeResource.addAnnotation(0, JPA.PRIMARY_KEY_JOIN_COLUMN, JPA.PRIMARY_KEY_JOIN_COLUMNS); joinColumn.setName("BAZ"); + getJpaProject().synchronizeContextModel(); primaryKeyJoinColumns = strategy.primaryKeyJoinColumns(); assertEquals("BAZ", primaryKeyJoinColumns.next().getName()); assertEquals("BAR", primaryKeyJoinColumns.next().getName()); @@ -1131,6 +1155,7 @@ public class JavaOneToOneMappingTests extends ContextModelTestCase //move an annotation to the resource model and verify the context model is updated attributeResource.moveAnnotation(1, 0, JPA.PRIMARY_KEY_JOIN_COLUMNS); + getJpaProject().synchronizeContextModel(); primaryKeyJoinColumns = strategy.primaryKeyJoinColumns(); assertEquals("BAR", primaryKeyJoinColumns.next().getName()); assertEquals("BAZ", primaryKeyJoinColumns.next().getName()); @@ -1138,18 +1163,21 @@ public class JavaOneToOneMappingTests extends ContextModelTestCase assertFalse(primaryKeyJoinColumns.hasNext()); attributeResource.removeAnnotation(0, JPA.PRIMARY_KEY_JOIN_COLUMN, JPA.PRIMARY_KEY_JOIN_COLUMNS); + getJpaProject().synchronizeContextModel(); primaryKeyJoinColumns = strategy.primaryKeyJoinColumns(); assertEquals("BAZ", primaryKeyJoinColumns.next().getName()); assertEquals("FOO", primaryKeyJoinColumns.next().getName()); assertFalse(primaryKeyJoinColumns.hasNext()); attributeResource.removeAnnotation(0, JPA.PRIMARY_KEY_JOIN_COLUMN, JPA.PRIMARY_KEY_JOIN_COLUMNS); + getJpaProject().synchronizeContextModel(); primaryKeyJoinColumns = strategy.primaryKeyJoinColumns(); assertEquals("FOO", primaryKeyJoinColumns.next().getName()); assertFalse(primaryKeyJoinColumns.hasNext()); attributeResource.removeAnnotation(0, JPA.PRIMARY_KEY_JOIN_COLUMN, JPA.PRIMARY_KEY_JOIN_COLUMNS); + getJpaProject().synchronizeContextModel(); primaryKeyJoinColumns = strategy.primaryKeyJoinColumns(); assertFalse(primaryKeyJoinColumns.hasNext()); } @@ -1324,6 +1352,7 @@ public class JavaOneToOneMappingTests extends ContextModelTestCase ((PrimaryKeyJoinColumnAnnotation) attributeResource.addAnnotation(0, PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME, PrimaryKeyJoinColumnsAnnotation.ANNOTATION_NAME)).setName("FOO"); ((PrimaryKeyJoinColumnAnnotation) attributeResource.addAnnotation(1, PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME, PrimaryKeyJoinColumnsAnnotation.ANNOTATION_NAME)).setName("BAR"); ((PrimaryKeyJoinColumnAnnotation) attributeResource.addAnnotation(2, PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME, PrimaryKeyJoinColumnsAnnotation.ANNOTATION_NAME)).setName("BAZ"); + getJpaProject().synchronizeContextModel(); ListIterator<PrimaryKeyJoinColumn> joinColumns = strategy.primaryKeyJoinColumns(); assertEquals("FOO", joinColumns.next().getName()); @@ -1332,6 +1361,7 @@ public class JavaOneToOneMappingTests extends ContextModelTestCase assertFalse(joinColumns.hasNext()); attributeResource.moveAnnotation(2, 0, PrimaryKeyJoinColumnsAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); joinColumns = strategy.primaryKeyJoinColumns(); assertEquals("BAR", joinColumns.next().getName()); assertEquals("BAZ", joinColumns.next().getName()); @@ -1339,6 +1369,7 @@ public class JavaOneToOneMappingTests extends ContextModelTestCase assertFalse(joinColumns.hasNext()); attributeResource.moveAnnotation(0, 1, PrimaryKeyJoinColumnsAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); joinColumns = strategy.primaryKeyJoinColumns(); assertEquals("BAZ", joinColumns.next().getName()); assertEquals("BAR", joinColumns.next().getName()); @@ -1346,17 +1377,20 @@ public class JavaOneToOneMappingTests extends ContextModelTestCase assertFalse(joinColumns.hasNext()); attributeResource.removeAnnotation(1, PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME, PrimaryKeyJoinColumnsAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); joinColumns = strategy.primaryKeyJoinColumns(); assertEquals("BAZ", joinColumns.next().getName()); assertEquals("FOO", joinColumns.next().getName()); assertFalse(joinColumns.hasNext()); attributeResource.removeAnnotation(1, PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME, PrimaryKeyJoinColumnsAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); joinColumns = strategy.primaryKeyJoinColumns(); assertEquals("BAZ", joinColumns.next().getName()); assertFalse(joinColumns.hasNext()); attributeResource.removeAnnotation(0, PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME, PrimaryKeyJoinColumnsAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); joinColumns = strategy.primaryKeyJoinColumns(); assertFalse(joinColumns.hasNext()); } diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaPrimaryKeyJoinColumnTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaPrimaryKeyJoinColumnTests.java index c80c08a7e8..c97875c543 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaPrimaryKeyJoinColumnTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaPrimaryKeyJoinColumnTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -79,6 +79,7 @@ public class JavaPrimaryKeyJoinColumnTests extends ContextModelTestCase PrimaryKeyJoinColumnAnnotation pkJoinColumnResource = (PrimaryKeyJoinColumnAnnotation) typeResource.getAnnotation(JPA.PRIMARY_KEY_JOIN_COLUMN); pkJoinColumnResource.setName("FOO"); + getJpaProject().synchronizeContextModel(); specifiedPkJoinColumn = getJavaEntity().specifiedPrimaryKeyJoinColumns().next(); assertEquals("FOO", specifiedPkJoinColumn.getName()); } @@ -145,14 +146,17 @@ public class JavaPrimaryKeyJoinColumnTests extends ContextModelTestCase JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME); PrimaryKeyJoinColumnAnnotation column = (PrimaryKeyJoinColumnAnnotation) typeResource.getAnnotation(JPA.PRIMARY_KEY_JOIN_COLUMN); column.setColumnDefinition(COLUMN_DEFINITION); + getJpaProject().synchronizeContextModel(); assertEquals(COLUMN_DEFINITION, specifiedPkJoinColumn.getColumnDefinition()); column.setColumnDefinition(null); + getJpaProject().synchronizeContextModel(); assertNull(specifiedPkJoinColumn.getColumnDefinition()); typeResource.removeAnnotation(JPA.PRIMARY_KEY_JOIN_COLUMN); + getJpaProject().synchronizeContextModel(); assertEquals(0, getJavaEntity().specifiedPrimaryKeyJoinColumnsSize()); } @@ -185,6 +189,7 @@ public class JavaPrimaryKeyJoinColumnTests extends ContextModelTestCase PrimaryKeyJoinColumnAnnotation pkJoinColumnResource = (PrimaryKeyJoinColumnAnnotation) typeResource.getAnnotation(JPA.PRIMARY_KEY_JOIN_COLUMN); pkJoinColumnResource.setReferencedColumnName("FOO"); + getJpaProject().synchronizeContextModel(); specifiedPkJoinColumn = getJavaEntity().specifiedPrimaryKeyJoinColumns().next(); assertEquals("FOO", specifiedPkJoinColumn.getSpecifiedReferencedColumnName()); } @@ -222,6 +227,7 @@ public class JavaPrimaryKeyJoinColumnTests extends ContextModelTestCase PrimaryKeyJoinColumnAnnotation pkJoinColumnResource = (PrimaryKeyJoinColumnAnnotation) typeResource.getAnnotation(JPA.PRIMARY_KEY_JOIN_COLUMN); pkJoinColumnResource.setReferencedColumnName("FOO"); + getJpaProject().synchronizeContextModel(); PrimaryKeyJoinColumn specifiedPkJoinColumn = getJavaEntity().specifiedPrimaryKeyJoinColumns().next(); assertEquals("FOO", specifiedPkJoinColumn.getReferencedColumnName()); diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaQueryHintTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaQueryHintTests.java index ce4e4d1c25..26db23a73d 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaQueryHintTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaQueryHintTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -60,11 +60,13 @@ public class JavaQueryHintTests extends ContextModelTestCase //set name in the resource model, verify context model updated javaQueryHint.setName("foo"); + getJpaProject().synchronizeContextModel(); assertEquals("foo", javaQueryHint.getName()); assertEquals("foo", queryHint.getName()); //set name to null in the resource model javaQueryHint.setName(null); + getJpaProject().synchronizeContextModel(); assertNull(javaQueryHint.getName()); assertEquals(0, entity.getQueryContainer().namedQueries().next().hintsSize()); } @@ -108,11 +110,13 @@ public class JavaQueryHintTests extends ContextModelTestCase //set name in the resource model, verify context model updated javaQueryhint.setValue("foo"); + getJpaProject().synchronizeContextModel(); assertEquals("foo", javaQueryhint.getValue()); assertEquals("foo", queryHint.getValue()); //set name to null in the resource model javaQueryhint.setValue(null); + getJpaProject().synchronizeContextModel(); assertNull(javaQueryhint.getValue()); assertEquals(0, entity.getQueryContainer().namedQueries().next().hintsSize()); } diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaSecondaryTableTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaSecondaryTableTests.java index 34e6f7cea7..a82efcd67c 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaSecondaryTableTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaSecondaryTableTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -133,6 +133,7 @@ public class JavaSecondaryTableTests extends ContextModelTestCase JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME); SecondaryTableAnnotation table = (SecondaryTableAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLE); table.setName("foo"); + getJpaProject().synchronizeContextModel(); assertEquals("foo", getJavaEntity().secondaryTables().next().getSpecifiedName()); } @@ -145,6 +146,7 @@ public class JavaSecondaryTableTests extends ContextModelTestCase Iterator<NestableAnnotation> secondaryTableResources = typeResource.annotations(JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES); ((SecondaryTableAnnotation) secondaryTableResources.next()).setCatalog("foo"); ((SecondaryTableAnnotation) secondaryTableResources.next()).setCatalog("bar"); + getJpaProject().synchronizeContextModel(); ListIterator<JavaSecondaryTable> secondaryTsbles = getJavaEntity().secondaryTables(); assertEquals("foo", secondaryTsbles.next().getSpecifiedCatalog()); @@ -159,6 +161,7 @@ public class JavaSecondaryTableTests extends ContextModelTestCase Iterator<NestableAnnotation> secondaryTableResources = typeResource.annotations(JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES); ((SecondaryTableAnnotation) secondaryTableResources.next()).setSchema("foo"); ((SecondaryTableAnnotation) secondaryTableResources.next()).setSchema("bar"); + getJpaProject().synchronizeContextModel(); ListIterator<JavaSecondaryTable> secondaryTsbles = getJavaEntity().secondaryTables(); assertEquals("foo", secondaryTsbles.next().getSpecifiedSchema()); @@ -173,6 +176,7 @@ public class JavaSecondaryTableTests extends ContextModelTestCase SecondaryTableAnnotation table = (SecondaryTableAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLE); table.setCatalog("myCatalog"); + getJpaProject().synchronizeContextModel(); assertEquals("myCatalog", getJavaEntity().secondaryTables().next().getSpecifiedCatalog()); assertEquals("myCatalog", getJavaEntity().secondaryTables().next().getCatalog()); @@ -213,6 +217,7 @@ public class JavaSecondaryTableTests extends ContextModelTestCase SecondaryTableAnnotation tableResource = (SecondaryTableAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLE); tableResource.setSchema("mySchema"); + getJpaProject().synchronizeContextModel(); assertEquals("mySchema", getJavaEntity().secondaryTables().next().getSpecifiedSchema()); assertEquals("mySchema", getJavaEntity().secondaryTables().next().getSchema()); @@ -260,12 +265,14 @@ public class JavaSecondaryTableTests extends ContextModelTestCase //add an annotation to the resource model and verify the context model is updated PrimaryKeyJoinColumnAnnotation pkJoinColumn = tableResource.addPkJoinColumn(0); pkJoinColumn.setName("FOO"); + getJpaProject().synchronizeContextModel(); specifiedPkJoinColumns = secondaryTable.specifiedPrimaryKeyJoinColumns(); assertEquals("FOO", specifiedPkJoinColumns.next().getName()); assertFalse(specifiedPkJoinColumns.hasNext()); pkJoinColumn = tableResource.addPkJoinColumn(0); pkJoinColumn.setName("BAR"); + getJpaProject().synchronizeContextModel(); specifiedPkJoinColumns = secondaryTable.specifiedPrimaryKeyJoinColumns(); assertEquals("BAR", specifiedPkJoinColumns.next().getName()); assertEquals("FOO", specifiedPkJoinColumns.next().getName()); @@ -274,17 +281,20 @@ public class JavaSecondaryTableTests extends ContextModelTestCase //move an annotation to the resource model and verify the context model is updated tableResource.movePkJoinColumn(1, 0); + getJpaProject().synchronizeContextModel(); specifiedPkJoinColumns = secondaryTable.specifiedPrimaryKeyJoinColumns(); assertEquals("FOO", specifiedPkJoinColumns.next().getName()); assertEquals("BAR", specifiedPkJoinColumns.next().getName()); assertFalse(specifiedPkJoinColumns.hasNext()); tableResource.removePkJoinColumn(0); + getJpaProject().synchronizeContextModel(); specifiedPkJoinColumns = secondaryTable.specifiedPrimaryKeyJoinColumns(); assertEquals("BAR", specifiedPkJoinColumns.next().getName()); assertFalse(specifiedPkJoinColumns.hasNext()); tableResource.removePkJoinColumn(0); + getJpaProject().synchronizeContextModel(); specifiedPkJoinColumns = secondaryTable.specifiedPrimaryKeyJoinColumns(); assertFalse(specifiedPkJoinColumns.hasNext()); } @@ -538,6 +548,7 @@ public class JavaSecondaryTableTests extends ContextModelTestCase SecondaryTableAnnotation secondaryTableAnnotation = (SecondaryTableAnnotation) resourcePersistentType.getAnnotation(JPA.SECONDARY_TABLE); secondaryTableAnnotation.addUniqueConstraint(0).addColumnName(0, "foo"); secondaryTableAnnotation.addUniqueConstraint(0).addColumnName(0, "bar"); + getJpaProject().synchronizeContextModel(); uniqueConstraints = secondaryTable.uniqueConstraints(); assertTrue(uniqueConstraints.hasNext()); @@ -694,6 +705,7 @@ public class JavaSecondaryTableTests extends ContextModelTestCase secondaryTableAnnotation.addUniqueConstraint(0).addColumnName("FOO"); secondaryTableAnnotation.addUniqueConstraint(1).addColumnName("BAR"); secondaryTableAnnotation.addUniqueConstraint(2).addColumnName("BAZ"); + getJpaProject().synchronizeContextModel(); ListIterator<UniqueConstraint> uniqueConstraints = secondaryTable.uniqueConstraints(); @@ -703,6 +715,7 @@ public class JavaSecondaryTableTests extends ContextModelTestCase assertFalse(uniqueConstraints.hasNext()); secondaryTableAnnotation.moveUniqueConstraint(2, 0); + getJpaProject().synchronizeContextModel(); uniqueConstraints = secondaryTable.uniqueConstraints(); assertEquals("BAR", uniqueConstraints.next().columnNames().next()); assertEquals("BAZ", uniqueConstraints.next().columnNames().next()); @@ -710,6 +723,7 @@ public class JavaSecondaryTableTests extends ContextModelTestCase assertFalse(uniqueConstraints.hasNext()); secondaryTableAnnotation.moveUniqueConstraint(0, 1); + getJpaProject().synchronizeContextModel(); uniqueConstraints = secondaryTable.uniqueConstraints(); assertEquals("BAZ", uniqueConstraints.next().columnNames().next()); assertEquals("BAR", uniqueConstraints.next().columnNames().next()); @@ -717,17 +731,20 @@ public class JavaSecondaryTableTests extends ContextModelTestCase assertFalse(uniqueConstraints.hasNext()); secondaryTableAnnotation.removeUniqueConstraint(1); + getJpaProject().synchronizeContextModel(); uniqueConstraints = secondaryTable.uniqueConstraints(); assertEquals("BAZ", uniqueConstraints.next().columnNames().next()); assertEquals("FOO", uniqueConstraints.next().columnNames().next()); assertFalse(uniqueConstraints.hasNext()); secondaryTableAnnotation.removeUniqueConstraint(1); + getJpaProject().synchronizeContextModel(); uniqueConstraints = secondaryTable.uniqueConstraints(); assertEquals("BAZ", uniqueConstraints.next().columnNames().next()); assertFalse(uniqueConstraints.hasNext()); secondaryTableAnnotation.removeUniqueConstraint(0); + getJpaProject().synchronizeContextModel(); uniqueConstraints = secondaryTable.uniqueConstraints(); assertFalse(uniqueConstraints.hasNext()); } diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaSequenceGeneratorTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaSequenceGeneratorTests.java index f758971830..6923317ade 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaSequenceGeneratorTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaSequenceGeneratorTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -63,6 +63,7 @@ public class JavaSequenceGeneratorTests extends ContextModelTestCase SequenceGeneratorAnnotation sequenceGenerator = (SequenceGeneratorAnnotation) attributeResource.getAnnotation(JPA.SEQUENCE_GENERATOR); sequenceGenerator.setName("foo"); + getJpaProject().synchronizeContextModel(); assertEquals("foo", idMapping.getGeneratorContainer().getSequenceGenerator().getName()); } @@ -115,6 +116,7 @@ public class JavaSequenceGeneratorTests extends ContextModelTestCase SequenceGeneratorAnnotation sequenceGenerator = (SequenceGeneratorAnnotation) attributeResource.getAnnotation(JPA.SEQUENCE_GENERATOR); sequenceGenerator.setInitialValue(Integer.valueOf(82)); + getJpaProject().synchronizeContextModel(); assertEquals(82, idMapping.getGeneratorContainer().getSequenceGenerator().getInitialValue()); assertEquals(Integer.valueOf(82), idMapping.getGeneratorContainer().getSequenceGenerator().getSpecifiedInitialValue()); @@ -165,6 +167,7 @@ public class JavaSequenceGeneratorTests extends ContextModelTestCase SequenceGeneratorAnnotation sequenceGenerator = (SequenceGeneratorAnnotation) attributeResource.getAnnotation(JPA.SEQUENCE_GENERATOR); sequenceGenerator.setAllocationSize(Integer.valueOf(20)); + getJpaProject().synchronizeContextModel(); assertEquals(20, idMapping.getGeneratorContainer().getSequenceGenerator().getAllocationSize()); assertEquals(Integer.valueOf(20), idMapping.getGeneratorContainer().getSequenceGenerator().getSpecifiedAllocationSize()); @@ -216,6 +219,7 @@ public class JavaSequenceGeneratorTests extends ContextModelTestCase SequenceGeneratorAnnotation sequenceGenerator = (SequenceGeneratorAnnotation) attributeResource.getAnnotation(JPA.SEQUENCE_GENERATOR); sequenceGenerator.setSequenceName("mySequenceName"); + getJpaProject().synchronizeContextModel(); assertEquals("mySequenceName", idMapping.getGeneratorContainer().getSequenceGenerator().getSequenceName()); assertEquals("mySequenceName", idMapping.getGeneratorContainer().getSequenceGenerator().getSpecifiedSequenceName()); diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaTableGeneratorTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaTableGeneratorTests.java index 1b8b01a726..8ae71343c3 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaTableGeneratorTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaTableGeneratorTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -72,6 +72,7 @@ public class JavaTableGeneratorTests extends ContextModelTestCase TableGeneratorAnnotation tableGenerator = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR); tableGenerator.setName("foo"); + getJpaProject().synchronizeContextModel(); assertEquals("foo", idMapping.getGeneratorContainer().getTableGenerator().getName()); } @@ -124,6 +125,7 @@ public class JavaTableGeneratorTests extends ContextModelTestCase TableGeneratorAnnotation tableGenerator = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR); tableGenerator.setCatalog("myCatalog"); + getJpaProject().synchronizeContextModel(); assertEquals("myCatalog", idMapping.getGeneratorContainer().getTableGenerator().getCatalog()); assertEquals("myCatalog", idMapping.getGeneratorContainer().getTableGenerator().getSpecifiedCatalog()); @@ -173,6 +175,7 @@ public class JavaTableGeneratorTests extends ContextModelTestCase TableGeneratorAnnotation tableGenerator = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR); tableGenerator.setSchema("mySchema"); + getJpaProject().synchronizeContextModel(); assertEquals("mySchema", idMapping.getGeneratorContainer().getTableGenerator().getSchema()); assertEquals("mySchema", idMapping.getGeneratorContainer().getTableGenerator().getSpecifiedSchema()); @@ -250,6 +253,7 @@ public class JavaTableGeneratorTests extends ContextModelTestCase TableGeneratorAnnotation tableGenerator = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR); tableGenerator.setPkColumnName("myPkColumnName"); + getJpaProject().synchronizeContextModel(); assertEquals("myPkColumnName", idMapping.getGeneratorContainer().getTableGenerator().getPkColumnName()); assertEquals("myPkColumnName", idMapping.getGeneratorContainer().getTableGenerator().getSpecifiedPkColumnName()); @@ -299,6 +303,7 @@ public class JavaTableGeneratorTests extends ContextModelTestCase TableGeneratorAnnotation tableGenerator = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR); tableGenerator.setValueColumnName("myValueColumnName"); + getJpaProject().synchronizeContextModel(); assertEquals("myValueColumnName", idMapping.getGeneratorContainer().getTableGenerator().getValueColumnName()); assertEquals("myValueColumnName", idMapping.getGeneratorContainer().getTableGenerator().getSpecifiedValueColumnName()); @@ -348,6 +353,7 @@ public class JavaTableGeneratorTests extends ContextModelTestCase TableGeneratorAnnotation tableGenerator = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR); tableGenerator.setPkColumnValue("myPkColumnValue"); + getJpaProject().synchronizeContextModel(); assertEquals("myPkColumnValue", idMapping.getGeneratorContainer().getTableGenerator().getPkColumnValue()); assertEquals("myPkColumnValue", idMapping.getGeneratorContainer().getTableGenerator().getSpecifiedPkColumnValue()); @@ -397,6 +403,7 @@ public class JavaTableGeneratorTests extends ContextModelTestCase TableGeneratorAnnotation tableGenerator = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR); tableGenerator.setInitialValue(Integer.valueOf(82)); + getJpaProject().synchronizeContextModel(); assertEquals(82, idMapping.getGeneratorContainer().getTableGenerator().getInitialValue()); assertEquals(Integer.valueOf(82), idMapping.getGeneratorContainer().getTableGenerator().getSpecifiedInitialValue()); @@ -447,6 +454,7 @@ public class JavaTableGeneratorTests extends ContextModelTestCase TableGeneratorAnnotation tableGenerator = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR); tableGenerator.setAllocationSize(Integer.valueOf(20)); + getJpaProject().synchronizeContextModel(); assertEquals(20, idMapping.getGeneratorContainer().getTableGenerator().getAllocationSize()); assertEquals(Integer.valueOf(20), idMapping.getGeneratorContainer().getTableGenerator().getSpecifiedAllocationSize()); @@ -499,6 +507,7 @@ public class JavaTableGeneratorTests extends ContextModelTestCase TableGeneratorAnnotation tableGeneratorAnnotation = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR); tableGeneratorAnnotation.addUniqueConstraint(0).addColumnName(0, "foo"); tableGeneratorAnnotation.addUniqueConstraint(0).addColumnName(0, "bar"); + getJpaProject().synchronizeContextModel(); uniqueConstraints = tableGenerator.uniqueConstraints(); assertTrue(uniqueConstraints.hasNext()); @@ -661,7 +670,7 @@ public class JavaTableGeneratorTests extends ContextModelTestCase tableGeneratorAnnotation.addUniqueConstraint(0).addColumnName("FOO"); tableGeneratorAnnotation.addUniqueConstraint(1).addColumnName("BAR"); tableGeneratorAnnotation.addUniqueConstraint(2).addColumnName("BAZ"); - + getJpaProject().synchronizeContextModel(); ListIterator<UniqueConstraint> uniqueConstraints = tableGenerator.uniqueConstraints(); assertEquals("FOO", uniqueConstraints.next().columnNames().next()); @@ -670,6 +679,7 @@ public class JavaTableGeneratorTests extends ContextModelTestCase assertFalse(uniqueConstraints.hasNext()); tableGeneratorAnnotation.moveUniqueConstraint(2, 0); + getJpaProject().synchronizeContextModel(); uniqueConstraints = tableGenerator.uniqueConstraints(); assertEquals("BAR", uniqueConstraints.next().columnNames().next()); assertEquals("BAZ", uniqueConstraints.next().columnNames().next()); @@ -677,6 +687,7 @@ public class JavaTableGeneratorTests extends ContextModelTestCase assertFalse(uniqueConstraints.hasNext()); tableGeneratorAnnotation.moveUniqueConstraint(0, 1); + getJpaProject().synchronizeContextModel(); uniqueConstraints = tableGenerator.uniqueConstraints(); assertEquals("BAZ", uniqueConstraints.next().columnNames().next()); assertEquals("BAR", uniqueConstraints.next().columnNames().next()); @@ -684,17 +695,20 @@ public class JavaTableGeneratorTests extends ContextModelTestCase assertFalse(uniqueConstraints.hasNext()); tableGeneratorAnnotation.removeUniqueConstraint(1); + getJpaProject().synchronizeContextModel(); uniqueConstraints = tableGenerator.uniqueConstraints(); assertEquals("BAZ", uniqueConstraints.next().columnNames().next()); assertEquals("FOO", uniqueConstraints.next().columnNames().next()); assertFalse(uniqueConstraints.hasNext()); tableGeneratorAnnotation.removeUniqueConstraint(1); + getJpaProject().synchronizeContextModel(); uniqueConstraints = tableGenerator.uniqueConstraints(); assertEquals("BAZ", uniqueConstraints.next().columnNames().next()); assertFalse(uniqueConstraints.hasNext()); tableGeneratorAnnotation.removeUniqueConstraint(0); + getJpaProject().synchronizeContextModel(); uniqueConstraints = tableGenerator.uniqueConstraints(); assertFalse(uniqueConstraints.hasNext()); } diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaTableTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaTableTests.java index cc7ba3d18a..3ab2043cea 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaTableTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaTableTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -241,10 +241,12 @@ public class JavaTableTests extends ContextModelTestCase JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME); TableAnnotation table = (TableAnnotation) typeResource.getAnnotation(JPA.TABLE); table.setName("foo"); + getJpaProject().synchronizeContextModel(); assertEquals("foo", getJavaEntity().getTable().getSpecifiedName()); typeResource.removeAnnotation(JPA.TABLE); + getJpaProject().synchronizeContextModel(); assertNull(getJavaEntity().getTable().getSpecifiedName()); } @@ -256,6 +258,7 @@ public class JavaTableTests extends ContextModelTestCase TableAnnotation table = (TableAnnotation) typeResource.getAnnotation(JPA.TABLE); table.setCatalog("myCatalog"); + getJpaProject().synchronizeContextModel(); assertEquals("myCatalog", getJavaEntity().getTable().getSpecifiedCatalog()); assertEquals("myCatalog", getJavaEntity().getTable().getCatalog()); @@ -332,6 +335,7 @@ public class JavaTableTests extends ContextModelTestCase TableAnnotation table = (TableAnnotation) typeResource.getAnnotation(JPA.TABLE); table.setSchema("mySchema"); + getJpaProject().synchronizeContextModel(); assertEquals("mySchema", getJavaEntity().getTable().getSpecifiedSchema()); assertEquals("mySchema", getJavaEntity().getTable().getSchema()); @@ -374,6 +378,7 @@ public class JavaTableTests extends ContextModelTestCase TableAnnotation tableAnnotation = (TableAnnotation) typeResource.getAnnotation(JPA.TABLE); tableAnnotation.addUniqueConstraint(0).addColumnName(0, "foo"); tableAnnotation.addUniqueConstraint(0).addColumnName(0, "bar"); + getJpaProject().synchronizeContextModel(); uniqueConstraints = getJavaEntity().getTable().uniqueConstraints(); assertTrue(uniqueConstraints.hasNext()); @@ -528,7 +533,7 @@ public class JavaTableTests extends ContextModelTestCase tableAnnotation.addUniqueConstraint(0).addColumnName("FOO"); tableAnnotation.addUniqueConstraint(1).addColumnName("BAR"); tableAnnotation.addUniqueConstraint(2).addColumnName("BAZ"); - + getJpaProject().synchronizeContextModel(); ListIterator<UniqueConstraint> uniqueConstraints = table.uniqueConstraints(); assertEquals("FOO", uniqueConstraints.next().columnNames().next()); @@ -537,6 +542,7 @@ public class JavaTableTests extends ContextModelTestCase assertFalse(uniqueConstraints.hasNext()); tableAnnotation.moveUniqueConstraint(2, 0); + getJpaProject().synchronizeContextModel(); uniqueConstraints = table.uniqueConstraints(); assertEquals("BAR", uniqueConstraints.next().columnNames().next()); assertEquals("BAZ", uniqueConstraints.next().columnNames().next()); @@ -544,6 +550,7 @@ public class JavaTableTests extends ContextModelTestCase assertFalse(uniqueConstraints.hasNext()); tableAnnotation.moveUniqueConstraint(0, 1); + getJpaProject().synchronizeContextModel(); uniqueConstraints = table.uniqueConstraints(); assertEquals("BAZ", uniqueConstraints.next().columnNames().next()); assertEquals("BAR", uniqueConstraints.next().columnNames().next()); @@ -551,17 +558,20 @@ public class JavaTableTests extends ContextModelTestCase assertFalse(uniqueConstraints.hasNext()); tableAnnotation.removeUniqueConstraint(1); + getJpaProject().synchronizeContextModel(); uniqueConstraints = table.uniqueConstraints(); assertEquals("BAZ", uniqueConstraints.next().columnNames().next()); assertEquals("FOO", uniqueConstraints.next().columnNames().next()); assertFalse(uniqueConstraints.hasNext()); tableAnnotation.removeUniqueConstraint(1); + getJpaProject().synchronizeContextModel(); uniqueConstraints = table.uniqueConstraints(); assertEquals("BAZ", uniqueConstraints.next().columnNames().next()); assertFalse(uniqueConstraints.hasNext()); tableAnnotation.removeUniqueConstraint(0); + getJpaProject().synchronizeContextModel(); uniqueConstraints = table.uniqueConstraints(); assertFalse(uniqueConstraints.hasNext()); } diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaVersionMappingTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaVersionMappingTests.java index c978368068..dc6dc9e420 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaVersionMappingTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaVersionMappingTests.java @@ -366,10 +366,12 @@ public class JavaVersionMappingTests extends ContextModelTestCase JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next(); TemporalAnnotation temporal = (TemporalAnnotation) attributeResource.addAnnotation(TemporalAnnotation.ANNOTATION_NAME); temporal.setValue(org.eclipse.jpt.core.resource.java.TemporalType.DATE); + getJpaProject().synchronizeContextModel(); assertEquals(TemporalType.DATE, ((TemporalConverter) versionMapping.getConverter()).getTemporalType()); attributeResource.removeAnnotation(TemporalAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertEquals(Converter.NO_CONVERTER, versionMapping.getConverter().getType()); assertFalse(versionMapping.isDefault()); @@ -390,6 +392,7 @@ public class JavaVersionMappingTests extends ContextModelTestCase JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next(); ColumnAnnotation column = (ColumnAnnotation) attributeResource.addAnnotation(JPA.COLUMN); column.setName("foo"); + getJpaProject().synchronizeContextModel(); assertEquals("foo", versionMapping.getColumn().getSpecifiedName()); assertEquals("foo", versionMapping.getColumn().getName()); diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/persistence/PersistenceUnitTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/persistence/PersistenceUnitTests.java index b2880656c4..c95b9f2740 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/persistence/PersistenceUnitTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/persistence/PersistenceUnitTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -698,16 +698,20 @@ public class PersistenceUnitTests extends ContextModelTestCase assertEquals(1, CollectionTools.size(getPersistenceUnit().impliedClassRefs())); javaType.removeAnnotation(JPA.ENTITY); - assertEquals(0, CollectionTools.size(getPersistenceUnit().impliedClassRefs())); + getJpaProject().synchronizeContextModel(); + assertEquals(0, getPersistenceUnit().impliedClassRefsSize()); javaType.addAnnotation(JPA.EMBEDDABLE); - assertEquals(1, CollectionTools.size(getPersistenceUnit().impliedClassRefs())); + getJpaProject().synchronizeContextModel(); + assertEquals(1, getPersistenceUnit().impliedClassRefsSize()); javaType.removeAnnotation(JPA.EMBEDDABLE); - assertEquals(0, CollectionTools.size(getPersistenceUnit().impliedClassRefs())); + getJpaProject().synchronizeContextModel(); + assertEquals(0, getPersistenceUnit().impliedClassRefsSize()); javaType.addAnnotation(JPA.MAPPED_SUPERCLASS); - assertEquals(1, CollectionTools.size(getPersistenceUnit().impliedClassRefs())); + getJpaProject().synchronizeContextModel(); + assertEquals(1, getPersistenceUnit().impliedClassRefsSize()); } public void testRenamePersistentTypeImpliedClassRefs() throws Exception { diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/java/GenericJavaAssociationOverride2_0Tests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/java/GenericJavaAssociationOverride2_0Tests.java index f2ffe1fd99..b2830ef7a4 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/java/GenericJavaAssociationOverride2_0Tests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/java/GenericJavaAssociationOverride2_0Tests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. + * Copyright (c) 2009, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -142,19 +142,23 @@ public class GenericJavaAssociationOverride2_0Tests extends Generic2_0ContextMod //set name in the resource model, verify context model updated associationOverrideResource.setName("FOO"); + getJpaProject().synchronizeContextModel(); assertEquals("FOO", javaAssociationOverride.getName()); assertEquals("FOO", associationOverrideResource.getName()); //set name to null in the resource model associationOverrideResource.setName(null); + getJpaProject().synchronizeContextModel(); assertNull(javaAssociationOverride.getName()); assertNull(associationOverrideResource.getName()); associationOverrideResource.setName("FOO"); + getJpaProject().synchronizeContextModel(); assertEquals("FOO", javaAssociationOverride.getName()); assertEquals("FOO", associationOverrideResource.getName()); typeResource.removeAnnotation(0, JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES); + getJpaProject().synchronizeContextModel(); assertFalse(overrideContainer.specifiedAssociationOverrides().hasNext()); assertFalse(typeResource.annotations(JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES).hasNext()); } @@ -340,6 +344,7 @@ public class GenericJavaAssociationOverride2_0Tests extends Generic2_0ContextMod associationOverrideResource.joinColumnAt(0).setName("FOO"); associationOverrideResource.joinColumnAt(1).setName("BAR"); associationOverrideResource.joinColumnAt(2).setName("BAZ"); + getJpaProject().synchronizeContextModel(); joinColumns = joiningStrategy.specifiedJoinColumns(); assertEquals("FOO", joinColumns.next().getName()); @@ -349,6 +354,7 @@ public class GenericJavaAssociationOverride2_0Tests extends Generic2_0ContextMod assertFalse(joinColumns.hasNext()); associationOverrideResource.moveJoinColumn(2, 0); + getJpaProject().synchronizeContextModel(); joinColumns = joiningStrategy.specifiedJoinColumns(); assertEquals("BAR", joinColumns.next().getName()); assertEquals("BAZ", joinColumns.next().getName()); @@ -357,6 +363,7 @@ public class GenericJavaAssociationOverride2_0Tests extends Generic2_0ContextMod assertFalse(joinColumns.hasNext()); associationOverrideResource.moveJoinColumn(0, 1); + getJpaProject().synchronizeContextModel(); joinColumns = joiningStrategy.specifiedJoinColumns(); assertEquals("BAZ", joinColumns.next().getName()); assertEquals("BAR", joinColumns.next().getName()); @@ -365,6 +372,7 @@ public class GenericJavaAssociationOverride2_0Tests extends Generic2_0ContextMod assertFalse(joinColumns.hasNext()); associationOverrideResource.removeJoinColumn(1); + getJpaProject().synchronizeContextModel(); joinColumns = joiningStrategy.specifiedJoinColumns(); assertEquals("BAZ", joinColumns.next().getName()); assertEquals("FOO", joinColumns.next().getName()); @@ -372,16 +380,19 @@ public class GenericJavaAssociationOverride2_0Tests extends Generic2_0ContextMod assertFalse(joinColumns.hasNext()); associationOverrideResource.removeJoinColumn(1); + getJpaProject().synchronizeContextModel(); joinColumns = joiningStrategy.specifiedJoinColumns(); assertEquals("BAZ", joinColumns.next().getName()); assertEquals("address_id", joinColumns.next().getName()); assertFalse(joinColumns.hasNext()); associationOverrideResource.removeJoinColumn(0); + getJpaProject().synchronizeContextModel(); joinColumns = joiningStrategy.specifiedJoinColumns(); assertEquals("address_id", joinColumns.next().getName()); associationOverrideResource.removeJoinColumn(0); + getJpaProject().synchronizeContextModel(); assertFalse(joiningStrategy.specifiedJoinColumns().hasNext()); } @@ -398,6 +409,7 @@ public class GenericJavaAssociationOverride2_0Tests extends Generic2_0ContextMod AssociationOverrideAnnotation associationOverrideResource = (AssociationOverrideAnnotation) typeResource.getAnnotation(JPA.ASSOCIATION_OVERRIDE); associationOverrideResource.setName("FOO"); + getJpaProject().synchronizeContextModel(); specifiedAssociationOverride = overrideContainer.specifiedAssociationOverrides().next(); assertEquals("FOO", specifiedAssociationOverride.getName()); } @@ -487,6 +499,7 @@ public class GenericJavaAssociationOverride2_0Tests extends Generic2_0ContextMod AssociationOverride2_0Annotation associationOverrideResource = (AssociationOverride2_0Annotation) typeResource.getAnnotation(JPA.ASSOCIATION_OVERRIDE); associationOverrideResource.getJoinTable().setName("MY_JOIN_TABLE"); + getJpaProject().synchronizeContextModel(); assertEquals("MY_JOIN_TABLE", joiningStrategy.getJoinTable().getSpecifiedName()); associationOverrideResource.getJoinTable().addJoinColumn(0); @@ -496,6 +509,7 @@ public class GenericJavaAssociationOverride2_0Tests extends Generic2_0ContextMod associationOverrideResource.getJoinTable().joinColumnAt(0).setName("FOO"); associationOverrideResource.getJoinTable().joinColumnAt(1).setName("BAR"); associationOverrideResource.getJoinTable().joinColumnAt(2).setName("BAZ"); + getJpaProject().synchronizeContextModel(); ListIterator<JoinColumn> joinColumns = joiningStrategy.getJoinTable().specifiedJoinColumns(); assertEquals("FOO", joinColumns.next().getName()); @@ -504,6 +518,7 @@ public class GenericJavaAssociationOverride2_0Tests extends Generic2_0ContextMod assertFalse(joinColumns.hasNext()); associationOverrideResource.getJoinTable().moveJoinColumn(2, 0); + getJpaProject().synchronizeContextModel(); joinColumns = joiningStrategy.getJoinTable().specifiedJoinColumns(); assertEquals("BAR", joinColumns.next().getName()); assertEquals("BAZ", joinColumns.next().getName()); @@ -511,6 +526,7 @@ public class GenericJavaAssociationOverride2_0Tests extends Generic2_0ContextMod assertFalse(joinColumns.hasNext()); associationOverrideResource.getJoinTable().moveJoinColumn(0, 1); + getJpaProject().synchronizeContextModel(); joinColumns = joiningStrategy.getJoinTable().specifiedJoinColumns(); assertEquals("BAZ", joinColumns.next().getName()); assertEquals("BAR", joinColumns.next().getName()); @@ -518,17 +534,20 @@ public class GenericJavaAssociationOverride2_0Tests extends Generic2_0ContextMod assertFalse(joinColumns.hasNext()); associationOverrideResource.getJoinTable().removeJoinColumn(1); + getJpaProject().synchronizeContextModel(); joinColumns = joiningStrategy.getJoinTable().specifiedJoinColumns(); assertEquals("BAZ", joinColumns.next().getName()); assertEquals("FOO", joinColumns.next().getName()); assertFalse(joinColumns.hasNext()); associationOverrideResource.getJoinTable().removeJoinColumn(1); + getJpaProject().synchronizeContextModel(); joinColumns = joiningStrategy.getJoinTable().specifiedJoinColumns(); assertEquals("BAZ", joinColumns.next().getName()); assertFalse(joinColumns.hasNext()); associationOverrideResource.getJoinTable().removeJoinColumn(0); + getJpaProject().synchronizeContextModel(); assertFalse(joiningStrategy.getJoinTable().specifiedJoinColumns().hasNext()); } diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/java/GenericJavaCollectionTable2_0Tests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/java/GenericJavaCollectionTable2_0Tests.java index f053eaad06..115caa6a91 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/java/GenericJavaCollectionTable2_0Tests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/java/GenericJavaCollectionTable2_0Tests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. + * Copyright (c) 2009, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -89,19 +89,23 @@ public class GenericJavaCollectionTable2_0Tests extends Generic2_0ContextModelTe attributeResource.addAnnotation(CollectionTable2_0Annotation.ANNOTATION_NAME); resourceCollectionTable = (CollectionTable2_0Annotation) attributeResource.getAnnotation(CollectionTable2_0Annotation.ANNOTATION_NAME); resourceCollectionTable.setName("FOO"); + getJpaProject().synchronizeContextModel(); assertEquals("FOO", collectionTable.getSpecifiedName()); assertEquals("FOO", resourceCollectionTable.getName()); //set name to null in the resource model resourceCollectionTable.setName(null); + getJpaProject().synchronizeContextModel(); assertNull(collectionTable.getSpecifiedName()); assertNull(resourceCollectionTable.getName()); resourceCollectionTable.setName("FOO"); + getJpaProject().synchronizeContextModel(); assertEquals("FOO", collectionTable.getSpecifiedName()); assertEquals("FOO", resourceCollectionTable.getName()); attributeResource.removeAnnotation(CollectionTable2_0Annotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertNull(collectionTable.getSpecifiedName()); assertNull(attributeResource.getAnnotation(CollectionTable2_0Annotation.ANNOTATION_NAME)); } @@ -177,19 +181,23 @@ public class GenericJavaCollectionTable2_0Tests extends Generic2_0ContextModelTe attributeResource.addAnnotation(CollectionTable2_0Annotation.ANNOTATION_NAME); resourceCollectionTable = (CollectionTable2_0Annotation) attributeResource.getAnnotation(CollectionTable2_0Annotation.ANNOTATION_NAME); resourceCollectionTable.setSchema("FOO"); + getJpaProject().synchronizeContextModel(); assertEquals("FOO", collectionTable.getSpecifiedSchema()); assertEquals("FOO", resourceCollectionTable.getSchema()); //set schema to null in the resource model resourceCollectionTable.setSchema(null); + getJpaProject().synchronizeContextModel(); assertNull(collectionTable.getSpecifiedSchema()); assertNull(resourceCollectionTable.getSchema()); resourceCollectionTable.setSchema("FOO"); + getJpaProject().synchronizeContextModel(); assertEquals("FOO", collectionTable.getSpecifiedSchema()); assertEquals("FOO", resourceCollectionTable.getSchema()); attributeResource.removeAnnotation(CollectionTable2_0Annotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertNull(collectionTable.getSpecifiedSchema()); assertNull(attributeResource.getAnnotation(CollectionTable2_0Annotation.ANNOTATION_NAME)); } @@ -241,19 +249,23 @@ public class GenericJavaCollectionTable2_0Tests extends Generic2_0ContextModelTe attributeResource.addAnnotation(CollectionTable2_0Annotation.ANNOTATION_NAME); resourceCollectionTable = (CollectionTable2_0Annotation) attributeResource.getAnnotation(CollectionTable2_0Annotation.ANNOTATION_NAME); resourceCollectionTable.setCatalog("FOO"); + getJpaProject().synchronizeContextModel(); assertEquals("FOO", collectionTable.getSpecifiedCatalog()); assertEquals("FOO", resourceCollectionTable.getCatalog()); //set catalog to null in the resource model resourceCollectionTable.setCatalog(null); + getJpaProject().synchronizeContextModel(); assertNull(collectionTable.getSpecifiedCatalog()); assertNull(resourceCollectionTable.getCatalog()); resourceCollectionTable.setCatalog("FOO"); + getJpaProject().synchronizeContextModel(); assertEquals("FOO", collectionTable.getSpecifiedCatalog()); assertEquals("FOO", resourceCollectionTable.getCatalog()); attributeResource.removeAnnotation(CollectionTable2_0Annotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertNull(collectionTable.getSpecifiedCatalog()); assertNull(attributeResource.getAnnotation(CollectionTable2_0Annotation.ANNOTATION_NAME)); } @@ -416,6 +428,7 @@ public class GenericJavaCollectionTable2_0Tests extends Generic2_0ContextModelTe joinTableResource.joinColumnAt(0).setName("FOO"); joinTableResource.joinColumnAt(1).setName("BAR"); joinTableResource.joinColumnAt(2).setName("BAZ"); + getJpaProject().synchronizeContextModel(); ListIterator<JoinColumn> joinColumns = collectionTable.specifiedJoinColumns(); assertEquals("FOO", joinColumns.next().getName()); @@ -424,6 +437,7 @@ public class GenericJavaCollectionTable2_0Tests extends Generic2_0ContextModelTe assertFalse(joinColumns.hasNext()); joinTableResource.moveJoinColumn(2, 0); + getJpaProject().synchronizeContextModel(); joinColumns = collectionTable.specifiedJoinColumns(); assertEquals("BAR", joinColumns.next().getName()); assertEquals("BAZ", joinColumns.next().getName()); @@ -431,6 +445,7 @@ public class GenericJavaCollectionTable2_0Tests extends Generic2_0ContextModelTe assertFalse(joinColumns.hasNext()); joinTableResource.moveJoinColumn(0, 1); + getJpaProject().synchronizeContextModel(); joinColumns = collectionTable.specifiedJoinColumns(); assertEquals("BAZ", joinColumns.next().getName()); assertEquals("BAR", joinColumns.next().getName()); @@ -438,17 +453,20 @@ public class GenericJavaCollectionTable2_0Tests extends Generic2_0ContextModelTe assertFalse(joinColumns.hasNext()); joinTableResource.removeJoinColumn(1); + getJpaProject().synchronizeContextModel(); joinColumns = collectionTable.specifiedJoinColumns(); assertEquals("BAZ", joinColumns.next().getName()); assertEquals("FOO", joinColumns.next().getName()); assertFalse(joinColumns.hasNext()); joinTableResource.removeJoinColumn(1); + getJpaProject().synchronizeContextModel(); joinColumns = collectionTable.specifiedJoinColumns(); assertEquals("BAZ", joinColumns.next().getName()); assertFalse(joinColumns.hasNext()); joinTableResource.removeJoinColumn(0); + getJpaProject().synchronizeContextModel(); assertFalse(collectionTable.specifiedJoinColumns().hasNext()); } @@ -487,6 +505,7 @@ public class GenericJavaCollectionTable2_0Tests extends Generic2_0ContextModelTe CollectionTable2_0Annotation joinTableAnnotation = (CollectionTable2_0Annotation) attributeResource.addAnnotation(CollectionTable2_0Annotation.ANNOTATION_NAME); joinTableAnnotation.addUniqueConstraint(0).addColumnName(0, "foo"); joinTableAnnotation.addUniqueConstraint(0).addColumnName(0, "bar"); + getJpaProject().synchronizeContextModel(); uniqueConstraints = collectionTable.uniqueConstraints(); assertTrue(uniqueConstraints.hasNext()); @@ -655,6 +674,7 @@ public class GenericJavaCollectionTable2_0Tests extends Generic2_0ContextModelTe joinTableAnnotation.addUniqueConstraint(0).addColumnName("FOO"); joinTableAnnotation.addUniqueConstraint(1).addColumnName("BAR"); joinTableAnnotation.addUniqueConstraint(2).addColumnName("BAZ"); + getJpaProject().synchronizeContextModel(); ListIterator<UniqueConstraint> uniqueConstraints = collectionTable.uniqueConstraints(); @@ -664,6 +684,7 @@ public class GenericJavaCollectionTable2_0Tests extends Generic2_0ContextModelTe assertFalse(uniqueConstraints.hasNext()); joinTableAnnotation.moveUniqueConstraint(2, 0); + getJpaProject().synchronizeContextModel(); uniqueConstraints = collectionTable.uniqueConstraints(); assertEquals("BAR", uniqueConstraints.next().columnNames().next()); assertEquals("BAZ", uniqueConstraints.next().columnNames().next()); @@ -671,6 +692,7 @@ public class GenericJavaCollectionTable2_0Tests extends Generic2_0ContextModelTe assertFalse(uniqueConstraints.hasNext()); joinTableAnnotation.moveUniqueConstraint(0, 1); + getJpaProject().synchronizeContextModel(); uniqueConstraints = collectionTable.uniqueConstraints(); assertEquals("BAZ", uniqueConstraints.next().columnNames().next()); assertEquals("BAR", uniqueConstraints.next().columnNames().next()); @@ -678,17 +700,20 @@ public class GenericJavaCollectionTable2_0Tests extends Generic2_0ContextModelTe assertFalse(uniqueConstraints.hasNext()); joinTableAnnotation.removeUniqueConstraint(1); + getJpaProject().synchronizeContextModel(); uniqueConstraints = collectionTable.uniqueConstraints(); assertEquals("BAZ", uniqueConstraints.next().columnNames().next()); assertEquals("FOO", uniqueConstraints.next().columnNames().next()); assertFalse(uniqueConstraints.hasNext()); joinTableAnnotation.removeUniqueConstraint(1); + getJpaProject().synchronizeContextModel(); uniqueConstraints = collectionTable.uniqueConstraints(); assertEquals("BAZ", uniqueConstraints.next().columnNames().next()); assertFalse(uniqueConstraints.hasNext()); joinTableAnnotation.removeUniqueConstraint(0); + getJpaProject().synchronizeContextModel(); uniqueConstraints = collectionTable.uniqueConstraints(); assertFalse(uniqueConstraints.hasNext()); } diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/java/GenericJavaElementCollectionMapping2_0Tests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/java/GenericJavaElementCollectionMapping2_0Tests.java index 3dfc995bea..14eda4dc4f 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/java/GenericJavaElementCollectionMapping2_0Tests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/java/GenericJavaElementCollectionMapping2_0Tests.java @@ -620,15 +620,18 @@ public class GenericJavaElementCollectionMapping2_0Tests extends Generic2_0Conte //set fetch in the resource model, verify context model updated elementCollection.setFetch(org.eclipse.jpt.core.resource.java.FetchType.EAGER); + getJpaProject().synchronizeContextModel(); assertEquals(FetchType.EAGER, elementCollectionMapping.getSpecifiedFetch()); assertEquals(org.eclipse.jpt.core.resource.java.FetchType.EAGER, elementCollection.getFetch()); elementCollection.setFetch(org.eclipse.jpt.core.resource.java.FetchType.LAZY); + getJpaProject().synchronizeContextModel(); assertEquals(FetchType.LAZY, elementCollectionMapping.getSpecifiedFetch()); assertEquals(org.eclipse.jpt.core.resource.java.FetchType.LAZY, elementCollection.getFetch()); //set fetch to null in the resource model elementCollection.setFetch(null); + getJpaProject().synchronizeContextModel(); assertNull(elementCollectionMapping.getSpecifiedFetch()); assertNull(elementCollection.getFetch()); } diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/java/GenericJavaEmbeddedMapping2_0Tests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/java/GenericJavaEmbeddedMapping2_0Tests.java index 95cda494c1..690c87892b 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/java/GenericJavaEmbeddedMapping2_0Tests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/java/GenericJavaEmbeddedMapping2_0Tests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. + * Copyright (c) 2009, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -538,12 +538,14 @@ public class GenericJavaEmbeddedMapping2_0Tests extends Generic2_0ContextModelTe //add an annotation to the resource model and verify the context model is updated AttributeOverrideAnnotation attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES); attributeOverride.setName("FOO"); + getJpaProject().synchronizeContextModel(); specifiedAttributeOverrides = attributeOverrideContainer.specifiedAttributeOverrides(); assertEquals("FOO", specifiedAttributeOverrides.next().getName()); assertFalse(specifiedAttributeOverrides.hasNext()); attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(1, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES); attributeOverride.setName("BAR"); + getJpaProject().synchronizeContextModel(); specifiedAttributeOverrides = attributeOverrideContainer.specifiedAttributeOverrides(); assertEquals("FOO", specifiedAttributeOverrides.next().getName()); assertEquals("BAR", specifiedAttributeOverrides.next().getName()); @@ -552,6 +554,7 @@ public class GenericJavaEmbeddedMapping2_0Tests extends Generic2_0ContextModelTe attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES); attributeOverride.setName("BAZ"); + getJpaProject().synchronizeContextModel(); specifiedAttributeOverrides = attributeOverrideContainer.specifiedAttributeOverrides(); assertEquals("BAZ", specifiedAttributeOverrides.next().getName()); assertEquals("FOO", specifiedAttributeOverrides.next().getName()); @@ -560,6 +563,7 @@ public class GenericJavaEmbeddedMapping2_0Tests extends Generic2_0ContextModelTe //move an annotation to the resource model and verify the context model is updated attributeResource.moveAnnotation(1, 0, JPA.ATTRIBUTE_OVERRIDES); + getJpaProject().synchronizeContextModel(); specifiedAttributeOverrides = attributeOverrideContainer.specifiedAttributeOverrides(); assertEquals("FOO", specifiedAttributeOverrides.next().getName()); assertEquals("BAZ", specifiedAttributeOverrides.next().getName()); @@ -567,18 +571,21 @@ public class GenericJavaEmbeddedMapping2_0Tests extends Generic2_0ContextModelTe assertFalse(specifiedAttributeOverrides.hasNext()); attributeResource.removeAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES); + getJpaProject().synchronizeContextModel(); specifiedAttributeOverrides = attributeOverrideContainer.specifiedAttributeOverrides(); assertEquals("BAZ", specifiedAttributeOverrides.next().getName()); assertEquals("BAR", specifiedAttributeOverrides.next().getName()); assertFalse(specifiedAttributeOverrides.hasNext()); attributeResource.removeAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES); + getJpaProject().synchronizeContextModel(); specifiedAttributeOverrides = attributeOverrideContainer.specifiedAttributeOverrides(); assertEquals("BAR", specifiedAttributeOverrides.next().getName()); assertFalse(specifiedAttributeOverrides.hasNext()); attributeResource.removeAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES); + getJpaProject().synchronizeContextModel(); specifiedAttributeOverrides = attributeOverrideContainer.specifiedAttributeOverrides(); assertFalse(specifiedAttributeOverrides.hasNext()); } @@ -672,6 +679,7 @@ public class GenericJavaEmbeddedMapping2_0Tests extends Generic2_0ContextModelTe AttributeOverrideAnnotation annotation = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES); annotation.setName("city"); + getJpaProject().synchronizeContextModel(); assertEquals(1, attributeOverrideContainer.virtualAttributeOverridesSize()); } @@ -693,6 +701,7 @@ public class GenericJavaEmbeddedMapping2_0Tests extends Generic2_0ContextModelTe attributeOverride.setName("FOO"); attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES); attributeOverride.setName("BAR"); + getJpaProject().synchronizeContextModel(); assertEquals(2, attributeOverrideContainer.specifiedAttributeOverridesSize()); } @@ -715,11 +724,13 @@ public class GenericJavaEmbeddedMapping2_0Tests extends Generic2_0ContextModelTe attributeOverride.setName("FOO"); attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES); attributeOverride.setName("BAR"); + getJpaProject().synchronizeContextModel(); assertEquals(4, attributeOverrideContainer.attributeOverridesSize()); attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES); attributeOverride.setName("city"); + getJpaProject().synchronizeContextModel(); assertEquals(4, attributeOverrideContainer.attributeOverridesSize()); } @@ -739,15 +750,18 @@ public class GenericJavaEmbeddedMapping2_0Tests extends Generic2_0ContextModelTe //add an annotation to the resource model and verify the context model is updated AttributeOverrideAnnotation attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES); attributeOverride.setName("FOO"); + getJpaProject().synchronizeContextModel(); assertEquals(2, attributeOverrideContainer.virtualAttributeOverridesSize()); attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES); attributeOverride.setName("city"); + getJpaProject().synchronizeContextModel(); assertEquals(1, attributeOverrideContainer.virtualAttributeOverridesSize()); attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES); attributeOverride.setName("state"); + getJpaProject().synchronizeContextModel(); assertEquals(0, attributeOverrideContainer.virtualAttributeOverridesSize()); } @@ -852,12 +866,14 @@ public class GenericJavaEmbeddedMapping2_0Tests extends Generic2_0ContextModelTe //add an annotation to the resource model and verify the context model is updated AssociationOverrideAnnotation associationOverride = (AssociationOverrideAnnotation) resourceAttribute.addAnnotation(0, JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES); associationOverride.setName("FOO"); + getJpaProject().synchronizeContextModel(); specifiedAssociationOverrides = overrideContainer.specifiedAssociationOverrides(); assertEquals("FOO", specifiedAssociationOverrides.next().getName()); assertFalse(specifiedAssociationOverrides.hasNext()); associationOverride = (AssociationOverrideAnnotation) resourceAttribute.addAnnotation(1, JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES); associationOverride.setName("BAR"); + getJpaProject().synchronizeContextModel(); specifiedAssociationOverrides = overrideContainer.specifiedAssociationOverrides(); assertEquals("FOO", specifiedAssociationOverrides.next().getName()); assertEquals("BAR", specifiedAssociationOverrides.next().getName()); @@ -866,6 +882,7 @@ public class GenericJavaEmbeddedMapping2_0Tests extends Generic2_0ContextModelTe associationOverride = (AssociationOverrideAnnotation) resourceAttribute.addAnnotation(0, JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES); associationOverride.setName("BAZ"); + getJpaProject().synchronizeContextModel(); specifiedAssociationOverrides = overrideContainer.specifiedAssociationOverrides(); assertEquals("BAZ", specifiedAssociationOverrides.next().getName()); assertEquals("FOO", specifiedAssociationOverrides.next().getName()); @@ -874,6 +891,7 @@ public class GenericJavaEmbeddedMapping2_0Tests extends Generic2_0ContextModelTe //move an annotation to the resource model and verify the context model is updated resourceAttribute.moveAnnotation(1, 0, JPA.ASSOCIATION_OVERRIDES); + getJpaProject().synchronizeContextModel(); specifiedAssociationOverrides = overrideContainer.specifiedAssociationOverrides(); assertEquals("FOO", specifiedAssociationOverrides.next().getName()); assertEquals("BAZ", specifiedAssociationOverrides.next().getName()); @@ -881,18 +899,21 @@ public class GenericJavaEmbeddedMapping2_0Tests extends Generic2_0ContextModelTe assertFalse(specifiedAssociationOverrides.hasNext()); resourceAttribute.removeAnnotation(0, JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES); + getJpaProject().synchronizeContextModel(); specifiedAssociationOverrides = overrideContainer.specifiedAssociationOverrides(); assertEquals("BAZ", specifiedAssociationOverrides.next().getName()); assertEquals("BAR", specifiedAssociationOverrides.next().getName()); assertFalse(specifiedAssociationOverrides.hasNext()); resourceAttribute.removeAnnotation(0, JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES); + getJpaProject().synchronizeContextModel(); specifiedAssociationOverrides = overrideContainer.specifiedAssociationOverrides(); assertEquals("BAR", specifiedAssociationOverrides.next().getName()); assertFalse(specifiedAssociationOverrides.hasNext()); resourceAttribute.removeAnnotation(0, JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES); + getJpaProject().synchronizeContextModel(); specifiedAssociationOverrides = overrideContainer.specifiedAssociationOverrides(); assertFalse(specifiedAssociationOverrides.hasNext()); } @@ -990,6 +1011,7 @@ public class GenericJavaEmbeddedMapping2_0Tests extends Generic2_0ContextModelTe associationOverride.setName("FOO"); associationOverride = (AssociationOverrideAnnotation) resourceAttribute.addAnnotation(0, JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES); associationOverride.setName("BAR"); + getJpaProject().synchronizeContextModel(); assertEquals(2, overrideContainer.specifiedAssociationOverridesSize()); } @@ -1173,6 +1195,7 @@ public class GenericJavaEmbeddedMapping2_0Tests extends Generic2_0ContextModelTe ((AssociationOverrideAnnotation) resourceAttribute.addAnnotation(0, AssociationOverrideAnnotation.ANNOTATION_NAME, AssociationOverridesAnnotation.ANNOTATION_NAME)).setName("FOO"); ((AssociationOverrideAnnotation) resourceAttribute.addAnnotation(1, AssociationOverrideAnnotation.ANNOTATION_NAME, AssociationOverridesAnnotation.ANNOTATION_NAME)).setName("BAR"); ((AssociationOverrideAnnotation) resourceAttribute.addAnnotation(2, AssociationOverrideAnnotation.ANNOTATION_NAME, AssociationOverridesAnnotation.ANNOTATION_NAME)).setName("BAZ"); + getJpaProject().synchronizeContextModel(); ListIterator<AssociationOverride> associationOverrides = overrideContainer.specifiedAssociationOverrides(); assertEquals("FOO", associationOverrides.next().getName()); @@ -1181,6 +1204,7 @@ public class GenericJavaEmbeddedMapping2_0Tests extends Generic2_0ContextModelTe assertFalse(associationOverrides.hasNext()); resourceAttribute.moveAnnotation(2, 0, AssociationOverridesAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); associationOverrides = overrideContainer.specifiedAssociationOverrides(); assertEquals("BAR", associationOverrides.next().getName()); assertEquals("BAZ", associationOverrides.next().getName()); @@ -1188,6 +1212,7 @@ public class GenericJavaEmbeddedMapping2_0Tests extends Generic2_0ContextModelTe assertFalse(associationOverrides.hasNext()); resourceAttribute.moveAnnotation(0, 1, AssociationOverridesAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); associationOverrides = overrideContainer.specifiedAssociationOverrides(); assertEquals("BAZ", associationOverrides.next().getName()); assertEquals("BAR", associationOverrides.next().getName()); @@ -1195,17 +1220,20 @@ public class GenericJavaEmbeddedMapping2_0Tests extends Generic2_0ContextModelTe assertFalse(associationOverrides.hasNext()); resourceAttribute.removeAnnotation(1, AssociationOverrideAnnotation.ANNOTATION_NAME, AssociationOverridesAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); associationOverrides = overrideContainer.specifiedAssociationOverrides(); assertEquals("BAZ", associationOverrides.next().getName()); assertEquals("FOO", associationOverrides.next().getName()); assertFalse(associationOverrides.hasNext()); resourceAttribute.removeAnnotation(1, AssociationOverrideAnnotation.ANNOTATION_NAME, AssociationOverridesAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); associationOverrides = overrideContainer.specifiedAssociationOverrides(); assertEquals("BAZ", associationOverrides.next().getName()); assertFalse(associationOverrides.hasNext()); resourceAttribute.removeAnnotation(0, AssociationOverrideAnnotation.ANNOTATION_NAME, AssociationOverridesAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); associationOverrides = overrideContainer.specifiedAssociationOverrides(); assertFalse(associationOverrides.hasNext()); } diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/java/GenericJavaEntity2_0Tests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/java/GenericJavaEntity2_0Tests.java index 5d813c758e..0e1560219c 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/java/GenericJavaEntity2_0Tests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/java/GenericJavaEntity2_0Tests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. + * Copyright (c) 2009, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -449,6 +449,7 @@ public class GenericJavaEntity2_0Tests extends Generic2_0ContextModelTestCase NamedQuery2_0Annotation annotation1 = (NamedQuery2_0Annotation) typeResource.addAnnotation(1, NamedQueryAnnotation.ANNOTATION_NAME, NamedQueriesAnnotation.ANNOTATION_NAME); annotation1.setName("BAZ"); annotation1.setLockMode(org.eclipse.jpt.core.jpa2.resource.java.LockModeType_2_0.OPTIMISTIC); + getJpaProject().synchronizeContextModel(); ListIterator<JavaNamedQuery> namedQueries = entity.getQueryContainer().namedQueries(); assertEquals("FOO", namedQueries.next().getName()); @@ -460,6 +461,7 @@ public class GenericJavaEntity2_0Tests extends Generic2_0ContextModelTestCase assertEquals(3, entity.getPersistenceUnit().queriesSize()); typeResource.moveAnnotation(2, 0, NamedQueriesAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); namedQueries = entity.getQueryContainer().namedQueries(); namedQuery1 = (NamedQuery2_0) namedQueries.next(); assertEquals("BAZ", namedQuery1.getName()); @@ -469,6 +471,7 @@ public class GenericJavaEntity2_0Tests extends Generic2_0ContextModelTestCase assertFalse(namedQueries.hasNext()); typeResource.moveAnnotation(0, 1, NamedQueriesAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); namedQueries = entity.getQueryContainer().namedQueries(); assertEquals("BAR", namedQueries.next().getName()); namedQuery1 = (NamedQuery2_0) namedQueries.next(); @@ -478,6 +481,7 @@ public class GenericJavaEntity2_0Tests extends Generic2_0ContextModelTestCase assertFalse(namedQueries.hasNext()); typeResource.removeAnnotation(1, NamedQueryAnnotation.ANNOTATION_NAME, NamedQueriesAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); namedQueries = entity.getQueryContainer().namedQueries(); assertEquals("BAR", namedQueries.next().getName()); assertEquals("FOO", namedQueries.next().getName()); @@ -485,12 +489,14 @@ public class GenericJavaEntity2_0Tests extends Generic2_0ContextModelTestCase assertEquals(2, entity.getPersistenceUnit().queriesSize()); typeResource.removeAnnotation(1, NamedQueryAnnotation.ANNOTATION_NAME, NamedQueriesAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); namedQueries = entity.getQueryContainer().namedQueries(); assertEquals("BAR", namedQueries.next().getName()); assertFalse(namedQueries.hasNext()); assertEquals(1, entity.getPersistenceUnit().queriesSize()); typeResource.removeAnnotation(0, NamedQueryAnnotation.ANNOTATION_NAME, NamedQueriesAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); namedQueries = entity.getQueryContainer().namedQueries(); assertFalse(namedQueries.hasNext()); assertEquals(0, entity.getPersistenceUnit().queriesSize()); @@ -663,12 +669,14 @@ public class GenericJavaEntity2_0Tests extends Generic2_0ContextModelTestCase //add an annotation to the resource model and verify the context model is updated AttributeOverrideAnnotation attributeOverride = (AttributeOverrideAnnotation) typeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES); attributeOverride.setName("FOO"); + getJpaProject().synchronizeContextModel(); specifiedAttributeOverrides = overrideContainer.specifiedAttributeOverrides(); assertEquals("FOO", specifiedAttributeOverrides.next().getName()); assertFalse(specifiedAttributeOverrides.hasNext()); attributeOverride = (AttributeOverrideAnnotation) typeResource.addAnnotation(1, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES); attributeOverride.setName("BAR"); + getJpaProject().synchronizeContextModel(); specifiedAttributeOverrides = overrideContainer.specifiedAttributeOverrides(); assertEquals("FOO", specifiedAttributeOverrides.next().getName()); assertEquals("BAR", specifiedAttributeOverrides.next().getName()); @@ -677,6 +685,7 @@ public class GenericJavaEntity2_0Tests extends Generic2_0ContextModelTestCase attributeOverride = (AttributeOverrideAnnotation) typeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES); attributeOverride.setName("BAZ"); + getJpaProject().synchronizeContextModel(); specifiedAttributeOverrides = overrideContainer.specifiedAttributeOverrides(); assertEquals("BAZ", specifiedAttributeOverrides.next().getName()); assertEquals("FOO", specifiedAttributeOverrides.next().getName()); @@ -685,6 +694,7 @@ public class GenericJavaEntity2_0Tests extends Generic2_0ContextModelTestCase //move an annotation to the resource model and verify the context model is updated typeResource.moveAnnotation(1, 0, JPA.ATTRIBUTE_OVERRIDES); + getJpaProject().synchronizeContextModel(); specifiedAttributeOverrides = overrideContainer.specifiedAttributeOverrides(); assertEquals("FOO", specifiedAttributeOverrides.next().getName()); assertEquals("BAZ", specifiedAttributeOverrides.next().getName()); @@ -692,18 +702,21 @@ public class GenericJavaEntity2_0Tests extends Generic2_0ContextModelTestCase assertFalse(specifiedAttributeOverrides.hasNext()); typeResource.removeAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES); + getJpaProject().synchronizeContextModel(); specifiedAttributeOverrides = overrideContainer.specifiedAttributeOverrides(); assertEquals("BAZ", specifiedAttributeOverrides.next().getName()); assertEquals("BAR", specifiedAttributeOverrides.next().getName()); assertFalse(specifiedAttributeOverrides.hasNext()); typeResource.removeAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES); + getJpaProject().synchronizeContextModel(); specifiedAttributeOverrides = overrideContainer.specifiedAttributeOverrides(); assertEquals("BAR", specifiedAttributeOverrides.next().getName()); assertFalse(specifiedAttributeOverrides.hasNext()); typeResource.removeAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES); + getJpaProject().synchronizeContextModel(); specifiedAttributeOverrides = overrideContainer.specifiedAttributeOverrides(); assertFalse(specifiedAttributeOverrides.hasNext()); } @@ -832,6 +845,7 @@ public class GenericJavaEntity2_0Tests extends Generic2_0ContextModelTestCase attributeOverride.setName("FOO"); attributeOverride = (AttributeOverrideAnnotation) typeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES); attributeOverride.setName("BAR"); + getJpaProject().synchronizeContextModel(); assertEquals(2, overrideContainer.specifiedAttributeOverridesSize()); } @@ -1019,6 +1033,7 @@ public class GenericJavaEntity2_0Tests extends Generic2_0ContextModelTestCase ((AttributeOverrideAnnotation) typeResource.addAnnotation(0, AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME)).setName("FOO"); ((AttributeOverrideAnnotation) typeResource.addAnnotation(1, AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME)).setName("BAR"); ((AttributeOverrideAnnotation) typeResource.addAnnotation(2, AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME)).setName("BAZ"); + getJpaProject().synchronizeContextModel(); ListIterator<AttributeOverride> attributeOverrides = overrideContainer.specifiedAttributeOverrides(); assertEquals("FOO", attributeOverrides.next().getName()); @@ -1027,6 +1042,7 @@ public class GenericJavaEntity2_0Tests extends Generic2_0ContextModelTestCase assertFalse(attributeOverrides.hasNext()); typeResource.moveAnnotation(2, 0, AttributeOverridesAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); attributeOverrides = overrideContainer.specifiedAttributeOverrides(); assertEquals("BAR", attributeOverrides.next().getName()); assertEquals("BAZ", attributeOverrides.next().getName()); @@ -1034,6 +1050,7 @@ public class GenericJavaEntity2_0Tests extends Generic2_0ContextModelTestCase assertFalse(attributeOverrides.hasNext()); typeResource.moveAnnotation(0, 1, AttributeOverridesAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); attributeOverrides = overrideContainer.specifiedAttributeOverrides(); assertEquals("BAZ", attributeOverrides.next().getName()); assertEquals("BAR", attributeOverrides.next().getName()); @@ -1041,17 +1058,20 @@ public class GenericJavaEntity2_0Tests extends Generic2_0ContextModelTestCase assertFalse(attributeOverrides.hasNext()); typeResource.removeAnnotation(1, AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); attributeOverrides = overrideContainer.specifiedAttributeOverrides(); assertEquals("BAZ", attributeOverrides.next().getName()); assertEquals("FOO", attributeOverrides.next().getName()); assertFalse(attributeOverrides.hasNext()); typeResource.removeAnnotation(1, AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); attributeOverrides = overrideContainer.specifiedAttributeOverrides(); assertEquals("BAZ", attributeOverrides.next().getName()); assertFalse(attributeOverrides.hasNext()); typeResource.removeAnnotation(0, AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); attributeOverrides = overrideContainer.specifiedAttributeOverrides(); assertFalse(attributeOverrides.hasNext()); } @@ -1153,12 +1173,14 @@ public class GenericJavaEntity2_0Tests extends Generic2_0ContextModelTestCase //add an annotation to the resource model and verify the context model is updated AssociationOverrideAnnotation associationOverride = (AssociationOverrideAnnotation) typeResource.addAnnotation(0, JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES); associationOverride.setName("FOO"); + getJpaProject().synchronizeContextModel(); specifiedAssociationOverrides = overrideContainer.specifiedAssociationOverrides(); assertEquals("FOO", specifiedAssociationOverrides.next().getName()); assertFalse(specifiedAssociationOverrides.hasNext()); associationOverride = (AssociationOverrideAnnotation) typeResource.addAnnotation(1, JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES); associationOverride.setName("BAR"); + getJpaProject().synchronizeContextModel(); specifiedAssociationOverrides = overrideContainer.specifiedAssociationOverrides(); assertEquals("FOO", specifiedAssociationOverrides.next().getName()); assertEquals("BAR", specifiedAssociationOverrides.next().getName()); @@ -1167,6 +1189,7 @@ public class GenericJavaEntity2_0Tests extends Generic2_0ContextModelTestCase associationOverride = (AssociationOverrideAnnotation) typeResource.addAnnotation(0, JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES); associationOverride.setName("BAZ"); + getJpaProject().synchronizeContextModel(); specifiedAssociationOverrides = overrideContainer.specifiedAssociationOverrides(); assertEquals("BAZ", specifiedAssociationOverrides.next().getName()); assertEquals("FOO", specifiedAssociationOverrides.next().getName()); @@ -1175,6 +1198,7 @@ public class GenericJavaEntity2_0Tests extends Generic2_0ContextModelTestCase //move an annotation to the resource model and verify the context model is updated typeResource.moveAnnotation(1, 0, JPA.ASSOCIATION_OVERRIDES); + getJpaProject().synchronizeContextModel(); specifiedAssociationOverrides = overrideContainer.specifiedAssociationOverrides(); assertEquals("FOO", specifiedAssociationOverrides.next().getName()); assertEquals("BAZ", specifiedAssociationOverrides.next().getName()); @@ -1182,18 +1206,21 @@ public class GenericJavaEntity2_0Tests extends Generic2_0ContextModelTestCase assertFalse(specifiedAssociationOverrides.hasNext()); typeResource.removeAnnotation(0, JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES); + getJpaProject().synchronizeContextModel(); specifiedAssociationOverrides = overrideContainer.specifiedAssociationOverrides(); assertEquals("BAZ", specifiedAssociationOverrides.next().getName()); assertEquals("BAR", specifiedAssociationOverrides.next().getName()); assertFalse(specifiedAssociationOverrides.hasNext()); typeResource.removeAnnotation(0, JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES); + getJpaProject().synchronizeContextModel(); specifiedAssociationOverrides = overrideContainer.specifiedAssociationOverrides(); assertEquals("BAR", specifiedAssociationOverrides.next().getName()); assertFalse(specifiedAssociationOverrides.hasNext()); typeResource.removeAnnotation(0, JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES); + getJpaProject().synchronizeContextModel(); specifiedAssociationOverrides = overrideContainer.specifiedAssociationOverrides(); assertFalse(specifiedAssociationOverrides.hasNext()); } @@ -1304,6 +1331,8 @@ public class GenericJavaEntity2_0Tests extends Generic2_0ContextModelTestCase associationOverride.setName("FOO"); associationOverride = (AssociationOverrideAnnotation) typeResource.addAnnotation(0, JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES); associationOverride.setName("BAR"); + getJpaProject().synchronizeContextModel(); + getJpaProject().synchronizeContextModel(); assertEquals(2, overrideContainer.specifiedAssociationOverridesSize()); } @@ -1476,6 +1505,7 @@ public class GenericJavaEntity2_0Tests extends Generic2_0ContextModelTestCase ((AssociationOverrideAnnotation) typeResource.addAnnotation(0, AssociationOverrideAnnotation.ANNOTATION_NAME, AssociationOverridesAnnotation.ANNOTATION_NAME)).setName("FOO"); ((AssociationOverrideAnnotation) typeResource.addAnnotation(1, AssociationOverrideAnnotation.ANNOTATION_NAME, AssociationOverridesAnnotation.ANNOTATION_NAME)).setName("BAR"); ((AssociationOverrideAnnotation) typeResource.addAnnotation(2, AssociationOverrideAnnotation.ANNOTATION_NAME, AssociationOverridesAnnotation.ANNOTATION_NAME)).setName("BAZ"); + getJpaProject().synchronizeContextModel(); ListIterator<AssociationOverride> associationOverrides = overrideContainer.specifiedAssociationOverrides(); assertEquals("FOO", associationOverrides.next().getName()); @@ -1484,6 +1514,7 @@ public class GenericJavaEntity2_0Tests extends Generic2_0ContextModelTestCase assertFalse(associationOverrides.hasNext()); typeResource.moveAnnotation(2, 0, AssociationOverridesAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); associationOverrides = overrideContainer.specifiedAssociationOverrides(); assertEquals("BAR", associationOverrides.next().getName()); assertEquals("BAZ", associationOverrides.next().getName()); @@ -1491,6 +1522,7 @@ public class GenericJavaEntity2_0Tests extends Generic2_0ContextModelTestCase assertFalse(associationOverrides.hasNext()); typeResource.moveAnnotation(0, 1, AssociationOverridesAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); associationOverrides = overrideContainer.specifiedAssociationOverrides(); assertEquals("BAZ", associationOverrides.next().getName()); assertEquals("BAR", associationOverrides.next().getName()); @@ -1498,17 +1530,20 @@ public class GenericJavaEntity2_0Tests extends Generic2_0ContextModelTestCase assertFalse(associationOverrides.hasNext()); typeResource.removeAnnotation(1, AssociationOverrideAnnotation.ANNOTATION_NAME, AssociationOverridesAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); associationOverrides = overrideContainer.specifiedAssociationOverrides(); assertEquals("BAZ", associationOverrides.next().getName()); assertEquals("FOO", associationOverrides.next().getName()); assertFalse(associationOverrides.hasNext()); typeResource.removeAnnotation(1, AssociationOverrideAnnotation.ANNOTATION_NAME, AssociationOverridesAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); associationOverrides = overrideContainer.specifiedAssociationOverrides(); assertEquals("BAZ", associationOverrides.next().getName()); assertFalse(associationOverrides.hasNext()); typeResource.removeAnnotation(0, AssociationOverrideAnnotation.ANNOTATION_NAME, AssociationOverridesAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); associationOverrides = overrideContainer.specifiedAssociationOverrides(); assertFalse(associationOverrides.hasNext()); } @@ -1711,27 +1746,32 @@ public class GenericJavaEntity2_0Tests extends Generic2_0ContextModelTestCase assertEquals(null, cacheableAnnotation); getJavaPersistentType().getResourcePersistentType().addAnnotation(JPA2_0.CACHEABLE); + getJpaProject().synchronizeContextModel(); cacheableAnnotation = (Cacheable2_0Annotation) getJavaPersistentType().getResourcePersistentType().getAnnotation(JPA2_0.CACHEABLE); assertEquals(Boolean.TRUE, cacheable.getSpecifiedCacheable()); assertEquals(null, cacheableAnnotation.getValue()); assertSourceContains("@Cacheable", cu); cacheableAnnotation.setValue(Boolean.FALSE); + getJpaProject().synchronizeContextModel(); assertEquals(Boolean.FALSE, cacheable.getSpecifiedCacheable()); assertEquals(Boolean.FALSE, cacheableAnnotation.getValue()); assertSourceContains("@Cacheable(false)", cu); cacheableAnnotation.setValue(Boolean.TRUE); + getJpaProject().synchronizeContextModel(); assertEquals(Boolean.TRUE, cacheable.getSpecifiedCacheable()); assertEquals(Boolean.TRUE, cacheableAnnotation.getValue()); assertSourceContains("@Cacheable(true)", cu); cacheableAnnotation.setValue(null); + getJpaProject().synchronizeContextModel(); assertEquals(Boolean.TRUE, cacheable.getSpecifiedCacheable()); assertEquals(null, cacheableAnnotation.getValue()); assertSourceContains("@Cacheable", cu); getJavaPersistentType().getResourcePersistentType().removeAnnotation(JPA2_0.CACHEABLE); + getJpaProject().synchronizeContextModel(); cacheableAnnotation = (Cacheable2_0Annotation) getJavaPersistentType().getResourcePersistentType().getAnnotation(JPA2_0.CACHEABLE); assertEquals(null, cacheable.getSpecifiedCacheable()); assertEquals(null, cacheableAnnotation); diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/java/GenericJavaManyToOneMapping2_0Tests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/java/GenericJavaManyToOneMapping2_0Tests.java index 484222c5e2..893c69d038 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/java/GenericJavaManyToOneMapping2_0Tests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/java/GenericJavaManyToOneMapping2_0Tests.java @@ -1,13 +1,12 @@ /******************************************************************************* - * Copyright (c) 2009 Oracle. - * All rights reserved. This program and the accompanying materials are - * made available under the terms of the Eclipse Public License v1.0 which - * accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle - initial API and implementation - *******************************************************************************/ + * Copyright (c) 2009, 2010 Oracle. All rights reserved. + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0, which accompanies this distribution + * and is available at http://www.eclipse.org/legal/epl-v10.html. + * + * Contributors: + * Oracle - initial API and implementation + ******************************************************************************/ package org.eclipse.jpt.core.tests.internal.jpa2.context.java; import java.util.Iterator; @@ -99,10 +98,12 @@ public class GenericJavaManyToOneMapping2_0Tests assertTrue(contextMapping.getDerivedIdentity().getIdDerivedIdentityStrategy().getValue()); resourceAttribute.removeAnnotation(JPA.ID); + getJpaProject().synchronizeContextModel(); assertNull(resourceAttribute.getAnnotation(JPA.ID)); assertFalse(contextMapping.getDerivedIdentity().getIdDerivedIdentityStrategy().getValue()); resourceAttribute.addAnnotation(JPA.ID); + getJpaProject().synchronizeContextModel(); assertNotNull(resourceAttribute.getAnnotation(JPA.ID)); assertTrue(contextMapping.getDerivedIdentity().getIdDerivedIdentityStrategy().getValue()); } @@ -145,14 +146,17 @@ public class GenericJavaManyToOneMapping2_0Tests MapsId2_0Annotation annotation = (MapsId2_0Annotation) resourceAttribute.getAnnotation(JPA2_0.MAPS_ID); annotation.setValue("foo"); + getJpaProject().synchronizeContextModel(); assertEquals("foo", annotation.getValue()); assertEquals("foo", contextMapping.getDerivedIdentity().getMapsIdDerivedIdentityStrategy().getSpecifiedValue()); annotation.setValue("bar"); + getJpaProject().synchronizeContextModel(); assertEquals("bar", annotation.getValue()); assertEquals("bar", contextMapping.getDerivedIdentity().getMapsIdDerivedIdentityStrategy().getSpecifiedValue()); resourceAttribute.removeAnnotation(JPA2_0.MAPS_ID); + getJpaProject().synchronizeContextModel(); assertNull(resourceAttribute.getAnnotation(JPA2_0.MAPS_ID)); assertNull(contextMapping.getDerivedIdentity().getMapsIdDerivedIdentityStrategy().getSpecifiedValue()); } diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/java/GenericJavaOneToManyMapping2_0Tests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/java/GenericJavaOneToManyMapping2_0Tests.java index f18223d540..d4eac6602b 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/java/GenericJavaOneToManyMapping2_0Tests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/java/GenericJavaOneToManyMapping2_0Tests.java @@ -1,12 +1,12 @@ /******************************************************************************* -* Copyright (c) 2009 Oracle. All rights reserved. -* This program and the accompanying materials are made available under the -* terms of the Eclipse Public License v1.0, which accompanies this distribution -* and is available at http://www.eclipse.org/legal/epl-v10.html. -* -* Contributors: -* Oracle - initial API and implementation - *******************************************************************************/ + * Copyright (c) 2009, 2010 Oracle. All rights reserved. + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0, which accompanies this distribution + * and is available at http://www.eclipse.org/legal/epl-v10.html. + * + * Contributors: + * Oracle - initial API and implementation + ******************************************************************************/ package org.eclipse.jpt.core.tests.internal.jpa2.context.java; import java.util.Iterator; @@ -230,6 +230,7 @@ public class GenericJavaOneToManyMapping2_0Tests JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next(); OneToMany2_0Annotation oneToMany = (OneToMany2_0Annotation) attributeResource.getAnnotation(JPA.ONE_TO_MANY); oneToMany.setOrphanRemoval(Boolean.FALSE); + getJpaProject().synchronizeContextModel(); assertEquals(Boolean.FALSE, mappingsOrphanRemoval.getSpecifiedOrphanRemoval()); } @@ -306,15 +307,18 @@ public class GenericJavaOneToManyMapping2_0Tests JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next(); OneToMany2_0Annotation oneToMany = (OneToMany2_0Annotation) attributeResource.getAnnotation(JPA.ONE_TO_MANY); oneToMany.setOrphanRemoval(Boolean.FALSE); + getJpaProject().synchronizeContextModel(); assertEquals(Boolean.FALSE, mappingsOrphanRemoval.getSpecifiedOrphanRemoval()); oneToMany.setOrphanRemoval(null); + getJpaProject().synchronizeContextModel(); assertNull(mappingsOrphanRemoval.getSpecifiedOrphanRemoval()); assertSame(oneToManyMapping, persistentAttribute.getSpecifiedMapping()); oneToMany.setOrphanRemoval(Boolean.FALSE); attributeResource.setPrimaryAnnotation(null, EmptyIterable.<String>instance()); + getJpaProject().synchronizeContextModel(); assertNull(persistentAttribute.getSpecifiedMapping()); } diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/java/GenericJavaOneToOneMapping2_0Tests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/java/GenericJavaOneToOneMapping2_0Tests.java index 944082ecf0..7755c62852 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/java/GenericJavaOneToOneMapping2_0Tests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/java/GenericJavaOneToOneMapping2_0Tests.java @@ -1,12 +1,12 @@ /******************************************************************************* -* Copyright (c) 2009 Oracle. All rights reserved. -* This program and the accompanying materials are made available under the -* terms of the Eclipse Public License v1.0, which accompanies this distribution -* and is available at http://www.eclipse.org/legal/epl-v10.html. -* -* Contributors: -* Oracle - initial API and implementation - *******************************************************************************/ + * Copyright (c) 2009, 2010 Oracle. All rights reserved. + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0, which accompanies this distribution + * and is available at http://www.eclipse.org/legal/epl-v10.html. + * + * Contributors: + * Oracle - initial API and implementation + ******************************************************************************/ package org.eclipse.jpt.core.tests.internal.jpa2.context.java; import java.util.Iterator; @@ -239,10 +239,12 @@ public class GenericJavaOneToOneMapping2_0Tests assertTrue(contextMapping.getDerivedIdentity().getIdDerivedIdentityStrategy().getValue()); resourceAttribute.removeAnnotation(JPA.ID); + getJpaProject().synchronizeContextModel(); assertNull(resourceAttribute.getAnnotation(JPA.ID)); assertFalse(contextMapping.getDerivedIdentity().getIdDerivedIdentityStrategy().getValue()); resourceAttribute.addAnnotation(JPA.ID); + getJpaProject().synchronizeContextModel(); assertNotNull(resourceAttribute.getAnnotation(JPA.ID)); assertTrue(contextMapping.getDerivedIdentity().getIdDerivedIdentityStrategy().getValue()); } @@ -285,14 +287,17 @@ public class GenericJavaOneToOneMapping2_0Tests MapsId2_0Annotation annotation = (MapsId2_0Annotation) resourceAttribute.getAnnotation(JPA2_0.MAPS_ID); annotation.setValue("foo"); + getJpaProject().synchronizeContextModel(); assertEquals("foo", annotation.getValue()); assertEquals("foo", contextMapping.getDerivedIdentity().getMapsIdDerivedIdentityStrategy().getSpecifiedValue()); annotation.setValue("bar"); + getJpaProject().synchronizeContextModel(); assertEquals("bar", annotation.getValue()); assertEquals("bar", contextMapping.getDerivedIdentity().getMapsIdDerivedIdentityStrategy().getSpecifiedValue()); resourceAttribute.removeAnnotation(JPA2_0.MAPS_ID); + getJpaProject().synchronizeContextModel(); assertNull(resourceAttribute.getAnnotation(JPA2_0.MAPS_ID)); assertNull(contextMapping.getDerivedIdentity().getMapsIdDerivedIdentityStrategy().getSpecifiedValue()); } @@ -336,6 +341,7 @@ public class GenericJavaOneToOneMapping2_0Tests JavaPersistentAttribute contextAttribute = contextType.getAttributeNamed("oneToOne"); ((MapsId2_0Annotation) resourceAttribute.getAnnotation(JPA2_0.MAPS_ID)).setValue("foo"); + getJpaProject().synchronizeContextModel(); assertNull(resourceAttribute.getAnnotation(JPA.ID)); assertFalse(((JavaOneToOneMapping2_0) contextAttribute.getMapping()). @@ -453,6 +459,7 @@ public class GenericJavaOneToOneMapping2_0Tests JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next(); OneToOne2_0Annotation oneToOne = (OneToOne2_0Annotation) attributeResource.getAnnotation(JPA.ONE_TO_ONE); oneToOne.setOrphanRemoval(Boolean.FALSE); + getJpaProject().synchronizeContextModel(); assertEquals(Boolean.FALSE, mappingsOrphanRemoval.getSpecifiedOrphanRemoval()); } @@ -529,15 +536,18 @@ public class GenericJavaOneToOneMapping2_0Tests JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next(); OneToOne2_0Annotation oneToOne = (OneToOne2_0Annotation) attributeResource.getAnnotation(JPA.ONE_TO_ONE); oneToOne.setOrphanRemoval(Boolean.FALSE); + getJpaProject().synchronizeContextModel(); assertEquals(Boolean.FALSE, mappingsOrphanRemoval.getSpecifiedOrphanRemoval()); oneToOne.setOrphanRemoval(null); + getJpaProject().synchronizeContextModel(); assertNull(mappingsOrphanRemoval.getSpecifiedOrphanRemoval()); assertSame(oneToOneMapping, persistentAttribute.getSpecifiedMapping()); oneToOne.setOrphanRemoval(Boolean.FALSE); attributeResource.setPrimaryAnnotation(null, EmptyIterable.<String>instance()); + getJpaProject().synchronizeContextModel(); assertNull(persistentAttribute.getSpecifiedMapping()); } diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/java/GenericJavaPersistentAttribute2_0Tests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/java/GenericJavaPersistentAttribute2_0Tests.java index baab3008c5..c11dc3f93f 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/java/GenericJavaPersistentAttribute2_0Tests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/java/GenericJavaPersistentAttribute2_0Tests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. + * Copyright (c) 2009, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -137,20 +137,25 @@ public class GenericJavaPersistentAttribute2_0Tests extends Generic2_0ContextMod assertEquals(id.getMappingKey(), MappingKeys.ID_ATTRIBUTE_MAPPING_KEY); id.getResourcePersistentAttribute().addAnnotation(JPA.ONE_TO_ONE); + getJpaProject().synchronizeContextModel(); assertEquals(id.getMappingKey(), MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY); assertNotNull(id.getResourcePersistentAttribute().getAnnotation(JPA.ID)); id.getResourcePersistentAttribute().removeAnnotation(JPA.ONE_TO_ONE); + getJpaProject().synchronizeContextModel(); assertEquals(id.getMappingKey(), MappingKeys.ID_ATTRIBUTE_MAPPING_KEY); id.getResourcePersistentAttribute().addAnnotation(JPA.MANY_TO_ONE); + getJpaProject().synchronizeContextModel(); assertEquals(id.getMappingKey(), MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY); assertNotNull(id.getResourcePersistentAttribute().getAnnotation(JPA.ID)); id.getResourcePersistentAttribute().removeAnnotation(JPA.MANY_TO_ONE); + getJpaProject().synchronizeContextModel(); assertEquals(id.getMappingKey(), MappingKeys.ID_ATTRIBUTE_MAPPING_KEY); id.getResourcePersistentAttribute().setPrimaryAnnotation(null, EmptyIterable.<String>instance()); + getJpaProject().synchronizeContextModel(); assertEquals(id.getMappingKey(), MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY); } } diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/java/GenericJavaSequenceGenerator2_0Tests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/java/GenericJavaSequenceGenerator2_0Tests.java index b0f3a22839..fc57b7ee5d 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/java/GenericJavaSequenceGenerator2_0Tests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/java/GenericJavaSequenceGenerator2_0Tests.java @@ -1,12 +1,12 @@ /******************************************************************************* -* Copyright (c) 2009 Oracle. All rights reserved. -* This program and the accompanying materials are made available under the -* terms of the Eclipse Public License v1.0, which accompanies this distribution -* and is available at http://www.eclipse.org/legal/epl-v10.html. -* -* Contributors: -* Oracle - initial API and implementation -*******************************************************************************/ + * Copyright (c) 2009, 2010 Oracle. All rights reserved. + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0, which accompanies this distribution + * and is available at http://www.eclipse.org/legal/epl-v10.html. + * + * Contributors: + * Oracle - initial API and implementation + ******************************************************************************/ package org.eclipse.jpt.core.tests.internal.jpa2.context.java; import java.util.Iterator; @@ -60,6 +60,7 @@ public class GenericJavaSequenceGenerator2_0Tests extends Generic2_0ContextModel SequenceGenerator2_0Annotation annotation = (SequenceGenerator2_0Annotation) attributeResource.getAnnotation(JPA.SEQUENCE_GENERATOR); annotation.setCatalog("testCatalog"); + getJpaProject().synchronizeContextModel(); assertEquals("testCatalog", sequenceGenerator.getCatalog()); assertEquals("testCatalog", sequenceGenerator.getSpecifiedCatalog()); @@ -115,6 +116,7 @@ public class GenericJavaSequenceGenerator2_0Tests extends Generic2_0ContextModel SequenceGenerator2_0Annotation annotation = (SequenceGenerator2_0Annotation) attributeResource.getAnnotation(JPA.SEQUENCE_GENERATOR); annotation.setSchema("testSchema"); + getJpaProject().synchronizeContextModel(); assertEquals("testSchema", sequenceGenerator.getSchema()); assertEquals("testSchema", sequenceGenerator.getSpecifiedSchema()); diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/model/JpaModelTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/model/JpaProjectManagerTests.java index 89a7b2f764..8af71cdb3f 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/model/JpaModelTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/model/JpaProjectManagerTests.java @@ -29,13 +29,13 @@ import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory; import org.eclipse.wst.common.frameworks.datamodel.IDataModel; @SuppressWarnings("nls") -public class JpaModelTests extends TestCase { +public class JpaProjectManagerTests extends TestCase { /** carriage return */ public static final String CR = System.getProperty("line.separator"); protected TestFacetedProject testProject; - public JpaModelTests(String name) { + public JpaProjectManagerTests(String name) { super(name); } @@ -49,13 +49,13 @@ public class JpaModelTests extends TestCase { } private boolean debug() { - Boolean debug = (Boolean) ReflectionTools.getStaticFieldValue(this.getGenericJpaModelClass(), "DEBUG"); + Boolean debug = (Boolean) ReflectionTools.getStaticFieldValue(this.getGenericJpaProjectManagerClass(), "DEBUG"); return debug.booleanValue(); } - // GenericJpaModel is package-private - private Class<?> getGenericJpaModelClass() { - return JptCorePlugin.getJpaModel().getClass(); + // GenericJpaProjectManager is package-private + private Class<?> getGenericJpaProjectManagerClass() { + return JptCorePlugin.getJpaProjectManager().getClass(); } private void printName() { @@ -101,7 +101,7 @@ public class JpaModelTests extends TestCase { * make sure the DEBUG constants are 'false' before checking in the code */ public void testDEBUG() { - this.verifyDEBUG(this.getGenericJpaModelClass()); + this.verifyDEBUG(this.getGenericJpaProjectManagerClass()); } private void verifyDEBUG(Class<?> clazz) { @@ -109,8 +109,8 @@ public class JpaModelTests extends TestCase { ((Boolean) ReflectionTools.getStaticFieldValue(clazz, "DEBUG")).booleanValue()); } - public void testJpaModel() { - assertNotNull(JptCorePlugin.getJpaModel()); + public void testJpaProjectManager() { + assertNotNull(JptCorePlugin.getJpaProjectManager()); } protected IDataModel buildJpaConfigDataModel() { @@ -145,12 +145,12 @@ public class JpaModelTests extends TestCase { this.testProject.installFacet(JptCorePlugin.FACET_ID, "1.0", buildJpaConfigDataModel()); JpaProject jpaProject = JptCorePlugin.getJpaProject(this.testProject.getProject()); assertNotNull(jpaProject); - assertEquals(1, JptCorePlugin.getJpaModel().getJpaProjectsSize()); + assertEquals(1, JptCorePlugin.getJpaProjectManager().getJpaProjectsSize()); this.testProject.getProject().delete(false, true, null); jpaProject = JptCorePlugin.getJpaProject(this.testProject.getProject()); assertNull(jpaProject); - assertEquals(0, JptCorePlugin.getJpaModel().getJpaProjectsSize()); + assertEquals(0, JptCorePlugin.getJpaProjectManager().getJpaProjectsSize()); assertEquals(0, ResourcesPlugin.getWorkspace().getRoot().getProjects().length); IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(this.testProject.getProject().getName()); @@ -173,7 +173,7 @@ public class JpaModelTests extends TestCase { assertNull(JptCorePlugin.getJpaProject(this.testProject.getProject())); this.testProject.installFacet(JptCorePlugin.FACET_ID, "1.0", buildJpaConfigDataModel()); - assertEquals(1, JptCorePlugin.getJpaModel().getJpaProjectsSize()); + assertEquals(1, JptCorePlugin.getJpaProjectManager().getJpaProjectsSize()); JpaProject jpaProject = JptCorePlugin.getJpaProject(this.testProject.getProject()); assertNotNull(jpaProject); assertEquals(4, jpaProject.jpaFilesSize()); @@ -184,7 +184,7 @@ public class JpaModelTests extends TestCase { assertNotNull(jpaProject.getJpaFile(this.getFile(this.testProject, "src/META-INF/orm.xml"))); this.testProject.uninstallFacet(JptCorePlugin.FACET_ID, "1.0"); - assertEquals(0, JptCorePlugin.getJpaModel().getJpaProjectsSize()); + assertEquals(0, JptCorePlugin.getJpaProjectManager().getJpaProjectsSize()); jpaProject = JptCorePlugin.getJpaProject(this.testProject.getProject()); assertNull(jpaProject); } @@ -207,7 +207,7 @@ public class JpaModelTests extends TestCase { facetSettingsFile.setContents(new ByteArrayInputStream(newDocument.getBytes()), false, false, null); - assertEquals(1, JptCorePlugin.getJpaModel().getJpaProjectsSize()); + assertEquals(1, JptCorePlugin.getJpaProjectManager().getJpaProjectsSize()); JpaProject jpaProject = JptCorePlugin.getJpaProject(this.testProject.getProject()); assertNotNull(jpaProject); // persistence.xml and orm.xml do not get created in this situation (?) @@ -220,7 +220,7 @@ public class JpaModelTests extends TestCase { // now remove the JPA facet facetSettingsFile.setContents(new ByteArrayInputStream(oldDocument.getBytes()), false, false, null); - assertEquals(0, JptCorePlugin.getJpaModel().getJpaProjectsSize()); + assertEquals(0, JptCorePlugin.getJpaProjectManager().getJpaProjectsSize()); jpaProject = JptCorePlugin.getJpaProject(this.testProject.getProject()); assertNull(jpaProject); } @@ -244,13 +244,13 @@ public class JpaModelTests extends TestCase { String newDocument = oldDocument.replaceAll(oldString, newString); facetSettingsFile.setContents(new ByteArrayInputStream(newDocument.getBytes()), false, false, null); - assertEquals(0, JptCorePlugin.getJpaModel().getJpaProjectsSize()); + assertEquals(0, JptCorePlugin.getJpaProjectManager().getJpaProjectsSize()); jpaProject = JptCorePlugin.getJpaProject(this.testProject.getProject()); assertNull(jpaProject); // now add the JPA facet back facetSettingsFile.setContents(new ByteArrayInputStream(oldDocument.getBytes()), false, false, null); - assertEquals(1, JptCorePlugin.getJpaModel().getJpaProjectsSize()); + assertEquals(1, JptCorePlugin.getJpaProjectManager().getJpaProjectsSize()); jpaProject = JptCorePlugin.getJpaProject(this.testProject.getProject()); assertNotNull(jpaProject); assertEquals(4, jpaProject.jpaFilesSize()); diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/model/JptCoreModelTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/model/JptCoreModelTests.java index 1a90dc6134..14a0130457 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/model/JptCoreModelTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/model/JptCoreModelTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -16,7 +16,7 @@ public class JptCoreModelTests { public static Test suite() { TestSuite suite = new TestSuite(JptCoreModelTests.class.getPackage().getName()); - suite.addTestSuite(JpaModelTests.class); + suite.addTestSuite(JpaProjectManagerTests.class); return suite; } diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/JavaResourceModelTestCase.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/JavaResourceModelTestCase.java index f98ccc9d00..cf144d9975 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/JavaResourceModelTestCase.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/JavaResourceModelTestCase.java @@ -80,20 +80,20 @@ public class JavaResourceModelTestCase extends AnnotationTestCase if (this.javaResourceCompilationUnit == null) { return; } - this.synchWithJavaDelta(event.getDelta()); + this.syncWithJavaDelta(event.getDelta()); } /** * NB: this is copied from GenericJpaProject, so it might need to be * kept in synch with that code if it changes... yech... */ - protected void synchWithJavaDelta(IJavaElementDelta delta) { + protected void syncWithJavaDelta(IJavaElementDelta delta) { switch (delta.getElement().getElementType()) { case IJavaElement.JAVA_MODEL : case IJavaElement.JAVA_PROJECT : case IJavaElement.PACKAGE_FRAGMENT_ROOT : case IJavaElement.PACKAGE_FRAGMENT : - this.synchWithJavaDeltaChildren(delta); + this.syncWithJavaDeltaChildren(delta); break; case IJavaElement.COMPILATION_UNIT : this.javaCompilationUnitChanged(delta); @@ -103,15 +103,15 @@ public class JavaResourceModelTestCase extends AnnotationTestCase } } - protected void synchWithJavaDeltaChildren(IJavaElementDelta delta) { + protected void syncWithJavaDeltaChildren(IJavaElementDelta delta) { for (IJavaElementDelta child : delta.getAffectedChildren()) { - this.synchWithJavaDelta(child); // recurse + this.syncWithJavaDelta(child); // recurse } } protected void javaCompilationUnitChanged(IJavaElementDelta delta) { if (this.deltaIsRelevant(delta)) { - this.javaResourceCompilationUnit.update(); + this.javaResourceCompilationUnit.synchronizeWithJavaSource(); } } diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/utility/jdt/AnnotationTestCase.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/utility/jdt/AnnotationTestCase.java index c3bcb8b17d..9642180a10 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/utility/jdt/AnnotationTestCase.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/utility/jdt/AnnotationTestCase.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2008 Oracle. All rights reserved. + * Copyright (c) 2006, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -130,8 +130,7 @@ public abstract class AnnotationTestCase extends TestCase { @Override public Iterator<String> imports() { return (annotationImport == null) ? - EmptyIterator.<String>instance() - : + EmptyIterator.<String>instance() : new SingleElementIterator<String>(annotationImport); } @Override diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/JptEclipseLinkCoreContextModelTests.java b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/JptEclipseLinkCoreContextModelTests.java index 693e9ecd88..16b0453ba6 100644 --- a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/JptEclipseLinkCoreContextModelTests.java +++ b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/JptEclipseLinkCoreContextModelTests.java @@ -1,13 +1,12 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle - initial API and implementation - *******************************************************************************/ + * Copyright (c) 2007, 2010 Oracle. All rights reserved. + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0, which accompanies this distribution + * and is available at http://www.eclipse.org/legal/epl-v10.html. + * + * Contributors: + * Oracle - initial API and implementation + ******************************************************************************/ package org.eclipse.jpt.eclipselink.core.tests.internal.context; import junit.framework.Test; diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/java/EclipseLinkJavaBasicMappingTests.java b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/java/EclipseLinkJavaBasicMappingTests.java index 0aa57e7ec7..b9435956ca 100644 --- a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/java/EclipseLinkJavaBasicMappingTests.java +++ b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/java/EclipseLinkJavaBasicMappingTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -123,6 +123,7 @@ public class EclipseLinkJavaBasicMappingTests extends EclipseLinkContextModelTes JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME); JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next(); attributeResource.addAnnotation(EclipseLinkConvertAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next(); BasicMapping basicMapping = (BasicMapping) persistentAttribute.getSpecifiedMapping(); @@ -176,11 +177,13 @@ public class EclipseLinkJavaBasicMappingTests extends EclipseLinkContextModelTes JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next(); EclipseLinkConvertAnnotation convert = (EclipseLinkConvertAnnotation) attributeResource.addAnnotation(EclipseLinkConvertAnnotation.ANNOTATION_NAME); convert.setValue("foo"); + getJpaProject().synchronizeContextModel(); assertEquals(EclipseLinkConvert.ECLIPSE_LINK_CONVERTER, basicMapping.getConverter().getType()); assertEquals("foo", ((EclipseLinkConvert) basicMapping.getConverter()).getConverterName()); attributeResource.removeAnnotation(EclipseLinkConvertAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertEquals(Converter.NO_CONVERTER, basicMapping.getConverter().getType()); assertFalse(basicMapping.isDefault()); @@ -200,19 +203,24 @@ public class EclipseLinkJavaBasicMappingTests extends EclipseLinkContextModelTes JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next(); EclipseLinkMutableAnnotation mutableAnnotation = (EclipseLinkMutableAnnotation) attributeResource.getAnnotation(EclipseLinkMutableAnnotation.ANNOTATION_NAME); mutableAnnotation.setValue(Boolean.TRUE); + getJpaProject().synchronizeContextModel(); assertEquals(Boolean.TRUE, mutable.getSpecifiedMutable()); mutableAnnotation.setValue(null); + getJpaProject().synchronizeContextModel(); assertEquals(Boolean.TRUE, mutable.getSpecifiedMutable()); mutableAnnotation.setValue(Boolean.FALSE); + getJpaProject().synchronizeContextModel(); assertEquals(Boolean.FALSE, mutable.getSpecifiedMutable()); attributeResource.removeAnnotation(EclipseLinkMutableAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertEquals(null, mutable.getSpecifiedMutable()); attributeResource.addAnnotation(EclipseLinkMutableAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertEquals(Boolean.TRUE, mutable.getSpecifiedMutable()); } diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/java/EclipseLinkJavaCachingTests.java b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/java/EclipseLinkJavaCachingTests.java index 66d1006c17..6a9ca7bcc0 100644 --- a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/java/EclipseLinkJavaCachingTests.java +++ b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/java/EclipseLinkJavaCachingTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -126,6 +126,7 @@ public class EclipseLinkJavaCachingTests extends EclipseLinkContextModelTestCase JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME); EclipseLinkCacheAnnotation cacheAnnotation = (EclipseLinkCacheAnnotation) typeResource.addAnnotation(EclipseLink.CACHE); cacheAnnotation.setShared(Boolean.FALSE); + getJpaProject().synchronizeContextModel(); assertEquals(Boolean.FALSE, cacheAnnotation.getShared()); assertEquals(Boolean.FALSE, entity.getCaching().getSpecifiedShared()); @@ -176,6 +177,7 @@ public class EclipseLinkJavaCachingTests extends EclipseLinkContextModelTestCase JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME); EclipseLinkCacheAnnotation cacheAnnotation = (EclipseLinkCacheAnnotation) typeResource.addAnnotation(EclipseLink.CACHE); cacheAnnotation.setType(org.eclipse.jpt.eclipselink.core.resource.java.CacheType.HARD_WEAK); + getJpaProject().synchronizeContextModel(); assertEquals(org.eclipse.jpt.eclipselink.core.resource.java.CacheType.HARD_WEAK, cacheAnnotation.getType()); assertEquals(EclipseLinkCacheType.HARD_WEAK, entity.getCaching().getSpecifiedType()); @@ -216,6 +218,7 @@ public class EclipseLinkJavaCachingTests extends EclipseLinkContextModelTestCase JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME); EclipseLinkCacheAnnotation cacheAnnotation = (EclipseLinkCacheAnnotation) typeResource.addAnnotation(EclipseLink.CACHE); cacheAnnotation.setAlwaysRefresh(Boolean.TRUE); + getJpaProject().synchronizeContextModel(); assertEquals(Boolean.TRUE, cacheAnnotation.getAlwaysRefresh()); assertEquals(Boolean.TRUE, entity.getCaching().getSpecifiedAlwaysRefresh()); @@ -256,6 +259,7 @@ public class EclipseLinkJavaCachingTests extends EclipseLinkContextModelTestCase JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME); EclipseLinkCacheAnnotation cacheAnnotation = (EclipseLinkCacheAnnotation) typeResource.addAnnotation(EclipseLink.CACHE); cacheAnnotation.setRefreshOnlyIfNewer(Boolean.TRUE); + getJpaProject().synchronizeContextModel(); assertEquals(Boolean.TRUE, cacheAnnotation.getRefreshOnlyIfNewer()); assertEquals(Boolean.TRUE, entity.getCaching().getSpecifiedRefreshOnlyIfNewer()); @@ -296,7 +300,8 @@ public class EclipseLinkJavaCachingTests extends EclipseLinkContextModelTestCase JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME); EclipseLinkCacheAnnotation cacheAnnotation = (EclipseLinkCacheAnnotation) typeResource.addAnnotation(EclipseLink.CACHE); cacheAnnotation.setDisableHits(Boolean.TRUE); - + getJpaProject().synchronizeContextModel(); + assertEquals(Boolean.TRUE, cacheAnnotation.getDisableHits()); assertEquals(Boolean.TRUE, entity.getCaching().getSpecifiedDisableHits()); assertEquals(true, entity.getCaching().isDisableHits()); @@ -346,6 +351,7 @@ public class EclipseLinkJavaCachingTests extends EclipseLinkContextModelTestCase JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME); EclipseLinkCacheAnnotation cacheAnnotation = (EclipseLinkCacheAnnotation) typeResource.addAnnotation(EclipseLink.CACHE); cacheAnnotation.setCoordinationType(org.eclipse.jpt.eclipselink.core.resource.java.CacheCoordinationType.INVALIDATE_CHANGED_OBJECTS); + getJpaProject().synchronizeContextModel(); assertEquals(org.eclipse.jpt.eclipselink.core.resource.java.CacheCoordinationType.INVALIDATE_CHANGED_OBJECTS, cacheAnnotation.getCoordinationType()); assertEquals(EclipseLinkCacheCoordinationType.INVALIDATE_CHANGED_OBJECTS, entity.getCaching().getSpecifiedCoordinationType()); @@ -363,9 +369,11 @@ public class EclipseLinkJavaCachingTests extends EclipseLinkContextModelTestCase JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME); typeResource.addAnnotation(EclipseLink.EXISTENCE_CHECKING); + getJpaProject().synchronizeContextModel(); assertEquals(true, caching.hasExistenceChecking()); typeResource.removeAnnotation(EclipseLink.EXISTENCE_CHECKING); + getJpaProject().synchronizeContextModel(); assertEquals(false, caching.hasExistenceChecking()); } @@ -411,6 +419,7 @@ public class EclipseLinkJavaCachingTests extends EclipseLinkContextModelTestCase JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME); EclipseLinkExistenceCheckingAnnotation existenceCheckingAnnotation = (EclipseLinkExistenceCheckingAnnotation) typeResource.addAnnotation(EclipseLink.EXISTENCE_CHECKING); existenceCheckingAnnotation.setValue(org.eclipse.jpt.eclipselink.core.resource.java.ExistenceType.ASSUME_NON_EXISTENCE); + getJpaProject().synchronizeContextModel(); assertEquals(org.eclipse.jpt.eclipselink.core.resource.java.ExistenceType.ASSUME_NON_EXISTENCE, existenceCheckingAnnotation.getValue()); assertEquals(EclipseLinkExistenceType.ASSUME_NON_EXISTENCE, entity.getCaching().getSpecifiedExistenceType()); @@ -463,10 +472,12 @@ public class EclipseLinkJavaCachingTests extends EclipseLinkContextModelTestCase assertNull(entity.getCaching().getExpiry()); cacheAnnotation.setExpiry(Integer.valueOf(57)); + getJpaProject().synchronizeContextModel(); assertEquals(Integer.valueOf(57), entity.getCaching().getExpiry()); typeResource.removeAnnotation(EclipseLink.CACHE); + getJpaProject().synchronizeContextModel(); assertNull(entity.getCaching().getExpiry()); } @@ -524,6 +535,7 @@ public class EclipseLinkJavaCachingTests extends EclipseLinkContextModelTestCase EclipseLinkCacheAnnotation cacheAnnotation = (EclipseLinkCacheAnnotation) typeResource.addAnnotation(EclipseLink.CACHE); cacheAnnotation.addExpiryTimeOfDay(); + getJpaProject().synchronizeContextModel(); assertNotNull(caching.getExpiryTimeOfDay()); } @@ -559,10 +571,12 @@ public class EclipseLinkJavaCachingTests extends EclipseLinkContextModelTestCase JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME); EclipseLinkCacheAnnotation cacheAnnotation = (EclipseLinkCacheAnnotation) typeResource.addAnnotation(EclipseLink.CACHE); cacheAnnotation.addExpiryTimeOfDay(); + getJpaProject().synchronizeContextModel(); assertNotNull(caching.getExpiryTimeOfDay()); caching.removeExpiryTimeOfDay(); + getJpaProject().synchronizeContextModel(); assertNull(caching.getExpiryTimeOfDay()); assertNull(typeResource.getAnnotation(EclipseLink.CACHE)); } @@ -623,6 +637,7 @@ public class EclipseLinkJavaCachingTests extends EclipseLinkContextModelTestCase JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME); EclipseLinkCacheAnnotation cacheAnnotation = (EclipseLinkCacheAnnotation) typeResource.addAnnotation(EclipseLink.CACHE); cacheAnnotation.setSize(new Integer(50)); + getJpaProject().synchronizeContextModel(); assertEquals(new Integer(50), cacheAnnotation.getSize()); assertEquals(new Integer(50), entity.getCaching().getSpecifiedSize()); diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/java/EclipseLinkJavaConvertTests.java b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/java/EclipseLinkJavaConvertTests.java index 291a85c15f..ecfa498ab6 100644 --- a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/java/EclipseLinkJavaConvertTests.java +++ b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/java/EclipseLinkJavaConvertTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -98,6 +98,7 @@ public class EclipseLinkJavaConvertTests extends EclipseLinkContextModelTestCase JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME); JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next(); attributeResource.addAnnotation(EclipseLinkConvertAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next(); BasicMapping basicMapping = (BasicMapping) persistentAttribute.getSpecifiedMapping(); @@ -157,11 +158,13 @@ public class EclipseLinkJavaConvertTests extends EclipseLinkContextModelTestCase JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next(); EclipseLinkConvertAnnotation convert = (EclipseLinkConvertAnnotation) attributeResource.addAnnotation(EclipseLinkConvertAnnotation.ANNOTATION_NAME); convert.setValue("foo"); + getJpaProject().synchronizeContextModel(); assertEquals(EclipseLinkConvert.ECLIPSE_LINK_CONVERTER, basicMapping.getConverter().getType()); assertEquals("foo", ((EclipseLinkConvert) basicMapping.getConverter()).getConverterName()); attributeResource.removeAnnotation(EclipseLinkConvertAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertEquals(Converter.NO_CONVERTER, basicMapping.getConverter().getType()); assertFalse(basicMapping.isDefault()); diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/java/EclipseLinkJavaConverterTests.java b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/java/EclipseLinkJavaConverterTests.java index 7c70cd56a1..9597c320e0 100644 --- a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/java/EclipseLinkJavaConverterTests.java +++ b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/java/EclipseLinkJavaConverterTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -129,15 +129,19 @@ public class EclipseLinkJavaConverterTests extends EclipseLinkContextModelTestCa JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next(); EclipseLinkConverterAnnotation converterAnnotation = (EclipseLinkConverterAnnotation) attributeResource.getAnnotation(EclipseLinkConverterAnnotation.ANNOTATION_NAME); converterAnnotation.setName("bar"); + getJpaProject().synchronizeContextModel(); assertEquals("bar", converter.getName()); attributeResource.removeAnnotation(EclipseLinkConverterAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertEquals(null, eclipseLinkConvert.getConverter()); converterAnnotation = (EclipseLinkConverterAnnotation) attributeResource.addAnnotation(EclipseLinkConverterAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertNotNull(eclipseLinkConvert.getConverter()); converterAnnotation.setName("FOO"); + getJpaProject().synchronizeContextModel(); assertEquals("FOO", eclipseLinkConvert.getConverter().getName()); } @@ -200,15 +204,19 @@ public class EclipseLinkJavaConverterTests extends EclipseLinkContextModelTestCa JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next(); EclipseLinkConverterAnnotation converterAnnotation = (EclipseLinkConverterAnnotation) attributeResource.getAnnotation(EclipseLinkConverterAnnotation.ANNOTATION_NAME); converterAnnotation.setConverterClass("Bar"); + getJpaProject().synchronizeContextModel(); assertEquals("Bar", converter.getConverterClass()); attributeResource.removeAnnotation(EclipseLinkConverterAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertEquals(null, eclipseLinkConvert.getConverter()); converterAnnotation = (EclipseLinkConverterAnnotation) attributeResource.addAnnotation(EclipseLinkConverterAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertNotNull(eclipseLinkConvert.getConverter()); converterAnnotation.setConverterClass("FooBar"); + getJpaProject().synchronizeContextModel(); assertEquals("FooBar", ((EclipseLinkCustomConverter) eclipseLinkConvert.getConverter()).getConverterClass()); } } diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/java/EclipseLinkJavaEmbeddableTests.java b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/java/EclipseLinkJavaEmbeddableTests.java index f1e04f08e8..46e858fcad 100644 --- a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/java/EclipseLinkJavaEmbeddableTests.java +++ b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/java/EclipseLinkJavaEmbeddableTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 Oracle. All rights reserved. + * Copyright (c) 2008, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -108,15 +108,19 @@ public class EclipseLinkJavaEmbeddableTests extends EclipseLinkContextModelTestC JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME); EclipseLinkCustomizerAnnotation customizerAnnotation = (EclipseLinkCustomizerAnnotation) typeResource.getAnnotation(EclipseLinkCustomizerAnnotation.ANNOTATION_NAME); customizerAnnotation.setValue("Bar"); + getJpaProject().synchronizeContextModel(); assertEquals("Bar", customizer.getSpecifiedCustomizerClass()); typeResource.removeAnnotation(EclipseLinkCustomizerAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertEquals(null, customizer.getSpecifiedCustomizerClass()); customizerAnnotation = (EclipseLinkCustomizerAnnotation) typeResource.addAnnotation(EclipseLinkCustomizerAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertEquals(null, customizer.getSpecifiedCustomizerClass()); customizerAnnotation.setValue("FooBar"); + getJpaProject().synchronizeContextModel(); assertEquals("FooBar", customizer.getSpecifiedCustomizerClass()); } @@ -130,15 +134,14 @@ public class EclipseLinkJavaEmbeddableTests extends EclipseLinkContextModelTestC EclipseLinkChangeTrackingAnnotation resourceChangeTracking = (EclipseLinkChangeTrackingAnnotation) typeResource.getAnnotation(EclipseLinkChangeTrackingAnnotation.ANNOTATION_NAME); // base annotated, test context value - assertNull(resourceChangeTracking.getValue()); assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getType()); assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getDefaultType()); assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getSpecifiedType()); // change resource to ATTRIBUTE specifically, test context - resourceChangeTracking.setValue(org.eclipse.jpt.eclipselink.core.resource.java.ChangeTrackingType.ATTRIBUTE); + getJpaProject().synchronizeContextModel(); assertEquals(org.eclipse.jpt.eclipselink.core.resource.java.ChangeTrackingType.ATTRIBUTE, resourceChangeTracking.getValue()); assertEquals(EclipseLinkChangeTrackingType.ATTRIBUTE, contextChangeTracking.getType()); @@ -146,8 +149,8 @@ public class EclipseLinkJavaEmbeddableTests extends EclipseLinkContextModelTestC assertEquals(EclipseLinkChangeTrackingType.ATTRIBUTE, contextChangeTracking.getSpecifiedType()); // change resource to OBJECT specifically, test context - resourceChangeTracking.setValue(org.eclipse.jpt.eclipselink.core.resource.java.ChangeTrackingType.OBJECT); + getJpaProject().synchronizeContextModel(); assertEquals(org.eclipse.jpt.eclipselink.core.resource.java.ChangeTrackingType.OBJECT, resourceChangeTracking.getValue()); assertEquals(EclipseLinkChangeTrackingType.OBJECT, contextChangeTracking.getType()); @@ -155,8 +158,8 @@ public class EclipseLinkJavaEmbeddableTests extends EclipseLinkContextModelTestC assertEquals(EclipseLinkChangeTrackingType.OBJECT, contextChangeTracking.getSpecifiedType()); // change resource to DEFERRED specifically, test context - resourceChangeTracking.setValue(org.eclipse.jpt.eclipselink.core.resource.java.ChangeTrackingType.DEFERRED); + getJpaProject().synchronizeContextModel(); assertEquals(org.eclipse.jpt.eclipselink.core.resource.java.ChangeTrackingType.DEFERRED, resourceChangeTracking.getValue()); assertEquals(EclipseLinkChangeTrackingType.DEFERRED, contextChangeTracking.getType()); @@ -164,8 +167,8 @@ public class EclipseLinkJavaEmbeddableTests extends EclipseLinkContextModelTestC assertEquals(EclipseLinkChangeTrackingType.DEFERRED, contextChangeTracking.getSpecifiedType()); // change resource to AUTO specifically, test context - resourceChangeTracking.setValue(org.eclipse.jpt.eclipselink.core.resource.java.ChangeTrackingType.AUTO); + getJpaProject().synchronizeContextModel(); assertEquals(org.eclipse.jpt.eclipselink.core.resource.java.ChangeTrackingType.AUTO, resourceChangeTracking.getValue()); assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getType()); @@ -173,8 +176,8 @@ public class EclipseLinkJavaEmbeddableTests extends EclipseLinkContextModelTestC assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getSpecifiedType()); // remove value from resource, test context - resourceChangeTracking.setValue(null); + getJpaProject().synchronizeContextModel(); assertNull(resourceChangeTracking.getValue()); assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getType()); @@ -182,8 +185,8 @@ public class EclipseLinkJavaEmbeddableTests extends EclipseLinkContextModelTestC assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getSpecifiedType()); // remove annotation, text context - typeResource.removeAnnotation(EclipseLinkChangeTrackingAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertNull(resourceChangeTracking.getValue()); assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getType()); diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/java/EclipseLinkJavaEntityTests.java b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/java/EclipseLinkJavaEntityTests.java index 909a8f1752..4203a01dda 100644 --- a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/java/EclipseLinkJavaEntityTests.java +++ b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/java/EclipseLinkJavaEntityTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 Oracle. All rights reserved. + * Copyright (c) 2008, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -160,15 +160,19 @@ public class EclipseLinkJavaEntityTests extends EclipseLinkContextModelTestCase JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME); EclipseLinkCustomizerAnnotation customizerAnnotation = (EclipseLinkCustomizerAnnotation) typeResource.getAnnotation(EclipseLinkCustomizerAnnotation.ANNOTATION_NAME); customizerAnnotation.setValue("Bar"); + getJpaProject().synchronizeContextModel(); assertEquals("Bar", customizer.getSpecifiedCustomizerClass()); typeResource.removeAnnotation(EclipseLinkCustomizerAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertEquals(null, customizer.getSpecifiedCustomizerClass()); customizerAnnotation = (EclipseLinkCustomizerAnnotation) typeResource.addAnnotation(EclipseLinkCustomizerAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertEquals(null, customizer.getSpecifiedCustomizerClass()); customizerAnnotation.setValue("FooBar"); + getJpaProject().synchronizeContextModel(); assertEquals("FooBar", customizer.getSpecifiedCustomizerClass()); } @@ -191,6 +195,7 @@ public class EclipseLinkJavaEntityTests extends EclipseLinkContextModelTestCase // change resource to ATTRIBUTE specifically, test context resourceChangeTracking.setValue(org.eclipse.jpt.eclipselink.core.resource.java.ChangeTrackingType.ATTRIBUTE); + getJpaProject().synchronizeContextModel(); assertEquals(org.eclipse.jpt.eclipselink.core.resource.java.ChangeTrackingType.ATTRIBUTE, resourceChangeTracking.getValue()); assertEquals(EclipseLinkChangeTrackingType.ATTRIBUTE, contextChangeTracking.getType()); @@ -200,6 +205,7 @@ public class EclipseLinkJavaEntityTests extends EclipseLinkContextModelTestCase // change resource to OBJECT specifically, test context resourceChangeTracking.setValue(org.eclipse.jpt.eclipselink.core.resource.java.ChangeTrackingType.OBJECT); + getJpaProject().synchronizeContextModel(); assertEquals(org.eclipse.jpt.eclipselink.core.resource.java.ChangeTrackingType.OBJECT, resourceChangeTracking.getValue()); assertEquals(EclipseLinkChangeTrackingType.OBJECT, contextChangeTracking.getType()); @@ -209,6 +215,7 @@ public class EclipseLinkJavaEntityTests extends EclipseLinkContextModelTestCase // change resource to DEFERRED specifically, test context resourceChangeTracking.setValue(org.eclipse.jpt.eclipselink.core.resource.java.ChangeTrackingType.DEFERRED); + getJpaProject().synchronizeContextModel(); assertEquals(org.eclipse.jpt.eclipselink.core.resource.java.ChangeTrackingType.DEFERRED, resourceChangeTracking.getValue()); assertEquals(EclipseLinkChangeTrackingType.DEFERRED, contextChangeTracking.getType()); @@ -218,6 +225,7 @@ public class EclipseLinkJavaEntityTests extends EclipseLinkContextModelTestCase // change resource to AUTO specifically, test context resourceChangeTracking.setValue(org.eclipse.jpt.eclipselink.core.resource.java.ChangeTrackingType.AUTO); + getJpaProject().synchronizeContextModel(); assertEquals(org.eclipse.jpt.eclipselink.core.resource.java.ChangeTrackingType.AUTO, resourceChangeTracking.getValue()); assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getType()); @@ -227,6 +235,7 @@ public class EclipseLinkJavaEntityTests extends EclipseLinkContextModelTestCase // remove value from resource, test context resourceChangeTracking.setValue(null); + getJpaProject().synchronizeContextModel(); assertNull(resourceChangeTracking.getValue()); assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getType()); @@ -236,6 +245,7 @@ public class EclipseLinkJavaEntityTests extends EclipseLinkContextModelTestCase // remove annotation, text context typeResource.removeAnnotation(EclipseLinkChangeTrackingAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertNull(resourceChangeTracking.getValue()); assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getType()); @@ -363,11 +373,13 @@ public class EclipseLinkJavaEntityTests extends EclipseLinkContextModelTestCase JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME); typeResource.removeAnnotation(EclipseLinkReadOnlyAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertEquals(null, readOnly.getSpecifiedReadOnly()); assertEquals(false, readOnly.isDefaultReadOnly()); typeResource.addAnnotation(EclipseLinkReadOnlyAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertEquals(Boolean.TRUE, readOnly.getSpecifiedReadOnly()); } diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/java/EclipseLinkJavaIdMappingTests.java b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/java/EclipseLinkJavaIdMappingTests.java index 116777091d..2a9b203412 100644 --- a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/java/EclipseLinkJavaIdMappingTests.java +++ b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/java/EclipseLinkJavaIdMappingTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -124,6 +124,7 @@ public class EclipseLinkJavaIdMappingTests extends EclipseLinkContextModelTestCa JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME); JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next(); attributeResource.addAnnotation(EclipseLinkConvertAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next(); IdMapping idMapping = (IdMapping) persistentAttribute.getSpecifiedMapping(); @@ -177,11 +178,13 @@ public class EclipseLinkJavaIdMappingTests extends EclipseLinkContextModelTestCa JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next(); EclipseLinkConvertAnnotation convert = (EclipseLinkConvertAnnotation) attributeResource.addAnnotation(EclipseLinkConvertAnnotation.ANNOTATION_NAME); convert.setValue("foo"); + getJpaProject().synchronizeContextModel(); assertEquals(EclipseLinkConvert.ECLIPSE_LINK_CONVERTER, idMapping.getConverter().getType()); assertEquals("foo", ((EclipseLinkConvert) idMapping.getConverter()).getConverterName()); attributeResource.removeAnnotation(EclipseLinkConvertAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertEquals(Converter.NO_CONVERTER, idMapping.getConverter().getType()); assertFalse(idMapping.isDefault()); @@ -201,19 +204,24 @@ public class EclipseLinkJavaIdMappingTests extends EclipseLinkContextModelTestCa JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next(); EclipseLinkMutableAnnotation mutableAnnotation = (EclipseLinkMutableAnnotation) attributeResource.getAnnotation(EclipseLinkMutableAnnotation.ANNOTATION_NAME); mutableAnnotation.setValue(Boolean.TRUE); + getJpaProject().synchronizeContextModel(); assertEquals(Boolean.TRUE, mutable.getSpecifiedMutable()); mutableAnnotation.setValue(null); + getJpaProject().synchronizeContextModel(); assertEquals(Boolean.TRUE, mutable.getSpecifiedMutable()); mutableAnnotation.setValue(Boolean.FALSE); + getJpaProject().synchronizeContextModel(); assertEquals(Boolean.FALSE, mutable.getSpecifiedMutable()); attributeResource.removeAnnotation(EclipseLinkMutableAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertEquals(null, mutable.getSpecifiedMutable()); attributeResource.addAnnotation(EclipseLinkMutableAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertEquals(Boolean.TRUE, mutable.getSpecifiedMutable()); } diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/java/EclipseLinkJavaManyToManyMappingTests.java b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/java/EclipseLinkJavaManyToManyMappingTests.java index f07fb49c44..1a5e1e2d3c 100644 --- a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/java/EclipseLinkJavaManyToManyMappingTests.java +++ b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/java/EclipseLinkJavaManyToManyMappingTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -71,6 +71,7 @@ public class EclipseLinkJavaManyToManyMappingTests extends EclipseLinkContextMod // change resource to INNER specifically, test context joinFetchAnnotation.setValue(org.eclipse.jpt.eclipselink.core.resource.java.JoinFetchType.INNER); + getJpaProject().synchronizeContextModel(); assertEquals(org.eclipse.jpt.eclipselink.core.resource.java.JoinFetchType.INNER, joinFetchAnnotation.getValue()); assertEquals(EclipseLinkJoinFetchType.INNER, contextJoinFetch.getValue()); @@ -78,6 +79,7 @@ public class EclipseLinkJavaManyToManyMappingTests extends EclipseLinkContextMod // change resource to OUTER, test context joinFetchAnnotation.setValue(org.eclipse.jpt.eclipselink.core.resource.java.JoinFetchType.OUTER); + getJpaProject().synchronizeContextModel(); assertEquals(org.eclipse.jpt.eclipselink.core.resource.java.JoinFetchType.OUTER, joinFetchAnnotation.getValue()); assertEquals(EclipseLinkJoinFetchType.OUTER, contextJoinFetch.getValue()); @@ -85,6 +87,7 @@ public class EclipseLinkJavaManyToManyMappingTests extends EclipseLinkContextMod // remove value from resource, test context joinFetchAnnotation.setValue(null); + getJpaProject().synchronizeContextModel(); assertNull(joinFetchAnnotation.getValue()); assertEquals(EclipseLinkJoinFetchType.INNER, contextJoinFetch.getValue()); @@ -92,6 +95,7 @@ public class EclipseLinkJavaManyToManyMappingTests extends EclipseLinkContextMod // remove annotation, text context attributeResource.removeAnnotation(EclipseLinkJoinFetchAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertNull(joinFetchAnnotation.getValue()); assertNull(contextJoinFetch.getValue()); diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/java/EclipseLinkJavaManyToOneMappingTests.java b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/java/EclipseLinkJavaManyToOneMappingTests.java index 55965f9083..c4adaff77e 100644 --- a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/java/EclipseLinkJavaManyToOneMappingTests.java +++ b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/java/EclipseLinkJavaManyToOneMappingTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -70,6 +70,7 @@ public class EclipseLinkJavaManyToOneMappingTests extends EclipseLinkContextMode // change resource to INNER specifically, test context joinFetchAnnotation.setValue(org.eclipse.jpt.eclipselink.core.resource.java.JoinFetchType.INNER); + getJpaProject().synchronizeContextModel(); assertEquals(org.eclipse.jpt.eclipselink.core.resource.java.JoinFetchType.INNER, joinFetchAnnotation.getValue()); assertEquals(EclipseLinkJoinFetchType.INNER, contextJoinFetch.getValue()); @@ -77,6 +78,7 @@ public class EclipseLinkJavaManyToOneMappingTests extends EclipseLinkContextMode // change resource to OUTER, test context joinFetchAnnotation.setValue(org.eclipse.jpt.eclipselink.core.resource.java.JoinFetchType.OUTER); + getJpaProject().synchronizeContextModel(); assertEquals(org.eclipse.jpt.eclipselink.core.resource.java.JoinFetchType.OUTER, joinFetchAnnotation.getValue()); assertEquals(EclipseLinkJoinFetchType.OUTER, contextJoinFetch.getValue()); @@ -84,6 +86,7 @@ public class EclipseLinkJavaManyToOneMappingTests extends EclipseLinkContextMode // remove value from resource, test context joinFetchAnnotation.setValue(null); + getJpaProject().synchronizeContextModel(); assertNull(joinFetchAnnotation.getValue()); assertEquals(EclipseLinkJoinFetchType.INNER, contextJoinFetch.getValue()); @@ -91,6 +94,7 @@ public class EclipseLinkJavaManyToOneMappingTests extends EclipseLinkContextMode // remove annotation, text context attributeResource.removeAnnotation(EclipseLinkJoinFetchAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertNull(joinFetchAnnotation.getValue()); assertNull(contextJoinFetch.getValue()); diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/java/EclipseLinkJavaMappedSuperclassTests.java b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/java/EclipseLinkJavaMappedSuperclassTests.java index 6609d1e10e..39e72a2fe0 100644 --- a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/java/EclipseLinkJavaMappedSuperclassTests.java +++ b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/java/EclipseLinkJavaMappedSuperclassTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 Oracle. All rights reserved. + * Copyright (c) 2008, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -138,11 +138,13 @@ public class EclipseLinkJavaMappedSuperclassTests extends EclipseLinkContextMode JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME); typeResource.removeAnnotation(EclipseLinkReadOnlyAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertEquals(null, readOnly.getSpecifiedReadOnly()); assertEquals(false, readOnly.isDefaultReadOnly()); typeResource.addAnnotation(EclipseLinkReadOnlyAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertEquals(Boolean.TRUE, readOnly.getSpecifiedReadOnly()); } @@ -193,15 +195,19 @@ public class EclipseLinkJavaMappedSuperclassTests extends EclipseLinkContextMode JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME); EclipseLinkCustomizerAnnotation customizerAnnotation = (EclipseLinkCustomizerAnnotation) typeResource.getAnnotation(EclipseLinkCustomizerAnnotation.ANNOTATION_NAME); customizerAnnotation.setValue("Bar"); + getJpaProject().synchronizeContextModel(); assertEquals("Bar", customizer.getSpecifiedCustomizerClass()); typeResource.removeAnnotation(EclipseLinkCustomizerAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertEquals(null, customizer.getSpecifiedCustomizerClass()); customizerAnnotation = (EclipseLinkCustomizerAnnotation) typeResource.addAnnotation(EclipseLinkCustomizerAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertEquals(null, customizer.getSpecifiedCustomizerClass()); customizerAnnotation.setValue("FooBar"); + getJpaProject().synchronizeContextModel(); assertEquals("FooBar", customizer.getSpecifiedCustomizerClass()); } @@ -224,6 +230,7 @@ public class EclipseLinkJavaMappedSuperclassTests extends EclipseLinkContextMode // change resource to ATTRIBUTE specifically, test context resourceChangeTracking.setValue(org.eclipse.jpt.eclipselink.core.resource.java.ChangeTrackingType.ATTRIBUTE); + getJpaProject().synchronizeContextModel(); assertEquals(org.eclipse.jpt.eclipselink.core.resource.java.ChangeTrackingType.ATTRIBUTE, resourceChangeTracking.getValue()); assertEquals(EclipseLinkChangeTrackingType.ATTRIBUTE, contextChangeTracking.getType()); @@ -233,6 +240,7 @@ public class EclipseLinkJavaMappedSuperclassTests extends EclipseLinkContextMode // change resource to OBJECT specifically, test context resourceChangeTracking.setValue(org.eclipse.jpt.eclipselink.core.resource.java.ChangeTrackingType.OBJECT); + getJpaProject().synchronizeContextModel(); assertEquals(org.eclipse.jpt.eclipselink.core.resource.java.ChangeTrackingType.OBJECT, resourceChangeTracking.getValue()); assertEquals(EclipseLinkChangeTrackingType.OBJECT, contextChangeTracking.getType()); @@ -242,6 +250,7 @@ public class EclipseLinkJavaMappedSuperclassTests extends EclipseLinkContextMode // change resource to DEFERRED specifically, test context resourceChangeTracking.setValue(org.eclipse.jpt.eclipselink.core.resource.java.ChangeTrackingType.DEFERRED); + getJpaProject().synchronizeContextModel(); assertEquals(org.eclipse.jpt.eclipselink.core.resource.java.ChangeTrackingType.DEFERRED, resourceChangeTracking.getValue()); assertEquals(EclipseLinkChangeTrackingType.DEFERRED, contextChangeTracking.getType()); @@ -251,6 +260,7 @@ public class EclipseLinkJavaMappedSuperclassTests extends EclipseLinkContextMode // change resource to AUTO specifically, test context resourceChangeTracking.setValue(org.eclipse.jpt.eclipselink.core.resource.java.ChangeTrackingType.AUTO); + getJpaProject().synchronizeContextModel(); assertEquals(org.eclipse.jpt.eclipselink.core.resource.java.ChangeTrackingType.AUTO, resourceChangeTracking.getValue()); assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getType()); @@ -260,6 +270,7 @@ public class EclipseLinkJavaMappedSuperclassTests extends EclipseLinkContextMode // remove value from resource, test context resourceChangeTracking.setValue(null); + getJpaProject().synchronizeContextModel(); assertNull(resourceChangeTracking.getValue()); assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getType()); @@ -269,6 +280,7 @@ public class EclipseLinkJavaMappedSuperclassTests extends EclipseLinkContextMode // remove annotation, text context typeResource.removeAnnotation(EclipseLinkChangeTrackingAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertNull(resourceChangeTracking.getValue()); assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getType()); diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/java/EclipseLinkJavaObjectTypeConverterTests.java b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/java/EclipseLinkJavaObjectTypeConverterTests.java index cc6954d544..9df9a8067a 100644 --- a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/java/EclipseLinkJavaObjectTypeConverterTests.java +++ b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/java/EclipseLinkJavaObjectTypeConverterTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -170,15 +170,19 @@ public class EclipseLinkJavaObjectTypeConverterTests extends EclipseLinkContextM JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next(); EclipseLinkObjectTypeConverterAnnotation converterAnnotation = (EclipseLinkObjectTypeConverterAnnotation) attributeResource.getAnnotation(EclipseLinkObjectTypeConverterAnnotation.ANNOTATION_NAME); converterAnnotation.setName("bar"); + getJpaProject().synchronizeContextModel(); assertEquals("bar", converter.getName()); attributeResource.removeAnnotation(EclipseLinkObjectTypeConverterAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertEquals(null, eclipseLinkConvert.getConverter()); converterAnnotation = (EclipseLinkObjectTypeConverterAnnotation) attributeResource.addAnnotation(EclipseLinkObjectTypeConverterAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertNotNull(eclipseLinkConvert.getConverter()); converterAnnotation.setName("FOO"); + getJpaProject().synchronizeContextModel(); assertEquals("FOO", eclipseLinkConvert.getConverter().getName()); } @@ -240,15 +244,19 @@ public class EclipseLinkJavaObjectTypeConverterTests extends EclipseLinkContextM JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next(); EclipseLinkObjectTypeConverterAnnotation converterAnnotation = (EclipseLinkObjectTypeConverterAnnotation) attributeResource.getAnnotation(EclipseLinkObjectTypeConverterAnnotation.ANNOTATION_NAME); converterAnnotation.setDataType("Bar"); + getJpaProject().synchronizeContextModel(); assertEquals("Bar", converter.getDataType()); attributeResource.removeAnnotation(EclipseLinkObjectTypeConverterAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertEquals(null, eclipseLinkConvert.getConverter()); converterAnnotation = (EclipseLinkObjectTypeConverterAnnotation) attributeResource.addAnnotation(EclipseLinkObjectTypeConverterAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertNotNull(eclipseLinkConvert.getConverter()); converterAnnotation.setDataType("FooBar"); + getJpaProject().synchronizeContextModel(); assertEquals("FooBar", ((EclipseLinkObjectTypeConverter) eclipseLinkConvert.getConverter()).getDataType()); } @@ -310,15 +318,19 @@ public class EclipseLinkJavaObjectTypeConverterTests extends EclipseLinkContextM JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next(); EclipseLinkObjectTypeConverterAnnotation converterAnnotation = (EclipseLinkObjectTypeConverterAnnotation) attributeResource.getAnnotation(EclipseLinkObjectTypeConverterAnnotation.ANNOTATION_NAME); converterAnnotation.setObjectType("Bar"); + getJpaProject().synchronizeContextModel(); assertEquals("Bar", converter.getObjectType()); attributeResource.removeAnnotation(EclipseLinkObjectTypeConverterAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertEquals(null, eclipseLinkConvert.getConverter()); converterAnnotation = (EclipseLinkObjectTypeConverterAnnotation) attributeResource.addAnnotation(EclipseLinkObjectTypeConverterAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertNotNull(eclipseLinkConvert.getConverter()); converterAnnotation.setObjectType("FooBar"); + getJpaProject().synchronizeContextModel(); assertEquals("FooBar", ((EclipseLinkObjectTypeConverter) eclipseLinkConvert.getConverter()).getObjectType()); } @@ -474,6 +486,7 @@ public class EclipseLinkJavaObjectTypeConverterTests extends EclipseLinkContextM converterAnnotation.addConversionValue(0).setDataValue("F"); converterAnnotation.addConversionValue(1).setDataValue("M"); converterAnnotation.addConversionValue(2).setDataValue("O"); + getJpaProject().synchronizeContextModel(); ListIterator<EclipseLinkConversionValue> conversionValues = converter.conversionValues(); assertEquals("F", conversionValues.next().getDataValue()); @@ -482,6 +495,7 @@ public class EclipseLinkJavaObjectTypeConverterTests extends EclipseLinkContextM assertFalse(conversionValues.hasNext()); converterAnnotation.moveConversionValue(2, 0); + getJpaProject().synchronizeContextModel(); conversionValues = converter.conversionValues(); assertEquals("M", conversionValues.next().getDataValue()); assertEquals("O", conversionValues.next().getDataValue()); @@ -489,6 +503,7 @@ public class EclipseLinkJavaObjectTypeConverterTests extends EclipseLinkContextM assertFalse(conversionValues.hasNext()); converterAnnotation.moveConversionValue(0, 1); + getJpaProject().synchronizeContextModel(); conversionValues = converter.conversionValues(); assertEquals("O", conversionValues.next().getDataValue()); assertEquals("M", conversionValues.next().getDataValue()); @@ -496,17 +511,20 @@ public class EclipseLinkJavaObjectTypeConverterTests extends EclipseLinkContextM assertFalse(conversionValues.hasNext()); converterAnnotation.removeConversionValue(1); + getJpaProject().synchronizeContextModel(); conversionValues = converter.conversionValues(); assertEquals("O", conversionValues.next().getDataValue()); assertEquals("F", conversionValues.next().getDataValue()); assertFalse(conversionValues.hasNext()); converterAnnotation.removeConversionValue(1); + getJpaProject().synchronizeContextModel(); conversionValues = converter.conversionValues(); assertEquals("O", conversionValues.next().getDataValue()); assertFalse(conversionValues.hasNext()); converterAnnotation.removeConversionValue(0); + getJpaProject().synchronizeContextModel(); conversionValues = converter.conversionValues(); assertFalse(conversionValues.hasNext()); } @@ -593,15 +611,19 @@ public class EclipseLinkJavaObjectTypeConverterTests extends EclipseLinkContextM JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next(); EclipseLinkObjectTypeConverterAnnotation converterAnnotation = (EclipseLinkObjectTypeConverterAnnotation) attributeResource.getAnnotation(EclipseLinkObjectTypeConverterAnnotation.ANNOTATION_NAME); converterAnnotation.setDefaultObjectValue("baz"); + getJpaProject().synchronizeContextModel(); assertEquals("baz", converter.getDefaultObjectValue()); attributeResource.removeAnnotation(EclipseLinkObjectTypeConverterAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertEquals(null, eclipseLinkConvert.getConverter()); converterAnnotation = (EclipseLinkObjectTypeConverterAnnotation) attributeResource.addAnnotation(EclipseLinkObjectTypeConverterAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertNotNull(eclipseLinkConvert.getConverter()); converterAnnotation.setDefaultObjectValue("FOO"); + getJpaProject().synchronizeContextModel(); assertEquals("FOO", ((EclipseLinkObjectTypeConverter) eclipseLinkConvert.getConverter()).getDefaultObjectValue()); } diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/java/EclipseLinkJavaOneToManyMappingTests.java b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/java/EclipseLinkJavaOneToManyMappingTests.java index 7c2550adc1..9bb7aa0fb5 100644 --- a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/java/EclipseLinkJavaOneToManyMappingTests.java +++ b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/java/EclipseLinkJavaOneToManyMappingTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 Oracle. All rights reserved. + * Copyright (c) 2008, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -147,10 +147,12 @@ public class EclipseLinkJavaOneToManyMappingTests extends EclipseLinkContextMode JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME); JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next(); attributeResource.removeAnnotation(EclipseLinkPrivateOwnedAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertEquals(false, privateOwnable.isPrivateOwned()); attributeResource.addAnnotation(EclipseLinkPrivateOwnedAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertEquals(true, privateOwnable.isPrivateOwned()); } @@ -173,6 +175,7 @@ public class EclipseLinkJavaOneToManyMappingTests extends EclipseLinkContextMode // change resource to INNER specifically, test context joinFetchAnnotation.setValue(org.eclipse.jpt.eclipselink.core.resource.java.JoinFetchType.INNER); + getJpaProject().synchronizeContextModel(); assertEquals(org.eclipse.jpt.eclipselink.core.resource.java.JoinFetchType.INNER, joinFetchAnnotation.getValue()); assertEquals(EclipseLinkJoinFetchType.INNER, contextJoinFetch.getValue()); @@ -180,6 +183,7 @@ public class EclipseLinkJavaOneToManyMappingTests extends EclipseLinkContextMode // change resource to OUTER, test context joinFetchAnnotation.setValue(org.eclipse.jpt.eclipselink.core.resource.java.JoinFetchType.OUTER); + getJpaProject().synchronizeContextModel(); assertEquals(org.eclipse.jpt.eclipselink.core.resource.java.JoinFetchType.OUTER, joinFetchAnnotation.getValue()); assertEquals(EclipseLinkJoinFetchType.OUTER, contextJoinFetch.getValue()); @@ -187,6 +191,7 @@ public class EclipseLinkJavaOneToManyMappingTests extends EclipseLinkContextMode // remove value from resource, test context joinFetchAnnotation.setValue(null); + getJpaProject().synchronizeContextModel(); assertNull(joinFetchAnnotation.getValue()); assertEquals(EclipseLinkJoinFetchType.INNER, contextJoinFetch.getValue()); @@ -194,6 +199,7 @@ public class EclipseLinkJavaOneToManyMappingTests extends EclipseLinkContextMode // remove annotation, text context attributeResource.removeAnnotation(EclipseLinkJoinFetchAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertNull(joinFetchAnnotation.getValue()); assertNull(contextJoinFetch.getValue()); diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/java/EclipseLinkJavaOneToOneMappingTests.java b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/java/EclipseLinkJavaOneToOneMappingTests.java index 5b7e39e454..2b43eaf239 100644 --- a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/java/EclipseLinkJavaOneToOneMappingTests.java +++ b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/java/EclipseLinkJavaOneToOneMappingTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 Oracle. All rights reserved. + * Copyright (c) 2008, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -147,10 +147,12 @@ public class EclipseLinkJavaOneToOneMappingTests extends EclipseLinkContextModel JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME); JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next(); attributeResource.removeAnnotation(EclipseLinkPrivateOwnedAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertEquals(false, privateOwnable.isPrivateOwned()); attributeResource.addAnnotation(EclipseLinkPrivateOwnedAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertEquals(true, privateOwnable.isPrivateOwned()); } @@ -173,6 +175,7 @@ public class EclipseLinkJavaOneToOneMappingTests extends EclipseLinkContextModel // change resource to INNER specifically, test context joinFetchAnnotation.setValue(org.eclipse.jpt.eclipselink.core.resource.java.JoinFetchType.INNER); + getJpaProject().synchronizeContextModel(); assertEquals(org.eclipse.jpt.eclipselink.core.resource.java.JoinFetchType.INNER, joinFetchAnnotation.getValue()); assertEquals(EclipseLinkJoinFetchType.INNER, contextJoinFetch.getValue()); @@ -180,6 +183,7 @@ public class EclipseLinkJavaOneToOneMappingTests extends EclipseLinkContextModel // change resource to OUTER, test context joinFetchAnnotation.setValue(org.eclipse.jpt.eclipselink.core.resource.java.JoinFetchType.OUTER); + getJpaProject().synchronizeContextModel(); assertEquals(org.eclipse.jpt.eclipselink.core.resource.java.JoinFetchType.OUTER, joinFetchAnnotation.getValue()); assertEquals(EclipseLinkJoinFetchType.OUTER, contextJoinFetch.getValue()); @@ -187,6 +191,7 @@ public class EclipseLinkJavaOneToOneMappingTests extends EclipseLinkContextModel // remove value from resource, test context joinFetchAnnotation.setValue(null); + getJpaProject().synchronizeContextModel(); assertNull(joinFetchAnnotation.getValue()); assertEquals(EclipseLinkJoinFetchType.INNER, contextJoinFetch.getValue()); @@ -194,6 +199,7 @@ public class EclipseLinkJavaOneToOneMappingTests extends EclipseLinkContextModel // remove annotation, text context attributeResource.removeAnnotation(EclipseLinkJoinFetchAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertNull(joinFetchAnnotation.getValue()); assertNull(contextJoinFetch.getValue()); diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/java/EclipseLinkJavaStructConverterTests.java b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/java/EclipseLinkJavaStructConverterTests.java index d5a80fb5b7..418f65e5a8 100644 --- a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/java/EclipseLinkJavaStructConverterTests.java +++ b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/java/EclipseLinkJavaStructConverterTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -128,15 +128,19 @@ public class EclipseLinkJavaStructConverterTests extends EclipseLinkContextModel JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next(); EclipseLinkStructConverterAnnotation converterAnnotation = (EclipseLinkStructConverterAnnotation) attributeResource.getAnnotation(EclipseLinkStructConverterAnnotation.ANNOTATION_NAME); converterAnnotation.setName("bar"); + getJpaProject().synchronizeContextModel(); assertEquals("bar", converter.getName()); attributeResource.removeAnnotation(EclipseLinkStructConverterAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertEquals(null, eclipseLinkConvert.getConverter()); converterAnnotation = (EclipseLinkStructConverterAnnotation) attributeResource.addAnnotation(EclipseLinkStructConverterAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertNotNull(eclipseLinkConvert.getConverter()); converterAnnotation.setName("FOO"); + getJpaProject().synchronizeContextModel(); assertEquals("FOO", eclipseLinkConvert.getConverter().getName()); } @@ -199,15 +203,19 @@ public class EclipseLinkJavaStructConverterTests extends EclipseLinkContextModel JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next(); EclipseLinkStructConverterAnnotation converterAnnotation = (EclipseLinkStructConverterAnnotation) attributeResource.getAnnotation(EclipseLinkStructConverterAnnotation.ANNOTATION_NAME); converterAnnotation.setConverter("Bar"); + getJpaProject().synchronizeContextModel(); assertEquals("Bar", converter.getConverterClass()); attributeResource.removeAnnotation(EclipseLinkStructConverterAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertEquals(null, eclipseLinkConvert.getConverter()); converterAnnotation = (EclipseLinkStructConverterAnnotation) attributeResource.addAnnotation(EclipseLinkStructConverterAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertNotNull(eclipseLinkConvert.getConverter()); converterAnnotation.setConverter("FooBar"); + getJpaProject().synchronizeContextModel(); assertEquals("FooBar", ((EclipseLinkStructConverter) eclipseLinkConvert.getConverter()).getConverterClass()); } } diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/java/EclipseLinkJavaTypeConverterTests.java b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/java/EclipseLinkJavaTypeConverterTests.java index 48ca7da643..a7f6c8af52 100644 --- a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/java/EclipseLinkJavaTypeConverterTests.java +++ b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/java/EclipseLinkJavaTypeConverterTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -147,15 +147,19 @@ public class EclipseLinkJavaTypeConverterTests extends EclipseLinkContextModelTe JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next(); EclipseLinkTypeConverterAnnotation converterAnnotation = (EclipseLinkTypeConverterAnnotation) attributeResource.getAnnotation(EclipseLinkTypeConverterAnnotation.ANNOTATION_NAME); converterAnnotation.setName("bar"); + getJpaProject().synchronizeContextModel(); assertEquals("bar", converter.getName()); attributeResource.removeAnnotation(EclipseLinkTypeConverterAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertEquals(null, eclipseLinkConvert.getConverter()); converterAnnotation = (EclipseLinkTypeConverterAnnotation) attributeResource.addAnnotation(EclipseLinkTypeConverterAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertNotNull(eclipseLinkConvert.getConverter()); converterAnnotation.setName("FOO"); + getJpaProject().synchronizeContextModel(); assertEquals("FOO", eclipseLinkConvert.getConverter().getName()); } @@ -217,15 +221,19 @@ public class EclipseLinkJavaTypeConverterTests extends EclipseLinkContextModelTe JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next(); EclipseLinkTypeConverterAnnotation converterAnnotation = (EclipseLinkTypeConverterAnnotation) attributeResource.getAnnotation(EclipseLinkTypeConverterAnnotation.ANNOTATION_NAME); converterAnnotation.setDataType("Bar"); + getJpaProject().synchronizeContextModel(); assertEquals("Bar", converter.getDataType()); attributeResource.removeAnnotation(EclipseLinkTypeConverterAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertEquals(null, eclipseLinkConvert.getConverter()); converterAnnotation = (EclipseLinkTypeConverterAnnotation) attributeResource.addAnnotation(EclipseLinkTypeConverterAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertNotNull(eclipseLinkConvert.getConverter()); converterAnnotation.setDataType("FooBar"); + getJpaProject().synchronizeContextModel(); assertEquals("FooBar", ((EclipseLinkTypeConverter) eclipseLinkConvert.getConverter()).getDataType()); } @@ -287,15 +295,19 @@ public class EclipseLinkJavaTypeConverterTests extends EclipseLinkContextModelTe JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next(); EclipseLinkTypeConverterAnnotation converterAnnotation = (EclipseLinkTypeConverterAnnotation) attributeResource.getAnnotation(EclipseLinkTypeConverterAnnotation.ANNOTATION_NAME); converterAnnotation.setObjectType("Bar"); + getJpaProject().synchronizeContextModel(); assertEquals("Bar", converter.getObjectType()); attributeResource.removeAnnotation(EclipseLinkTypeConverterAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertEquals(null, eclipseLinkConvert.getConverter()); converterAnnotation = (EclipseLinkTypeConverterAnnotation) attributeResource.addAnnotation(EclipseLinkTypeConverterAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertNotNull(eclipseLinkConvert.getConverter()); converterAnnotation.setObjectType("FooBar"); + getJpaProject().synchronizeContextModel(); assertEquals("FooBar", ((EclipseLinkTypeConverter) eclipseLinkConvert.getConverter()).getObjectType()); } } diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/java/EclipseLinkJavaVersionMappingTests.java b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/java/EclipseLinkJavaVersionMappingTests.java index 844fd99c33..b69855a25b 100644 --- a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/java/EclipseLinkJavaVersionMappingTests.java +++ b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/java/EclipseLinkJavaVersionMappingTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -123,6 +123,7 @@ public class EclipseLinkJavaVersionMappingTests extends EclipseLinkContextModelT JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME); JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next(); attributeResource.addAnnotation(EclipseLinkConvertAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next(); VersionMapping versionMapping = (VersionMapping) persistentAttribute.getSpecifiedMapping(); @@ -176,11 +177,13 @@ public class EclipseLinkJavaVersionMappingTests extends EclipseLinkContextModelT JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next(); EclipseLinkConvertAnnotation convert = (EclipseLinkConvertAnnotation) attributeResource.addAnnotation(EclipseLinkConvertAnnotation.ANNOTATION_NAME); convert.setValue("foo"); + getJpaProject().synchronizeContextModel(); assertEquals(EclipseLinkConvert.ECLIPSE_LINK_CONVERTER, versionMapping.getConverter().getType()); assertEquals("foo", ((EclipseLinkConvert) versionMapping.getConverter()).getConverterName()); attributeResource.removeAnnotation(EclipseLinkConvertAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertEquals(Converter.NO_CONVERTER, versionMapping.getConverter().getType()); assertFalse(versionMapping.isDefault()); @@ -200,19 +203,24 @@ public class EclipseLinkJavaVersionMappingTests extends EclipseLinkContextModelT JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next(); EclipseLinkMutableAnnotation mutableAnnotation = (EclipseLinkMutableAnnotation) attributeResource.getAnnotation(EclipseLinkMutableAnnotation.ANNOTATION_NAME); mutableAnnotation.setValue(Boolean.TRUE); + getJpaProject().synchronizeContextModel(); assertEquals(Boolean.TRUE, mutable.getSpecifiedMutable()); mutableAnnotation.setValue(null); + getJpaProject().synchronizeContextModel(); assertEquals(Boolean.TRUE, mutable.getSpecifiedMutable()); mutableAnnotation.setValue(Boolean.FALSE); + getJpaProject().synchronizeContextModel(); assertEquals(Boolean.FALSE, mutable.getSpecifiedMutable()); attributeResource.removeAnnotation(EclipseLinkMutableAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertEquals(null, mutable.getSpecifiedMutable()); attributeResource.addAnnotation(EclipseLinkMutableAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertEquals(Boolean.TRUE, mutable.getSpecifiedMutable()); } diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/java/JptEclipseLinkCoreJavaContextModelTests.java b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/java/JptEclipseLinkCoreJavaContextModelTests.java index 762c6fecd1..415bf4fd14 100644 --- a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/java/JptEclipseLinkCoreJavaContextModelTests.java +++ b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/java/JptEclipseLinkCoreJavaContextModelTests.java @@ -1,13 +1,12 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 Oracle. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle - initial API and implementation - *******************************************************************************/ + * Copyright (c) 2008, 2010 Oracle. All rights reserved. + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0, which accompanies this distribution + * and is available at http://www.eclipse.org/legal/epl-v10.html. + * + * Contributors: + * Oracle - initial API and implementation + ******************************************************************************/ package org.eclipse.jpt.eclipselink.core.tests.internal.context.java; import junit.framework.Test; @@ -20,17 +19,17 @@ public class JptEclipseLinkCoreJavaContextModelTests extends TestCase TestSuite suite = new TestSuite(JptEclipseLinkCoreJavaContextModelTests.class.getName()); suite.addTestSuite(EclipseLinkJavaBasicMappingTests.class); suite.addTestSuite(EclipseLinkJavaCachingTests.class); - suite.addTestSuite(EclipseLinkJavaConvertTests.class); suite.addTestSuite(EclipseLinkJavaConverterTests.class); + suite.addTestSuite(EclipseLinkJavaConvertTests.class); suite.addTestSuite(EclipseLinkJavaEmbeddableTests.class); suite.addTestSuite(EclipseLinkJavaEntityTests.class); suite.addTestSuite(EclipseLinkJavaIdMappingTests.class); + suite.addTestSuite(EclipseLinkJavaManyToManyMappingTests.class); + suite.addTestSuite(EclipseLinkJavaManyToOneMappingTests.class); suite.addTestSuite(EclipseLinkJavaMappedSuperclassTests.class); suite.addTestSuite(EclipseLinkJavaObjectTypeConverterTests.class); suite.addTestSuite(EclipseLinkJavaOneToManyMappingTests.class); suite.addTestSuite(EclipseLinkJavaOneToOneMappingTests.class); - suite.addTestSuite(EclipseLinkJavaManyToManyMappingTests.class); - suite.addTestSuite(EclipseLinkJavaManyToOneMappingTests.class); suite.addTestSuite(EclipseLinkJavaStructConverterTests.class); suite.addTestSuite(EclipseLinkJavaTypeConverterTests.class); suite.addTestSuite(EclipseLinkJavaVersionMappingTests.class); diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/java/EclipseLink2_0JavaEntityTests.java b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/java/EclipseLink2_0JavaEntityTests.java index 853ba7123f..6bdad08d71 100644 --- a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/java/EclipseLink2_0JavaEntityTests.java +++ b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/java/EclipseLink2_0JavaEntityTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. + * Copyright (c) 2009, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -434,12 +434,14 @@ public class EclipseLink2_0JavaEntityTests extends EclipseLink2_0ContextModelTes //add an annotation to the resource model and verify the context model is updated AttributeOverrideAnnotation attributeOverride = (AttributeOverrideAnnotation) typeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES); attributeOverride.setName("FOO"); + getJpaProject().synchronizeContextModel(); specifiedAttributeOverrides = overrideContainer.specifiedAttributeOverrides(); assertEquals("FOO", specifiedAttributeOverrides.next().getName()); assertFalse(specifiedAttributeOverrides.hasNext()); attributeOverride = (AttributeOverrideAnnotation) typeResource.addAnnotation(1, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES); attributeOverride.setName("BAR"); + getJpaProject().synchronizeContextModel(); specifiedAttributeOverrides = overrideContainer.specifiedAttributeOverrides(); assertEquals("FOO", specifiedAttributeOverrides.next().getName()); assertEquals("BAR", specifiedAttributeOverrides.next().getName()); @@ -448,6 +450,7 @@ public class EclipseLink2_0JavaEntityTests extends EclipseLink2_0ContextModelTes attributeOverride = (AttributeOverrideAnnotation) typeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES); attributeOverride.setName("BAZ"); + getJpaProject().synchronizeContextModel(); specifiedAttributeOverrides = overrideContainer.specifiedAttributeOverrides(); assertEquals("BAZ", specifiedAttributeOverrides.next().getName()); assertEquals("FOO", specifiedAttributeOverrides.next().getName()); @@ -456,6 +459,7 @@ public class EclipseLink2_0JavaEntityTests extends EclipseLink2_0ContextModelTes //move an annotation to the resource model and verify the context model is updated typeResource.moveAnnotation(1, 0, JPA.ATTRIBUTE_OVERRIDES); + getJpaProject().synchronizeContextModel(); specifiedAttributeOverrides = overrideContainer.specifiedAttributeOverrides(); assertEquals("FOO", specifiedAttributeOverrides.next().getName()); assertEquals("BAZ", specifiedAttributeOverrides.next().getName()); @@ -463,18 +467,21 @@ public class EclipseLink2_0JavaEntityTests extends EclipseLink2_0ContextModelTes assertFalse(specifiedAttributeOverrides.hasNext()); typeResource.removeAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES); + getJpaProject().synchronizeContextModel(); specifiedAttributeOverrides = overrideContainer.specifiedAttributeOverrides(); assertEquals("BAZ", specifiedAttributeOverrides.next().getName()); assertEquals("BAR", specifiedAttributeOverrides.next().getName()); assertFalse(specifiedAttributeOverrides.hasNext()); typeResource.removeAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES); + getJpaProject().synchronizeContextModel(); specifiedAttributeOverrides = overrideContainer.specifiedAttributeOverrides(); assertEquals("BAR", specifiedAttributeOverrides.next().getName()); assertFalse(specifiedAttributeOverrides.hasNext()); typeResource.removeAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES); + getJpaProject().synchronizeContextModel(); specifiedAttributeOverrides = overrideContainer.specifiedAttributeOverrides(); assertFalse(specifiedAttributeOverrides.hasNext()); } @@ -603,6 +610,7 @@ public class EclipseLink2_0JavaEntityTests extends EclipseLink2_0ContextModelTes attributeOverride.setName("FOO"); attributeOverride = (AttributeOverrideAnnotation) typeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES); attributeOverride.setName("BAR"); + getJpaProject().synchronizeContextModel(); assertEquals(2, overrideContainer.specifiedAttributeOverridesSize()); } @@ -790,6 +798,7 @@ public class EclipseLink2_0JavaEntityTests extends EclipseLink2_0ContextModelTes ((AttributeOverrideAnnotation) typeResource.addAnnotation(0, AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME)).setName("FOO"); ((AttributeOverrideAnnotation) typeResource.addAnnotation(1, AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME)).setName("BAR"); ((AttributeOverrideAnnotation) typeResource.addAnnotation(2, AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME)).setName("BAZ"); + getJpaProject().synchronizeContextModel(); ListIterator<AttributeOverride> attributeOverrides = overrideContainer.specifiedAttributeOverrides(); assertEquals("FOO", attributeOverrides.next().getName()); @@ -798,6 +807,7 @@ public class EclipseLink2_0JavaEntityTests extends EclipseLink2_0ContextModelTes assertFalse(attributeOverrides.hasNext()); typeResource.moveAnnotation(2, 0, AttributeOverridesAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); attributeOverrides = overrideContainer.specifiedAttributeOverrides(); assertEquals("BAR", attributeOverrides.next().getName()); assertEquals("BAZ", attributeOverrides.next().getName()); @@ -805,6 +815,7 @@ public class EclipseLink2_0JavaEntityTests extends EclipseLink2_0ContextModelTes assertFalse(attributeOverrides.hasNext()); typeResource.moveAnnotation(0, 1, AttributeOverridesAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); attributeOverrides = overrideContainer.specifiedAttributeOverrides(); assertEquals("BAZ", attributeOverrides.next().getName()); assertEquals("BAR", attributeOverrides.next().getName()); @@ -812,17 +823,20 @@ public class EclipseLink2_0JavaEntityTests extends EclipseLink2_0ContextModelTes assertFalse(attributeOverrides.hasNext()); typeResource.removeAnnotation(1, AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); attributeOverrides = overrideContainer.specifiedAttributeOverrides(); assertEquals("BAZ", attributeOverrides.next().getName()); assertEquals("FOO", attributeOverrides.next().getName()); assertFalse(attributeOverrides.hasNext()); typeResource.removeAnnotation(1, AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); attributeOverrides = overrideContainer.specifiedAttributeOverrides(); assertEquals("BAZ", attributeOverrides.next().getName()); assertFalse(attributeOverrides.hasNext()); typeResource.removeAnnotation(0, AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); attributeOverrides = overrideContainer.specifiedAttributeOverrides(); assertFalse(attributeOverrides.hasNext()); } @@ -924,12 +938,14 @@ public class EclipseLink2_0JavaEntityTests extends EclipseLink2_0ContextModelTes //add an annotation to the resource model and verify the context model is updated AssociationOverrideAnnotation associationOverride = (AssociationOverrideAnnotation) typeResource.addAnnotation(0, JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES); associationOverride.setName("FOO"); + getJpaProject().synchronizeContextModel(); specifiedAssociationOverrides = overrideContainer.specifiedAssociationOverrides(); assertEquals("FOO", specifiedAssociationOverrides.next().getName()); assertFalse(specifiedAssociationOverrides.hasNext()); associationOverride = (AssociationOverrideAnnotation) typeResource.addAnnotation(1, JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES); associationOverride.setName("BAR"); + getJpaProject().synchronizeContextModel(); specifiedAssociationOverrides = overrideContainer.specifiedAssociationOverrides(); assertEquals("FOO", specifiedAssociationOverrides.next().getName()); assertEquals("BAR", specifiedAssociationOverrides.next().getName()); @@ -938,6 +954,7 @@ public class EclipseLink2_0JavaEntityTests extends EclipseLink2_0ContextModelTes associationOverride = (AssociationOverrideAnnotation) typeResource.addAnnotation(0, JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES); associationOverride.setName("BAZ"); + getJpaProject().synchronizeContextModel(); specifiedAssociationOverrides = overrideContainer.specifiedAssociationOverrides(); assertEquals("BAZ", specifiedAssociationOverrides.next().getName()); assertEquals("FOO", specifiedAssociationOverrides.next().getName()); @@ -946,6 +963,7 @@ public class EclipseLink2_0JavaEntityTests extends EclipseLink2_0ContextModelTes //move an annotation to the resource model and verify the context model is updated typeResource.moveAnnotation(1, 0, JPA.ASSOCIATION_OVERRIDES); + getJpaProject().synchronizeContextModel(); specifiedAssociationOverrides = overrideContainer.specifiedAssociationOverrides(); assertEquals("FOO", specifiedAssociationOverrides.next().getName()); assertEquals("BAZ", specifiedAssociationOverrides.next().getName()); @@ -953,18 +971,21 @@ public class EclipseLink2_0JavaEntityTests extends EclipseLink2_0ContextModelTes assertFalse(specifiedAssociationOverrides.hasNext()); typeResource.removeAnnotation(0, JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES); + getJpaProject().synchronizeContextModel(); specifiedAssociationOverrides = overrideContainer.specifiedAssociationOverrides(); assertEquals("BAZ", specifiedAssociationOverrides.next().getName()); assertEquals("BAR", specifiedAssociationOverrides.next().getName()); assertFalse(specifiedAssociationOverrides.hasNext()); typeResource.removeAnnotation(0, JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES); + getJpaProject().synchronizeContextModel(); specifiedAssociationOverrides = overrideContainer.specifiedAssociationOverrides(); assertEquals("BAR", specifiedAssociationOverrides.next().getName()); assertFalse(specifiedAssociationOverrides.hasNext()); typeResource.removeAnnotation(0, JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES); + getJpaProject().synchronizeContextModel(); specifiedAssociationOverrides = overrideContainer.specifiedAssociationOverrides(); assertFalse(specifiedAssociationOverrides.hasNext()); } @@ -1075,6 +1096,7 @@ public class EclipseLink2_0JavaEntityTests extends EclipseLink2_0ContextModelTes associationOverride.setName("FOO"); associationOverride = (AssociationOverrideAnnotation) typeResource.addAnnotation(0, JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES); associationOverride.setName("BAR"); + getJpaProject().synchronizeContextModel(); assertEquals(2, overrideContainer.specifiedAssociationOverridesSize()); } @@ -1247,6 +1269,7 @@ public class EclipseLink2_0JavaEntityTests extends EclipseLink2_0ContextModelTes ((AssociationOverrideAnnotation) typeResource.addAnnotation(0, AssociationOverrideAnnotation.ANNOTATION_NAME, AssociationOverridesAnnotation.ANNOTATION_NAME)).setName("FOO"); ((AssociationOverrideAnnotation) typeResource.addAnnotation(1, AssociationOverrideAnnotation.ANNOTATION_NAME, AssociationOverridesAnnotation.ANNOTATION_NAME)).setName("BAR"); ((AssociationOverrideAnnotation) typeResource.addAnnotation(2, AssociationOverrideAnnotation.ANNOTATION_NAME, AssociationOverridesAnnotation.ANNOTATION_NAME)).setName("BAZ"); + getJpaProject().synchronizeContextModel(); ListIterator<AssociationOverride> associationOverrides = overrideContainer.specifiedAssociationOverrides(); assertEquals("FOO", associationOverrides.next().getName()); @@ -1255,6 +1278,7 @@ public class EclipseLink2_0JavaEntityTests extends EclipseLink2_0ContextModelTes assertFalse(associationOverrides.hasNext()); typeResource.moveAnnotation(2, 0, AssociationOverridesAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); associationOverrides = overrideContainer.specifiedAssociationOverrides(); assertEquals("BAR", associationOverrides.next().getName()); assertEquals("BAZ", associationOverrides.next().getName()); @@ -1262,6 +1286,7 @@ public class EclipseLink2_0JavaEntityTests extends EclipseLink2_0ContextModelTes assertFalse(associationOverrides.hasNext()); typeResource.moveAnnotation(0, 1, AssociationOverridesAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); associationOverrides = overrideContainer.specifiedAssociationOverrides(); assertEquals("BAZ", associationOverrides.next().getName()); assertEquals("BAR", associationOverrides.next().getName()); @@ -1269,17 +1294,20 @@ public class EclipseLink2_0JavaEntityTests extends EclipseLink2_0ContextModelTes assertFalse(associationOverrides.hasNext()); typeResource.removeAnnotation(1, AssociationOverrideAnnotation.ANNOTATION_NAME, AssociationOverridesAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); associationOverrides = overrideContainer.specifiedAssociationOverrides(); assertEquals("BAZ", associationOverrides.next().getName()); assertEquals("FOO", associationOverrides.next().getName()); assertFalse(associationOverrides.hasNext()); typeResource.removeAnnotation(1, AssociationOverrideAnnotation.ANNOTATION_NAME, AssociationOverridesAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); associationOverrides = overrideContainer.specifiedAssociationOverrides(); assertEquals("BAZ", associationOverrides.next().getName()); assertFalse(associationOverrides.hasNext()); typeResource.removeAnnotation(0, AssociationOverrideAnnotation.ANNOTATION_NAME, AssociationOverridesAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); associationOverrides = overrideContainer.specifiedAssociationOverrides(); assertFalse(associationOverrides.hasNext()); } @@ -1482,28 +1510,33 @@ public class EclipseLink2_0JavaEntityTests extends EclipseLink2_0ContextModelTes assertEquals(null, cacheableAnnotation); getJavaPersistentType().getResourcePersistentType().addAnnotation(JPA2_0.CACHEABLE); + getJpaProject().synchronizeContextModel(); cacheableAnnotation = (Cacheable2_0Annotation) getJavaPersistentType().getResourcePersistentType().getAnnotation(JPA2_0.CACHEABLE); assertEquals(Boolean.TRUE, cacheable.getSpecifiedCacheable()); assertEquals(null, cacheableAnnotation.getValue()); assertSourceContains("@Cacheable", cu); cacheableAnnotation.setValue(Boolean.FALSE); + getJpaProject().synchronizeContextModel(); assertEquals(Boolean.FALSE, cacheable.getSpecifiedCacheable()); assertEquals(Boolean.FALSE, cacheableAnnotation.getValue()); assertSourceContains("@Cacheable(false)", cu); cacheableAnnotation.setValue(Boolean.TRUE); + getJpaProject().synchronizeContextModel(); assertEquals(Boolean.TRUE, cacheable.getSpecifiedCacheable()); assertEquals(Boolean.TRUE, cacheableAnnotation.getValue()); assertSourceContains("@Cacheable(true)", cu); cacheableAnnotation.setValue(null); + getJpaProject().synchronizeContextModel(); assertEquals(Boolean.TRUE, cacheable.getSpecifiedCacheable()); assertEquals(null, cacheableAnnotation.getValue()); assertSourceContains("@Cacheable", cu); getJavaPersistentType().getResourcePersistentType().removeAnnotation(JPA2_0.CACHEABLE); cacheableAnnotation = (Cacheable2_0Annotation) getJavaPersistentType().getResourcePersistentType().getAnnotation(JPA2_0.CACHEABLE); + getJpaProject().synchronizeContextModel(); assertEquals(null, cacheable.getSpecifiedCacheable()); assertEquals(null, cacheableAnnotation); assertSourceDoesNotContain("@Cacheable", cu); diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/java/EclipseLink2_0JavaManyToOneMappingTests.java b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/java/EclipseLink2_0JavaManyToOneMappingTests.java index c8472e1778..08971a766a 100644 --- a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/java/EclipseLink2_0JavaManyToOneMappingTests.java +++ b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/java/EclipseLink2_0JavaManyToOneMappingTests.java @@ -1,13 +1,12 @@ /******************************************************************************* - * Copyright (c) 2009 Oracle. - * All rights reserved. This program and the accompanying materials are - * made available under the terms of the Eclipse Public License v1.0 which - * accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle - initial API and implementation - *******************************************************************************/ + * Copyright (c) 2009, 2010 Oracle. All rights reserved. + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0, which accompanies this distribution + * and is available at http://www.eclipse.org/legal/epl-v10.html. + * + * Contributors: + * Oracle - initial API and implementation + ******************************************************************************/ package org.eclipse.jpt.eclipselink2_0.core.tests.internal.context.java; import java.util.Iterator; @@ -123,10 +122,12 @@ public class EclipseLink2_0JavaManyToOneMappingTests assertTrue(contextMapping.getDerivedIdentity().getIdDerivedIdentityStrategy().getValue()); resourceAttribute.removeAnnotation(JPA.ID); + getJpaProject().synchronizeContextModel(); assertNull(resourceAttribute.getAnnotation(JPA.ID)); assertFalse(contextMapping.getDerivedIdentity().getIdDerivedIdentityStrategy().getValue()); resourceAttribute.addAnnotation(JPA.ID); + getJpaProject().synchronizeContextModel(); assertNotNull(resourceAttribute.getAnnotation(JPA.ID)); assertTrue(contextMapping.getDerivedIdentity().getIdDerivedIdentityStrategy().getValue()); } @@ -166,14 +167,17 @@ public class EclipseLink2_0JavaManyToOneMappingTests MapsId2_0Annotation annotation = (MapsId2_0Annotation) resourceAttribute.getAnnotation(JPA2_0.MAPS_ID); annotation.setValue("foo"); + getJpaProject().synchronizeContextModel(); assertEquals("foo", annotation.getValue()); assertEquals("foo", contextMapping.getDerivedIdentity().getMapsIdDerivedIdentityStrategy().getSpecifiedValue()); annotation.setValue("bar"); + getJpaProject().synchronizeContextModel(); assertEquals("bar", annotation.getValue()); assertEquals("bar", contextMapping.getDerivedIdentity().getMapsIdDerivedIdentityStrategy().getSpecifiedValue()); resourceAttribute.removeAnnotation(JPA2_0.MAPS_ID); + getJpaProject().synchronizeContextModel(); assertNull(resourceAttribute.getAnnotation(JPA2_0.MAPS_ID)); assertNull(contextMapping.getDerivedIdentity().getMapsIdDerivedIdentityStrategy().getSpecifiedValue()); } @@ -217,6 +221,7 @@ public class EclipseLink2_0JavaManyToOneMappingTests JavaPersistentAttribute contextAttribute = contextType.getAttributeNamed("manyToOne"); ((MapsId2_0Annotation) resourceAttribute.getAnnotation(JPA2_0.MAPS_ID)).setValue("foo"); + getJpaProject().synchronizeContextModel(); assertNull(resourceAttribute.getAnnotation(JPA.ID)); assertFalse(((JavaManyToOneMapping2_0) contextAttribute.getMapping()). diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/java/EclipseLink2_0JavaMappedSuperclassTests.java b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/java/EclipseLink2_0JavaMappedSuperclassTests.java index b48a8bcb95..cbb6b3846d 100644 --- a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/java/EclipseLink2_0JavaMappedSuperclassTests.java +++ b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/java/EclipseLink2_0JavaMappedSuperclassTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. + * Copyright (c) 2009, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -178,11 +178,13 @@ public class EclipseLink2_0JavaMappedSuperclassTests extends EclipseLink2_0Conte JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME); typeResource.removeAnnotation(EclipseLinkReadOnlyAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertEquals(null, readOnly.getSpecifiedReadOnly()); assertEquals(false, readOnly.isDefaultReadOnly()); typeResource.addAnnotation(EclipseLinkReadOnlyAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertEquals(Boolean.TRUE, readOnly.getSpecifiedReadOnly()); } @@ -233,15 +235,19 @@ public class EclipseLink2_0JavaMappedSuperclassTests extends EclipseLink2_0Conte JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME); EclipseLinkCustomizerAnnotation customizerAnnotation = (EclipseLinkCustomizerAnnotation) typeResource.getAnnotation(EclipseLinkCustomizerAnnotation.ANNOTATION_NAME); customizerAnnotation.setValue("Bar"); + getJpaProject().synchronizeContextModel(); assertEquals("Bar", customizer.getSpecifiedCustomizerClass()); typeResource.removeAnnotation(EclipseLinkCustomizerAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertEquals(null, customizer.getSpecifiedCustomizerClass()); customizerAnnotation = (EclipseLinkCustomizerAnnotation) typeResource.addAnnotation(EclipseLinkCustomizerAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertEquals(null, customizer.getSpecifiedCustomizerClass()); customizerAnnotation.setValue("FooBar"); + getJpaProject().synchronizeContextModel(); assertEquals("FooBar", customizer.getSpecifiedCustomizerClass()); } @@ -264,6 +270,7 @@ public class EclipseLink2_0JavaMappedSuperclassTests extends EclipseLink2_0Conte // change resource to ATTRIBUTE specifically, test context resourceChangeTracking.setValue(org.eclipse.jpt.eclipselink.core.resource.java.ChangeTrackingType.ATTRIBUTE); + getJpaProject().synchronizeContextModel(); assertEquals(org.eclipse.jpt.eclipselink.core.resource.java.ChangeTrackingType.ATTRIBUTE, resourceChangeTracking.getValue()); assertEquals(EclipseLinkChangeTrackingType.ATTRIBUTE, contextChangeTracking.getType()); @@ -273,6 +280,7 @@ public class EclipseLink2_0JavaMappedSuperclassTests extends EclipseLink2_0Conte // change resource to OBJECT specifically, test context resourceChangeTracking.setValue(org.eclipse.jpt.eclipselink.core.resource.java.ChangeTrackingType.OBJECT); + getJpaProject().synchronizeContextModel(); assertEquals(org.eclipse.jpt.eclipselink.core.resource.java.ChangeTrackingType.OBJECT, resourceChangeTracking.getValue()); assertEquals(EclipseLinkChangeTrackingType.OBJECT, contextChangeTracking.getType()); @@ -282,6 +290,7 @@ public class EclipseLink2_0JavaMappedSuperclassTests extends EclipseLink2_0Conte // change resource to DEFERRED specifically, test context resourceChangeTracking.setValue(org.eclipse.jpt.eclipselink.core.resource.java.ChangeTrackingType.DEFERRED); + getJpaProject().synchronizeContextModel(); assertEquals(org.eclipse.jpt.eclipselink.core.resource.java.ChangeTrackingType.DEFERRED, resourceChangeTracking.getValue()); assertEquals(EclipseLinkChangeTrackingType.DEFERRED, contextChangeTracking.getType()); @@ -291,6 +300,7 @@ public class EclipseLink2_0JavaMappedSuperclassTests extends EclipseLink2_0Conte // change resource to AUTO specifically, test context resourceChangeTracking.setValue(org.eclipse.jpt.eclipselink.core.resource.java.ChangeTrackingType.AUTO); + getJpaProject().synchronizeContextModel(); assertEquals(org.eclipse.jpt.eclipselink.core.resource.java.ChangeTrackingType.AUTO, resourceChangeTracking.getValue()); assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getType()); @@ -300,6 +310,7 @@ public class EclipseLink2_0JavaMappedSuperclassTests extends EclipseLink2_0Conte // remove value from resource, test context resourceChangeTracking.setValue(null); + getJpaProject().synchronizeContextModel(); assertNull(resourceChangeTracking.getValue()); assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getType()); @@ -309,6 +320,7 @@ public class EclipseLink2_0JavaMappedSuperclassTests extends EclipseLink2_0Conte // remove annotation, text context typeResource.removeAnnotation(EclipseLinkChangeTrackingAnnotation.ANNOTATION_NAME); + getJpaProject().synchronizeContextModel(); assertNull(resourceChangeTracking.getValue()); assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getType()); @@ -413,27 +425,32 @@ public class EclipseLink2_0JavaMappedSuperclassTests extends EclipseLink2_0Conte assertEquals(null, cacheableAnnotation); getJavaPersistentType().getResourcePersistentType().addAnnotation(JPA2_0.CACHEABLE); + getJpaProject().synchronizeContextModel(); cacheableAnnotation = (Cacheable2_0Annotation) getJavaPersistentType().getResourcePersistentType().getAnnotation(JPA2_0.CACHEABLE); assertEquals(Boolean.TRUE, cacheable.getSpecifiedCacheable()); assertEquals(null, cacheableAnnotation.getValue()); assertSourceContains("@Cacheable", cu); cacheableAnnotation.setValue(Boolean.FALSE); + getJpaProject().synchronizeContextModel(); assertEquals(Boolean.FALSE, cacheable.getSpecifiedCacheable()); assertEquals(Boolean.FALSE, cacheableAnnotation.getValue()); assertSourceContains("@Cacheable(false)", cu); cacheableAnnotation.setValue(Boolean.TRUE); + getJpaProject().synchronizeContextModel(); assertEquals(Boolean.TRUE, cacheable.getSpecifiedCacheable()); assertEquals(Boolean.TRUE, cacheableAnnotation.getValue()); assertSourceContains("@Cacheable(true)", cu); cacheableAnnotation.setValue(null); + getJpaProject().synchronizeContextModel(); assertEquals(Boolean.TRUE, cacheable.getSpecifiedCacheable()); assertEquals(null, cacheableAnnotation.getValue()); assertSourceContains("@Cacheable", cu); getJavaPersistentType().getResourcePersistentType().removeAnnotation(JPA2_0.CACHEABLE); + getJpaProject().synchronizeContextModel(); cacheableAnnotation = (Cacheable2_0Annotation) getJavaPersistentType().getResourcePersistentType().getAnnotation(JPA2_0.CACHEABLE); assertEquals(null, cacheable.getSpecifiedCacheable()); assertEquals(null, cacheableAnnotation); diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/java/EclipseLink2_0JavaOneToManyMappingTests.java b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/java/EclipseLink2_0JavaOneToManyMappingTests.java index 717c666f39..16bcfaadd0 100644 --- a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/java/EclipseLink2_0JavaOneToManyMappingTests.java +++ b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/java/EclipseLink2_0JavaOneToManyMappingTests.java @@ -1,5 +1,5 @@ /******************************************************************************* -* Copyright (c) 2009 Oracle. All rights reserved. +* Copyright (c) 2009, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -130,6 +130,7 @@ public class EclipseLink2_0JavaOneToManyMappingTests JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next(); OneToMany2_0Annotation oneToMany = (OneToMany2_0Annotation) attributeResource.getAnnotation(JPA.ONE_TO_MANY); oneToMany.setOrphanRemoval(Boolean.FALSE); + getJpaProject().synchronizeContextModel(); assertEquals(Boolean.FALSE, mappingsOrphanRemoval.getSpecifiedOrphanRemoval()); } @@ -206,15 +207,18 @@ public class EclipseLink2_0JavaOneToManyMappingTests JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next(); OneToMany2_0Annotation oneToMany = (OneToMany2_0Annotation) attributeResource.getAnnotation(JPA.ONE_TO_MANY); oneToMany.setOrphanRemoval(Boolean.FALSE); + getJpaProject().synchronizeContextModel(); assertEquals(Boolean.FALSE, mappingsOrphanRemoval.getSpecifiedOrphanRemoval()); oneToMany.setOrphanRemoval(null); + getJpaProject().synchronizeContextModel(); assertNull(mappingsOrphanRemoval.getSpecifiedOrphanRemoval()); assertSame(oneToManyMapping, persistentAttribute.getSpecifiedMapping()); oneToMany.setOrphanRemoval(Boolean.FALSE); attributeResource.setPrimaryAnnotation(null, EmptyIterable.<String>instance()); + getJpaProject().synchronizeContextModel(); assertNull(persistentAttribute.getSpecifiedMapping()); } diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/java/EclipseLink2_0JavaOneToOneMappingTests.java b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/java/EclipseLink2_0JavaOneToOneMappingTests.java index 5f5f0587da..6436c4b2b9 100644 --- a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/java/EclipseLink2_0JavaOneToOneMappingTests.java +++ b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/java/EclipseLink2_0JavaOneToOneMappingTests.java @@ -1,12 +1,12 @@ /******************************************************************************* -* Copyright (c) 2009 Oracle. All rights reserved. -* This program and the accompanying materials are made available under the -* terms of the Eclipse Public License v1.0, which accompanies this distribution -* and is available at http://www.eclipse.org/legal/epl-v10.html. -* -* Contributors: -* Oracle - initial API and implementation - *******************************************************************************/ + * Copyright (c) 2009, 2010 Oracle. All rights reserved. + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0, which accompanies this distribution + * and is available at http://www.eclipse.org/legal/epl-v10.html. + * + * Contributors: + * Oracle - initial API and implementation + ******************************************************************************/ package org.eclipse.jpt.eclipselink2_0.core.tests.internal.context.java; import java.util.Iterator; @@ -241,10 +241,12 @@ public class EclipseLink2_0JavaOneToOneMappingTests assertTrue(contextMapping.getDerivedIdentity().getIdDerivedIdentityStrategy().getValue()); resourceAttribute.removeAnnotation(JPA.ID); + getJpaProject().synchronizeContextModel(); assertNull(resourceAttribute.getAnnotation(JPA.ID)); assertFalse(contextMapping.getDerivedIdentity().getIdDerivedIdentityStrategy().getValue()); resourceAttribute.addAnnotation(JPA.ID); + getJpaProject().synchronizeContextModel(); assertNotNull(resourceAttribute.getAnnotation(JPA.ID)); assertTrue(contextMapping.getDerivedIdentity().getIdDerivedIdentityStrategy().getValue()); } @@ -287,14 +289,17 @@ public class EclipseLink2_0JavaOneToOneMappingTests MapsId2_0Annotation annotation = (MapsId2_0Annotation) resourceAttribute.getAnnotation(JPA2_0.MAPS_ID); annotation.setValue("foo"); + getJpaProject().synchronizeContextModel(); assertEquals("foo", annotation.getValue()); assertEquals("foo", contextMapping.getDerivedIdentity().getMapsIdDerivedIdentityStrategy().getSpecifiedValue()); annotation.setValue("bar"); + getJpaProject().synchronizeContextModel(); assertEquals("bar", annotation.getValue()); assertEquals("bar", contextMapping.getDerivedIdentity().getMapsIdDerivedIdentityStrategy().getSpecifiedValue()); resourceAttribute.removeAnnotation(JPA2_0.MAPS_ID); + getJpaProject().synchronizeContextModel(); assertNull(resourceAttribute.getAnnotation(JPA2_0.MAPS_ID)); assertNull(contextMapping.getDerivedIdentity().getMapsIdDerivedIdentityStrategy().getSpecifiedValue()); } @@ -467,6 +472,7 @@ public class EclipseLink2_0JavaOneToOneMappingTests JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next(); OneToOne2_0Annotation oneToOne = (OneToOne2_0Annotation) attributeResource.getAnnotation(JPA.ONE_TO_ONE); oneToOne.setOrphanRemoval(Boolean.FALSE); + getJpaProject().synchronizeContextModel(); assertEquals(Boolean.FALSE, mappingsOrphanRemoval.getSpecifiedOrphanRemoval()); } @@ -541,15 +547,18 @@ public class EclipseLink2_0JavaOneToOneMappingTests JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next(); OneToOne2_0Annotation oneToOne = (OneToOne2_0Annotation) attributeResource.getAnnotation(JPA.ONE_TO_ONE); oneToOne.setOrphanRemoval(Boolean.FALSE); + getJpaProject().synchronizeContextModel(); assertEquals(Boolean.FALSE, mappingsOrphanRemoval.getSpecifiedOrphanRemoval()); oneToOne.setOrphanRemoval(null); + getJpaProject().synchronizeContextModel(); assertNull(mappingsOrphanRemoval.getSpecifiedOrphanRemoval()); assertSame(oneToOneMapping, persistentAttribute.getSpecifiedMapping()); oneToOne.setOrphanRemoval(Boolean.FALSE); attributeResource.setPrimaryAnnotation(null, EmptyIterable.<String>instance()); + getJpaProject().synchronizeContextModel(); assertNull(persistentAttribute.getSpecifiedMapping()); } diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/java/JptEclipseLink2_0JavaContextModelTests.java b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/java/JptEclipseLink2_0JavaContextModelTests.java index 8abfa78fae..7704bb3392 100644 --- a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/java/JptEclipseLink2_0JavaContextModelTests.java +++ b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/java/JptEclipseLink2_0JavaContextModelTests.java @@ -1,5 +1,5 @@ /******************************************************************************* -* Copyright (c) 2009 Oracle. All rights reserved. +* Copyright (c) 2009, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -20,8 +20,8 @@ public class JptEclipseLink2_0JavaContextModelTests extends TestCase suite.addTestSuite(EclipseLink2_0JavaEntityTests.class); suite.addTestSuite(EclipseLink2_0JavaManyToOneMappingTests.class); suite.addTestSuite(EclipseLink2_0JavaMappedSuperclassTests.class); - suite.addTestSuite(EclipseLink2_0JavaOneToOneMappingTests.class); suite.addTestSuite(EclipseLink2_0JavaOneToManyMappingTests.class); + suite.addTestSuite(EclipseLink2_0JavaOneToOneMappingTests.class); return suite; } |