Java Code Examples for org.pentaho.di.trans.step.StepMeta#drawStep()
The following examples show how to use
org.pentaho.di.trans.step.StepMeta#drawStep() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JobGenerator.java From pentaho-kettle with Apache License 2.0 | 4 votes |
private StepMeta generateTableInputStepFromLogicalTable(LogicalTable logicalTable) { String name = ConceptUtil.getName(logicalTable, locale); String description = ConceptUtil.getDescription(logicalTable, locale); TableInputMeta meta = new TableInputMeta(); // Source database, retain first // Source table, retain first // Source columns, retain all // DatabaseMeta sourceDatabaseMeta = null; String sourceTable = null; List<String> sourceColumns = new ArrayList<String>(); for (LogicalColumn column : logicalTable.getLogicalColumns()) { String phDb = ConceptUtil.getString(column, DefaultIDs.LOGICAL_COLUMN_SOURCE_DB); String phTable = ConceptUtil.getString(column, DefaultIDs.LOGICAL_COLUMN_SOURCE_TABLE); String phCol = ConceptUtil.getString(column, DefaultIDs.LOGICAL_COLUMN_SOURCE_COLUMN); if (!Utils.isEmpty(phDb) && sourceDatabaseMeta==null) { sourceDatabaseMeta = DatabaseMeta.findDatabase(databases, phDb); } if (!Utils.isEmpty(phTable)) { sourceTable = phDb; } if (!Utils.isEmpty(phCol)) { sourceColumns.add(phCol); } } String sql = "SELECT * FROM --< Source query for dimension '"+name+"'"; meta.setDatabaseMeta(sourceDatabaseMeta); if (sourceDatabaseMeta!=null && !Utils.isEmpty(sourceTable)) { sql = "SELECT "; if (sourceColumns.isEmpty()) { sql+=" * "; } else { sql+=Const.CR; } boolean first=true; for (String sourceColumn : sourceColumns) { if (first) { first=false; } else { sql+=" , "; } sql+=sourceDatabaseMeta.quoteField(sourceColumn)+Const.CR; } sql+="FROM "+sourceDatabaseMeta.getQuotedSchemaTableCombination(null, sourceTable); } meta.setSQL(sql); // Wrap it up... // StepMeta stepMeta = new StepMeta("Source data for '"+name+"'", meta); stepMeta.drawStep(); stepMeta.setDescription("Reads data for '"+name+"' : "+description); return stepMeta; }
Example 2
Source File: JobGenerator.java From pentaho-kettle with Apache License 2.0 | 4 votes |
protected StepMeta generateCombinationLookupStepFromLogicalTable(DatabaseMeta databaseMeta, LogicalTable logicalTable) { String name = ConceptUtil.getName(logicalTable, locale); String description = ConceptUtil.getDescription(logicalTable, locale); String phTable = ConceptUtil.getString(logicalTable, DefaultIDs.LOGICAL_TABLE_PHYSICAL_TABLE_NAME); String schemaTable = databaseMeta.getQuotedSchemaTableCombination(null, Const.NVL(phTable, name)); CombinationLookupMeta meta = new CombinationLookupMeta(); meta.setDatabaseMeta(databaseMeta); meta.setSchemaName(null); // TODO meta.setTablename(schemaTable); meta.setUseAutoinc(databaseMeta.supportsAutoinc()); meta.setCacheSize(5000); meta.setCommitSize(500); meta.setReplaceFields(true); // replace attribute fields with a TK // Find the technical key (if any defined) // LogicalColumn keyColumn = ConceptUtil.findLogicalColumn(logicalTable, AttributeType.TECHNICAL_KEY); if (keyColumn!=null) { ValueMetaInterface keyValue = getValueForLogicalColumn(databaseMeta, keyColumn); meta.setTechnicalKeyField(keyValue.getName()); } // Simply add all the attributes as key columns... // List<LogicalColumn> attributes = ConceptUtil.findLogicalColumns(logicalTable, AttributeType.ATTRIBUTE); meta.setKeyLookup(new String[attributes.size()]); meta.setKeyField(new String[attributes.size()]); for (int i=0;i<attributes.size();i++) { LogicalColumn logicalColumn = attributes.get(i); ValueMetaInterface valueMeta = getValueForLogicalColumn(databaseMeta, logicalColumn); meta.getKeyLookup()[i] = valueMeta.getName(); meta.getKeyField()[i] = valueMeta.getName(); } StepMeta stepMeta = new StepMeta(name, meta); stepMeta.drawStep(); stepMeta.setDescription(description); return stepMeta; }