Search in sources :

Example 26 with PipelineMeta

use of org.apache.hop.pipeline.PipelineMeta in project hop by apache.

the class HopGuiUnitTestCreated method callExtensionPoint.

@Override
public void callExtensionPoint(ILogChannel log, IVariables variables, Object object) throws HopException {
    // Refresh the tests list
    // 
    super.callExtensionPoint(log, variables, object);
    // 
    if (!(object instanceof PipelineUnitTest)) {
        return;
    }
    PipelineUnitTest test = (PipelineUnitTest) object;
    HopGui hopGui = HopGui.getInstance();
    TestingGuiPlugin testingGuiPlugin = TestingGuiPlugin.getInstance();
    // Create this for the active pipeline...
    // 
    PipelineMeta pipelineMeta = testingGuiPlugin.getActivePipelineMeta();
    if (pipelineMeta == null) {
        return;
    }
    MessageBox messageBox = new MessageBox(hopGui.getShell(), SWT.YES | SWT.NO | SWT.ICON_QUESTION);
    messageBox.setText("Attach?");
    messageBox.setMessage("Do you want to use this unit test for the active pipeline '" + pipelineMeta.getName() + "'?");
    int answer = messageBox.open();
    if ((answer & SWT.YES) == 0) {
        return;
    }
    // Attach it to the active pipeline
    // Calculate a relative filename
    // 
    test.setRelativeFilename(variables, pipelineMeta.getFilename());
    // Also switch to this unit test
    // 
    TestingGuiPlugin.selectUnitTest(pipelineMeta, test);
    // Refresh
    // 
    hopGui.getActiveFileTypeHandler().updateGui();
}
Also used : TestingGuiPlugin(org.apache.hop.testing.gui.TestingGuiPlugin) PipelineUnitTest(org.apache.hop.testing.PipelineUnitTest) IExtensionPoint(org.apache.hop.core.extension.IExtensionPoint) ExtensionPoint(org.apache.hop.core.extension.ExtensionPoint) HopGui(org.apache.hop.ui.hopgui.HopGui) PipelineMeta(org.apache.hop.pipeline.PipelineMeta) MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 27 with PipelineMeta

use of org.apache.hop.pipeline.PipelineMeta in project hop by apache.

the class DrawGoldenDataSetOnTransformExtensionPoint method callExtensionPoint.

@Override
public void callExtensionPoint(ILogChannel log, IVariables variables, PipelinePainterExtension ext) throws HopException {
    TransformMeta transformMeta = ext.transformMeta;
    PipelineMeta pipelineMeta = ext.pipelineMeta;
    PipelineUnitTest unitTest = TestingGuiPlugin.getCurrentUnitTest(pipelineMeta);
    if (unitTest != null) {
        drawGoldenSetMarker(ext, transformMeta, unitTest, ext.areaOwners);
    }
}
Also used : TransformMeta(org.apache.hop.pipeline.transform.TransformMeta) PipelineUnitTest(org.apache.hop.testing.PipelineUnitTest) PipelineMeta(org.apache.hop.pipeline.PipelineMeta)

Example 28 with PipelineMeta

use of org.apache.hop.pipeline.PipelineMeta in project hop by apache.

the class DrawInputDataSetOnTransformExtensionPoint method callExtensionPoint.

@Override
public void callExtensionPoint(ILogChannel log, IVariables variables, PipelinePainterExtension ext) throws HopException {
    TransformMeta transformMeta = ext.transformMeta;
    PipelineMeta pipelineMeta = ext.pipelineMeta;
    PipelineUnitTest unitTest = TestingGuiPlugin.getCurrentUnitTest(pipelineMeta);
    if (unitTest != null) {
        drawInputDataSetMarker(ext, transformMeta, unitTest, ext.areaOwners);
    }
}
Also used : TransformMeta(org.apache.hop.pipeline.transform.TransformMeta) PipelineUnitTest(org.apache.hop.testing.PipelineUnitTest) PipelineMeta(org.apache.hop.pipeline.PipelineMeta)

Example 29 with PipelineMeta

use of org.apache.hop.pipeline.PipelineMeta in project hop by apache.

the class CombinationLookupTest method setup.

@Before
public void setup() {
    databaseMeta = mock(DatabaseMeta.class);
    doReturn("").when(databaseMeta).quoteField(anyString());
    combinationLookupMeta = mock(CombinationLookupMeta.class);
    doReturn(databaseMeta).when(combinationLookupMeta).getDatabaseMeta();
    doReturn("sasas").when(combinationLookupMeta).getTechnicalKeyField();
    doReturn(new String[] {}).when(combinationLookupMeta).getKeyLookup();
    transformMeta = mock(TransformMeta.class);
    doReturn("transform").when(transformMeta).getName();
    doReturn(mock(TransformPartitioningMeta.class)).when(transformMeta).getTargetTransformPartitioningMeta();
    doReturn(combinationLookupMeta).when(transformMeta).getTransform();
    Database db = mock(Database.class);
    doReturn(mock(Connection.class)).when(db).getConnection();
    combinationLookupData = mock(CombinationLookupData.class);
    combinationLookupData.db = db;
    combinationLookupData.keynrs = new int[] {};
    PipelineMeta pipelineMeta = mock(PipelineMeta.class);
    doReturn(transformMeta).when(pipelineMeta).findTransform(anyString());
    Pipeline pipeline = spy(new LocalPipelineEngine());
    combinationLookup = spy(new CombinationLookup(transformMeta, combinationLookupMeta, combinationLookupData, 1, pipelineMeta, pipeline));
    doReturn(false).when(combinationLookup).isRowLevel();
    doReturn(true).when(combinationLookup).isAutoIncrement();
    doNothing().when(combinationLookup).logDetailed(anyString());
}
Also used : LocalPipelineEngine(org.apache.hop.pipeline.engines.local.LocalPipelineEngine) TransformMeta(org.apache.hop.pipeline.transform.TransformMeta) TransformPartitioningMeta(org.apache.hop.pipeline.transform.TransformPartitioningMeta) Database(org.apache.hop.core.database.Database) Connection(java.sql.Connection) DatabaseMeta(org.apache.hop.core.database.DatabaseMeta) PipelineMeta(org.apache.hop.pipeline.PipelineMeta) Pipeline(org.apache.hop.pipeline.Pipeline) Before(org.junit.Before)

Example 30 with PipelineMeta

use of org.apache.hop.pipeline.PipelineMeta in project hop by apache.

the class JsonOutputTest method test.

public String test(boolean compatibilityMode) throws Exception {
    HopEnvironment.init();
    // Create a new transformation...
    // 
    PipelineMeta pipelineMeta = new PipelineMeta();
    pipelineMeta.setName("testJsonOutput");
    PluginRegistry registry = PluginRegistry.getInstance();
    // create an injector transform
    String injectorTransformName = "injector transform";
    TransformMeta injectorTransform = TestUtilities.createInjectorTransform(injectorTransformName, registry);
    pipelineMeta.addTransform(injectorTransform);
    // create a row generator transform
    TransformMeta rowGeneratorTransform = createRowGeneratorTransform("Create rows for testJsonOutput1", registry);
    pipelineMeta.addTransform(rowGeneratorTransform);
    // create a PipelineHopMeta for injector and add it to the pipelineMeta
    PipelineHopMeta hop_injectoryRowGenerator = new PipelineHopMeta(injectorTransform, rowGeneratorTransform);
    pipelineMeta.addPipelineHop(hop_injectoryRowGenerator);
    // create the json output transform
    // but first lets get a filename
    String jsonFileName = TestUtilities.createEmptyTempFile("testJsonOutput1_");
    TransformMeta jsonOutputTransform = createJsonOutputTransform("json output transform", jsonFileName, registry);
    ((JsonOutputMeta) jsonOutputTransform.getTransform()).setCompatibilityMode(compatibilityMode);
    pipelineMeta.addTransform(jsonOutputTransform);
    // create a PipelineHopMeta for jsonOutputTransform and add it to the pipelineMeta
    PipelineHopMeta hop_RowGeneratorOutputTextFile = new PipelineHopMeta(rowGeneratorTransform, jsonOutputTransform);
    pipelineMeta.addPipelineHop(hop_RowGeneratorOutputTextFile);
    // Create a dummy transform and add it to the tranMeta
    String dummyTransformName = "dummy transform";
    TransformMeta dummyTransform = createDummyTransform(dummyTransformName, registry);
    pipelineMeta.addTransform(dummyTransform);
    // create a PipelineHopMeta for the
    PipelineHopMeta hopOutputJson_dummyTransform = new PipelineHopMeta(jsonOutputTransform, dummyTransform);
    pipelineMeta.addPipelineHop(hopOutputJson_dummyTransform);
    // Now execute the transformation...
    Pipeline pipeline = new LocalPipelineEngine(pipelineMeta);
    pipeline.prepareExecution();
    // Create a row collector and add it to the dummy transform interface
    IEngineComponent dummyITransform = pipeline.findComponent(dummyTransformName, 0);
    TransformRowsCollector dummyRowCollector = new TransformRowsCollector();
    dummyITransform.addRowListener(dummyRowCollector);
    // RowProducer rowProducer = pipeline.addRowProducer(injectorTransformName, 0);
    pipeline.startThreads();
    pipeline.waitUntilFinished();
    // get the results and return it
    File outputFile = new File(jsonFileName + ".js");
    String jsonStructure = FileUtils.readFileToString(outputFile);
    return jsonStructure;
}
Also used : LocalPipelineEngine(org.apache.hop.pipeline.engines.local.LocalPipelineEngine) PluginRegistry(org.apache.hop.core.plugins.PluginRegistry) TransformMeta(org.apache.hop.pipeline.transform.TransformMeta) PipelineHopMeta(org.apache.hop.pipeline.PipelineHopMeta) TransformRowsCollector(org.apache.hop.pipeline.transforms.TransformRowsCollector) ValueMetaString(org.apache.hop.core.row.value.ValueMetaString) File(java.io.File) IEngineComponent(org.apache.hop.pipeline.engine.IEngineComponent) PipelineMeta(org.apache.hop.pipeline.PipelineMeta) Pipeline(org.apache.hop.pipeline.Pipeline)

Aggregations

PipelineMeta (org.apache.hop.pipeline.PipelineMeta)218 HopException (org.apache.hop.core.exception.HopException)83 TransformMeta (org.apache.hop.pipeline.transform.TransformMeta)73 Pipeline (org.apache.hop.pipeline.Pipeline)61 LocalPipelineEngine (org.apache.hop.pipeline.engines.local.LocalPipelineEngine)42 IVariables (org.apache.hop.core.variables.IVariables)40 ErrorDialog (org.apache.hop.ui.core.dialog.ErrorDialog)36 PipelinePreviewProgressDialog (org.apache.hop.ui.pipeline.dialog.PipelinePreviewProgressDialog)33 Test (org.junit.Test)33 IRowMeta (org.apache.hop.core.row.IRowMeta)31 ValueMetaString (org.apache.hop.core.row.value.ValueMetaString)29 HopTransformException (org.apache.hop.core.exception.HopTransformException)26 IHopMetadataProvider (org.apache.hop.metadata.api.IHopMetadataProvider)24 PipelineHopMeta (org.apache.hop.pipeline.PipelineHopMeta)22 PrintWriter (java.io.PrintWriter)19 HopGui (org.apache.hop.ui.hopgui.HopGui)19 IOException (java.io.IOException)16 Before (org.junit.Before)16 ArrayList (java.util.ArrayList)15 HopPluginException (org.apache.hop.core.exception.HopPluginException)15