Search in sources :

Example 1 with ValueMetaBase

use of org.pentaho.di.core.row.value.ValueMetaBase in project pentaho-kettle by pentaho.

the class TextFileOutputTest method testFastDumpDisableStreamEncodeTest.

/**
 * Test for PDI-13987
 */
@Test
public void testFastDumpDisableStreamEncodeTest() throws Exception {
    textFileOutput = new TextFileOutputTestHandler(stepMockHelper.stepMeta, stepMockHelper.stepDataInterface, 0, stepMockHelper.transMeta, stepMockHelper.trans);
    textFileOutput.meta = stepMockHelper.processRowsStepMetaInterface;
    String testString = "ÖÜä";
    String inputEncode = StandardCharsets.UTF_8.name();
    String outputEncode = StandardCharsets.ISO_8859_1.name();
    Object[] rows = { testString.getBytes(inputEncode) };
    ValueMetaBase valueMetaInterface = new ValueMetaBase("test", ValueMetaInterface.TYPE_STRING);
    valueMetaInterface.setStringEncoding(inputEncode);
    valueMetaInterface.setStorageType(ValueMetaInterface.STORAGE_TYPE_BINARY_STRING);
    valueMetaInterface.setStorageMetadata(new ValueMetaString());
    TextFileOutputData data = new TextFileOutputData();
    data.binarySeparator = " ".getBytes();
    data.binaryEnclosure = "\"".getBytes();
    data.binaryNewline = "\n".getBytes();
    textFileOutput.data = data;
    RowMeta rowMeta = new RowMeta();
    rowMeta.addValueMeta(valueMetaInterface);
    doReturn(outputEncode).when(stepMockHelper.processRowsStepMetaInterface).getEncoding();
    textFileOutput.data.writer = mock(BufferedOutputStream.class);
    textFileOutput.writeRow(rowMeta, rows);
    verify(textFileOutput.data.writer).write(testString.getBytes(outputEncode));
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) RowMeta(org.pentaho.di.core.row.RowMeta) Matchers.anyObject(org.mockito.Matchers.anyObject) FileObject(org.apache.commons.vfs2.FileObject) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) Matchers.anyString(org.mockito.Matchers.anyString) BufferedOutputStream(java.io.BufferedOutputStream) ValueMetaBase(org.pentaho.di.core.row.value.ValueMetaBase) Test(org.junit.Test)

Example 2 with ValueMetaBase

use of org.pentaho.di.core.row.value.ValueMetaBase in project pentaho-kettle by pentaho.

the class BaseLogTable method computeValueMeta.

protected ValueMetaInterface computeValueMeta(LogTableField field) {
    ValueMetaInterface valueMeta = new ValueMetaBase(field.getFieldName(), field.getDataType());
    valueMeta.setLength(field.getLength());
    return valueMeta;
}
Also used : ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface) ValueMetaBase(org.pentaho.di.core.row.value.ValueMetaBase)

Example 3 with ValueMetaBase

use of org.pentaho.di.core.row.value.ValueMetaBase in project pentaho-kettle by pentaho.

the class MappingOutputMetaIT method testGetFields_OutputValueRenames_WillRenameOutputIfValueMetaExist.

@Test
public void testGetFields_OutputValueRenames_WillRenameOutputIfValueMetaExist() throws KettleStepException {
    ValueMetaInterface valueMeta1 = new ValueMetaBase("valueMeta1");
    ValueMetaInterface valueMeta2 = new ValueMetaBase("valueMeta2");
    RowMetaInterface rowMeta = new RowMeta();
    rowMeta.addValueMeta(valueMeta1);
    rowMeta.addValueMeta(valueMeta2);
    List<MappingValueRename> outputValueRenames = new ArrayList<MappingValueRename>();
    outputValueRenames.add(new MappingValueRename("valueMeta2", "valueMeta1"));
    MappingOutputMeta meta = new MappingOutputMeta();
    meta.setOutputValueRenames(outputValueRenames);
    meta.getFields(rowMeta, null, info, nextStep, space, repository, metaStore);
    // we must not add additional field
    assertEquals(2, rowMeta.getValueMetaList().size());
    // we must not keep the first value meta since we want to rename second
    assertEquals(valueMeta1, rowMeta.getValueMeta(0));
    // the second value meta must be other than we want to rename since we already have value meta with such name
    assertFalse("valueMeta1".equals(rowMeta.getValueMeta(1).getName()));
    // the second value meta must be other than we want to rename since we already have value meta with such name.
    // It must be renamed according the rules from the #RowMeta
    assertTrue("valueMeta1_1".equals(rowMeta.getValueMeta(1).getName()));
}
Also used : RowMeta(org.pentaho.di.core.row.RowMeta) ArrayList(java.util.ArrayList) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface) ValueMetaBase(org.pentaho.di.core.row.value.ValueMetaBase) MappingOutputMeta(org.pentaho.di.trans.steps.mappingoutput.MappingOutputMeta) Test(org.junit.Test)

Example 4 with ValueMetaBase

use of org.pentaho.di.core.row.value.ValueMetaBase in project pentaho-kettle by pentaho.

the class BaseStepTest method nullFieldName.

@Test(expected = KettleStepException.class)
public void nullFieldName() throws KettleStepException {
    BaseStep baseStep = new BaseStep(mockHelper.stepMeta, mockHelper.stepDataInterface, 0, mockHelper.transMeta, mockHelper.trans);
    baseStep.setRowHandler(rowHandler);
    RowMetaInterface rowMeta = new RowMeta();
    rowMeta.addValueMeta(new ValueMetaBase(null, ValueMetaInterface.TYPE_INTEGER));
    baseStep.putRow(rowMeta, new Object[] { 0 });
}
Also used : RowMeta(org.pentaho.di.core.row.RowMeta) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) ValueMetaBase(org.pentaho.di.core.row.value.ValueMetaBase) Test(org.junit.Test)

Example 5 with ValueMetaBase

use of org.pentaho.di.core.row.value.ValueMetaBase in project pentaho-kettle by pentaho.

the class JmsProducerDialog method open.

@Override
public String open() {
    Shell parent = getParent();
    Display display = parent.getDisplay();
    shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.MIN | SWT.MAX | SWT.RESIZE);
    props.setLook(shell);
    setShellImage(shell, meta);
    shell.setMinimumSize(SHELL_MIN_WIDTH, SHELL_MIN_HEIGHT);
    changed = meta.hasChanged();
    FormLayout formLayout = new FormLayout();
    formLayout.marginWidth = 15;
    formLayout.marginHeight = 15;
    shell.setLayout(formLayout);
    shell.setText(BaseMessages.getString(PKG, "JmsProducerDialog.Shell.Title"));
    Label wicon = new Label(shell, SWT.RIGHT);
    wicon.setImage(getImage());
    FormData fdlicon = new FormData();
    fdlicon.top = new FormAttachment(0, 0);
    fdlicon.right = new FormAttachment(100, 0);
    wicon.setLayoutData(fdlicon);
    props.setLook(wicon);
    wlStepname = new Label(shell, SWT.RIGHT);
    wlStepname.setText(BaseMessages.getString(PKG, "JmsProducerDialog.Stepname.Label"));
    props.setLook(wlStepname);
    fdlStepname = new FormData();
    fdlStepname.left = new FormAttachment(0, 0);
    fdlStepname.top = new FormAttachment(0, 0);
    wlStepname.setLayoutData(fdlStepname);
    wStepname = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    wStepname.setText(stepname);
    props.setLook(wStepname);
    wStepname.addModifyListener(lsMod);
    fdStepname = new FormData();
    fdStepname.width = 250;
    fdStepname.left = new FormAttachment(0, 0);
    fdStepname.top = new FormAttachment(wlStepname, 5);
    wStepname.setLayoutData(fdStepname);
    Label spacer = new Label(shell, SWT.HORIZONTAL | SWT.SEPARATOR);
    props.setLook(spacer);
    FormData fdSpacer = new FormData();
    fdSpacer.height = 2;
    fdSpacer.left = new FormAttachment(0, 0);
    fdSpacer.top = new FormAttachment(wStepname, 15);
    fdSpacer.right = new FormAttachment(100, 0);
    fdSpacer.width = 497;
    spacer.setLayoutData(fdSpacer);
    // Start of tabbed display
    wTabFolder = new CTabFolder(shell, SWT.BORDER);
    props.setLook(wTabFolder, Props.WIDGET_STYLE_TAB);
    wTabFolder.setSimple(false);
    wTabFolder.setUnselectedCloseVisible(true);
    wCancel = new Button(shell, SWT.PUSH);
    wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
    FormData fdCancel = new FormData();
    fdCancel.right = new FormAttachment(100, 0);
    fdCancel.bottom = new FormAttachment(100, 0);
    wCancel.setLayoutData(fdCancel);
    wOK = new Button(shell, SWT.PUSH);
    wOK.setText(BaseMessages.getString(PKG, "System.Button.OK"));
    FormData fdOk = new FormData();
    fdOk.right = new FormAttachment(wCancel, -5);
    fdOk.bottom = new FormAttachment(100, 0);
    wOK.setLayoutData(fdOk);
    Label hSpacer = new Label(shell, SWT.HORIZONTAL | SWT.SEPARATOR);
    props.setLook(hSpacer);
    FormData fdhSpacer = new FormData();
    fdhSpacer.height = 2;
    fdhSpacer.left = new FormAttachment(0, 0);
    fdhSpacer.bottom = new FormAttachment(wCancel, -15);
    fdhSpacer.right = new FormAttachment(100, 0);
    hSpacer.setLayoutData(fdhSpacer);
    FormData fdTabFolder = new FormData();
    fdTabFolder.left = new FormAttachment(0, 0);
    fdTabFolder.top = new FormAttachment(spacer, 15);
    fdTabFolder.bottom = new FormAttachment(hSpacer, -15);
    fdTabFolder.right = new FormAttachment(100, 0);
    wTabFolder.setLayoutData(fdTabFolder);
    // Setup Tab
    CTabItem wSetupTab = new CTabItem(wTabFolder, SWT.NONE);
    wSetupTab.setText(BaseMessages.getString(PKG, "JmsProducerDialog.SetupTab"));
    Composite wSetupComp = new Composite(wTabFolder, SWT.NONE);
    props.setLook(wSetupComp);
    FormLayout setupLayout = new FormLayout();
    setupLayout.marginHeight = 15;
    setupLayout.marginWidth = 15;
    wSetupComp.setLayout(setupLayout);
    jmsDialogSecurityLayout = new JmsDialogSecurityLayout(props, wTabFolder, lsMod, transMeta, jmsDelegate.sslEnabled, jmsDelegate);
    jmsDialogSecurityLayout.buildSecurityTab();
    connectionForm = new ConnectionForm(wSetupComp, props, transMeta, lsMod, jmsDelegate, jmsDialogSecurityLayout);
    Group group = connectionForm.layoutForm();
    jmsDialogSecurityLayout.setConnectionForm(connectionForm);
    destinationForm = new DestinationForm(wSetupComp, group, props, transMeta, lsMod, jmsDelegate.destinationType, jmsDelegate.destinationName);
    Composite destinationFormComposite = destinationForm.layoutForm();
    Label lbMessageField = new Label(wSetupComp, SWT.LEFT);
    props.setLook(lbMessageField);
    lbMessageField.setText(getString(PKG, "JmsProducerDialog.MessageField"));
    FormData fdMessage = new FormData();
    fdMessage.left = new FormAttachment(0, 0);
    fdMessage.top = new FormAttachment(destinationFormComposite, 15);
    fdMessage.width = 250;
    lbMessageField.setLayoutData(fdMessage);
    wMessageField = new ComboVar(transMeta, wSetupComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wMessageField);
    wMessageField.addModifyListener(lsMod);
    FormData fdMessageField = new FormData();
    fdMessageField.left = new FormAttachment(0, 0);
    fdMessageField.top = new FormAttachment(lbMessageField, 5);
    fdMessageField.width = 250;
    wMessageField.setLayoutData(fdMessageField);
    Listener lsMessageFocus = e -> {
        String current = wMessageField.getText();
        wMessageField.getCComboWidget().removeAll();
        wMessageField.setText(current);
        try {
            RowMetaInterface rmi = transMeta.getPrevStepFields(meta.getParentStepMeta().getName());
            List ls = rmi.getValueMetaList();
            for (Object l : ls) {
                ValueMetaBase vmb = (ValueMetaBase) l;
                wMessageField.add(vmb.getName());
            }
        } catch (KettleStepException ex) {
        // do nothing
        }
    };
    wMessageField.getCComboWidget().addListener(SWT.FocusIn, lsMessageFocus);
    FormData fdSetupComp = new FormData();
    fdSetupComp.left = new FormAttachment(0, 0);
    fdSetupComp.top = new FormAttachment(0, 0);
    fdSetupComp.right = new FormAttachment(100, 0);
    fdSetupComp.bottom = new FormAttachment(100, 0);
    wSetupComp.setLayoutData(fdSetupComp);
    wSetupComp.layout();
    wSetupTab.setControl(wSetupComp);
    wTabFolder.setSelection(0);
    wOK.addListener(SWT.Selection, lsOK);
    wCancel.addListener(SWT.Selection, lsCancel);
    // get data for message field, other fields data is loaded by the forms
    wMessageField.setText(nullToEmpty(meta.getFieldToSend()));
    buildOptionsTab();
    buildProperiesTab();
    setSize();
    meta.setChanged(changed);
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    return stepname;
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) StringUtils(org.apache.commons.lang.StringUtils) Arrays(java.util.Arrays) StepPluginType(org.pentaho.di.core.plugins.StepPluginType) StepDialogInterface(org.pentaho.di.trans.step.StepDialogInterface) GUIResource(org.pentaho.di.ui.core.gui.GUIResource) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) TransMeta(org.pentaho.di.trans.TransMeta) Composite(org.eclipse.swt.widgets.Composite) Map(java.util.Map) ConstUI(org.pentaho.di.ui.core.ConstUI) TableView(org.pentaho.di.ui.core.widget.TableView) BaseStepDialog(org.pentaho.di.ui.trans.step.BaseStepDialog) ComboVar(org.pentaho.di.ui.core.widget.ComboVar) BaseMessages(org.pentaho.di.i18n.BaseMessages) StepOption(org.pentaho.di.trans.step.StepOption) Text(org.eclipse.swt.widgets.Text) Button(org.eclipse.swt.widgets.Button) JMS_TYPE(org.pentaho.di.trans.step.jms.JmsProducerMeta.JMS_TYPE) CTabFolder(org.eclipse.swt.custom.CTabFolder) DISABLE_MESSAGE_TIMESTAMP(org.pentaho.di.trans.step.jms.JmsProducerMeta.DISABLE_MESSAGE_TIMESTAMP) Display(org.eclipse.swt.widgets.Display) List(java.util.List) DELIVERY_MODE(org.pentaho.di.trans.step.jms.JmsProducerMeta.DELIVERY_MODE) SWT(org.eclipse.swt.SWT) JMS_CORRELATION_ID(org.pentaho.di.trans.step.jms.JmsProducerMeta.JMS_CORRELATION_ID) KettleStepException(org.pentaho.di.core.exception.KettleStepException) BaseStepMeta(org.pentaho.di.trans.step.BaseStepMeta) PKG(org.pentaho.di.trans.step.jms.JmsConstants.PKG) Label(org.eclipse.swt.widgets.Label) ColumnInfo(org.pentaho.di.ui.core.widget.ColumnInfo) Arrays.stream(java.util.Arrays.stream) JmsDelegate(org.pentaho.di.trans.step.jms.JmsDelegate) IntStream(java.util.stream.IntStream) ValueMetaBase(org.pentaho.di.core.row.value.ValueMetaBase) Strings.nullToEmpty(com.google.common.base.Strings.nullToEmpty) TIME_TO_LIVE(org.pentaho.di.trans.step.jms.JmsProducerMeta.TIME_TO_LIVE) Image(org.eclipse.swt.graphics.Image) Table(org.eclipse.swt.widgets.Table) BaseMessages.getString(org.pentaho.di.i18n.BaseMessages.getString) PluginInterface(org.pentaho.di.core.plugins.PluginInterface) LinkedHashMap(java.util.LinkedHashMap) Listener(org.eclipse.swt.widgets.Listener) PluginRegistry(org.pentaho.di.core.plugins.PluginRegistry) JmsProducerMeta(org.pentaho.di.trans.step.jms.JmsProducerMeta) TableItem(org.eclipse.swt.widgets.TableItem) Props(org.pentaho.di.core.Props) Shell(org.eclipse.swt.widgets.Shell) FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) DISABLE_MESSAGE_ID(org.pentaho.di.trans.step.jms.JmsProducerMeta.DISABLE_MESSAGE_ID) FormAttachment(org.eclipse.swt.layout.FormAttachment) Group(org.eclipse.swt.widgets.Group) CTabItem(org.eclipse.swt.custom.CTabItem) DELIVERY_DELAY(org.pentaho.di.trans.step.jms.JmsProducerMeta.DELIVERY_DELAY) ModifyListener(org.eclipse.swt.events.ModifyListener) PRIORITY(org.pentaho.di.trans.step.jms.JmsProducerMeta.PRIORITY) INPUT_WIDTH(org.pentaho.di.ui.trans.step.BaseStreamingDialog.INPUT_WIDTH) Group(org.eclipse.swt.widgets.Group) ComboVar(org.pentaho.di.ui.core.widget.ComboVar) CTabFolder(org.eclipse.swt.custom.CTabFolder) Listener(org.eclipse.swt.widgets.Listener) ModifyListener(org.eclipse.swt.events.ModifyListener) KettleStepException(org.pentaho.di.core.exception.KettleStepException) Composite(org.eclipse.swt.widgets.Composite) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) BaseMessages.getString(org.pentaho.di.i18n.BaseMessages.getString) CTabItem(org.eclipse.swt.custom.CTabItem) Shell(org.eclipse.swt.widgets.Shell) Button(org.eclipse.swt.widgets.Button) List(java.util.List) FormAttachment(org.eclipse.swt.layout.FormAttachment) Display(org.eclipse.swt.widgets.Display) ValueMetaBase(org.pentaho.di.core.row.value.ValueMetaBase)

Aggregations

ValueMetaBase (org.pentaho.di.core.row.value.ValueMetaBase)34 RowMeta (org.pentaho.di.core.row.RowMeta)27 Test (org.junit.Test)25 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)17 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)13 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)9 ArrayList (java.util.ArrayList)7 Matchers.anyString (org.mockito.Matchers.anyString)4 ValueMetaInteger (org.pentaho.di.core.row.value.ValueMetaInteger)3 XmlObject (com.sforce.ws.bind.XmlObject)2 List (java.util.List)2 StringUtils (org.apache.commons.lang.StringUtils)2 SWT (org.eclipse.swt.SWT)2 CTabFolder (org.eclipse.swt.custom.CTabFolder)2 CTabItem (org.eclipse.swt.custom.CTabItem)2 FormAttachment (org.eclipse.swt.layout.FormAttachment)2 FormData (org.eclipse.swt.layout.FormData)2 FormLayout (org.eclipse.swt.layout.FormLayout)2 Composite (org.eclipse.swt.widgets.Composite)2 Listener (org.eclipse.swt.widgets.Listener)2