diff options
author | tle | 2011-04-19 22:18:48 +0000 |
---|---|---|
committer | tle | 2011-04-19 22:18:48 +0000 |
commit | 92e84c1f1c7323ae7ba463f4164637933b4a0a0e (patch) | |
tree | f22da2f7a2175fd1994fb2eb67cb6ca9c3f1de9c /jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org | |
parent | aa67fe676fa07b715d55bbcf2eb8a268b4e0cd4b (diff) | |
download | webtools.dali-92e84c1f1c7323ae7ba463f4164637933b4a0a0e.tar.gz webtools.dali-92e84c1f1c7323ae7ba463f4164637933b4a0a0e.tar.xz webtools.dali-92e84c1f1c7323ae7ba463f4164637933b4a0a0e.zip |
310824 - Generate Tables should offer DDL script only generation
Diffstat (limited to 'jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org')
4 files changed, 45 insertions, 18 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/context/persistence/schema/generation/SchemaGeneration.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/context/persistence/schema/generation/SchemaGeneration.java index 82941b0744..4678657581 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/context/persistence/schema/generation/SchemaGeneration.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/context/persistence/schema/generation/SchemaGeneration.java @@ -1,5 +1,5 @@ /******************************************************************************* -* Copyright (c) 2008, 2010 Oracle. All rights reserved. +* Copyright (c) 2008, 2011 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 interface SchemaGeneration extends PersistenceUnitProperties static final String CREATE_FILE_NAME_PROPERTY = "createFileName"; //$NON-NLS-1$ // EclipseLink key string static final String ECLIPSELINK_CREATE_FILE_NAME = "eclipselink.create-ddl-jdbc-file-name"; //$NON-NLS-1$ - static final String DEFAULT_SCHEMA_GENERATION_CREATE_FILE_NAME = "createDDL.jdbc"; //$NON-NLS-1$ + static final String DEFAULT_SCHEMA_GENERATION_CREATE_FILE_NAME = "createDDL.sql"; //$NON-NLS-1$ String getDefaultDropFileName(); String getDropFileName(); @@ -46,7 +46,7 @@ public interface SchemaGeneration extends PersistenceUnitProperties static final String DROP_FILE_NAME_PROPERTY = "dropFileName"; //$NON-NLS-1$ // EclipseLink key string static final String ECLIPSELINK_DROP_FILE_NAME = "eclipselink.drop-ddl-jdbc-file-name"; //$NON-NLS-1$ - static final String DEFAULT_SCHEMA_GENERATION_DROP_FILE_NAME = "dropDDL.jdbc"; //$NON-NLS-1$ + static final String DEFAULT_SCHEMA_GENERATION_DROP_FILE_NAME = "dropDDL.sql"; //$NON-NLS-1$ String getDefaultApplicationLocation(); String getApplicationLocation(); diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/ddlgen/AbstractEclipseLinkDDLGenerator.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/ddlgen/AbstractEclipseLinkDDLGenerator.java index 0651a847d3..7ba94b5af3 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/ddlgen/AbstractEclipseLinkDDLGenerator.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/ddlgen/AbstractEclipseLinkDDLGenerator.java @@ -18,6 +18,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; import java.util.List; +import java.util.Locale; import java.util.Properties; import org.eclipse.core.resources.IProject; @@ -36,6 +37,7 @@ import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants; import org.eclipse.jdt.launching.IRuntimeClasspathEntry; import org.eclipse.jpt.common.core.internal.gen.AbstractJptGenerator; +import org.eclipse.jpt.common.utility.internal.ReflectionTools; import org.eclipse.jpt.jpa.core.JpaPlatform; import org.eclipse.jpt.jpa.core.JpaProject; import org.eclipse.jpt.jpa.core.internal.JptCoreMessages; @@ -64,15 +66,17 @@ public abstract class AbstractEclipseLinkDDLGenerator extends AbstractJptGenerat public static final String FALSE = "false"; //$NON-NLS-1$ public static final String NONE = "NONE"; //$NON-NLS-1$ - private String puName; - private JpaProject jpaProject; + private final String puName; + private final JpaProject jpaProject; + private final OutputMode outputMode; // ********** constructors ********** - protected AbstractEclipseLinkDDLGenerator(String puName, JpaProject jpaProject) { + protected AbstractEclipseLinkDDLGenerator(String puName, JpaProject jpaProject, OutputMode outputMode) { super(JavaCore.create(jpaProject.getProject())); this.puName = puName; this.jpaProject = jpaProject; + this.outputMode = outputMode; } // ********** overrides ********** @@ -209,6 +213,19 @@ public abstract class AbstractEclipseLinkDDLGenerator extends AbstractJptGenerat protected void putProperty(Properties properties, String key, String value) { properties.put(key, (value == null) ? "" : value); //$NON-NLS-1$ } + + /** + * Returns the Property string value of the given property value. + */ + protected String getPropertyStringValueOf(Object value) { + if (value == null) { + return null; + } + if (value.getClass().isEnum()) { + return (String) ReflectionTools.getStaticFieldValue(value.getClass(), value.toString().toUpperCase(Locale.ENGLISH)); + } + return value.toString(); + } protected void buildAllProperties(Properties properties) { this.buildConnectionProperties(properties); @@ -229,11 +246,19 @@ public abstract class AbstractEclipseLinkDDLGenerator extends AbstractJptGenerat private void buildDDLModeProperties(Properties properties) { this.putProperty(properties, + SchemaGeneration.ECLIPSELINK_DDL_GENERATION_OUTPUT_MODE, + this.getPropertyStringValueOf(this.outputMode)); + + this.putProperty(properties, SchemaGeneration.ECLIPSELINK_DDL_GENERATION_TYPE, DdlGenerationType.DROP_AND_CREATE_TABLES); + this.putProperty(properties, - SchemaGeneration.ECLIPSELINK_DDL_GENERATION_OUTPUT_MODE, - OutputMode.DATABASE); + SchemaGeneration.ECLIPSELINK_CREATE_FILE_NAME, + SchemaGeneration.DEFAULT_SCHEMA_GENERATION_CREATE_FILE_NAME); + this.putProperty(properties, + SchemaGeneration.ECLIPSELINK_DROP_FILE_NAME, + SchemaGeneration.DEFAULT_SCHEMA_GENERATION_DROP_FILE_NAME); } private void buildConnectionPoolingProperties(Properties properties) { diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/ddlgen/EclipseLinkDDLGenerator.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/ddlgen/EclipseLinkDDLGenerator.java index b95c7ff507..f3b7f8543a 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/ddlgen/EclipseLinkDDLGenerator.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/ddlgen/EclipseLinkDDLGenerator.java @@ -1,5 +1,5 @@ /******************************************************************************* -* Copyright (c) 2008, 2010 Oracle. All rights reserved. +* Copyright (c) 2008, 2011 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,6 +14,7 @@ import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jpt.jpa.core.JpaProject; import org.eclipse.jpt.jpa.db.ConnectionProfile; import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.connection.Connection; +import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.schema.generation.OutputMode; /** * EclipseLinkDLLGenerator launches the EclipseLink DDL generator in a separate VM. @@ -30,15 +31,15 @@ public class EclipseLinkDDLGenerator extends AbstractEclipseLinkDDLGenerator // ********** constructors ********** - public static void generate(String puName, JpaProject project, IProgressMonitor monitor) { + public static void generate(String puName, JpaProject project, OutputMode outputMode, IProgressMonitor monitor) { if (puName == null || puName.length() == 0 || project == null) { throw new NullPointerException(); } - new EclipseLinkDDLGenerator(puName, project).generate(monitor); + new EclipseLinkDDLGenerator(puName, project, outputMode).generate(monitor); } - private EclipseLinkDDLGenerator(String puName, JpaProject jpaProject) { - super(puName, jpaProject); + private EclipseLinkDDLGenerator(String puName, JpaProject jpaProject, OutputMode outputMode) { + super(puName, jpaProject, outputMode); } @Override diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/v2_0/ddlgen/EclipseLink2_0DDLGenerator.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/v2_0/ddlgen/EclipseLink2_0DDLGenerator.java index 819eacac5e..2c81f1fe47 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/v2_0/ddlgen/EclipseLink2_0DDLGenerator.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/v2_0/ddlgen/EclipseLink2_0DDLGenerator.java @@ -1,5 +1,5 @@ /******************************************************************************* -* Copyright (c) 2009, 2010 Oracle. All rights reserved. +* Copyright (c) 2009, 2011 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,6 +15,7 @@ import org.eclipse.jpt.jpa.core.JpaProject; import org.eclipse.jpt.jpa.core.jpa2.context.persistence.connection.JpaConnection2_0; import org.eclipse.jpt.jpa.db.ConnectionProfile; import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.customization.Customization; +import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.schema.generation.OutputMode; import org.eclipse.jpt.jpa.eclipselink.core.internal.ddlgen.AbstractEclipseLinkDDLGenerator; /** @@ -33,15 +34,15 @@ public class EclipseLink2_0DDLGenerator extends AbstractEclipseLinkDDLGenerator // ********** constructors ********** - public static void generate(String puName, JpaProject project, IProgressMonitor monitor) { + public static void generate(String puName, JpaProject project, OutputMode outputMode, IProgressMonitor monitor) { if (puName == null || puName.length() == 0 || project == null) { throw new NullPointerException(); } - new EclipseLink2_0DDLGenerator(puName, project).generate(monitor); + new EclipseLink2_0DDLGenerator(puName, project, outputMode).generate(monitor); } - private EclipseLink2_0DDLGenerator(String puName, JpaProject jpaProject) { - super(puName, jpaProject); + private EclipseLink2_0DDLGenerator(String puName, JpaProject jpaProject, OutputMode outputMode) { + super(puName, jpaProject, outputMode); } // ********** EclipseLink properties ********** |