Search in sources :

Example 1 with IVariables

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());
    }
}
Also used : FormData(org.eclipse.swt.layout.FormData) CTabFolder(org.eclipse.swt.custom.CTabFolder) IVariables(org.apache.hop.core.variables.IVariables) FormAttachment(org.eclipse.swt.layout.FormAttachment) PropsUi(org.apache.hop.ui.core.PropsUi)

Example 2 with IVariables

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);
    }
}
Also used : IVariables(org.apache.hop.core.variables.IVariables)

Example 3 with IVariables

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;
}
Also used : HopException(org.apache.hop.core.exception.HopException) IVariables(org.apache.hop.core.variables.IVariables) CurrentDirectoryResolver(org.apache.hop.core.util.CurrentDirectoryResolver) UnknownParamException(org.apache.hop.core.parameters.UnknownParamException) HopException(org.apache.hop.core.exception.HopException) DuplicateParamException(org.apache.hop.core.parameters.DuplicateParamException)

Example 4 with IVariables

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();
}
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 5 with IVariables

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

Aggregations

IVariables (org.apache.hop.core.variables.IVariables)87 HopException (org.apache.hop.core.exception.HopException)34 PipelineMeta (org.apache.hop.pipeline.PipelineMeta)26 Test (org.junit.Test)20 Variables (org.apache.hop.core.variables.Variables)19 ErrorDialog (org.apache.hop.ui.core.dialog.ErrorDialog)19 IHopMetadataProvider (org.apache.hop.metadata.api.IHopMetadataProvider)17 IRowMeta (org.apache.hop.core.row.IRowMeta)15 HopGui (org.apache.hop.ui.hopgui.HopGui)13 ValueMetaString (org.apache.hop.core.row.value.ValueMetaString)12 WorkflowMeta (org.apache.hop.workflow.WorkflowMeta)12 GuiContextAction (org.apache.hop.core.action.GuiContextAction)11 TransformMeta (org.apache.hop.pipeline.transform.TransformMeta)11 HopTransformException (org.apache.hop.core.exception.HopTransformException)10 HopPluginException (org.apache.hop.core.exception.HopPluginException)9 ILogChannel (org.apache.hop.core.logging.ILogChannel)9 IOException (java.io.IOException)8 FileObject (org.apache.commons.vfs2.FileObject)7 HopValueException (org.apache.hop.core.exception.HopValueException)7 EnterSelectionDialog (org.apache.hop.ui.core.dialog.EnterSelectionDialog)7