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