summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNan Li2013-04-15 23:00:03 (EDT)
committer Neil Hauge2013-04-15 23:00:03 (EDT)
commit226d55177a7da248ad0d148a3b98b143344ab38c (patch)
tree6e2b72baed950a1d4a61edfa2047d19b400cefe7
parent40e7038c4717547872d800d78a2bc5ac2ade5cdc (diff)
downloadwebtools.dali-226d55177a7da248ad0d148a3b98b143344ab38c.zip
webtools.dali-226d55177a7da248ad0d148a3b98b143344ab38c.tar.gz
webtools.dali-226d55177a7da248ad0d148a3b98b143344ab38c.tar.bz2
403131 - Complete removal of ORM XML creation from project creation.
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/facet/JpaFacetInstallDataModelProperties.java7
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/facet/JpaFacetInstallDataModelProvider.java6
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/facet/JpaFacetInstallDelegate.java26
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/ContextModelTestCase.java23
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/model/JpaProjectManagerTests.java24
5 files changed, 42 insertions, 44 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/facet/JpaFacetInstallDataModelProperties.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/facet/JpaFacetInstallDataModelProperties.java
index a72c420..ec3b9ee 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/facet/JpaFacetInstallDataModelProperties.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/facet/JpaFacetInstallDataModelProperties.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2009 Oracle. All rights reserved.
+ * Copyright (c) 2006, 2013 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.
@@ -25,9 +25,4 @@ public interface JpaFacetInstallDataModelProperties
* Not required, type String, identifies the database driver library added to the classpath
*/
String DB_DRIVER_NAME = PREFIX_ + "DB_DRIVER_NAME";
-
- /**
- * Required, type boolean, details whether orm.xml should be created
- */
- String CREATE_ORM_XML = PREFIX_ + "CREATE_ORM_XML";
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/facet/JpaFacetInstallDataModelProvider.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/facet/JpaFacetInstallDataModelProvider.java
index 58937fe..2de8e27 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/facet/JpaFacetInstallDataModelProvider.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/facet/JpaFacetInstallDataModelProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2012 Oracle. All rights reserved.
+ * Copyright (c) 2006, 2013 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.
@@ -40,7 +40,6 @@ public class JpaFacetInstallDataModelProvider
Set<String> propertyNames = super.getPropertyNames();
propertyNames.add(USER_WANTS_TO_ADD_DB_DRIVER_JARS_TO_CLASSPATH);
propertyNames.add(DB_DRIVER_NAME);
- propertyNames.add(CREATE_ORM_XML);
return propertyNames;
}
@@ -81,9 +80,6 @@ public class JpaFacetInstallDataModelProvider
if (propertyName.equals(DB_DRIVER_NAME)) {
return this.getDefaultDriverName();
}
- if (propertyName.equals(CREATE_ORM_XML)) {
- return Boolean.FALSE;
- }
return super.getDefaultProperty(propertyName);
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/facet/JpaFacetInstallDelegate.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/facet/JpaFacetInstallDelegate.java
index bca98d4..9aa446b 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/facet/JpaFacetInstallDelegate.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/facet/JpaFacetInstallDelegate.java
@@ -23,7 +23,6 @@ import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jpt.common.core.resource.ProjectResourceLocator;
import org.eclipse.jpt.common.utility.internal.ArrayTools;
import org.eclipse.jpt.jpa.core.JpaWorkspace;
-import org.eclipse.jpt.jpa.core.internal.operations.OrmFileCreationDataModelProvider;
import org.eclipse.jpt.jpa.core.internal.operations.PersistenceFileCreationDataModelProvider;
import org.eclipse.jpt.jpa.core.internal.plugin.JptJpaCorePlugin;
import org.eclipse.jpt.jpa.db.ConnectionProfileFactory;
@@ -59,7 +58,7 @@ public class JpaFacetInstallDelegate
this.addDbDriverLibraryToClasspath(javaProject, dataModel, sm.newChild(1));
// create project XML files
- this.createProjectXml(project, dataModel.getBooleanProperty(CREATE_ORM_XML), sm.newChild(8));
+ this.createProjectXml(project, sm.newChild(8));
}
protected void addDbDriverLibraryToClasspath(
@@ -96,14 +95,9 @@ public class JpaFacetInstallDelegate
}
}
- private void createProjectXml(IProject project, boolean buildOrmXml, IProgressMonitor monitor) {
- int tasks = 1 + (buildOrmXml ? 1 : 0);
- SubMonitor sm = SubMonitor.convert(monitor, tasks);
-
+ private void createProjectXml(IProject project, IProgressMonitor monitor) {
+ SubMonitor sm = SubMonitor.convert(monitor, 1);
this.createPersistenceXml(project, sm.newChild(1));
- if (buildOrmXml) {
- this.createOrmXml(project, sm.newChild(1));
- }
}
private void createPersistenceXml(IProject project, IProgressMonitor monitor) {
@@ -120,20 +114,6 @@ public class JpaFacetInstallDelegate
}
}
- private void createOrmXml(IProject project, IProgressMonitor monitor) {
- SubMonitor sm = SubMonitor.convert(monitor, 5);
-
- IDataModel config = DataModelFactory.createDataModel(new OrmFileCreationDataModelProvider());
- config.setProperty(CONTAINER_PATH, defaultResourceLocation(project));
- sm.worked(1);
- // default values for all other properties should suffice
- try {
- config.getDefaultOperation().execute(sm.newChild(4), null);
- } catch (ExecutionException ex) {
- JptJpaCorePlugin.instance().logError(ex);
- }
- }
-
protected IPath defaultResourceLocation(IProject project) {
ProjectResourceLocator resourceLocator = (ProjectResourceLocator) project.getAdapter(ProjectResourceLocator.class);
if (resourceLocator == null) {
diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/ContextModelTestCase.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/ContextModelTestCase.java
index 80be4ce..2cd55a1 100644
--- a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/ContextModelTestCase.java
+++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/ContextModelTestCase.java
@@ -16,6 +16,7 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.jpt.common.core.internal.operations.JptFileCreationDataModelProperties;
import org.eclipse.jpt.common.core.resource.xml.JptXmlResource;
import org.eclipse.jpt.common.core.tests.internal.projects.TestJavaProject;
import org.eclipse.jpt.common.core.tests.internal.utility.jdt.AnnotationTestCase;
@@ -32,8 +33,9 @@ import org.eclipse.jpt.jpa.core.context.persistence.ClassRef;
import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
import org.eclipse.jpt.jpa.core.internal.GenericJpaPlatformFactory;
import org.eclipse.jpt.jpa.core.internal.facet.JpaFacetDataModelProperties;
-import org.eclipse.jpt.jpa.core.internal.facet.JpaFacetInstallDataModelProperties;
import org.eclipse.jpt.jpa.core.internal.facet.JpaFacetInstallDataModelProvider;
+import org.eclipse.jpt.jpa.core.internal.operations.OrmFileCreationDataModelProvider;
+import org.eclipse.jpt.jpa.core.internal.operations.OrmFileCreationOperation;
import org.eclipse.jpt.jpa.core.platform.JpaPlatformManager;
import org.eclipse.jpt.jpa.core.resource.orm.XmlEntityMappings;
import org.eclipse.jpt.jpa.core.resource.persistence.PersistenceFactory;
@@ -85,16 +87,31 @@ public abstract class ContextModelTestCase extends AnnotationTestCase
protected TestJpaProject buildJpaProject(String projectName, boolean autoBuild, IDataModel jpaConfig)
throws Exception {
- return TestJpaProject.buildJpaProject(projectName, autoBuild, jpaConfig);
+ TestJpaProject testJpaProject =TestJpaProject.buildJpaProject(projectName, autoBuild, jpaConfig);
+
+ if (createOrmXml()) {
+ OrmFileCreationOperation operation =
+ new OrmFileCreationOperation(buildGenericOrmConfig(testJpaProject));
+ operation.execute(null, null);
+ }
+
+ return testJpaProject;
}
protected IDataModel buildJpaConfigDataModel() {
IDataModel dataModel = DataModelFactory.createDataModel(new JpaFacetInstallDataModelProvider());
dataModel.setProperty(IFacetDataModelProperties.FACET_VERSION_STR, this.getJpaFacetVersionString());
dataModel.setProperty(JpaFacetDataModelProperties.PLATFORM, this.getJpaPlatformConfig());
- dataModel.setProperty(JpaFacetInstallDataModelProperties.CREATE_ORM_XML, Boolean.valueOf(this.createOrmXml()));
return dataModel;
}
+
+ protected IDataModel buildGenericOrmConfig(TestJpaProject testJpaProject) {
+ IDataModel config =
+ DataModelFactory.createDataModel(new OrmFileCreationDataModelProvider());
+ config.setProperty(JptFileCreationDataModelProperties.CONTAINER_PATH,
+ testJpaProject.getProject().getFolder("src/META-INF").getFullPath());
+ return config;
+ }
// default facet version is the latest version - but most tests use 1.0
protected String getJpaFacetVersionString() {
diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/model/JpaProjectManagerTests.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/model/JpaProjectManagerTests.java
index c5d9670..f341e6a 100644
--- a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/model/JpaProjectManagerTests.java
+++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/model/JpaProjectManagerTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2012 Oracle. All rights reserved.
+ * Copyright (c) 2006, 2013 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.
@@ -18,6 +18,7 @@ import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.jpt.common.core.internal.operations.JptFileCreationDataModelProperties;
import org.eclipse.jpt.common.core.internal.utility.JptPlugin;
import org.eclipse.jpt.common.core.internal.utility.ProjectTools;
import org.eclipse.jpt.common.core.tests.internal.projects.TestFacetedProject;
@@ -29,8 +30,8 @@ import org.eclipse.jpt.common.utility.internal.iterable.IterableTools;
import org.eclipse.jpt.jpa.core.JpaPreferences;
import org.eclipse.jpt.jpa.core.JpaProject;
import org.eclipse.jpt.jpa.core.JpaProjectManager;
-import org.eclipse.jpt.jpa.core.internal.facet.JpaFacetInstallDataModelProperties;
import org.eclipse.jpt.jpa.core.internal.facet.JpaFacetInstallDataModelProvider;
+import org.eclipse.jpt.jpa.core.internal.operations.OrmFileCreationDataModelProvider;
import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
@@ -120,12 +121,20 @@ public class JpaProjectManagerTests
private IDataModel buildJpaConfigDataModel() {
IDataModel dataModel = DataModelFactory.createDataModel(new JpaFacetInstallDataModelProvider());
- dataModel.setProperty(JpaFacetInstallDataModelProperties.CREATE_ORM_XML, Boolean.TRUE);
return dataModel;
}
+ private void createDefaultOrmXmlFile() throws Exception {
+ IDataModel config =
+ DataModelFactory.createDataModel(new OrmFileCreationDataModelProvider());
+ config.setProperty(JptFileCreationDataModelProperties.CONTAINER_PATH,
+ this.getJpaProject().getProject().getFolder("src/META-INF").getFullPath());
+ config.getDefaultOperation().execute(null, null);
+ }
+
public void testProjectCloseReopen() throws Exception {
this.testProjectHarness.installFacet(JpaProject.FACET_ID, JpaProject.FACET_VERSION_STRING, buildJpaConfigDataModel());
+ this.createDefaultOrmXmlFile();
JpaProject jpaProject = this.getJpaProject();
assertNotNull(jpaProject);
@@ -148,6 +157,7 @@ public class JpaProjectManagerTests
public void testProjectDeleteReimport() throws Exception {
this.testProjectHarness.installFacet(JpaProject.FACET_ID, JpaProject.FACET_VERSION_STRING, buildJpaConfigDataModel());
+ this.createDefaultOrmXmlFile();
JpaProject jpaProject = this.getJpaProject();
assertNotNull(jpaProject);
assertEquals(1, IterableTools.size(this.getJpaProjectManager().waitToGetJpaProjects()));
@@ -195,12 +205,12 @@ public class JpaProjectManagerTests
assertEquals(1, IterableTools.size(this.getJpaProjectManager().waitToGetJpaProjects()));
JpaProject jpaProject = this.getJpaProject();
assertNotNull(jpaProject);
- assertEquals(4, jpaProject.getJpaFilesSize());
+ assertEquals(3, jpaProject.getJpaFilesSize());
assertNotNull(jpaProject.getJpaFile(this.getFile(this.testProjectHarness, "src/test/pkg/TestEntity.java")));
assertNotNull(jpaProject.getJpaFile(this.getFile(this.testProjectHarness, "src/test/pkg/TestEntity2.java")));
assertNotNull(jpaProject.getJpaFile(this.getFile(this.testProjectHarness, "src/META-INF/persistence.xml")));
- assertNotNull(jpaProject.getJpaFile(this.getFile(this.testProjectHarness, "src/META-INF/orm.xml")));
+ assertNull(jpaProject.getJpaFile(this.getFile(this.testProjectHarness, "src/META-INF/orm.xml")));
this.testProjectHarness.uninstallFacet(JpaProject.FACET_ID, "1.0");
assertEquals(0, IterableTools.size(this.getJpaProjectManager().waitToGetJpaProjects()));
@@ -272,10 +282,10 @@ public class JpaProjectManagerTests
assertEquals(1, IterableTools.size(this.getJpaProjectManager().waitToGetJpaProjects()));
jpaProject = this.getJpaProject();
assertNotNull(jpaProject);
- assertEquals(4, jpaProject.getJpaFilesSize());
+ assertEquals(3, jpaProject.getJpaFilesSize());
assertNotNull(jpaProject.getJpaFile(this.getFile(this.testProjectHarness, "src/test/pkg/TestEntity.java")));
assertNotNull(jpaProject.getJpaFile(this.getFile(this.testProjectHarness, "src/test/pkg/TestEntity2.java")));
assertNotNull(jpaProject.getJpaFile(this.getFile(this.testProjectHarness, "src/META-INF/persistence.xml")));
- assertNotNull(jpaProject.getJpaFile(this.getFile(this.testProjectHarness, "src/META-INF/orm.xml")));
+ assertNull(jpaProject.getJpaFile(this.getFile(this.testProjectHarness, "src/META-INF/orm.xml")));
}
}