public BusinessData loadBusinessData( String domainId, String modelId ) throws DatasourceServiceException { Domain domain = getMetadataDomainRepository().getDomain( domainId ); List<List<String>> data = null; if ( domain.getPhysicalModels().get( 0 ) instanceof InlineEtlPhysicalModel ) { InlineEtlPhysicalModel model = (InlineEtlPhysicalModel) domain.getPhysicalModels().get( 0 ); data = DatasourceInMemoryServiceHelper.getCsvDataSample( model.getFileLocation(), model.getHeaderPresent(), model .getDelimiter(), model.getEnclosure(), 5 ); } else { SqlPhysicalModel model = (SqlPhysicalModel) domain.getPhysicalModels().get( 0 ); String query = model.getPhysicalTables().get( 0 ).getTargetTable(); SerializedResultSet resultSet = DatasourceInMemoryServiceHelper .getSerializeableResultSet( model.getDatasource().getDatabaseName(), query, 5, null ); data = resultSet.getData(); } return new BusinessData( domain, data ); }
public BusinessData loadBusinessData( String domainId, String modelId ) throws DatasourceServiceException { Domain domain = getMetadataDomainRepository().getDomain( domainId ); List<List<String>> data = null; if ( domain.getPhysicalModels().get( 0 ) instanceof InlineEtlPhysicalModel ) { InlineEtlPhysicalModel model = (InlineEtlPhysicalModel) domain.getPhysicalModels().get( 0 ); String relativePath = PentahoSystem.getSystemSetting( "file-upload-defaults/relative-path", String.valueOf( CsvTransformGenerator.DEFAULT_RELATIVE_UPLOAD_FILE_PATH ) ); //$NON-NLS-1$ String csvFileLoc = PentahoSystem.getApplicationContext().getSolutionPath( relativePath ); data = DatasourceServiceHelper.getCsvDataSample( csvFileLoc + model.getFileLocation(), model.getHeaderPresent(), model.getDelimiter(), model.getEnclosure(), 5 ); } else { SqlPhysicalModel model = (SqlPhysicalModel) domain.getPhysicalModels().get( 0 ); String query = model.getPhysicalTables().get( 0 ).getTargetTable(); SerializedResultSet resultSet = DatasourceServiceHelper.getSerializeableResultSet( model.getDatasource().getDatabaseName(), query, 5, PentahoSessionHolder.getSession() ); data = resultSet.getData(); } return new BusinessData( domain, data ); }
"DATABASE_ACCESS", datasource.getType().toString(), idGen.getNextId() ) ); //$NON-NLS-1$ modelElement.appendChild( createTaggedValue( doc, "DATABASE_DATABASE", datasource.getDatabaseName(), idGen.getNextId() ) ); //$NON-NLS-1$ modelElement.appendChild( createTaggedValue( doc, "DATABASE_SERVER", datasource.getHostname(), idGen.getNextId() ) ); //$NON-NLS-1$
public static DatabaseMeta convertToLegacy( String name, SqlDataSource datasource ) { // make sure that the Kettle environment is initialized before DatabaseMeta creation try { KettleEnvironment.init( false ); } catch ( KettleException e ) { logger.error( "Error initializing the Kettle Environment", e ); throw new RuntimeException( "Error initializing the Kettle Environment", e ); } DatabaseMeta databaseMeta = new DatabaseMeta(); databaseMeta.setName( name ); databaseMeta.setHostname( datasource.getHostname() ); if ( datasource.getDialectType() == null ) { // default to mysql if dialect is null databaseMeta.setDatabaseType( "GENERIC" ); //$NON-NLS-1$ } else { databaseMeta.setDatabaseType( datasource.getDialectType() ); } databaseMeta.setAccessType( DatabaseMeta.getAccessType( datasource.getType().toString() ) ); databaseMeta.setDBName( datasource.getDatabaseName() ); databaseMeta.setDBPort( datasource.getPort() ); databaseMeta.setUsername( datasource.getUsername() ); databaseMeta.setPassword( datasource.getPassword() ); databaseMeta.setServername( datasource.getServername() ); // And now load the attributes... for ( String key : datasource.getAttributes().keySet() ) { databaseMeta.getAttributes().put( key, datasource.getAttributes().get( key ) ); } return databaseMeta; }
database = new DatabaseMeta( ( (SqlPhysicalModel) physicalModel ).getDatasource().getDatabaseName(), "MYSQL", //$NON-NLS-1$ "JNDI", "", "", "", "", "" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ database.getDatabaseInterface().setDatabaseName( ( (SqlPhysicalModel) physicalModel ).getDatasource().getDatabaseName() );