diff options
author | nhauge | 2009-09-02 21:37:27 +0000 |
---|---|---|
committer | nhauge | 2009-09-02 21:37:27 +0000 |
commit | 44201b4da3236254f361b2501789b24245d81478 (patch) | |
tree | 40dd548995566a5c60915ef7ee804bc74f438954 /jpa/plugins | |
parent | 57660d408e7234773a602144000c97c421a787b4 (diff) | |
download | webtools.dali-44201b4da3236254f361b2501789b24245d81478.tar.gz webtools.dali-44201b4da3236254f361b2501789b24245d81478.tar.xz webtools.dali-44201b4da3236254f361b2501789b24245d81478.zip |
269057 - filter out tables that don't have columns from the list of possible tables. This prevents synonyms from showing up when they aren't fully supported by the DTP extension and given driver.
Diffstat (limited to 'jpa/plugins')
2 files changed, 35 insertions, 6 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/gen/GenerateEntitiesFromSchemaWizard.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/gen/GenerateEntitiesFromSchemaWizard.java index 776891d33a..2a42ae34e6 100644 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/gen/GenerateEntitiesFromSchemaWizard.java +++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/gen/GenerateEntitiesFromSchemaWizard.java @@ -12,8 +12,10 @@ package org.eclipse.jpt.ui.internal.wizards.gen; import java.io.File; import java.io.IOException; +import java.util.ArrayList; import java.util.Collection; import java.util.Collections; +import java.util.Iterator; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; @@ -491,10 +493,25 @@ public class GenerateEntitiesFromSchemaWizard extends Wizard return customizer; } Collection<Table> getPossibleTables() { + Collection<Table> tables = new ArrayList<Table>(); if ( this.tablesSelectorPage != null) { - return this.tablesSelectorPage.getTables(); + tables = this.tablesSelectorPage.getTables(); } - return ( this.projectDefaultSchemaExists()) ? CollectionTools.collection( this.getDefaultSchema().tables()) : Collections.<Table>emptyList(); + tables = this.projectDefaultSchemaExists() ? CollectionTools.collection( this.getDefaultSchema().tables()) : Collections.<Table>emptyList(); + //return only tables that have columns - this filters out synonyms where they are not + //fully supported and potentially other problematic table types - see bug 269057 + return filterEmptyTables(tables); + } + + private Collection<Table> filterEmptyTables(Collection<Table> tables){ + Collection<Table> nonEmptyTables = new ArrayList<Table>(); + for (Iterator<Table> stream = tables.iterator(); stream.hasNext();){ + Table candidateTable = stream.next(); + if (candidateTable.columnsSize() > 0){ + nonEmptyTables.add(candidateTable); + } + } + return nonEmptyTables; } public ConnectionProfile getProjectConnectionProfile() { 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 3d419c2a28..ac5594e462 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 @@ -15,6 +15,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.HashSet; +import java.util.Iterator; import java.util.List; import java.util.Set; @@ -247,8 +248,8 @@ class TablesSelectorWizardPage extends WizardPage{ doStatusUpdate(); } - private void initTablesSelectionControl(Collection<Table> possibleTables) { - this.tableTable.setInput(possibleTables); + private void initTablesSelectionControl(Collection<Table> nonEmptyTables) { + this.tableTable.setInput(nonEmptyTables); } private void createTablesSelectionControl(Composite parent, int columns) { @@ -484,7 +485,8 @@ class TablesSelectorWizardPage extends WizardPage{ this.jpaProject.setUserOverrideDefaultSchema( schema.getName()); JptCorePlugin.setUserOverrideDefaultSchemaName(jpaProject.getProject(), schema.getName()); - updateTablesListViewer( CollectionTools.collection(schema.tables())); + //update the listViewer with non empty tables (filtering out unsupported schemas) + updateTablesListViewer(filterEmptyTables(schema.tables())); //Create the ORMGenCustomizer GenerateEntitiesFromSchemaWizard wizard = (GenerateEntitiesFromSchemaWizard) getWizard(); @@ -494,9 +496,19 @@ class TablesSelectorWizardPage extends WizardPage{ restoreWizardState(); } doStatusUpdate(); - } + private Collection<Table> filterEmptyTables(Iterator<Table> tables){ + Collection<Table> nonEmptyTables = new ArrayList<Table>(); + while (tables.hasNext()){ + Table candidateTable = tables.next(); + if (candidateTable.columnsSize() > 0){ + nonEmptyTables.add(candidateTable); + } + } + return nonEmptyTables; + } + private boolean restoreWizardState(){ boolean pageComplete = false; List<String> preSelectedTableNames = this.customizer.getTableNames(); |