public void initialize( Domain domain ) throws ModelerException { SqlPhysicalModel model = (SqlPhysicalModel) domain.getPhysicalModels().get( 0 ); SqlPhysicalTable table = model.getPhysicalTables().get( 0 ); String targetTable = (String) table.getProperty( "target_table" ); if ( !StringUtils.isEmpty( targetTable ) ) { domain.setId( targetTable ); } this.databaseMeta = ThinModelConverter.convertToLegacy( model.getId(), model.getDatasource() ); this.tableName = table.getTargetTable(); this.schemaName = table.getTargetSchema(); if ( schemaName == null ) { schemaName = ""; } }
public static final String proposeSqlBasedLogicalTableId( String locale, LogicalTable businessTable, SqlPhysicalTable physicalTable ) { String baseID = Util.toId( businessTable.getName( locale ) ); String namePart = Util.toId( Util.NVL( physicalTable.getName( locale ), physicalTable.getTargetTable() ) ); String id = Settings.getBusinessTableIDPrefix() + baseID + "_" + namePart; //$NON-NLS-1$ if ( Settings.isAnIdUppercase() ) { id = id.toUpperCase(); } return id; }
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 ); }
private LogicalTable createBusinessTable( SqlPhysicalTable physicalTable, String locale ) { // Create a business table with a new ID and localized name // LogicalTable businessTable = new LogicalTable( null, physicalTable ); // Try to set the name of the business table to something nice (beautify) // String tableName = PhysicalTableImporter.beautifyName( physicalTable.getTargetTable() ); businessTable.setName( new LocalizedString( locale, tableName ) ); businessTable.setId( Util.proposeSqlBasedLogicalTableId( locale, businessTable, physicalTable ) ); // Add columns to this by copying the physical columns to the business // columns... // for ( IPhysicalColumn physicalColumn : physicalTable.getPhysicalColumns() ) { LogicalColumn businessColumn = new LogicalColumn(); businessColumn.setPhysicalColumn( physicalColumn ); businessColumn.setLogicalTable( businessTable ); // We're done, add the business column. // // Propose a new ID businessColumn.setId( Util.proposeSqlBasedLogicalColumnId( locale, businessTable, (SqlPhysicalColumn) physicalColumn ) ); businessTable.addLogicalColumn( businessColumn ); } return businessTable; }
targetTable = ( (SqlPhysicalTable) domain.getPhysicalModels().get( 0 ).getPhysicalTables().get( 0 ) ).getTargetTable(); DatasourceDTO datasource = null;