use of org.apache.hop.ui.testing.PipelineUnitTestSetLocationDialog in project hop by apache.
the class LocationMouseDoubleClickExtensionPoint method callExtensionPoint.
@Override
public void callExtensionPoint(ILogChannel log, IVariables variables, HopGuiPipelineGraphExtension pipelineGraphExtension) throws HopException {
HopGuiPipelineGraph pipelineGraph = pipelineGraphExtension.getPipelineGraph();
PipelineMeta pipelineMeta = pipelineGraph.getPipelineMeta();
PipelineUnitTest unitTest = TestingGuiPlugin.getCurrentUnitTest(pipelineMeta);
if (unitTest == null) {
return;
}
HopGui hopGui = HopGui.getInstance();
try {
List<DataSet> dataSets = hopGui.getMetadataProvider().getSerializer(DataSet.class).loadAll();
Map<String, IRowMeta> transformFieldsMap = new HashMap<>();
for (TransformMeta transformMeta : pipelineMeta.getTransforms()) {
try {
IRowMeta transformFields = pipelineMeta.getTransformFields(pipelineGraph.getVariables(), transformMeta);
transformFieldsMap.put(transformMeta.getName(), transformFields);
} catch (Exception e) {
// Ignore GUI errors...
}
}
// Find the location that was double clicked on...
//
MouseEvent e = pipelineGraphExtension.getEvent();
Point point = pipelineGraphExtension.getPoint();
if (e.button == 1 || e.button == 2) {
AreaOwner areaOwner = pipelineGraph.getVisibleAreaOwner(point.x, point.y);
if (areaOwner != null && areaOwner.getAreaType() != null) {
//
if (DataSetConst.AREA_DRAWN_INPUT_DATA_SET.equals(areaOwner.getParent())) {
// Open the dataset double clicked on...
//
String transformName = (String) areaOwner.getOwner();
PipelineUnitTestSetLocation inputLocation = unitTest.findInputLocation(transformName);
if (inputLocation != null) {
PipelineUnitTestSetLocationDialog dialog = new PipelineUnitTestSetLocationDialog(hopGui.getShell(), variables, hopGui.getMetadataProvider(), inputLocation, dataSets, transformFieldsMap);
if (dialog.open()) {
hopGui.getMetadataProvider().getSerializer(PipelineUnitTest.class).save(unitTest);
pipelineGraph.updateGui();
}
}
} else if (DataSetConst.AREA_DRAWN_GOLDEN_DATA_SET.equals(areaOwner.getParent())) {
// Open the dataset double clicked on...
//
String transformName = (String) areaOwner.getOwner();
PipelineUnitTestSetLocation goldenLocation = unitTest.findGoldenLocation(transformName);
if (goldenLocation != null) {
PipelineUnitTestSetLocationDialog dialog = new PipelineUnitTestSetLocationDialog(hopGui.getShell(), variables, hopGui.getMetadataProvider(), goldenLocation, dataSets, transformFieldsMap);
if (dialog.open()) {
// Save the unit test
hopGui.getMetadataProvider().getSerializer(PipelineUnitTest.class).save(unitTest);
pipelineGraph.updateGui();
}
}
} else if (DataSetConst.AREA_DRAWN_GOLDEN_DATA_RESULT.equals(areaOwner.getParent())) {
// Open the dataset double clicked on...
//
String transformName = (String) areaOwner.getOwner();
PipelineUnitTestSetLocation goldenLocation = unitTest.findGoldenLocation(transformName);
if (goldenLocation != null) {
// Find the errors list of the unit test...
//
IPipelineEngine<PipelineMeta> pipeline = pipelineGraph.getPipeline();
if (pipeline == null) {
return;
}
List<UnitTestResult> results = (List<UnitTestResult>) pipeline.getExtensionDataMap().get(DataSetConst.UNIT_TEST_RESULTS);
if (results == null || results.isEmpty()) {
return;
}
ValidatePipelineUnitTestExtensionPoint.showUnitTestErrors(pipeline, results, hopGui);
}
}
}
}
} catch (Exception e) {
new ErrorDialog(hopGui.getShell(), "Error", "Error editing location", e);
}
}
Aggregations