use of org.pentaho.di.trans.TransMeta in project pentaho-kettle by pentaho.
the class JobGeneratorTest method testGenerateDimensionTransformations.
@Test
public void testGenerateDimensionTransformations() throws Exception {
final LogicalModel logicalModel = mock(LogicalModel.class);
when(jobGenerator.domain.getLogicalModels()).thenReturn(new LinkedList<LogicalModel>() {
{
add(logicalModel);
}
});
final LogicalTable logicalTable = mock(LogicalTable.class);
when(logicalTable.getProperty(eq(DefaultIDs.LOGICAL_TABLE_PHYSICAL_TABLE_NAME))).thenReturn("test_table_name");
when(logicalModel.getLogicalTables()).thenReturn(new LinkedList<LogicalTable>() {
{
add(logicalTable);
}
});
when(logicalTable.getProperty(eq(DefaultPropertyID.TABLE_TYPE.getId()))).thenReturn(TableType.DIMENSION);
when(logicalTable.getProperty(eq(DefaultIDs.LOGICAL_TABLE_DIMENSION_TYPE))).thenReturn(DimensionType.JUNK_DIMENSION.name());
final List<TransMeta> transMetas = jobGenerator.generateDimensionTransformations();
assertNotNull(transMetas);
assertEquals(1, transMetas.size());
}
use of org.pentaho.di.trans.TransMeta 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
wSetupTab = new CTabItem(wTabFolder, SWT.NONE);
wSetupTab.setText(BaseMessages.getString(PKG, "JmsProducerDialog.SetupTab"));
wSetupComp = new Composite(wTabFolder, SWT.NONE);
props.setLook(wSetupComp);
FormLayout setupLayout = new FormLayout();
setupLayout.marginHeight = 15;
setupLayout.marginWidth = 15;
wSetupComp.setLayout(setupLayout);
connectionForm = new ConnectionForm(wSetupComp, props, transMeta, lsMod, jmsDelegate);
Group group = connectionForm.layoutForm();
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()));
setSize();
meta.setChanged(changed);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
return stepname;
}
use of org.pentaho.di.trans.TransMeta 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.trans.TransMeta in project pentaho-kettle by pentaho.
the class MQTTConsumerMetaTest method testXmlHasAllFields.
@Test
public void testXmlHasAllFields() {
String serverName = "some_cluster";
meta.setDefault();
meta.setMqttServer(serverName);
ArrayList<String> topicList = new ArrayList<>();
topicList.add("temperature");
meta.setTopics(topicList);
meta.setQos("1");
meta.setUsername("testuser");
meta.setPassword("test");
meta.setUseSsl(true);
meta.setTransformationPath("/home/pentaho/myKafkaTransformation.ktr");
meta.setBatchSize("54321");
meta.setBatchDuration("987");
StepMeta stepMeta = new StepMeta();
TransMeta transMeta = mock(TransMeta.class);
stepMeta.setParentTransMeta(transMeta);
meta.setParentStepMeta(stepMeta);
// tests serialization/deserialization round trip
assertTrue(meta.equals(fromXml(meta.getXML())));
}
use of org.pentaho.di.trans.TransMeta in project pentaho-kettle by pentaho.
the class MQTTProducerTest method setup.
@Before
public void setup() throws Exception {
KettleLogStore.setLogChannelInterfaceFactory(logChannelFactory);
when(logChannelFactory.create(any(), any())).thenReturn(logChannel);
when(logChannelFactory.create(any())).thenReturn(logChannel);
TransMeta transMeta = new TransMeta(getClass().getResource("/ProduceFourRows.ktr").getPath());
trans = new Trans(transMeta);
trans.setVariable("mqttServer", "127.0.0.1:1883");
trans.setVariable("clientId", "client1");
trans.setVariable("topic", "TestWinning");
trans.setVariable("messageField", "message");
trans.setVariable("qos", "0");
trans.prepareExecution(new String[] {});
StepMetaDataCombi combi = trans.getSteps().get(1);
MQTTProducer step = (MQTTProducer) combi.step;
MQTTProducerData data = (MQTTProducerData) combi.data;
data.mqttClient = mqttClient;
step.first = false;
}
Aggregations