Package org.pentaho.di.core.database

Examples of org.pentaho.di.core.database.DatabaseMeta


    return xstream.toXML(systemObjects);
  }
 
  public void deserializeConnection(Schema schema, String rdbmsXml, String schemaXml) {
    XStream xstream = getXStream(schema);
    DatabaseMeta databaseMeta = (DatabaseMeta)xstream.fromXML(rdbmsXml);
    SchemaModel schemaModel = (SchemaModel)xstream.fromXML(schemaXml);
   
    //save off cubeName since setSelectedSchemaModel will clear it out
    String cubeName = schemaModel.getCubeName();
   
View Full Code Here


    dataHandler.setData(connectionModel.getDatabaseMeta());

    XulDialog dialog = (XulDialog) document.getElementById(GENERAL_DATASOURCE_WINDOW);
    dialog.show();

    DatabaseMeta databaseMeta = (DatabaseMeta) dataHandler.getData();

    if (databaseMeta != null) {
      connectionModel.setDatabaseMeta(databaseMeta);
    }
  }
View Full Code Here

            }
            if (dbMeta != null) {
                return dbMeta;
            }
            if (xml == null) {
                dbMeta = new DatabaseMeta();
            } else {
                dbMeta = new DatabaseMeta(xml);
            }
        } catch (KettleException e) {
            throw new RuntimeException(
                    getResourceConverter()
                    .getFormattedString(
View Full Code Here

            }
            if (dbMeta != null) {
                return dbMeta;
            }
            if (xml == null) {
                dbMeta = new DatabaseMeta();
            } else {
                dbMeta = new DatabaseMeta(xml);
            }
        } catch (KettleException e) {
            throw new RuntimeException(
                    getResourceConverter()
                    .getFormattedString(
View Full Code Here

import com.thoughtworks.xstream.io.HierarchicalStreamWriter;

public class DatabaseMetaConverter implements Converter {

  public void marshal(Object arg0, HierarchicalStreamWriter writer, MarshallingContext arg2) {
    DatabaseMeta obj = (DatabaseMeta)arg0;
    writer.setValue(obj.getXML());
  }
View Full Code Here

    writer.setValue(obj.getXML());
  }

  public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext arg1) {
    try {
      return new DatabaseMeta(reader.getValue());
    } catch (Exception e) {
      e.printStackTrace();
    }
    return null;
  }
View Full Code Here

        try {
          while (dialog.isHidden()) {
            sleep(500);
          }
         
          DatabaseMeta dbMeta = connectionModel.getDatabaseMeta();
          final String mondrianConnectionUrl = MessageFormat.format(
              "Provider={0};Jdbc={1};JdbcUser={2};JdbcPassword={3};Catalog={4};JdbcDrivers={5}", "Mondrian", dbMeta.getURL(), dbMeta
                  .getUsername(), dbMeta.getPassword(), "file:" + getMondrianSchemaFilename(),
                  dbMeta.getDriverClass());
          Map<Parameter, Object> parameterValues = new HashMap<Parameter, Object>();

          parameterValues.put(mondrianSchemaLoader.getParameters().get(0), mondrianConnectionUrl);
          parameterValues.put(mondrianSchemaLoader.getParameters().get(1), cubeName);
         
View Full Code Here

    if (validationHasErrors && !continueOnValidationErrors) {
      return null;
    }
   
    try {
      DatabaseMeta dbMeta = connectionModel.getDatabaseMeta();
      final String mondrianConnectionUrl = MessageFormat.format(
          "Provider={0};Jdbc={1};JdbcUser={2};JdbcPassword={3};Catalog={4};JdbcDrivers={5}", "Mondrian", dbMeta.getURL(), dbMeta
              .getUsername(), dbMeta.getPassword(), "file:" + getMondrianSchemaFilename(),
              dbMeta.getDriverClass());
     
      Map<Parameter, Object> parameterValues = new HashMap<Parameter, Object>();

      parameterValues.put(mondrianSchemaLoader.getParameters().get(0), mondrianConnectionUrl);
      parameterValues.put(mondrianSchemaLoader.getParameters().get(1), cubeName);
View Full Code Here

   
    // special binding based on type of database meta
    BindingConvertor<Boolean, Boolean> converter = new BindingConvertor<Boolean, Boolean>() {
      @Override
      public Boolean sourceToTarget(Boolean value) {
        DatabaseMeta databaseMeta = connectionModel.getDatabaseMeta();
        boolean disabled = connectionModel.isSchemaLocked();
       
        if (disabled && isSelected()) {
          setSelected(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();
        if (key.startsWith("::pentaho-reporting::"))
        {
          continue;
        }
        if ("user".equals(key) || "password".equals(key))
        {
          continue;
        }
        // This line makes the database dialog crash later. This seems to be a Swing/Xul issue.
        this.meta.addExtraOption(meta.getPluginId(), key, (String) entry.getValue());
      }
    }
    else if (def instanceof JndiConnectionDefinition)
    {
      final JndiConnectionDefinition jndiDef = (JndiConnectionDefinition) def;
      this.meta = new DatabaseMeta();
      this.meta.setDBName(jndiDef.getJndiName()); //JNDI name stored in DBname
      this.meta.setName(jndiDef.getName());
      try
      {
        if (jndiDef.getDatabaseType() != null)
View Full Code Here

TOP

Related Classes of org.pentaho.di.core.database.DatabaseMeta

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.