Search in sources :

Example 16 with TransformMeta

use of org.apache.hop.pipeline.transform.TransformMeta in project hop by apache.

the class TestingGuiPlugin method clearGoldenDataSet.

/**
 * We set an golden data set on the selected unit test
 */
@GuiContextAction(id = ACTION_ID_PIPELINE_GRAPH_TRANSFORM_CLEAR_GOLDEN_DATA_SET, parentId = HopGuiPipelineTransformContext.CONTEXT_ID, type = GuiActionType.Delete, name = "i18n::TestingGuiPlugin.ContextAction.ClearGoldenDataset.Name", tooltip = "i18n::TestingGuiPlugin.ContextAction.ClearGoldenDataset.Tooltip", image = "clear-golden-dataset.svg", category = "i18n::TestingGuiPlugin.Category", categoryOrder = "8")
public void clearGoldenDataSet(HopGuiPipelineTransformContext context) {
    HopGui hopGui = HopGui.getInstance();
    PipelineMeta pipelineMeta = context.getPipelineMeta();
    TransformMeta transformMeta = context.getTransformMeta();
    IVariables variables = context.getPipelineGraph().getVariables();
    if (checkTestPresent(hopGui, pipelineMeta)) {
        return;
    }
    try {
        PipelineUnitTest currentUnitTest = getCurrentUnitTest(pipelineMeta);
        PipelineUnitTestSetLocation goldenLocation = currentUnitTest.findGoldenLocation(transformMeta.getName());
        if (goldenLocation != null) {
            currentUnitTest.getGoldenDataSets().remove(goldenLocation);
        }
        saveUnitTest(variables, hopGui.getMetadataProvider(), currentUnitTest, pipelineMeta);
    } catch (Exception e) {
        new ErrorDialog(hopGui.getShell(), BaseMessages.getString(PKG, "TestingGuiPlugin.ContextAction.ClearGoldenDataset.Error.Header"), BaseMessages.getString(PKG, "TestingGuiPlugin.ContextAction.ClearGoldenDataset.Error.Message"), e);
    }
    pipelineMeta.setChanged();
    context.getPipelineGraph().updateGui();
}
Also used : IVariables(org.apache.hop.core.variables.IVariables) TransformMeta(org.apache.hop.pipeline.transform.TransformMeta) ErrorDialog(org.apache.hop.ui.core.dialog.ErrorDialog) HopException(org.apache.hop.core.exception.HopException) HopTransformException(org.apache.hop.core.exception.HopTransformException) HopValueException(org.apache.hop.core.exception.HopValueException) HopPluginException(org.apache.hop.core.exception.HopPluginException) HopGui(org.apache.hop.ui.hopgui.HopGui) PipelineMeta(org.apache.hop.pipeline.PipelineMeta) GuiContextAction(org.apache.hop.core.action.GuiContextAction)

Example 17 with TransformMeta

use of org.apache.hop.pipeline.transform.TransformMeta in project hop by apache.

the class TestingGuiPlugin method setGoldenDataSet.

/**
 * We set an golden data set on the selected unit test
 */
@GuiContextAction(id = ACTION_ID_PIPELINE_GRAPH_TRANSFORM_DEFINE_GOLDEN_DATA_SET, parentId = HopGuiPipelineTransformContext.CONTEXT_ID, type = GuiActionType.Modify, name = "i18n::TestingGuiPlugin.ContextAction.SetGoldenDataset.Name", tooltip = "i18n::TestingGuiPlugin.ContextAction.SetGoldenDataset.Tooltip", image = "set-golden-dataset.svg", category = "i18n::TestingGuiPlugin.Category", categoryOrder = "8")
public void setGoldenDataSet(HopGuiPipelineTransformContext context) {
    PipelineMeta sourcePipelineMeta = context.getPipelineMeta();
    TransformMeta transformMeta = context.getTransformMeta();
    HopGuiPipelineGraph pipelineGraph = context.getPipelineGraph();
    IVariables variables = pipelineGraph.getVariables();
    HopGui hopGui = HopGui.getInstance();
    IHopMetadataProvider metadataProvider = hopGui.getMetadataProvider();
    if (checkTestPresent(hopGui, sourcePipelineMeta)) {
        return;
    }
    PipelineUnitTest unitTest = getCurrentUnitTest(sourcePipelineMeta);
    try {
        // Create a copy and modify the pipeline
        // This way we have
        PipelineMetaModifier modifier = new PipelineMetaModifier(variables, sourcePipelineMeta, unitTest);
        PipelineMeta pipelineMeta = modifier.getTestPipeline(LogChannel.UI, variables, metadataProvider);
        IHopMetadataSerializer<DataSet> setSerializer = metadataProvider.getSerializer(DataSet.class);
        List<String> setNames = setSerializer.listObjectNames();
        Collections.sort(setNames);
        EnterSelectionDialog esd = new EnterSelectionDialog(hopGui.getShell(), setNames.toArray(new String[setNames.size()]), BaseMessages.getString(PKG, "TestingGuiPlugin.ContextAction.SetGoldenDataset.Header"), BaseMessages.getString(PKG, "TestingGuiPlugin.ContextAction.SetGoldenDataset.Message"));
        String setName = esd.open();
        if (setName != null) {
            DataSet dataSet = setSerializer.load(setName);
            boolean changed = setGoldenDataSetOnTransform(variables, metadataProvider, pipelineMeta, transformMeta, unitTest, dataSet);
            if (changed) {
                pipelineGraph.updateGui();
            }
        }
    } catch (Exception e) {
        new ErrorDialog(hopGui.getShell(), BaseMessages.getString(PKG, "TestingGuiPlugin.ContextAction.SetGoldenDataset.Error.Header"), BaseMessages.getString(PKG, "TestingGuiPlugin.ContextAction.SetGoldenDataset.Error.Message"), e);
    }
}
Also used : PipelineMetaModifier(org.apache.hop.testing.xp.PipelineMetaModifier) ErrorDialog(org.apache.hop.ui.core.dialog.ErrorDialog) ValueMetaString(org.apache.hop.core.row.value.ValueMetaString) HopException(org.apache.hop.core.exception.HopException) HopTransformException(org.apache.hop.core.exception.HopTransformException) HopValueException(org.apache.hop.core.exception.HopValueException) HopPluginException(org.apache.hop.core.exception.HopPluginException) PipelineMeta(org.apache.hop.pipeline.PipelineMeta) IVariables(org.apache.hop.core.variables.IVariables) TransformMeta(org.apache.hop.pipeline.transform.TransformMeta) IHopMetadataProvider(org.apache.hop.metadata.api.IHopMetadataProvider) HopGuiPipelineGraph(org.apache.hop.ui.hopgui.file.pipeline.HopGuiPipelineGraph) EnterSelectionDialog(org.apache.hop.ui.core.dialog.EnterSelectionDialog) HopGui(org.apache.hop.ui.hopgui.HopGui) GuiContextAction(org.apache.hop.core.action.GuiContextAction)

Example 18 with TransformMeta

use of org.apache.hop.pipeline.transform.TransformMeta in project hop by apache.

the class TestingGuiPlugin method createDataSetFromTransform.

/**
 * Create a new data set with the output from
 */
@GuiContextAction(id = "pipeline-graph-transform-20400-create-data-set-from-transform", parentId = HopGuiPipelineTransformContext.CONTEXT_ID, type = GuiActionType.Delete, name = "i18n::TestingGuiPlugin.ContextAction.CreateDataset.Name", tooltip = "i18n::TestingGuiPlugin.ContextAction.CreateDataset.Tooltip", image = "create-dataset.svg", category = "i18n::TestingGuiPlugin.Category", categoryOrder = "8")
public void createDataSetFromTransform(HopGuiPipelineTransformContext context) {
    HopGui hopGui = HopGui.getInstance();
    IHopMetadataProvider metadataProvider = hopGui.getMetadataProvider();
    IVariables variables = context.getPipelineGraph().getVariables();
    TransformMeta transformMeta = context.getTransformMeta();
    PipelineMeta pipelineMeta = context.getPipelineMeta();
    try {
        DataSet dataSet = new DataSet();
        IRowMeta rowMeta = pipelineMeta.getTransformFields(variables, transformMeta);
        for (int i = 0; i < rowMeta.size(); i++) {
            IValueMeta valueMeta = rowMeta.getValueMeta(i);
            String setFieldName = valueMeta.getName();
            DataSetField field = new DataSetField(setFieldName, valueMeta.getType(), valueMeta.getLength(), valueMeta.getPrecision(), valueMeta.getComments(), valueMeta.getFormatMask());
            dataSet.getFields().add(field);
        }
        MetadataManager<DataSet> manager = new MetadataManager<>(hopGui.getVariables(), hopGui.getMetadataProvider(), DataSet.class);
        if (manager.newMetadata(dataSet) != null) {
            PipelineUnitTest unitTest = getCurrentUnitTest(pipelineMeta);
            if (unitTest == null) {
                return;
            }
            // Now that the data set is created and we have an active unit test, perhaps the user wants
            // to use it on the transform?
            // 
            MessageBox box = new MessageBox(hopGui.getShell(), SWT.YES | SWT.NO | SWT.CANCEL | SWT.ICON_QUESTION);
            box.setText(BaseMessages.getString(PKG, "TestingGuiPlugin.ContextAction.CreateDataset.DatasetType.Header"));
            box.setMessage(BaseMessages.getString(PKG, "TestingGuiPlugin.ContextAction.CreateDataset.DatasetType.Message", dataSet.getName(), transformMeta.getName()) + Const.CR + BaseMessages.getString(PKG, "TestingGuiPlugin.ContextAction.CreateDataset.DatasetType.Answer1") + Const.CR + BaseMessages.getString(PKG, "TestingGuiPlugin.ContextAction.CreateDataset.DatasetType.Answer2") + Const.CR + BaseMessages.getString(PKG, "TestingGuiPlugin.ContextAction.CreateDataset.DatasetType.Answer3") + Const.CR);
            int answer = box.open();
            if ((answer & SWT.YES) != 0) {
                // set the new data set as an input
                // 
                setInputDataSetOnTransform(variables, metadataProvider, pipelineMeta, transformMeta, unitTest, dataSet);
            }
            if ((answer & SWT.NO) != 0) {
                setGoldenDataSetOnTransform(variables, metadataProvider, pipelineMeta, transformMeta, unitTest, dataSet);
            }
        }
    } catch (Exception e) {
        new ErrorDialog(hopGui.getShell(), BaseMessages.getString(PKG, "TestingGuiPlugin.ContextAction.CreateDataset.Error.Header"), BaseMessages.getString(PKG, "TestingGuiPlugin.ContextAction.CreateDataset.Error.Message"), e);
    }
}
Also used : IRowMeta(org.apache.hop.core.row.IRowMeta) ErrorDialog(org.apache.hop.ui.core.dialog.ErrorDialog) ValueMetaString(org.apache.hop.core.row.value.ValueMetaString) WriteToDataSetExtensionPoint(org.apache.hop.testing.xp.WriteToDataSetExtensionPoint) HopException(org.apache.hop.core.exception.HopException) HopTransformException(org.apache.hop.core.exception.HopTransformException) HopValueException(org.apache.hop.core.exception.HopValueException) HopPluginException(org.apache.hop.core.exception.HopPluginException) PipelineMeta(org.apache.hop.pipeline.PipelineMeta) MessageBox(org.eclipse.swt.widgets.MessageBox) IValueMeta(org.apache.hop.core.row.IValueMeta) MetadataManager(org.apache.hop.ui.core.metadata.MetadataManager) IVariables(org.apache.hop.core.variables.IVariables) TransformMeta(org.apache.hop.pipeline.transform.TransformMeta) IHopMetadataProvider(org.apache.hop.metadata.api.IHopMetadataProvider) HopGui(org.apache.hop.ui.hopgui.HopGui) GuiContextAction(org.apache.hop.core.action.GuiContextAction)

Example 19 with TransformMeta

use of org.apache.hop.pipeline.transform.TransformMeta in project hop by apache.

the class TestingGuiPlugin method clearInputDataSet.

/**
 * We set an golden data set on the selected unit test
 */
@GuiContextAction(id = ACTION_ID_PIPELINE_GRAPH_TRANSFORM_CLEAR_INPUT_DATA_SET, parentId = HopGuiPipelineTransformContext.CONTEXT_ID, type = GuiActionType.Delete, name = "i18n::TestingGuiPlugin.ContextAction.ClearInputDataset.Name", tooltip = "i18n::TestingGuiPlugin.ContextAction.ClearInputDataset.Message", image = "clear-input-dataset.svg", category = "i18n::TestingGuiPlugin.Category", categoryOrder = "8")
public void clearInputDataSet(HopGuiPipelineTransformContext context) {
    HopGui hopGui = ((HopGui) HopGui.getInstance());
    PipelineMeta pipelineMeta = context.getPipelineMeta();
    TransformMeta transformMeta = context.getTransformMeta();
    IVariables variables = context.getPipelineGraph().getVariables();
    if (checkTestPresent(hopGui, pipelineMeta)) {
        return;
    }
    try {
        PipelineUnitTest currentUnitTest = getCurrentUnitTest(pipelineMeta);
        PipelineUnitTestSetLocation inputLocation = currentUnitTest.findInputLocation(transformMeta.getName());
        if (inputLocation != null) {
            currentUnitTest.getInputDataSets().remove(inputLocation);
        }
        saveUnitTest(variables, hopGui.getMetadataProvider(), currentUnitTest, pipelineMeta);
        context.getPipelineGraph().updateGui();
    } catch (Exception e) {
        new ErrorDialog(hopGui.getShell(), BaseMessages.getString(PKG, "TestingGuiPlugin.ContextAction.ClearInputDataset.Error.Header"), BaseMessages.getString(PKG, "TestingGuiPlugin.ContextAction.ClearInputDataset.Error.Message"), e);
    }
}
Also used : IVariables(org.apache.hop.core.variables.IVariables) TransformMeta(org.apache.hop.pipeline.transform.TransformMeta) ErrorDialog(org.apache.hop.ui.core.dialog.ErrorDialog) HopException(org.apache.hop.core.exception.HopException) HopTransformException(org.apache.hop.core.exception.HopTransformException) HopValueException(org.apache.hop.core.exception.HopValueException) HopPluginException(org.apache.hop.core.exception.HopPluginException) HopGui(org.apache.hop.ui.hopgui.HopGui) PipelineMeta(org.apache.hop.pipeline.PipelineMeta) GuiContextAction(org.apache.hop.core.action.GuiContextAction)

Example 20 with TransformMeta

use of org.apache.hop.pipeline.transform.TransformMeta in project hop by apache.

the class PipelineLogEditor method createPipelineFile.

/**
 * Create a new pipeline file: ask the user for a name. Add a standard transform and a dummy to
 * show how it works.
 *
 * @param parent
 */
private void createPipelineFile(Composite parent) {
    try {
        PipelineMeta pipelineMeta = new PipelineMeta();
        // Add a Pipeline Logging transform...
        // 
        PipelineLoggingMeta pipelineLoggingMeta = new PipelineLoggingMeta();
        pipelineLoggingMeta.setLoggingTransforms(true);
        TransformMeta pipelineLogging = new TransformMeta("Pipeline Logging", pipelineLoggingMeta);
        pipelineLogging.setLocation(200, 150);
        pipelineMeta.addTransform(pipelineLogging);
        // Add a dummy
        // 
        DummyMeta dummyMeta = new DummyMeta();
        TransformMeta dummy = new TransformMeta("Save logging here", dummyMeta);
        dummy.setLocation(500, 150);
        pipelineMeta.addTransform(dummy);
        // Add a hop between both transforms...
        // 
        pipelineMeta.addPipelineHop(new PipelineHopMeta(pipelineLogging, dummy));
        // Save it...
        // 
        HopPipelineFileType<PipelineMeta> type = new HopPipelineFileType<>();
        String filename = BaseDialog.presentFileDialog(// save
        true, parent.getShell(), wFilename, manager.getVariables(), type.getFilterExtensions(), type.getFilterNames(), true);
        if (filename != null) {
            // User specified a pipeline filename
            // 
            String realFilename = manager.getVariables().resolve(filename);
            pipelineMeta.setFilename(realFilename);
            pipelineMeta.clearChanged();
            HopDataOrchestrationPerspective perspective = HopGui.getDataOrchestrationPerspective();
            // Switch to the perspective
            // 
            perspective.activate();
            // Open it in the Hop GUI
            // 
            HopGui.getDataOrchestrationPerspective().addPipeline(hopGui, pipelineMeta, type);
            // Save the file
            hopGui.fileDelegate.fileSave();
        }
    } catch (Exception e) {
        new ErrorDialog(parent.getShell(), "Error", "Error creating pipeline", e);
    }
}
Also used : DummyMeta(org.apache.hop.pipeline.transforms.dummy.DummyMeta) HopDataOrchestrationPerspective(org.apache.hop.ui.hopgui.perspective.dataorch.HopDataOrchestrationPerspective) TransformMeta(org.apache.hop.pipeline.transform.TransformMeta) PipelineHopMeta(org.apache.hop.pipeline.PipelineHopMeta) ErrorDialog(org.apache.hop.ui.core.dialog.ErrorDialog) PipelineLoggingMeta(org.apache.hop.reflection.pipeline.transform.PipelineLoggingMeta) HopPipelineFileType(org.apache.hop.ui.hopgui.file.pipeline.HopPipelineFileType) PipelineMeta(org.apache.hop.pipeline.PipelineMeta)

Aggregations

TransformMeta (org.apache.hop.pipeline.transform.TransformMeta)231 PipelineMeta (org.apache.hop.pipeline.PipelineMeta)132 HopException (org.apache.hop.core.exception.HopException)115 IRowMeta (org.apache.hop.core.row.IRowMeta)108 BaseTransformMeta (org.apache.hop.pipeline.transform.BaseTransformMeta)101 ErrorDialog (org.apache.hop.ui.core.dialog.ErrorDialog)86 IVariables (org.apache.hop.core.variables.IVariables)79 FormLayout (org.eclipse.swt.layout.FormLayout)70 FormAttachment (org.eclipse.swt.layout.FormAttachment)69 FormData (org.eclipse.swt.layout.FormData)69 List (java.util.List)62 BaseMessages (org.apache.hop.i18n.BaseMessages)62 BaseDialog (org.apache.hop.ui.core.dialog.BaseDialog)62 SWT (org.eclipse.swt.SWT)62 Utils (org.apache.hop.core.util.Utils)61 BaseTransformDialog (org.apache.hop.ui.pipeline.transform.BaseTransformDialog)61 Const (org.apache.hop.core.Const)59 org.eclipse.swt.widgets (org.eclipse.swt.widgets)59 ITransformDialog (org.apache.hop.pipeline.transform.ITransformDialog)58 java.util (java.util)52