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);
}
}
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);
}
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);
}
}
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;
}
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);
}
}
Aggregations