{
final DriverDataSourceProvider dcp = (DriverDataSourceProvider) provider;
final ListModel model = dialogModel.getConnections();
for (int i = 0; i < model.getSize(); i++)
{
final JdbcConnectionDefinition definition = (JdbcConnectionDefinition) model.getElementAt(i);
if (definition instanceof DriverConnectionDefinition == false)
{
continue;
}
final DriverConnectionDefinition dcd = (DriverConnectionDefinition) definition;
if (ObjectUtilities.equal(dcd.getDriverClass(), dcp.getDriver()) &&
ObjectUtilities.equal(dcd.getUsername(), dcp.getProperty("user")) &&
ObjectUtilities.equal(dcd.getPassword(), dcp.getProperty("password")) &&
ObjectUtilities.equal(dcd.getConnectionString(), dcp.getUrl()) &&
ObjectUtilities.equal(dcd.getName(), dcp.getProperty("::pentaho-reporting::name")))
{
return definition;
}
}
final String[] strings = dcp.getPropertyNames();
final Properties p = new Properties();
for (int i = 0; i < strings.length; i++)
{
final String string = strings[i];
p.put(string, dcp.getProperty(string));
}
return new DriverConnectionDefinition
(customName, dcp.getDriver(), dcp.getUrl(),
dataFactory.getJdbcUser(), dataFactory.getJdbcPassword(),
dcp.getProperty("::pentaho-reporting::hostname"),
dcp.getProperty("::pentaho-reporting::database-name"),
dcp.getProperty("::pentaho-reporting::database-type"),
dcp.getProperty("::pentaho-reporting::port"),
p);
}
else if (provider instanceof JndiDataSourceProvider)
{
final JndiDataSourceProvider jcp = (JndiDataSourceProvider) provider;
final ListModel model = dialogModel.getConnections();
for (int i = 0; i < model.getSize(); i++)
{
final JdbcConnectionDefinition definition = (JdbcConnectionDefinition) model.getElementAt(i);
if (definition instanceof JndiConnectionDefinition == false)
{
continue;
}
final JndiConnectionDefinition dcd = (JndiConnectionDefinition) definition;