Search in sources :

Example 96 with StepMeta

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);
}
Also used : LogicalTable(org.pentaho.metadata.model.LogicalTable) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) StepMeta(org.pentaho.di.trans.step.StepMeta) Test(org.junit.Test)

Example 97 with 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())));
}
Also used : ArrayList(java.util.ArrayList) TransMeta(org.pentaho.di.trans.TransMeta) StepMeta(org.pentaho.di.trans.step.StepMeta) Test(org.junit.Test)

Example 98 with StepMeta

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;
}
Also used : DimensionType(org.pentaho.di.starmodeler.DimensionType) TransMeta(org.pentaho.di.trans.TransMeta) Point(org.pentaho.di.core.gui.Point) TransHopMeta(org.pentaho.di.trans.TransHopMeta) StepMeta(org.pentaho.di.trans.step.StepMeta) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) TableInputMeta(org.pentaho.di.trans.steps.tableinput.TableInputMeta)

Example 99 with StepMeta

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;
}
Also used : LogicalColumn(org.pentaho.metadata.model.LogicalColumn) ArrayList(java.util.ArrayList) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) StepMeta(org.pentaho.di.trans.step.StepMeta) TableInputMeta(org.pentaho.di.trans.steps.tableinput.TableInputMeta)

Example 100 with 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);
}
Also used : Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint) NotePadMeta(org.pentaho.di.core.NotePadMeta) StepMeta(org.pentaho.di.trans.step.StepMeta) Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint)

Aggregations

StepMeta (org.pentaho.di.trans.step.StepMeta)637 TransMeta (org.pentaho.di.trans.TransMeta)228 KettleException (org.pentaho.di.core.exception.KettleException)174 BaseStepMeta (org.pentaho.di.trans.step.BaseStepMeta)167 Test (org.junit.Test)162 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)147 TransHopMeta (org.pentaho.di.trans.TransHopMeta)128 Trans (org.pentaho.di.trans.Trans)119 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)113 DummyTransMeta (org.pentaho.di.trans.steps.dummytrans.DummyTransMeta)107 PluginRegistry (org.pentaho.di.core.plugins.PluginRegistry)106 StepInterface (org.pentaho.di.trans.step.StepInterface)92 RowMetaAndData (org.pentaho.di.core.RowMetaAndData)79 Point (org.pentaho.di.core.gui.Point)79 FormAttachment (org.eclipse.swt.layout.FormAttachment)76 FormData (org.eclipse.swt.layout.FormData)76 FormLayout (org.eclipse.swt.layout.FormLayout)76 Label (org.eclipse.swt.widgets.Label)76 Shell (org.eclipse.swt.widgets.Shell)76 Button (org.eclipse.swt.widgets.Button)75