Search in sources :

Example 1 with HopGuiPipelineGraph

use of org.apache.hop.ui.hopgui.file.pipeline.HopGuiPipelineGraph in project hop by apache.

the class HopNeo4jPerspective method openTransform.

private void openTransform(Session session, String name, String type, String id) {
    LogChannel.UI.logDetailed("Open transform : " + id + ", name : " + name + ", type: " + type);
    Map<String, Object> params = new HashMap<>();
    params.put("subjectName", name);
    params.put("subjectType", type);
    params.put("subjectId", id);
    StringBuilder cypher = new StringBuilder();
    cypher.append(// TRANSFORM
    "MATCH(e:Execution { name : $subjectName, type : $subjectType, id : $subjectId } )");
    cypher.append(// Transform
    "-[:EXECUTION_OF_TRANSFORM]->(t:Transform { name : $subjectName } )");
    cypher.append("-[:TRANSFORM_OF_PIPELINE]->(p:Pipeline) ");
    cypher.append("RETURN p.filename, t.name ");
    String[] names = session.readTransaction(tx -> {
        Result statementResult = tx.run(cypher.toString(), params);
        if (!statementResult.hasNext()) {
            statementResult.consume();
            // No file found
            return null;
        }
        Record record = statementResult.next();
        statementResult.consume();
        String filename = LoggingCore.getStringValue(record, 0);
        String transformName = LoggingCore.getStringValue(record, 1);
        return new String[] { filename, transformName };
    });
    if (names == null) {
        return;
    }
    String filename = names[0];
    String transformName = names[1];
    if (StringUtils.isEmpty(filename)) {
        return;
    }
    try {
        hopGui.fileDelegate.fileOpen(filename);
        if (StringUtils.isEmpty(transformName)) {
            return;
        }
        HopDataOrchestrationPerspective perspective = HopGui.getDataOrchestrationPerspective();
        IHopFileTypeHandler typeHandler = perspective.getActiveFileTypeHandler();
        if (typeHandler == null || !(typeHandler instanceof HopGuiPipelineGraph)) {
            return;
        }
        HopGuiPipelineGraph graph = (HopGuiPipelineGraph) typeHandler;
        PipelineMeta pipelineMeta = graph.getPipelineMeta();
        TransformMeta transformMeta = pipelineMeta.findTransform(transformName);
        if (transformMeta == null) {
            return;
        }
        pipelineMeta.unselectAll();
        transformMeta.setSelected(true);
        graph.editTransform(pipelineMeta, transformMeta);
    } catch (Exception e) {
        new ErrorDialog(hopGui.getShell(), BaseMessages.getString(PKG, "Neo4jPerspectiveDialog.OpeningTransform.Dialog.Header"), BaseMessages.getString(PKG, "Neo4jPerspectiveDialog.OpeningTransform.Dialog.Message"), e);
    }
}
Also used : IHopFileTypeHandler(org.apache.hop.ui.hopgui.file.IHopFileTypeHandler) ErrorDialog(org.apache.hop.ui.core.dialog.ErrorDialog) HopException(org.apache.hop.core.exception.HopException) HopConfigException(org.apache.hop.core.exception.HopConfigException) PipelineMeta(org.apache.hop.pipeline.PipelineMeta) HopDataOrchestrationPerspective(org.apache.hop.ui.hopgui.perspective.dataorch.HopDataOrchestrationPerspective) TransformMeta(org.apache.hop.pipeline.transform.TransformMeta) HopGuiPipelineGraph(org.apache.hop.ui.hopgui.file.pipeline.HopGuiPipelineGraph)

Example 2 with HopGuiPipelineGraph

use of org.apache.hop.ui.hopgui.file.pipeline.HopGuiPipelineGraph in project hop by apache.

the class TestingGuiPlugin method refreshUnitTestsList.

public static void refreshUnitTestsList() {
    HopGuiPipelineGraph pipelineGraph = HopGui.getActivePipelineGraph();
    if (pipelineGraph == null) {
        return;
    }
    pipelineGraph.getToolBarWidgets().refreshComboItemList(ID_TOOLBAR_UNIT_TESTS_COMBO);
}
Also used : HopGuiPipelineGraph(org.apache.hop.ui.hopgui.file.pipeline.HopGuiPipelineGraph)

Example 3 with HopGuiPipelineGraph

use of org.apache.hop.ui.hopgui.file.pipeline.HopGuiPipelineGraph 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 4 with HopGuiPipelineGraph

use of org.apache.hop.ui.hopgui.file.pipeline.HopGuiPipelineGraph in project hop by apache.

the class TestingGuiPlugin method getUnitTestsCombo.

private Combo getUnitTestsCombo() {
    HopGuiPipelineGraph pipelineGraph = HopGui.getActivePipelineGraph();
    if (pipelineGraph == null) {
        return null;
    }
    Control control = pipelineGraph.getToolBarWidgets().getWidgetsMap().get(ID_TOOLBAR_UNIT_TESTS_COMBO);
    if ((control != null) && (control instanceof Combo)) {
        Combo combo = (Combo) control;
        return combo;
    }
    return null;
}
Also used : Control(org.eclipse.swt.widgets.Control) Combo(org.eclipse.swt.widgets.Combo) HopGuiPipelineGraph(org.apache.hop.ui.hopgui.file.pipeline.HopGuiPipelineGraph)

Example 5 with HopGuiPipelineGraph

use of org.apache.hop.ui.hopgui.file.pipeline.HopGuiPipelineGraph in project hop by apache.

the class HopGuiFlagUnitTestExtensionPoint method callExtensionPoint.

@Override
public void callExtensionPoint(ILogChannel log, IVariables variables, PipelineMeta pipelineMeta) throws HopException {
    PipelineUnitTest unitTest = TestingGuiPlugin.getCurrentUnitTest(pipelineMeta);
    if (unitTest == null) {
        return;
    }
    // Look up the variables of the current active pipeline graph...
    // 
    HopGuiPipelineGraph activePipelineGraph = HopGui.getActivePipelineGraph();
    if (activePipelineGraph == null) {
        return;
    }
    String unitTestName = unitTest.getName();
    if (!StringUtil.isEmpty(unitTestName)) {
        // We're running in HopGui and there's a unit test selected : test it
        // 
        variables.setVariable(DataSetConst.VAR_RUN_UNIT_TEST, "Y");
        variables.setVariable(DataSetConst.VAR_UNIT_TEST_NAME, unitTestName);
    }
}
Also used : PipelineUnitTest(org.apache.hop.testing.PipelineUnitTest) HopGuiPipelineGraph(org.apache.hop.ui.hopgui.file.pipeline.HopGuiPipelineGraph)

Aggregations

HopGuiPipelineGraph (org.apache.hop.ui.hopgui.file.pipeline.HopGuiPipelineGraph)17 PipelineMeta (org.apache.hop.pipeline.PipelineMeta)9 HopException (org.apache.hop.core.exception.HopException)8 ErrorDialog (org.apache.hop.ui.core.dialog.ErrorDialog)7 ValueMetaString (org.apache.hop.core.row.value.ValueMetaString)5 IVariables (org.apache.hop.core.variables.IVariables)4 HopGui (org.apache.hop.ui.hopgui.HopGui)4 HopTransformException (org.apache.hop.core.exception.HopTransformException)3 IRowMeta (org.apache.hop.core.row.IRowMeta)3 TransformMeta (org.apache.hop.pipeline.transform.TransformMeta)3 PipelineUnitTest (org.apache.hop.testing.PipelineUnitTest)3 EnterSelectionDialog (org.apache.hop.ui.core.dialog.EnterSelectionDialog)3 ArrayList (java.util.ArrayList)2 FileObject (org.apache.commons.vfs2.FileObject)2 GuiContextAction (org.apache.hop.core.action.GuiContextAction)2 HopPluginException (org.apache.hop.core.exception.HopPluginException)2 HopValueException (org.apache.hop.core.exception.HopValueException)2 IHopMetadataProvider (org.apache.hop.metadata.api.IHopMetadataProvider)2 IHopFileTypeHandler (org.apache.hop.ui.hopgui.file.IHopFileTypeHandler)2 HopDataOrchestrationPerspective (org.apache.hop.ui.hopgui.perspective.dataorch.HopDataOrchestrationPerspective)2