use of org.pentaho.di.trans.step.StepMeta in project pentaho-kettle by pentaho.
the class JobGeneratorTest method testGenerateCombinationLookupStepFromLogicalTable.
@Test
public void testGenerateCombinationLookupStepFromLogicalTable() throws Exception {
final LogicalTable logicalTable = mock(LogicalTable.class);
final DatabaseMeta databaseMeta = mock(DatabaseMeta.class);
final StepMeta stepMeta = jobGenerator.generateCombinationLookupStepFromLogicalTable(databaseMeta, logicalTable);
assertNotNull(stepMeta);
}
use of org.pentaho.di.trans.step.StepMeta in project pentaho-kettle by pentaho.
the class MQTTConsumerMetaTest method testXmlHasAllFields.
@Test
public void testXmlHasAllFields() {
String serverName = "some_cluster";
meta.setDefault();
meta.setMqttServer(serverName);
ArrayList<String> topicList = new ArrayList<>();
topicList.add("temperature");
meta.setTopics(topicList);
meta.setQos("1");
meta.setUsername("testuser");
meta.setPassword("test");
meta.setUseSsl(true);
meta.setTransformationPath("/home/pentaho/myKafkaTransformation.ktr");
meta.setBatchSize("54321");
meta.setBatchDuration("987");
StepMeta stepMeta = new StepMeta();
TransMeta transMeta = mock(TransMeta.class);
stepMeta.setParentTransMeta(transMeta);
meta.setParentStepMeta(stepMeta);
// tests serialization/deserialization round trip
assertTrue(meta.equals(fromXml(meta.getXML())));
}
use of org.pentaho.di.trans.step.StepMeta in project pentaho-kettle by pentaho.
the class JobGenerator method generateDimensionTransformation.
/**
* Generates a template
* @param databaseMeta
* @param logicalModel
* @return
*/
public TransMeta generateDimensionTransformation(DatabaseMeta databaseMeta, LogicalTable logicalTable) {
TransMeta transMeta = new TransMeta();
String tableName = ConceptUtil.getName(logicalTable, locale);
String tableDescription = ConceptUtil.getDescription(logicalTable, locale);
DimensionType dimensionType = ConceptUtil.getDimensionType(logicalTable);
transMeta.setName("Update dimension '" + tableName + "'");
transMeta.setDescription(tableDescription);
// Let's not forget to add the target database
//
transMeta.addDatabase(databaseMeta);
Point location = new Point(GRAPH_LEFT, GRAPH_TOP);
// Find all the source columns and source tables and put them into a table input step...
//
StepMeta inputStep = generateTableInputStepFromLogicalTable(logicalTable);
DatabaseMeta sourceDatabaseMeta = ((TableInputMeta) inputStep.getStepMetaInterface()).getDatabaseMeta();
if (sourceDatabaseMeta != null)
transMeta.addOrReplaceDatabase(sourceDatabaseMeta);
inputStep.setLocation(location.x, location.y);
nextLocation(location);
transMeta.addStep(inputStep);
StepMeta lastStep = inputStep;
// Generate an dimension lookup/update step for each table
//
StepMeta dimensionStep;
if (dimensionType == DimensionType.SLOWLY_CHANGING_DIMENSION) {
dimensionStep = generateDimensionLookupStepFromLogicalTable(databaseMeta, logicalTable);
} else {
dimensionStep = generateCombinationLookupStepFromLogicalTable(databaseMeta, logicalTable);
}
dimensionStep.setLocation(location.x, location.y);
nextLocation(location);
transMeta.addStep(dimensionStep);
TransHopMeta transHop = new TransHopMeta(lastStep, dimensionStep);
transMeta.addTransHop(transHop);
return transMeta;
}
use of org.pentaho.di.trans.step.StepMeta in project pentaho-kettle by pentaho.
the class JobGenerator method generateTableInputStepFromLogicalTable.
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;
}
use of org.pentaho.di.trans.step.StepMeta in project pentaho-kettle by pentaho.
the class TransMeta method getMaximum.
/**
* Gets the maximum size of the canvas by calculating the maximum location of a step.
*
* @return Maximum coordinate of a step in the transformation + (100,100) for safety.
*/
public Point getMaximum() {
int maxx = 0, maxy = 0;
for (int i = 0; i < nrSteps(); i++) {
StepMeta stepMeta = getStep(i);
Point loc = stepMeta.getLocation();
if (loc.x > maxx) {
maxx = loc.x;
}
if (loc.y > maxy) {
maxy = loc.y;
}
}
for (int i = 0; i < nrNotes(); i++) {
NotePadMeta notePadMeta = getNote(i);
Point loc = notePadMeta.getLocation();
if (loc.x + notePadMeta.width > maxx) {
maxx = loc.x + notePadMeta.width;
}
if (loc.y + notePadMeta.height > maxy) {
maxy = loc.y + notePadMeta.height;
}
}
return new Point(maxx + 100, maxy + 100);
}
Aggregations