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 ); }
protected void doInputWiring( Query query, TransMeta transMeta ) { // // CSV FILE LOCATION AND FIELDS // InlineEtlPhysicalModel physicalModel = (InlineEtlPhysicalModel) query.getLogicalModel().getPhysicalModel(); CsvInputMeta csvinput = (CsvInputMeta) getStepMeta( transMeta, "CSV file input" ).getStepMetaInterface(); //$NON-NLS-1$ // the file name might need to be translated to the correct location here if ( csvFileLoc != null ) { csvinput.setFilename( csvFileLoc + physicalModel.getFileLocation() ); } else { csvinput.setFilename( physicalModel.getFileLocation() ); } csvinput.setDelimiter( physicalModel.getDelimiter() ); csvinput.setEnclosure( physicalModel.getEnclosure() ); csvinput.setHeaderPresent( physicalModel.getHeaderPresent() ); // update fields LogicalTable table = query.getLogicalModel().getLogicalTables().get( 0 ); csvinput.allocate( table.getLogicalColumns().size() ); for ( int i = 0; i < csvinput.getInputFields().length; i++ ) { // Update csv input LogicalColumn col = table.getLogicalColumns().get( i ); csvinput.getInputFields()[i] = new TextFileInputField(); String fieldName = (String) col.getProperty( InlineEtlPhysicalColumn.FIELD_NAME ); if ( logger.isDebugEnabled() ) { logger.debug( "FROM CSV: " + fieldName ); //$NON-NLS-1$ } csvinput.getInputFields()[i].setName( fieldName ); csvinput.getInputFields()[i].setType( convertType( col.getDataType() ) ); } }