use of org.apache.hop.core.variables.IVariables in project hop by apache.
the class NeoConnectionEditor method createControl.
@Override
public void createControl(Composite composite) {
PropsUi props = PropsUi.getInstance();
int middle = props.getMiddlePct();
int margin = Const.MARGIN + 2;
IVariables variables = getHopGui().getVariables();
// The name
Label wlName = new Label(composite, SWT.RIGHT);
props.setLook(wlName);
wlName.setText(BaseMessages.getString(PKG, "NeoConnectionEditor.Name.Label"));
FormData fdlName = new FormData();
fdlName.top = new FormAttachment(0, margin);
// First one in the left top corner
fdlName.left = new FormAttachment(0, 0);
fdlName.right = new FormAttachment(middle, -margin);
wlName.setLayoutData(fdlName);
wName = new Text(composite, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wName);
FormData fdName = new FormData();
fdName.top = new FormAttachment(wlName, 0, SWT.CENTER);
// To the right of the label
fdName.left = new FormAttachment(middle, 0);
fdName.right = new FormAttachment(95, 0);
wName.setLayoutData(fdName);
wTabFolder = new CTabFolder(composite, SWT.BORDER);
FormData fdTabFolder = new FormData();
fdTabFolder.left = new FormAttachment(0, 0);
fdTabFolder.right = new FormAttachment(100, 0);
fdTabFolder.top = new FormAttachment(wName, 2 * margin);
fdTabFolder.bottom = new FormAttachment(100, -2 * margin);
wTabFolder.setLayoutData(fdTabFolder);
addBasicTab(props, variables, middle, margin);
addProtocolTab(props, variables, middle, margin);
addAdvancedTab(props, variables, middle, margin);
addUrlsTab(props, variables);
// Always select the basic tab
wTabFolder.setSelection(0);
setWidgetsContent();
enableFields();
clearChanged();
// Add modify listeners to all controls.
// This will inform the Metadata perspective in the Hop GUI that this object was modified and
// needs to be saved.
//
Control[] controls = { wName, wAutomatic, wServer, wDatabaseName, wVersion4, wDatabasePort, wBrowserPort, wPolicy, wUsername, wRouting, wEncryption, wTrustAllCertificates, wConnectionLivenessCheckTimeout, wMaxConnectionLifetime, wMaxConnectionPoolSize, wConnectionAcquisitionTimeout, wConnectionTimeout, wMaxTransactionRetryTime };
for (Control control : controls) {
control.addListener(SWT.Modify, e -> setChanged());
control.addListener(SWT.Selection, e -> setChanged());
}
}
use of org.apache.hop.core.variables.IVariables in project hop by apache.
the class ScriptValuesAddedFunctions method setParentScopeVariable.
static void setParentScopeVariable(IPipelineEngine pipeline, String variableName, String variableValue) {
pipeline.setVariable(variableName, variableValue);
IVariables parentSpace = pipeline.getParentVariables();
if (parentSpace != null) {
parentSpace.setVariable(variableName, variableValue);
}
}
use of org.apache.hop.core.variables.IVariables in project hop by apache.
the class TransformWithMappingMeta method loadMappingMeta.
public static synchronized PipelineMeta loadMappingMeta(TransformWithMappingMeta executorMeta, IHopMetadataProvider metadataProvider, IVariables variables) throws HopException {
PipelineMeta mappingPipelineMeta = null;
CurrentDirectoryResolver r = new CurrentDirectoryResolver();
// send restricted parentVariables with several important options
// Otherwise we destroy child variables and the option "Inherit all variables from the pipeline"
// is enabled always.
IVariables tmpSpace = r.resolveCurrentDirectory(getVarSpaceOnlyWithRequiredParentVars(variables), executorMeta.getParentTransformMeta(), executorMeta.getFilename());
String realFilename = tmpSpace.resolve(executorMeta.getFilename());
if (variables != null) {
// This is a parent pipeline and parent variable should work here. A child file name can be
// resolved via parent variables.
realFilename = variables.resolve(realFilename);
}
try {
// Don't set internal variables: they belong to the parent thread!
if (mappingPipelineMeta == null) {
mappingPipelineMeta = new PipelineMeta(realFilename, metadataProvider, true, tmpSpace);
LogChannel.GENERAL.logDetailed("Loading pipeline", "Pipeline was loaded from XML file [" + realFilename + "]");
}
} catch (Exception e) {
throw new HopException(BaseMessages.getString(PKG, "TransformWithMappingMeta.Exception.UnableToLoadPipeline"), e);
}
if (mappingPipelineMeta == null) {
// skip warning
return null;
}
mappingPipelineMeta.setMetadataProvider(metadataProvider);
mappingPipelineMeta.setFilename(mappingPipelineMeta.getFilename());
return mappingPipelineMeta;
}
use of org.apache.hop.core.variables.IVariables 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();
}
use of org.apache.hop.core.variables.IVariables 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);
}
}
Aggregations