diff options
author | bvosburgh | 2009-07-08 20:20:51 +0000 |
---|---|---|
committer | bvosburgh | 2009-07-08 20:20:51 +0000 |
commit | 5d19d8c2b4f7b403cc79275ce204ebc04ed99a45 (patch) | |
tree | 7d535864c8eccb2f590e75574d38ca8e65f9d90a | |
parent | 8bab5b75b3da083df6fb0c0c8c966b7e4e171e73 (diff) | |
download | webtools.dali-5d19d8c2b4f7b403cc79275ce204ebc04ed99a45.tar.gz webtools.dali-5d19d8c2b4f7b403cc79275ce204ebc04ed99a45.tar.xz webtools.dali-5d19d8c2b4f7b403cc79275ce204ebc04ed99a45.zip |
clearing up yet more database "name" vs. "identifier" stuff
23 files changed, 155 insertions, 113 deletions
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 109c6dfead..93c5e84583 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 @@ -94,14 +94,14 @@ public class JptCorePlugin extends Plugin { * The key for storing a JPA project's user overridden default catalog name * in the Eclipse project's persistent properties. */ - public static final QualifiedName USER_OVERRIDE_DEFAULT_CATALOG_NAME = + public static final QualifiedName USER_OVERRIDE_DEFAULT_CATALOG = new QualifiedName(PLUGIN_ID, "userOverrideDefaultCatalogName"); //$NON-NLS-1$ /** * The key for storing a JPA project's user overridden default schema name * in the Eclipse project's persistent properties. */ - public static final QualifiedName USER_OVERRIDE_DEFAULT_SCHEMA_NAME = + public static final QualifiedName USER_OVERRIDE_DEFAULT_SCHEMA = new QualifiedName(PLUGIN_ID, "userOverrideDefaultSchemaName"); //$NON-NLS-1$ /** @@ -435,56 +435,52 @@ public class JptCorePlugin extends Plugin { } /** - * Return the default catalog name associated with the specified Eclipse project. - * @see JpaProject#getUserOverrideDefaultCatalogName() + * Return the default catalog (identifier) associated with the specified Eclipse project. + * @see JpaProject#getUserOverrideDefaultCatalog() */ - public static String getUserOverrideDefaultCatalogName(IProject project) { + public static String getUserOverrideDefaultCatalog(IProject project) { try { - return project.getPersistentProperty(USER_OVERRIDE_DEFAULT_CATALOG_NAME); - } - catch (CoreException ce) { - log(ce); + return project.getPersistentProperty(USER_OVERRIDE_DEFAULT_CATALOG); + } catch (CoreException ex) { + log(ex); return null; } } /** - * Set the default catalog name associated with the specified Eclipse project. - * @see JpaProject#setUserOverrideDefaultCatalogName() + * Set the default catalog (identifier) associated with the specified Eclipse project. + * @see JpaProject#setUserOverrideDefaultCatalog(String) */ - public static void setUserOverrideDefaultCatalogName(IProject project, String defaultCatalogName) { + public static void setUserOverrideDefaultCatalog(IProject project, String defaultCatalog) { try { - project.setPersistentProperty(USER_OVERRIDE_DEFAULT_CATALOG_NAME, defaultCatalogName); - } - catch (CoreException ce) { - log(ce); + project.setPersistentProperty(USER_OVERRIDE_DEFAULT_CATALOG, defaultCatalog); + } catch (CoreException ex) { + log(ex); } } /** - * Return the default schema name associated with the specified Eclipse project. - * @see JpaProject#getUserOverrideDefaultSchemaName() + * Return the default schema (identifier) associated with the specified Eclipse project. + * @see JpaProject#getUserOverrideDefaultSchema() */ - public static String getUserOverrideDefaultSchemaName(IProject project) { + public static String getUserOverrideDefaultSchema(IProject project) { try { - return project.getPersistentProperty(USER_OVERRIDE_DEFAULT_SCHEMA_NAME); - } - catch (CoreException ce) { - log(ce); + return project.getPersistentProperty(USER_OVERRIDE_DEFAULT_SCHEMA); + } catch (CoreException ex) { + log(ex); return null; } } /** - * Set the default schema name associated with the specified Eclipse project. - * @see JpaProject#setUserOverrideDefaultSchemaName() + * Set the default schema (identifier) associated with the specified Eclipse project. + * @see JpaProject#setUserOverrideDefaultSchema(String) */ - public static void setUserOverrideDefaultSchemaName(IProject project, String defaultSchemaName) { + public static void setUserOverrideDefaultSchema(IProject project, String defaultSchema) { try { - project.setPersistentProperty(USER_OVERRIDE_DEFAULT_SCHEMA_NAME, defaultSchemaName); - } - catch (CoreException ce) { - log(ce); + project.setPersistentProperty(USER_OVERRIDE_DEFAULT_SCHEMA, defaultSchema); + } catch (CoreException ex) { + log(ex); } } 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 276c00b3d7..ffbd2f0732 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 @@ -399,7 +399,7 @@ public abstract class AbstractJpaProject public void setUserOverrideDefaultCatalog(String catalog) { String old = this.userOverrideDefaultCatalog; this.userOverrideDefaultCatalog = catalog; - JptCorePlugin.setUserOverrideDefaultCatalogName(this.project, catalog); + JptCorePlugin.setUserOverrideDefaultCatalog(this.project, catalog); this.firePropertyChanged(USER_OVERRIDE_DEFAULT_CATALOG_PROPERTY, old, catalog); } @@ -413,7 +413,7 @@ public abstract class AbstractJpaProject public void setUserOverrideDefaultSchema(String schema) { String old = this.userOverrideDefaultSchema; this.userOverrideDefaultSchema = schema; - JptCorePlugin.setUserOverrideDefaultSchemaName(this.project, schema); + JptCorePlugin.setUserOverrideDefaultSchema(this.project, schema); this.firePropertyChanged(USER_OVERRIDE_DEFAULT_SCHEMA_PROPERTY, old, schema); } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/GenericJpaModel.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/GenericJpaModel.java index 28c9ecf507..4d72046c0d 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/GenericJpaModel.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/GenericJpaModel.java @@ -131,8 +131,8 @@ public class GenericJpaModel config.setProject(project); config.setJpaPlatform(JptCorePlugin.getJpaPlatform(project)); config.setConnectionProfileName(JptCorePlugin.getConnectionProfileName(project)); - config.setUserOverrideDefaultCatalogName(JptCorePlugin.getUserOverrideDefaultCatalogName(project)); - config.setUserOverrideDefaultSchemaName(JptCorePlugin.getUserOverrideDefaultSchemaName(project)); + config.setUserOverrideDefaultCatalog(JptCorePlugin.getUserOverrideDefaultCatalog(project)); + config.setUserOverrideDefaultSchema(JptCorePlugin.getUserOverrideDefaultSchema(project)); config.setDiscoverAnnotatedClasses(JptCorePlugin.discoverAnnotatedClasses(project)); return config; } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/SimpleJpaProjectConfig.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/SimpleJpaProjectConfig.java index c4d7745b09..0852bea195 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/SimpleJpaProjectConfig.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/SimpleJpaProjectConfig.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Oracle. All rights reserved. + * 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. @@ -57,16 +57,16 @@ public class SimpleJpaProjectConfig implements JpaProject.Config { return this.userOverrideDefaultSchema; } - public void setUserOverrideDefaultSchemaName(String userOverrideDefaultSchemaName) { - this.userOverrideDefaultSchema = userOverrideDefaultSchemaName; + public void setUserOverrideDefaultSchema(String userOverrideDefaultSchema) { + this.userOverrideDefaultSchema = userOverrideDefaultSchema; } public String getUserOverrideDefaultCatalog() { return this.userOverrideDefaultCatalog; } - public void setUserOverrideDefaultCatalogName(String userOverrideDefaultCatalogName) { - this.userOverrideDefaultCatalog = userOverrideDefaultCatalogName; + public void setUserOverrideDefaultCatalog(String userOverrideDefaultCatalog) { + this.userOverrideDefaultCatalog = userOverrideDefaultCatalog; } public boolean discoverAnnotatedClasses() { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/facet/JpaFacetDataModelProvider.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/facet/JpaFacetDataModelProvider.java index 9caf54bb76..c1e68877da 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/facet/JpaFacetDataModelProvider.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/facet/JpaFacetDataModelProvider.java @@ -212,13 +212,13 @@ public class JpaFacetDataModelProvider return Boolean.FALSE; } if (propertyName.equals(USER_OVERRIDE_DEFAULT_CATALOG)) { - return this.getDefaultCatalogName(); + return this.getDefaultCatalogIdentifier(); } if (propertyName.equals(USER_WANTS_TO_OVERRIDE_DEFAULT_SCHEMA)) { return Boolean.FALSE; } if (propertyName.equals(USER_OVERRIDE_DEFAULT_SCHEMA)) { - return this.getDefaultSchemaName(); + return this.getDefaultSchemaIdentifier(); } if (propertyName.equals(DISCOVER_ANNOTATED_CLASSES)) { return Boolean.valueOf(this.runtimeSupportsEjb30()); @@ -274,7 +274,7 @@ public class JpaFacetDataModelProvider return (cp == null) ? null : cp.getDriverName(); } - private String getDefaultCatalogName() { + private String getDefaultCatalogIdentifier() { Catalog catalog = this.getDefaultCatalog(); return (catalog == null) ? null : catalog.getIdentifier(); } @@ -284,7 +284,7 @@ public class JpaFacetDataModelProvider return (db == null) ? null : db.getDefaultCatalog(); } - private String getDefaultSchemaName() { + private String getDefaultSchemaIdentifier() { Schema schema = this.getDefaultSchema(); return (schema == null) ? null : schema.getIdentifier(); } @@ -355,7 +355,7 @@ public class JpaFacetDataModelProvider // catalog if ((propertyValue != null) && this.databaseSupportsCatalogs()) { // connection set to something that supports catalogs - this.setProperty(USER_OVERRIDE_DEFAULT_CATALOG, this.getDefaultCatalogName()); + this.setProperty(USER_OVERRIDE_DEFAULT_CATALOG, this.getDefaultCatalogIdentifier()); } else { // connection either '<None>' or non-catalog database this.setBooleanProperty(USER_WANTS_TO_OVERRIDE_DEFAULT_CATALOG, false); } @@ -367,7 +367,7 @@ public class JpaFacetDataModelProvider if (propertyValue == null) { // connection set to '<None>' this.setBooleanProperty(USER_WANTS_TO_OVERRIDE_DEFAULT_SCHEMA, false); } else { - this.setProperty(USER_OVERRIDE_DEFAULT_SCHEMA, this.getDefaultSchemaName()); + this.setProperty(USER_OVERRIDE_DEFAULT_SCHEMA, this.getDefaultSchemaIdentifier()); } this.model.notifyPropertyChange(USER_WANTS_TO_OVERRIDE_DEFAULT_SCHEMA, IDataModel.ENABLE_CHG); this.model.notifyPropertyChange(USER_OVERRIDE_DEFAULT_SCHEMA, IDataModel.DEFAULT_CHG); @@ -403,7 +403,7 @@ public class JpaFacetDataModelProvider } } else if (propertyName.equals(USER_OVERRIDE_DEFAULT_CATALOG)) { - this.setProperty(USER_OVERRIDE_DEFAULT_SCHEMA, this.getDefaultSchemaName()); + this.setProperty(USER_OVERRIDE_DEFAULT_SCHEMA, this.getDefaultSchemaIdentifier()); } else if (propertyName.equals(USER_WANTS_TO_OVERRIDE_DEFAULT_SCHEMA)) { this.model.notifyPropertyChange(USER_OVERRIDE_DEFAULT_SCHEMA, IDataModel.ENABLE_CHG); @@ -500,28 +500,30 @@ public class JpaFacetDataModelProvider private DataModelPropertyDescriptor[] buildValidCatalogDescriptors() { Database db = this.getDatabase(); - return (db == null) ? EMPTY_DMPD_ARRAY : this.buildDescriptors(this.buildValidCatalogNames(db)); + return (db == null) ? EMPTY_DMPD_ARRAY : this.buildDescriptors(this.buildValidCatalogIdentifiers(db)); } /** * pre-condition: 'db' is not null */ - private List<String> buildValidCatalogNames(Database db) { - return this.buildValidStrings(db.sortedCatalogIdentifiers(), this.getDefaultCatalogName()); + private List<String> buildValidCatalogIdentifiers(Database db) { + // use catalog *identifiers* since the string ends up being the "default" for various text entries + return this.buildValidStrings(db.sortedCatalogIdentifiers(), this.getDefaultCatalogIdentifier()); } private DataModelPropertyDescriptor[] buildValidSchemaDescriptors() { Database db = this.getDatabase(); - return (db == null) ? EMPTY_DMPD_ARRAY : this.buildDescriptors(this.buildValidSchemaNames()); + return (db == null) ? EMPTY_DMPD_ARRAY : this.buildDescriptors(this.buildValidSchemaIdentifiers()); } - private List<String> buildValidSchemaNames() { - return this.buildValidStrings(this.schemaNames(), this.getDefaultSchemaName()); + private List<String> buildValidSchemaIdentifiers() { + return this.buildValidStrings(this.schemaIdentifiers(), this.getDefaultSchemaIdentifier()); } - private Iterator<String> schemaNames() { + private Iterator<String> schemaIdentifiers() { SchemaContainer sc = this.getSchemaContainer(); - return (sc == null) ? EmptyIterator.<String>instance() : sc.sortedSchemaIdentifiers(); + // use schema *identifiers* since the string ends up being the "default" for various text entries + return (sc != null) ? sc.sortedSchemaIdentifiers() : EmptyIterator.<String>instance(); } /** diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/facet/JpaFacetInstallDelegate.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/facet/JpaFacetInstallDelegate.java index 5327b8c325..de6c0858f1 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/facet/JpaFacetInstallDelegate.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/facet/JpaFacetInstallDelegate.java @@ -60,10 +60,10 @@ public class JpaFacetInstallDelegate JptCorePlugin.setJpaPlatformId(project, dataModel.getStringProperty(PLATFORM_ID)); JptCorePlugin.setConnectionProfileName(project, dataModel.getStringProperty(CONNECTION)); if (dataModel.getBooleanProperty(USER_WANTS_TO_OVERRIDE_DEFAULT_CATALOG)) { - JptCorePlugin.setUserOverrideDefaultCatalogName(project, dataModel.getStringProperty(USER_OVERRIDE_DEFAULT_CATALOG)); + JptCorePlugin.setUserOverrideDefaultCatalog(project, dataModel.getStringProperty(USER_OVERRIDE_DEFAULT_CATALOG)); } if (dataModel.getBooleanProperty(USER_WANTS_TO_OVERRIDE_DEFAULT_SCHEMA)) { - JptCorePlugin.setUserOverrideDefaultSchemaName(project, dataModel.getStringProperty(USER_OVERRIDE_DEFAULT_SCHEMA)); + JptCorePlugin.setUserOverrideDefaultSchema(project, dataModel.getStringProperty(USER_OVERRIDE_DEFAULT_SCHEMA)); } this.addDbDriverLibraryToClasspath(javaProject, dataModel, monitor); diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/Database.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/Database.java index ac5ed09e14..62fcfade7b 100644 --- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/Database.java +++ b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/Database.java @@ -77,6 +77,14 @@ public interface Database int catalogsSize(); /** + * Return the database's catalog names, sorted. + * Return an empty iterator if the database does not support catalogs. + * This is useful when the user is selecting a catalog from a read-only + * combo-box (e.g. in a wizard). + */ + Iterator<String> sortedCatalogNames(); + + /** * Return the catalog with specified name. The name must be an exact match * of the catalog's name. * Return null if the database does not support catalogs. @@ -88,6 +96,8 @@ public interface Database /** * Return the database's catalog identifiers, sorted by name. * Return an empty iterator if the database does not support catalogs. + * This is useful when the user is selecting an identifier that will be + * placed in a text file (e.g. in a Java annotation). */ Iterator<String> sortedCatalogIdentifiers(); diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/SchemaContainer.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/SchemaContainer.java index 26372f4a03..bde243a43d 100644 --- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/SchemaContainer.java +++ b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/SchemaContainer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Oracle. All rights reserved. + * 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. @@ -37,6 +37,13 @@ public interface SchemaContainer int schemataSize(); /** + * Return the container's schema names, sorted. + * This is useful when the user is selecting a schema from a read-only + * combo-box (e.g. in a wizard). + */ + Iterator<String> sortedSchemaNames(); + + /** * Return the schema with specified name. The name must be an exact match * of the schema's name. * @see #schemaNames() @@ -46,6 +53,8 @@ public interface SchemaContainer /** * Return the container's schema identifiers, sorted by name. + * This is useful when the user is selecting an identifier that will be + * placed in a text file (e.g. in a Java annotation). */ Iterator<String> sortedSchemaIdentifiers(); diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPDatabaseWrapper.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPDatabaseWrapper.java index 529d8eec0d..a21bb3eefa 100644 --- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPDatabaseWrapper.java +++ b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPDatabaseWrapper.java @@ -221,6 +221,16 @@ final class DTPDatabaseWrapper throw new IllegalArgumentException("invalid DTP catalog: " + dtpCatalog); //$NON-NLS-1$ } + public Iterator<String> sortedCatalogNames() { + // the catalogs are already sorted + return new TransformationIterator<DTPCatalogWrapper, String>(this.catalogWrappers()) { + @Override + protected String transform(DTPCatalogWrapper next) { + return next.getName(); + } + }; + } + public DTPCatalogWrapper getCatalogNamed(String name) { return this.selectDatabaseObjectNamed(this.getCatalogs(), name); } diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPSchemaContainerWrapper.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPSchemaContainerWrapper.java index a8dabea711..630d34624b 100644 --- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPSchemaContainerWrapper.java +++ b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPSchemaContainerWrapper.java @@ -125,6 +125,16 @@ abstract class DTPSchemaContainerWrapper return this.getSchemata().length; } + public Iterator<String> sortedSchemaNames() { + // the schemata are already sorted + return new TransformationIterator<DTPSchemaWrapper, String>(this.schemaWrappers()) { + @Override + protected String transform(DTPSchemaWrapper next) { + return next.getName(); + } + }; + } + public DTPSchemaWrapper getSchemaNamed(String name) { return this.selectDatabaseObjectNamed(this.getSchemata(), name); } diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/vendor/AbstractVendor.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/vendor/AbstractVendor.java index 257b65776e..7001e9da71 100644 --- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/vendor/AbstractVendor.java +++ b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/vendor/AbstractVendor.java @@ -74,8 +74,18 @@ abstract class AbstractVendor return identifiers; } + /** + * The user name passed in here was retrieved from DTP. + * DTP stores the user name that was passed to it during the connection + * to the database. As a result, this user name is an "identifier" not a "name". + * If the user name were retrieved from the JDBC connection it would probably + * be a "name". For example, you can connect to an Oracle database with the + * user name "scott", but that identifer is folded to the actual user name + * "SCOTT". DTP stores the original string "scott", while the Oracle JDBC + * driver stores the folded string "SCOTT". + */ void addDefaultSchemaIdentifiersTo(@SuppressWarnings("unused") Database database, String userName, ArrayList<String> identifiers) { - identifiers.add(this.convertNameToIdentifier(userName)); + identifiers.add(userName); } diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/vendor/Derby.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/vendor/Derby.java index 4c53179012..01bce02199 100644 --- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/vendor/Derby.java +++ b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/vendor/Derby.java @@ -53,17 +53,14 @@ class Derby identifiers.add(this.buildDefaultSchemaIdentifier(userName)); } - private String buildDefaultSchemaIdentifier(String userName) { - return this.convertNameToIdentifier(this.buildDefaultSchemaName(userName)); - } - /** - * The default user name on Derby is "APP". + * The default user name on Derby is "APP" when the user connects without + * a user name. */ - private String buildDefaultSchemaName(String userName) { - return ((userName != null) && (userName.length() != 0)) ? userName : DEFAULT_USER_NAME; + private String buildDefaultSchemaIdentifier(String userName) { + return ((userName != null) && (userName.length() != 0)) ? userName : DEFAULT_USER_IDENTIFIER; } - private static final String DEFAULT_USER_NAME = "APP"; //$NON-NLS-1$ + private static final String DEFAULT_USER_IDENTIFIER = "APP"; //$NON-NLS-1$ @Override char[] getExtendedNormalNamePartCharacters() { diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/vendor/Sybase.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/vendor/Sybase.java index 4a7a2ef804..1433e920fb 100644 --- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/vendor/Sybase.java +++ b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/vendor/Sybase.java @@ -62,8 +62,8 @@ class Sybase * 'dbo'. * * Actually, the default schema is more like a search path: - * The server looks for a schema object (e.g table) first in the user's - * schema, the it look for the schema object in the database owner's + * The server looks for a schema object (e.g. a table) first in the user's + * schema, then it looks for the schema object in the database owner's * schema (dbo). As a result, it's really not possible to specify * the "default" schema without knowing the schema object we are * looking for. diff --git a/jpa/plugins/org.eclipse.jpt.ui/property_files/jpt_ui_entity_gen.properties b/jpa/plugins/org.eclipse.jpt.ui/property_files/jpt_ui_entity_gen.properties index 15ec882150..8d053c26e4 100644 --- a/jpa/plugins/org.eclipse.jpt.ui/property_files/jpt_ui_entity_gen.properties +++ b/jpa/plugins/org.eclipse.jpt.ui/property_files/jpt_ui_entity_gen.properties @@ -1,8 +1,8 @@ ############################################################################### -# Copyright (c) 2006, 2008 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. +# Copyright (c) 2006, 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 @@ -16,6 +16,7 @@ schema=&Schema: schemaInfo=(Note: You must have an active connection to select schema.) addConnectionLink=Add connections... connectLink=Connect +connectingToDatabase=Connecting to database manyToOne=&Many to one manyToMany=Man&y to many oneToMany=&One to many diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/db/CatalogCombo.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/db/CatalogCombo.java index bb12eb6a23..1270ed265f 100644 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/db/CatalogCombo.java +++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/db/CatalogCombo.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Oracle. All rights reserved. + * 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. @@ -48,7 +48,7 @@ public abstract class CatalogCombo<T extends JpaNode> @Override protected Iterator<String> values() { Database db = this.getDatabase(); - return (db == null) ? EmptyIterator.<String>instance() : db.sortedCatalogIdentifiers(); + return (db != null) ? db.sortedCatalogIdentifiers() : EmptyIterator.<String>instance(); } } diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/db/ColumnCombo.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/db/ColumnCombo.java index bd6317a9a6..2e7cfede61 100644 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/db/ColumnCombo.java +++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/db/ColumnCombo.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Oracle. All rights reserved. + * 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. @@ -47,7 +47,7 @@ public abstract class ColumnCombo<T extends JpaNode> @Override protected Iterator<String> values() { Table dbTable = this.getDbTable(); - return (dbTable == null) ? EmptyIterator.<String>instance() : dbTable.sortedColumnIdentifiers(); + return (dbTable != null) ? dbTable.sortedColumnIdentifiers() : EmptyIterator.<String>instance(); } protected Table getDbTable() { diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/db/SchemaCombo.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/db/SchemaCombo.java index 075d45a3ee..afa0b50ce2 100644 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/db/SchemaCombo.java +++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/db/SchemaCombo.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Oracle. All rights reserved. + * 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. @@ -47,7 +47,7 @@ public abstract class SchemaCombo<T extends JpaNode> @Override protected Iterator<String> values() { SchemaContainer sc = this.getDbSchemaContainer(); - return (sc == null) ? EmptyIterator.<String>instance() : sc.sortedSchemaIdentifiers(); + return (sc != null) ? sc.sortedSchemaIdentifiers() : EmptyIterator.<String>instance(); } protected SchemaContainer getDbSchemaContainer() { diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/db/SequenceCombo.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/db/SequenceCombo.java index 5734c8ab52..5f8753939c 100644 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/db/SequenceCombo.java +++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/db/SequenceCombo.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Oracle. All rights reserved. + * 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. @@ -47,7 +47,7 @@ public abstract class SequenceCombo<T extends JpaNode> @Override protected Iterator<String> values() { Schema dbSchema = this.getDbSchema(); - return (dbSchema == null) ? EmptyIterator.<String>instance() : dbSchema.sortedSequenceIdentifiers(); + return (dbSchema != null) ? dbSchema.sortedSequenceIdentifiers() : EmptyIterator.<String>instance(); } protected Schema getDbSchema() { diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/db/TableCombo.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/db/TableCombo.java index f488505481..4c43427d92 100644 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/db/TableCombo.java +++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/db/TableCombo.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Oracle. All rights reserved. + * 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. @@ -48,7 +48,7 @@ public abstract class TableCombo<T extends JpaNode> @Override protected Iterator<String> values() { Schema dbSchema = this.getDbSchema(); - return (dbSchema == null) ? EmptyIterator.<String>instance() : dbSchema.sortedTableIdentifiers(); + return (dbSchema != null) ? dbSchema.sortedTableIdentifiers() : EmptyIterator.<String>instance(); } protected Schema getDbSchema() { diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/DatabaseSchemaWizardPage.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/DatabaseSchemaWizardPage.java index 4b459e9b19..a96f839a4d 100644 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/DatabaseSchemaWizardPage.java +++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/DatabaseSchemaWizardPage.java @@ -209,7 +209,7 @@ public class DatabaseSchemaWizardPage extends WizardPage { // ********** internal methods ********** - private void addJpaProjectConnectionListener() { + void addJpaProjectConnectionListener() { this.addJpaProjectConnectionProfileListener(this.connectionListener); } @@ -247,7 +247,7 @@ public class DatabaseSchemaWizardPage extends WizardPage { this.reconnectLink.setEnabled(this.reconnectLinkCanBeEnabled()); } - private void updateAddJpaProjectConnectionLink() { + void updateAddJpaProjectConnectionLink() { this.addJpaProjectConnectionLink.setEnabled(this.addJpaProjectConnectionLinkCanBeEnabled()); } @@ -268,25 +268,26 @@ public class DatabaseSchemaWizardPage extends WizardPage { */ private void updateSchemaComboBox() { this.schemaComboBox.removeAll(); - for (Iterator<String> stream = this.getSchemata(); stream.hasNext(); ) { + for (Iterator<String> stream = this.schemaNames(); stream.hasNext(); ) { this.schemaComboBox.add(stream.next()); } // the current schema *should* be in the current connection profile if (this.selectedSchema != null) { - this.schemaComboBox.select(this.schemaComboBox.indexOf(this.selectedSchema.getIdentifier())); + this.schemaComboBox.select(this.schemaComboBox.indexOf(this.selectedSchema.getName())); } } - private Iterator<String> getSchemata() { + private Iterator<String> schemaNames() { SchemaContainer sc = DatabaseSchemaWizardPage.this.jpaProject.getDefaultDbSchemaContainer(); - return (sc == null) ? EmptyIterator.<String>instance() : sc.sortedSchemaIdentifiers(); + // use schema *names* since the combo-box is read-only + return (sc != null) ? sc.sortedSchemaNames() : EmptyIterator.<String>instance(); } // ********** listener callbacks ********** void selectedSchemaChanged() { Schema old = this.selectedSchema; - this.selectedSchema = this.getJpaProjectConnectionProfile().getDatabase().getSchemaForIdentifier(this.schemaComboBox.getText()); + this.selectedSchema = this.getJpaProjectConnectionProfile().getDatabase().getSchemaNamed(this.schemaComboBox.getText()); if (this.selectedSchema != old) { DatabaseSchemaWizardPage.this.fireSchemaChanged(this.selectedSchema); } @@ -389,7 +390,7 @@ public class DatabaseSchemaWizardPage extends WizardPage { }; } - private void promptToConfigJpaProjectConnection() { + void promptToConfigJpaProjectConnection() { PreferenceDialog dialog = PreferencesUtil.createPropertyDialogOn( getShell(), DatabaseSchemaWizardPage.this.jpaProject.getProject(), diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/gen/DatabaseGroup.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/gen/DatabaseGroup.java index 8a030c1bf6..b27bf09e47 100644 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/gen/DatabaseGroup.java +++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/gen/DatabaseGroup.java @@ -60,7 +60,7 @@ public class DatabaseGroup private final Set<Listener> listeners = Collections.synchronizedSet(new HashSet<Listener>()); // these are kept in synch with the selection - private ConnectionProfile selectedConnectionProfile; + ConnectionProfile selectedConnectionProfile; private Schema selectedSchema; private final Combo connectionComboBox; @@ -89,7 +89,7 @@ public class DatabaseGroup this.buildButton(parent, JptUiEntityGenMessages.addConnectionLink, CommonImages.createImage( CommonImages.ADD_CONNECTION_IMAGE ), this.buildAddConnectionLinkSelectionListener()); // A composite holds the reconnect button & text - this.buildLabel(parent, 1, ""); + this.buildLabel(parent, 1, ""); //$NON-NLS-1$ Composite comp = new Composite( parent , SWT.NONE ); GridData gd = new GridData(); gd.grabExcessHorizontalSpace = true ; @@ -139,10 +139,6 @@ public class DatabaseGroup } // ********** intra-wizard methods ********** - ConnectionProfile getSelectedConnectionProfile() { - return this.selectedConnectionProfile; - } - Schema getSelectedSchema() { return this.selectedSchema; } @@ -213,7 +209,7 @@ public class DatabaseGroup */ private void updateSchemaComboBox() { this.schemaComboBox.removeAll(); - for (Iterator<String> stream = this.getSchemata(); stream.hasNext(); ) { + for (Iterator<String> stream = this.schemaNames(); stream.hasNext(); ) { this.schemaComboBox.add(stream.next()); } // the current schema *should* be in the current connection profile @@ -222,15 +218,13 @@ public class DatabaseGroup } } - private Iterator<String> getSchemata() { - ConnectionProfile profile = this.getSelectedConnectionProfile(); - if( profile == null ) - return EmptyIterator.<String>instance() ; - Database db = profile.getDatabase(); - if ( db == null) - return EmptyIterator.<String>instance() ; - Iterator<String> ret = db.sortedSchemaIdentifiers(); - return ret; + private Iterator<String> schemaNames() { + if (this.selectedConnectionProfile == null) { + return EmptyIterator.instance(); + } + Database db = this.selectedConnectionProfile.getDatabase(); + // use schema *names* since the combo-box is read-only + return (db != null) ? db.sortedSchemaNames() : EmptyIterator.<String>instance(); } /** @@ -279,7 +273,7 @@ public class DatabaseGroup void selectedSchemaChanged() { Schema old = this.selectedSchema; - this.selectedSchema = this.selectedConnectionProfile.getDatabase().getSchemaForIdentifier(this.schemaComboBox.getText()); + this.selectedSchema = this.selectedConnectionProfile.getDatabase().getSchemaNamed(this.schemaComboBox.getText()); if (this.selectedSchema != old) { fireSchemaChanged(this.selectedSchema); } @@ -313,14 +307,16 @@ public class DatabaseGroup public void run( final IProgressMonitor monitor ) throws InvocationTargetException, InterruptedException { - monitor.beginTask("Connecting to database", 10); + monitor.beginTask(JptUiEntityGenMessages.connectingToDatabase, 10); final boolean[] isConnected= new boolean[1]; isConnected[0]=false; Thread t= new Thread(){ + @Override public void run() { - try{ - selectedConnectionProfile.connect(); - }catch(Exception e ){ + try { + DatabaseGroup.this.selectedConnectionProfile.connect(); + } catch (Exception ex) { + // huh? } isConnected[0]=true; } diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/gen/JptUiEntityGenMessages.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/gen/JptUiEntityGenMessages.java index 9c570cc64f..b5c1c33350 100644 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/gen/JptUiEntityGenMessages.java +++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/gen/JptUiEntityGenMessages.java @@ -37,6 +37,7 @@ public class JptUiEntityGenMessages { public static String connectLink; public static String schemaInfo; public static String schema; + public static String connectingToDatabase; //Default table gen properties public static String GenerateEntitiesWizard_defaultTablePage_title; diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/gen/TablesSelectorWizardPage.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/gen/TablesSelectorWizardPage.java index a08a9d3f46..c5c1741777 100644 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/gen/TablesSelectorWizardPage.java +++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/gen/TablesSelectorWizardPage.java @@ -480,8 +480,7 @@ class TablesSelectorWizardPage extends WizardPage{ private void updateTablesSelector(final Schema schema) { if(schema ==null) return; - this.jpaProject.setUserOverrideDefaultSchema( schema.getName()); - JptCorePlugin.setUserOverrideDefaultSchemaName(jpaProject.getProject(), schema.getName()); + this.jpaProject.setUserOverrideDefaultSchema( schema.getIdentifier()); updateTablesListViewer( CollectionTools.collection(schema.tables())); |