Search in sources :

Example 6 with ValueMetaBase

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);
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) ValueMetaBase(org.pentaho.di.core.row.value.ValueMetaBase) StepPluginType(org.pentaho.di.core.plugins.StepPluginType) Strings.nullToEmpty(com.google.common.base.Strings.nullToEmpty) MQTT_VERSION(org.pentaho.di.trans.step.mqtt.MQTTConstants.MQTT_VERSION) Image(org.eclipse.swt.graphics.Image) StepDialogInterface(org.pentaho.di.trans.step.StepDialogInterface) GUIResource(org.pentaho.di.ui.core.gui.GUIResource) TextVar(org.pentaho.di.ui.core.widget.TextVar) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) PluginInterface(org.pentaho.di.core.plugins.PluginInterface) KEEP_ALIVE_INTERVAL(org.pentaho.di.trans.step.mqtt.MQTTConstants.KEEP_ALIVE_INTERVAL) TransMeta(org.pentaho.di.trans.TransMeta) SERVER_URIS(org.pentaho.di.trans.step.mqtt.MQTTConstants.SERVER_URIS) Composite(org.eclipse.swt.widgets.Composite) Listener(org.eclipse.swt.widgets.Listener) CONNECTION_TIMEOUT(org.pentaho.di.trans.step.mqtt.MQTTConstants.CONNECTION_TIMEOUT) PluginRegistry(org.pentaho.di.core.plugins.PluginRegistry) AUTOMATIC_RECONNECT(org.pentaho.di.trans.step.mqtt.MQTTConstants.AUTOMATIC_RECONNECT) ConstUI(org.pentaho.di.ui.core.ConstUI) BaseStepDialog(org.pentaho.di.ui.trans.step.BaseStepDialog) ComboVar(org.pentaho.di.ui.core.widget.ComboVar) CLEAN_SESSION(org.pentaho.di.trans.step.mqtt.MQTTConstants.CLEAN_SESSION) PluginDialog(org.pentaho.di.core.annotations.PluginDialog) BaseMessages(org.pentaho.di.i18n.BaseMessages) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Props(org.pentaho.di.core.Props) Text(org.eclipse.swt.widgets.Text) Shell(org.eclipse.swt.widgets.Shell) Button(org.eclipse.swt.widgets.Button) CTabFolder(org.eclipse.swt.custom.CTabFolder) FormLayout(org.eclipse.swt.layout.FormLayout) ShellEvent(org.eclipse.swt.events.ShellEvent) FormData(org.eclipse.swt.layout.FormData) FormAttachment(org.eclipse.swt.layout.FormAttachment) Display(org.eclipse.swt.widgets.Display) ShellAdapter(org.eclipse.swt.events.ShellAdapter) STORAGE_LEVEL(org.pentaho.di.trans.step.mqtt.MQTTConstants.STORAGE_LEVEL) CTabItem(org.eclipse.swt.custom.CTabItem) List(java.util.List) ModifyListener(org.eclipse.swt.events.ModifyListener) SWT(org.eclipse.swt.SWT) KettleStepException(org.pentaho.di.core.exception.KettleStepException) MAX_INFLIGHT(org.pentaho.di.trans.step.mqtt.MQTTConstants.MAX_INFLIGHT) BaseStepMeta(org.pentaho.di.trans.step.BaseStepMeta) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Label(org.eclipse.swt.widgets.Label) ComboVar(org.pentaho.di.ui.core.widget.ComboVar) 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) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) CTabItem(org.eclipse.swt.custom.CTabItem) TextVar(org.pentaho.di.ui.core.widget.TextVar) List(java.util.List) FormAttachment(org.eclipse.swt.layout.FormAttachment) ValueMetaBase(org.pentaho.di.core.row.value.ValueMetaBase)

Example 7 with ValueMetaBase

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]));
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) RowMeta(org.pentaho.di.core.row.RowMeta) ValueMetaBase(org.pentaho.di.core.row.value.ValueMetaBase) Test(org.junit.Test)

Example 8 with ValueMetaBase

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());
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) RowMeta(org.pentaho.di.core.row.RowMeta) ValueMetaBase(org.pentaho.di.core.row.value.ValueMetaBase) Test(org.junit.Test)

Example 9 with ValueMetaBase

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());
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) RowMeta(org.pentaho.di.core.row.RowMeta) ValueMetaBase(org.pentaho.di.core.row.value.ValueMetaBase) Test(org.junit.Test)

Example 10 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)

Aggregations

ValueMetaBase (org.pentaho.di.core.row.value.ValueMetaBase)31 RowMeta (org.pentaho.di.core.row.RowMeta)26 Test (org.junit.Test)25 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)16 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)13 ArrayList (java.util.ArrayList)7 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)7 Matchers.anyString (org.mockito.Matchers.anyString)3 Strings.nullToEmpty (com.google.common.base.Strings.nullToEmpty)2 XmlObject (com.sforce.ws.bind.XmlObject)2 List (java.util.List)2 SWT (org.eclipse.swt.SWT)2 CTabFolder (org.eclipse.swt.custom.CTabFolder)2 CTabItem (org.eclipse.swt.custom.CTabItem)2 ModifyListener (org.eclipse.swt.events.ModifyListener)2 Image (org.eclipse.swt.graphics.Image)2 FormAttachment (org.eclipse.swt.layout.FormAttachment)2 FormData (org.eclipse.swt.layout.FormData)2 FormLayout (org.eclipse.swt.layout.FormLayout)2 Button (org.eclipse.swt.widgets.Button)2