Package org.pentaho.reporting.ui.datasources.jdbc.connection

Examples of org.pentaho.reporting.ui.datasources.jdbc.connection.DriverConnectionDefinition


        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;

        if (ObjectUtilities.equal(dcd.getJndiName(), jcp.getConnectionPath()))
        {
          return dcd;
        }
      }
      return new JndiConnectionDefinition(customName, jcp.getConnectionPath(), null,
View Full Code Here


        (JdbcConnectionDefinition) getDialogModel().getConnections().getSelectedItem();
    dataFactory.setDesignTimeName(connectionDefinition.getName());

    if (connectionDefinition instanceof DriverConnectionDefinition)
    {
      final DriverConnectionDefinition dcd = (DriverConnectionDefinition) connectionDefinition;
      dataFactory.setJdbcUser(dcd.getUsername());
      dataFactory.setJdbcPassword(dcd.getPassword());

      final DriverDataSourceProvider dataSourceProvider = new DriverDataSourceProvider();
      dataSourceProvider.setUrl(dcd.getConnectionString());
      dataSourceProvider.setDriver(dcd.getDriverClass());
      final Properties properties = dcd.getProperties();
      final Enumeration keys = properties.keys();
      while (keys.hasMoreElements())
      {
        final String key = (String) keys.nextElement();
        if ("user".equals(key) || "password".equals(key))
View Full Code Here

        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(), null, null,
              dcp.getProperty("::pentaho-reporting::hostname"),// NON-NLS
              dcp.getProperty("::pentaho-reporting::database-name"),// NON-NLS
              dcp.getProperty("::pentaho-reporting::database-type"),// NON-NLS
              dcp.getProperty("::pentaho-reporting::port"),// NON-NLS
              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;

        if (ObjectUtilities.equal(dcd.getJndiName(), jcp.getConnectionPath()))
        {
          return dcd;
        }
      }
      return new JndiConnectionDefinition(customName, jcp.getConnectionPath(), null, null, null);
View Full Code Here

        (JdbcConnectionDefinition) getDialogModel().getConnections().getSelectedItem();
    dataFactory.setDesignTimeName(connectionDefinition.getName());

    if (connectionDefinition instanceof DriverConnectionDefinition)
    {
      final DriverConnectionDefinition dcd = (DriverConnectionDefinition) connectionDefinition;
      final DriverDataSourceProvider dataSourceProvider = new DriverDataSourceProvider();
      dataSourceProvider.setUrl(dcd.getConnectionString());
      dataSourceProvider.setDriver(dcd.getDriverClass());
      final Properties properties = dcd.getProperties();
      final Enumeration keys = properties.keys();
      while (keys.hasMoreElements())
      {
        final String key = (String) keys.nextElement();
        dataSourceProvider.setProperty(key, properties.getProperty(key));
View Full Code Here

      provider.setPassword(jcd.getPassword());
      return new SimpleBandedMDXDataFactory(provider);
    }
    else if (connectionDefinition instanceof DriverConnectionDefinition)
    {
      final DriverConnectionDefinition dcd = (DriverConnectionDefinition) connectionDefinition;
      final DriverConnectionProvider provider = new DriverConnectionProvider();
      provider.setDriver(dcd.getDriverClass());
      provider.setUrl(dcd.getConnectionString());

      final Properties properties = dcd.getProperties();
      final Enumeration keys = properties.keys();
      while (keys.hasMoreElements())
      {
        final String key = (String) keys.nextElement();
        provider.setProperty(key, properties.getProperty(key));
View Full Code Here

      provider.setPassword(jcd.getPassword());
      return new SimpleLegacyBandedMDXDataFactory(provider);
    }
    else if (connectionDefinition instanceof DriverConnectionDefinition)
    {
      final DriverConnectionDefinition dcd = (DriverConnectionDefinition) connectionDefinition;
      final DriverConnectionProvider provider = new DriverConnectionProvider();
      provider.setDriver(dcd.getDriverClass());
      provider.setUrl(dcd.getConnectionString());

      final Properties properties = dcd.getProperties();
      final Enumeration keys = properties.keys();
      while (keys.hasMoreElements())
      {
        final String key = (String) keys.nextElement();
        provider.setProperty(key, properties.getProperty(key));
View Full Code Here

        final JdbcConnectionDefinition definition = (JdbcConnectionDefinition) model.getElementAt(i);
        if (definition instanceof DriverConnectionDefinition == false)
        {
          continue;
        }
        final DriverConnectionDefinition dcd = (DriverConnectionDefinition) definition;
        if (ObjectUtilities.equal(dcd.getUsername(), dcp.getProperty("JdbcUser")) &&
            ObjectUtilities.equal(dcd.getPassword(), dcp.getProperty("JdbcPassword")) &&
            ObjectUtilities.equal(dcd.getConnectionString(), dcp.getProperty("Jdbc")) &&
            ObjectUtilities.equal(dcd.getDriverClass(), dcp.getProperty("JdbcDrivers")) &&
            ObjectUtilities.equal(dcd.getName(), dcp.getProperty("::pentaho-reporting::name")))
        {
          return definition;
        }
      }

      String customName = dcp.getProperty("::pentaho-reporting::name");
      if (customName == null)
      {
        customName = Messages.getString("Olap4JDataSourceEditor.CustomConnection");
      }

      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(),
              dcp.getProperty("user"), dcp.getProperty("password"),
              dcp.getProperty("::pentaho-reporting::hostname"),
              dcp.getProperty("::pentaho-reporting::database-name"),
              dcp.getProperty("::pentaho-reporting::database-type"),
              dcp.getProperty("::pentaho-reporting::port"),
              p);
    }
    if (currentJNDISource instanceof JndiConnectionProvider)
    {
      final JndiConnectionProvider jcp = (JndiConnectionProvider) currentJNDISource;
      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;

        if (ObjectUtilities.equal(dcd.getJndiName(), jcp.getConnectionPath()))
        {
          return dcd;
        }
      }
      return new JndiConnectionDefinition(Messages.getString("Olap4JDataSourceEditor.CustomConnection"),
View Full Code Here

      provider.setPassword(jcd.getPassword());
      connectionProvider = provider;
    }
    else if (connectionDefinition instanceof DriverConnectionDefinition)
    {
      final DriverConnectionDefinition dcd = (DriverConnectionDefinition) connectionDefinition;
      final DriverConnectionProvider provider = new DriverConnectionProvider();
      provider.setDriver(dcd.getDriverClass());
      provider.setUrl(dcd.getConnectionString());

      final Properties properties = dcd.getProperties();
      final Enumeration keys = properties.keys();
      while (keys.hasMoreElements())
      {
        final String key = (String) keys.nextElement();
        provider.setProperty(key, properties.getProperty(key));
View Full Code Here

        // Fetch the currently selected connection for inspection
        final Object connection = dialogModel.getConnections().getSelectedItem();

        if (connection instanceof DriverConnectionDefinition)
        {
          final DriverConnectionDefinition dcd = (DriverConnectionDefinition) connection;

          // There are some instances where the DatabaseType is coming back null
          if (dcd.getDatabaseType() != null)
          {
            if (dcd.getDatabaseType().equalsIgnoreCase("HIVE"))
            { //$NON-NLS-1$
              // Disable SQLeonardo for Hadoop's Hive JDBC
              enable = false;
            }
          }
View Full Code Here

  private void setData(final JdbcConnectionDefinition def)
  {
    if (def instanceof DriverConnectionDefinition)
    {
      final DriverConnectionDefinition jdbcDef = (DriverConnectionDefinition) def;
      this.meta = new DatabaseMeta();
      this.meta.setUsername(jdbcDef.getUsername());
      this.meta.setPassword(jdbcDef.getPassword());
      this.meta.setName(jdbcDef.getName());

      if (jdbcDef.getDatabaseType() != null)
      {
        log.debug("Database type is known: " + jdbcDef.getDatabaseType());
        try
        {
          this.meta.setDatabaseType(jdbcDef.getDatabaseType());
        }
        catch (RuntimeException re)
        {
          // sic!
        }
        this.meta.setDBName(jdbcDef.getDatabaseName());
        this.meta.setHostname(jdbcDef.getHostName());
        this.meta.setDBPort(jdbcDef.getPort());
        this.meta.getAttributes().setProperty(GenericDatabaseMeta.ATRRIBUTE_CUSTOM_URL, jdbcDef.getConnectionString());
        this.meta.getAttributes().setProperty(GenericDatabaseMeta.ATRRIBUTE_CUSTOM_DRIVER_CLASS, jdbcDef.getDriverClass());
      }
      else if (String.valueOf(jdbcDef.getConnectionString()).startsWith(HSQLDB_MEM_PREFIX))
      {
        this.meta.setDatabaseType(DatabaseMapping.getGenericInterface().getPluginId());
        this.meta.getAttributes().put(GenericDatabaseMeta.ATRRIBUTE_CUSTOM_URL, jdbcDef.getConnectionString());
        this.meta.getAttributes().put(GenericDatabaseMeta.ATRRIBUTE_CUSTOM_DRIVER_CLASS, jdbcDef.getDriverClass());
      }
      else if (String.valueOf(jdbcDef.getConnectionString()).startsWith(HSQLDB_LOCAL_PREFIX))
      {
         this.meta.setDatabaseType(DatabaseMapping.getGenericInterface().getPluginId());
         this.meta.getAttributes().put(GenericDatabaseMeta.ATRRIBUTE_CUSTOM_URL, jdbcDef.getConnectionString());
         this.meta.getAttributes().put(GenericDatabaseMeta.ATRRIBUTE_CUSTOM_DRIVER_CLASS, jdbcDef.getDriverClass());
      }
      else
      {
        final DatabaseInterface databaseInterface = DatabaseMapping.getMappingForDriver(jdbcDef.getDriverClass());
        this.meta.setDatabaseType(databaseInterface.getPluginId());
        log.debug("Database type is unknown, using " + databaseInterface);
        try
        {
          final String pattern;
          if (databaseInterface instanceof HypersonicDatabaseMeta)
          {
            final String connectionString = jdbcDef.getConnectionString();
            if (connectionString.startsWith(HSQLDB_PREFIX))
            {
              if (connectionString.indexOf(':', HSQLDB_PREFIX.length()) == -1)
              {
                pattern = HSQLDB_PREFIX + "{0}/{2}";
              }
              else
              {
                pattern = HSQLDB_PREFIX + "{0}:{1}/{2}";
              }
            }
            else
            {
              pattern = databaseInterface.getURL("{0}", "{1}", "{2}");
            }
          }
          else
          {
            pattern = databaseInterface.getURL("{0}", "{1}", "{2}");
          }
          // knowing that most databases are written in C, we can be sure that the zero-character
          // is not a common value.
          if (pattern != null && pattern.length() > 0)
          {
            final MessageFormat format = new MessageFormat(pattern);
            final Object[] objects = format.parse(jdbcDef.getConnectionString());
            if (objects[0] != null)
            {
              this.meta.setHostname(String.valueOf(objects[0]));
            }
            if (objects[1] != null)
            {
              this.meta.setDBPort(String.valueOf(objects[1]));
            }
            if (objects[2] != null)
            {
              this.meta.setDBName(String.valueOf(objects[2]));
            }
          }
        }
        catch (Exception e)
        {
          designTimeContext.error(new XulException("Unable to parse database-URL, please report " +
              "your database driver to Pentaho to include it in our list of databases.", e));
          this.meta.setDatabaseType(DatabaseMapping.getGenericInterface().getPluginId());
          this.meta.getAttributes().put(GenericDatabaseMeta.ATRRIBUTE_CUSTOM_URL, jdbcDef.getConnectionString());
          this.meta.getAttributes().put(GenericDatabaseMeta.ATRRIBUTE_CUSTOM_DRIVER_CLASS, jdbcDef.getDriverClass());
        }
      }


      final Properties properties = jdbcDef.getProperties();
      final Iterator entryIterator = properties.entrySet().iterator();
      while (entryIterator.hasNext())
      {
        final Map.Entry entry = (Map.Entry) entryIterator.next();
        final String key = (String) entry.getKey();
View Full Code Here

TOP

Related Classes of org.pentaho.reporting.ui.datasources.jdbc.connection.DriverConnectionDefinition

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.