use of org.pentaho.di.core.row.value.ValueMetaBase in project pentaho-kettle by pentaho.
the class MQTTProducerDialog method buildSetupTab.
private void buildSetupTab() {
CTabItem wSetupTab = new CTabItem(wTabFolder, SWT.NONE);
wSetupTab.setText(BaseMessages.getString(PKG, "MQTTProducerDialog.SetupTab"));
Composite wSetupComp = new Composite(wTabFolder, SWT.NONE);
props.setLook(wSetupComp);
FormLayout setupLayout = new FormLayout();
setupLayout.marginHeight = 15;
setupLayout.marginWidth = 15;
wSetupComp.setLayout(setupLayout);
Label wlMqttServer = new Label(wSetupComp, SWT.LEFT);
props.setLook(wlMqttServer);
wlMqttServer.setText(BaseMessages.getString(PKG, "MQTTProducerDialog.Connection"));
FormData fdlBootstrapServers = new FormData();
fdlBootstrapServers.left = new FormAttachment(0, 0);
fdlBootstrapServers.top = new FormAttachment(0, 0);
fdlBootstrapServers.right = new FormAttachment(0, INPUT_WIDTH);
wlMqttServer.setLayoutData(fdlBootstrapServers);
wMqttServer = new TextVar(transMeta, wSetupComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wMqttServer);
wMqttServer.addModifyListener(lsMod);
FormData fdBootstrapServers = new FormData();
fdBootstrapServers.left = new FormAttachment(0, 0);
fdBootstrapServers.top = new FormAttachment(wlMqttServer, 5);
fdBootstrapServers.right = new FormAttachment(0, INPUT_WIDTH);
wMqttServer.setLayoutData(fdBootstrapServers);
Label wlClientId = new Label(wSetupComp, SWT.LEFT);
props.setLook(wlClientId);
wlClientId.setText(BaseMessages.getString(PKG, "MQTTProducerDialog.ClientId"));
FormData fdlClientId = new FormData();
fdlClientId.left = new FormAttachment(0, 0);
fdlClientId.top = new FormAttachment(wMqttServer, 10);
fdlClientId.right = new FormAttachment(50, 0);
wlClientId.setLayoutData(fdlClientId);
wClientId = new TextVar(transMeta, wSetupComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wClientId);
wClientId.addModifyListener(lsMod);
FormData fdClientId = new FormData();
fdClientId.left = new FormAttachment(0, 0);
fdClientId.top = new FormAttachment(wlClientId, 5);
fdClientId.right = new FormAttachment(0, INPUT_WIDTH);
wClientId.setLayoutData(fdClientId);
Label wlTopic = new Label(wSetupComp, SWT.LEFT);
props.setLook(wlTopic);
wlTopic.setText(BaseMessages.getString(PKG, "MQTTProducerDialog.Topic"));
FormData fdlTopic = new FormData();
fdlTopic.left = new FormAttachment(0, 0);
fdlTopic.top = new FormAttachment(wClientId, 10);
fdlTopic.width = 200;
wlTopic.setLayoutData(fdlTopic);
wTopic = new TextVar(transMeta, wSetupComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wTopic);
wTopic.addModifyListener(lsMod);
FormData fdTopic = new FormData();
fdTopic.left = new FormAttachment(0, 0);
fdTopic.top = new FormAttachment(wlTopic, 5);
fdTopic.width = 200;
wTopic.setLayoutData(fdTopic);
Label wlQOS = new Label(wSetupComp, SWT.LEFT);
props.setLook(wlQOS);
wlQOS.setText(BaseMessages.getString(PKG, "MQTTProducerDialog.QOS"));
FormData fdlQOS = new FormData();
fdlQOS.left = new FormAttachment(wlTopic, 15);
fdlQOS.top = new FormAttachment(wClientId, 10);
fdlQOS.width = 120;
wlQOS.setLayoutData(fdlQOS);
wQOS = new ComboVar(transMeta, wSetupComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wQOS);
wQOS.addModifyListener(lsMod);
FormData fdQOS = new FormData();
fdQOS.left = new FormAttachment(wTopic, 15);
fdQOS.top = new FormAttachment(wlQOS, 5);
fdQOS.width = 135;
wQOS.setLayoutData(fdQOS);
wQOS.add("0");
wQOS.add("1");
wQOS.add("2");
Label wlMessageField = new Label(wSetupComp, SWT.LEFT);
props.setLook(wlMessageField);
wlMessageField.setText(BaseMessages.getString(PKG, "MQTTProducerDialog.MessageField"));
FormData fdlMessageField = new FormData();
fdlMessageField.left = new FormAttachment(0, 0);
fdlMessageField.top = new FormAttachment(wTopic, 10);
fdlMessageField.right = new FormAttachment(50, 0);
wlMessageField.setLayoutData(fdlMessageField);
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(wlMessageField, 5);
fdMessageField.right = new FormAttachment(0, INPUT_WIDTH);
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);
}
use of org.pentaho.di.core.row.value.ValueMetaBase in project pentaho-kettle by pentaho.
the class SalesforceUpdateTest method testWriteToSalesForceForNullExtIdField_WithExtIdYES.
@Test
public void testWriteToSalesForceForNullExtIdField_WithExtIdYES() throws Exception {
SalesforceUpdate sfInputStep = new SalesforceUpdate(smh.stepMeta, smh.stepDataInterface, 0, smh.transMeta, smh.trans);
SalesforceUpdateMeta meta = generateSalesforceUpdateMeta(new String[] { ACCOUNT_EXT_ID_ACCOUNT_ID_C_ACCOUNT }, new Boolean[] { true });
SalesforceUpdateData data = generateSalesforceUpdateData();
sfInputStep.init(meta, data);
RowMeta rowMeta = new RowMeta();
ValueMetaBase valueMeta = new ValueMetaString("AccExtId");
rowMeta.addValueMeta(valueMeta);
smh.initStepDataInterface.inputRowMeta = rowMeta;
sfInputStep.writeToSalesForce(new Object[] { null });
assertEquals(1, data.sfBuffer[0].getFieldsToNull().length);
assertEquals(ACCOUNT_ID, data.sfBuffer[0].getFieldsToNull()[0]);
assertNull(SalesforceConnection.getChildren(data.sfBuffer[0]));
}
use of org.pentaho.di.core.row.value.ValueMetaBase in project pentaho-kettle by pentaho.
the class SalesforceUpdateTest method testWriteToSalesForceForNotNullExtIdField_WithExtIdYES.
@Test
public void testWriteToSalesForceForNotNullExtIdField_WithExtIdYES() throws Exception {
SalesforceUpdate sfInputStep = new SalesforceUpdate(smh.stepMeta, smh.stepDataInterface, 0, smh.transMeta, smh.trans);
SalesforceUpdateMeta meta = generateSalesforceUpdateMeta(new String[] { ACCOUNT_EXT_ID_ACCOUNT_ID_C_ACCOUNT }, new Boolean[] { true });
SalesforceUpdateData data = generateSalesforceUpdateData();
sfInputStep.init(meta, data);
RowMeta rowMeta = new RowMeta();
ValueMetaBase valueMeta = new ValueMetaString("AccExtId");
rowMeta.addValueMeta(valueMeta);
smh.initStepDataInterface.inputRowMeta = rowMeta;
sfInputStep.writeToSalesForce(new Object[] { "tkas88" });
assertEquals(0, data.sfBuffer[0].getFieldsToNull().length);
assertEquals(1, SalesforceConnection.getChildren(data.sfBuffer[0]).length);
assertEquals(Constants.PARTNER_SOBJECT_NS, SalesforceConnection.getChildren(data.sfBuffer[0])[0].getName().getNamespaceURI());
assertEquals("Account", SalesforceConnection.getChildren(data.sfBuffer[0])[0].getName().getLocalPart());
assertNull(SalesforceConnection.getChildren(data.sfBuffer[0])[0].getValue());
assertFalse(SalesforceConnection.getChildren(data.sfBuffer[0])[0].hasChildren());
}
use of org.pentaho.di.core.row.value.ValueMetaBase in project pentaho-kettle by pentaho.
the class SalesforceUpsertTest method testWriteToSalesForceForNotNullExtIdField_WithExtIdNO.
@Test
public void testWriteToSalesForceForNotNullExtIdField_WithExtIdNO() throws Exception {
SalesforceUpsert sfInputStep = new SalesforceUpsert(smh.stepMeta, smh.stepDataInterface, 0, smh.transMeta, smh.trans);
SalesforceUpsertMeta meta = generateSalesforceUpsertMeta(new String[] { ACCOUNT_ID }, new Boolean[] { false });
SalesforceUpsertData data = generateSalesforceUpsertData();
sfInputStep.init(meta, data);
RowMeta rowMeta = new RowMeta();
ValueMetaBase valueMeta = new ValueMetaString("AccNoExtId");
rowMeta.addValueMeta(valueMeta);
smh.initStepDataInterface.inputRowMeta = rowMeta;
sfInputStep.writeToSalesForce(new Object[] { "001i000001c5Nv9AAE" });
assertEquals(0, data.sfBuffer[0].getFieldsToNull().length);
assertEquals(1, SalesforceConnection.getChildren(data.sfBuffer[0]).length);
assertEquals(Constants.PARTNER_SOBJECT_NS, SalesforceConnection.getChildren(data.sfBuffer[0])[0].getName().getNamespaceURI());
assertEquals(ACCOUNT_ID, SalesforceConnection.getChildren(data.sfBuffer[0])[0].getName().getLocalPart());
assertEquals("001i000001c5Nv9AAE", SalesforceConnection.getChildren(data.sfBuffer[0])[0].getValue());
assertFalse(SalesforceConnection.getChildren(data.sfBuffer[0])[0].hasChildren());
}
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()));
}
Aggregations