Skip to content

Commit

Permalink
FORGE-2633: Upgraded to Hibernate Tools 5.1.0.Alpha2
Browse files Browse the repository at this point in the history
FORGE-2644: Refactored DatabaseTableSelectionStep for better performance and allowing selection of catalog + schema
  • Loading branch information
gastaldi committed Apr 4, 2016
1 parent 317569c commit 3cd8296
Show file tree
Hide file tree
Showing 8 changed files with 364 additions and 126 deletions.
8 changes: 8 additions & 0 deletions database-tools/impl/pom.xml
Expand Up @@ -69,6 +69,14 @@
<artifactId>slf4j-api</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
<exclusion>
<artifactId>ant</artifactId>
<groupId>ant</groupId>
</exclusion>
<exclusion>
<artifactId>geronimo-jta_1.1_spec</artifactId>
<groupId>org.apache.geronimo.specs</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
Expand Down
Expand Up @@ -34,6 +34,7 @@
import org.jboss.forge.addon.ui.input.events.ValueChangeEvent;
import org.jboss.forge.addon.ui.validate.UIValidator;

@SuppressWarnings("rawtypes")
public abstract class AbstractConnectionProfileDetailsPage implements UICommand
{
private static final Logger log = Logger.getLogger(AbstractConnectionProfileDetailsPage.class.getName());
Expand Down Expand Up @@ -69,7 +70,8 @@ public void initializeUI(UIBuilder builder) throws Exception
driverLocation = factory.createInput("driverLocation", FileResource.class)
.setLabel("Driver Location")
.setDescription("The location of the jar file that contains the JDBC driver").setRequired(true);
driverClass = factory.createSelectOne("driverClass", Class.class).setLabel("Driver Class")
driverClass = factory.createSelectOne("driverClass", Class.class)
.setLabel("Driver Class")
.setDescription("The class name of the JDBC driver").setRequired(true);
verifyConnection = factory.createInput("verifyConnection", Boolean.class).setLabel("Verify Database Connection")
.setDescription("Attempt to connect to the database and verify connectivity");
Expand Down Expand Up @@ -107,23 +109,13 @@ public void validate(UIValidationContext context)
new DriverNamesStaleValueChangeListener()));

driverClass.setValueChoices(new LocateDriverClassNamesCallable())
.setItemLabelConverter(new Converter<Class, String>()
{
@Override
public String convert(Class source)
{
if (source != null)
return source.getName();
else
return "";
}
})
.setItemLabelConverter((source) -> source.getName())
.setDefaultValue(new Callable<Class>()
{
@Override
public Class call() throws Exception
{
Class<?> result = null;
Class result = null;
Iterator<Class> iterator = driverClass.getValueChoices().iterator();
if (iterator.hasNext())
{
Expand Down
Expand Up @@ -34,12 +34,6 @@ public UICommandMetadata getMetadata(UIContext context)
.description("Edit the connection profile details");
}

@Override
public boolean isEnabled(UIContext context)
{
return true;
}

@Override
public void initializeUI(UIBuilder builder) throws Exception
{
Expand Down
@@ -0,0 +1,107 @@
/*
* Copyright 2016 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Eclipse Public License version 1.0, available at
* http://www.eclipse.org/legal/epl-v10.html
*/

package org.jboss.forge.addon.database.tools.generate;

/**
*
* @author <a href="mailto:ggastald@redhat.com">George Gastaldi</a>
*/
public final class DatabaseTable
{
private final String catalog;
private final String schema;
private final String name;

/**
* @param catalog
* @param schema
* @param name
*/
public DatabaseTable(String catalog, String schema, String name)
{
super();
this.catalog = catalog;
this.schema = schema;
this.name = name;
}

/**
* @return the catalog
*/
public String getCatalog()
{
return catalog;
}

/**
* @return the schema
*/
public String getSchema()
{
return schema;
}

/**
* @return the name
*/
public String getName()
{
return name;
}

@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + ((catalog == null) ? 0 : catalog.hashCode());
result = prime * result + ((name == null) ? 0 : name.hashCode());
result = prime * result + ((schema == null) ? 0 : schema.hashCode());
return result;
}

@Override
public boolean equals(Object obj)
{
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
DatabaseTable other = (DatabaseTable) obj;
if (catalog == null)
{
if (other.catalog != null)
return false;
}
else if (!catalog.equals(other.catalog))
return false;
if (name == null)
{
if (other.name != null)
return false;
}
else if (!name.equals(other.name))
return false;
if (schema == null)
{
if (other.schema != null)
return false;
}
else if (!schema.equals(other.schema))
return false;
return true;
}

@Override
public String toString()
{
return "DatabaseTable [catalog=" + catalog + ", schema=" + schema + ", name=" + name + "]";
}
}

0 comments on commit 3cd8296

Please sign in to comment.