use of org.pentaho.di.base.AbstractMeta in project pentaho-metaverse by pentaho.
the class KettleAnalyzerUtilTest method tesBuildDocument.
@Test
public void tesBuildDocument() throws MetaverseException {
final IMetaverseBuilder builder = new BaseMetaverseBuilder(null);
final AbstractMeta transMeta = Mockito.mock(TransMeta.class);
final String transName = "MyTransMeta";
Mockito.doReturn(transName).when(transMeta).getName();
Mockito.doReturn("ktr").when(transMeta).getDefaultExtension();
final String id = "path.ktr";
final String namespaceId = "MyNamespace";
final INamespace namespace = new Namespace(namespaceId);
assertNull(KettleAnalyzerUtil.buildDocument(null, transMeta, id, namespace));
IDocument document = KettleAnalyzerUtil.buildDocument(builder, transMeta, id, namespace);
assertNotNull(document);
assertEquals(namespace, document.getNamespace());
assertEquals(transMeta, document.getContent());
assertEquals(id, document.getStringID());
assertEquals(transName, document.getName());
assertEquals("ktr", document.getExtension());
assertEquals(DictionaryConst.CONTEXT_RUNTIME, document.getContext().getContextName());
assertEquals(document.getName(), document.getProperty(DictionaryConst.PROPERTY_NAME));
assertEquals(KettleAnalyzerUtil.normalizeFilePath("path.ktr"), document.getProperty(DictionaryConst.PROPERTY_PATH));
assertEquals(namespaceId, document.getProperty(DictionaryConst.PROPERTY_NAMESPACE));
}
use of org.pentaho.di.base.AbstractMeta in project pentaho-kettle by pentaho.
the class DefaultRunConfigurationUI method attach.
@Override
public void attach(RunConfigurationDialog runConfigurationDialog) {
this.runConfigurationDialog = runConfigurationDialog;
FormLayout gformLayout = new FormLayout();
gformLayout.marginWidth = 10;
gformLayout.marginHeight = 10;
runConfigurationDialog.getGroup().setLayout(gformLayout);
Composite wTarget = new Composite(runConfigurationDialog.getGroup(), SWT.NONE);
wTarget.setLayout(new FormLayout());
props.setLook(wTarget);
Button wbLocal = new Button(wTarget, SWT.RADIO);
props.setLook(wbLocal);
wbLocal.setText(BaseMessages.getString(PKG, "DefaultRunConfigurationDialog.Label.Local"));
wbLocal.setSelection(defaultRunConfiguration.isLocal());
FormData fdbLocal = new FormData();
fdbLocal.top = new FormAttachment(0);
fdbLocal.left = new FormAttachment(0);
wbLocal.setLayoutData(fdbLocal);
Button wbPentaho = new Button(wTarget, SWT.RADIO);
props.setLook(wbPentaho);
boolean connectedToPentahoServer = spoonSupplier.get().getRepository() != null && spoonSupplier.get().getRepository().getRepositoryMeta().getId().equals("PentahoEnterpriseRepository");
wbPentaho.setVisible(connectedToPentahoServer);
if (connectedToPentahoServer) {
wbPentaho.setText(BaseMessages.getString(PKG, "DefaultRunConfigurationDialog.Label.Pentaho"));
wbPentaho.setSelection(defaultRunConfiguration.isPentaho());
FormData fdbPentaho = new FormData();
fdbPentaho.top = new FormAttachment(wbLocal, 10);
fdbPentaho.left = new FormAttachment(0);
wbPentaho.setLayoutData(fdbPentaho);
}
Button wbRemote = new Button(wTarget, SWT.RADIO);
props.setLook(wbRemote);
wbRemote.setText(BaseMessages.getString(PKG, "DefaultRunConfigurationDialog.Label.Remote"));
wbRemote.setSelection(defaultRunConfiguration.isRemote() || defaultRunConfiguration.isClustered());
FormData fdbRemote = new FormData();
fdbRemote.top = new FormAttachment(wbPentaho, 10);
fdbRemote.left = new FormAttachment(0);
wbRemote.setLayoutData(fdbRemote);
FormData fdTarget = new FormData();
fdTarget.left = new FormAttachment(0);
fdTarget.top = new FormAttachment(0);
wTarget.setLayoutData(fdTarget);
Label vSpacer = new Label(runConfigurationDialog.getGroup(), SWT.VERTICAL | SWT.SEPARATOR);
FormData fdvSpacer = new FormData();
fdvSpacer.width = 1;
fdvSpacer.left = new FormAttachment(wTarget, 30);
fdvSpacer.top = new FormAttachment(0, 0);
fdvSpacer.bottom = new FormAttachment(100, 0);
vSpacer.setLayoutData(fdvSpacer);
Composite wcLocal = new Composite(runConfigurationDialog.getGroup(), SWT.NONE);
props.setLook(wcLocal);
wcLocal.setLayout(new GridLayout());
Text wlLocal = new Text(wcLocal, SWT.MULTI | SWT.WRAP);
wlLocal.setEditable(false);
props.setLook(wlLocal);
wlLocal.setText(BaseMessages.getString(PKG, "DefaultRunConfigurationDialog.Text.Local"));
GridData gdlLocal = new GridData(GridData.FILL_HORIZONTAL);
gdlLocal.widthHint = 200;
wlLocal.setLayoutData(gdlLocal);
FormData fdcLocal = new FormData();
fdcLocal.left = new FormAttachment(vSpacer, 10);
fdcLocal.top = new FormAttachment(0);
fdcLocal.right = new FormAttachment(100);
fdcLocal.bottom = new FormAttachment(100);
wcLocal.setLayoutData(fdcLocal);
Composite wcPentaho = new Composite(runConfigurationDialog.getGroup(), SWT.NONE);
props.setLook(wcPentaho);
wcPentaho.setLayout(new GridLayout());
Text wlPentaho = new Text(wcPentaho, SWT.MULTI | SWT.WRAP | SWT.LEFT);
wlPentaho.setEditable(false);
props.setLook(wlPentaho);
wlPentaho.setText(BaseMessages.getString(PKG, "DefaultRunConfigurationDialog.Text.Pentaho"));
GridData gdlPentaho = new GridData(GridData.FILL_HORIZONTAL);
gdlPentaho.widthHint = 200;
wlPentaho.setLayoutData(gdlPentaho);
FormData fdcPentaho = new FormData();
fdcPentaho.left = new FormAttachment(vSpacer, 10);
fdcPentaho.top = new FormAttachment(0);
fdcPentaho.right = new FormAttachment(100);
fdcPentaho.bottom = new FormAttachment(100);
wcPentaho.setLayoutData(fdcPentaho);
Composite wcRemote = new Composite(runConfigurationDialog.getGroup(), SWT.NONE);
props.setLook(wcRemote);
wcRemote.setLayout(new FormLayout());
Label wlRemote = new Label(wcRemote, SWT.LEFT);
props.setLook(wlRemote);
wlRemote.setText(BaseMessages.getString(PKG, "DefaultRunConfigurationDialog.Label.Location"));
FormData fdlRemote = new FormData();
fdlRemote.left = new FormAttachment(0);
fdlRemote.top = new FormAttachment(0);
wlRemote.setLayoutData(fdlRemote);
wcSlaveServer = new CCombo(wcRemote, SWT.SINGLE | SWT.READ_ONLY | SWT.BORDER);
props.setLook(wcSlaveServer);
FormData fdSlaveServer = new FormData();
fdSlaveServer.width = 150;
fdSlaveServer.top = new FormAttachment(wlRemote, 5);
fdSlaveServer.left = new FormAttachment(0);
wcSlaveServer.setLayoutData(fdSlaveServer);
Button wbSendResources = new Button(wcRemote, SWT.CHECK);
wbSendResources.setSelection(defaultRunConfiguration.isSendResources());
wbSendResources.setVisible(!Utils.isEmpty(defaultRunConfiguration.getServer()) && !defaultRunConfiguration.isClustered());
props.setLook(wbSendResources);
wbSendResources.setText(BaseMessages.getString(PKG, "DefaultRunConfigurationDialog.Button.SendResources"));
FormData fdbSendResources = new FormData();
fdbSendResources.top = new FormAttachment(wcSlaveServer, 10);
fdbSendResources.left = new FormAttachment(0);
wbSendResources.setLayoutData(fdbSendResources);
wbSendResources.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent selectionEvent) {
defaultRunConfiguration.setSendResources(wbSendResources.getSelection());
}
});
Button wbLogRemoteExecutionLocally = new Button(wcRemote, SWT.CHECK);
wbLogRemoteExecutionLocally.setSelection(defaultRunConfiguration.isLogRemoteExecutionLocally());
wbLogRemoteExecutionLocally.setVisible(defaultRunConfiguration.isClustered());
props.setLook(wbLogRemoteExecutionLocally);
wbLogRemoteExecutionLocally.setText(BaseMessages.getString(PKG, "DefaultRunConfigurationDialog.Checkbox.LogRemoteExecutionLocally"));
FormData fdbLogRemoteExecutionLocally = new FormData();
fdbLogRemoteExecutionLocally.top = new FormAttachment(wcSlaveServer, 10);
fdbLogRemoteExecutionLocally.left = new FormAttachment(0);
wbLogRemoteExecutionLocally.setLayoutData(fdbLogRemoteExecutionLocally);
wbLogRemoteExecutionLocally.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent selectionEvent) {
defaultRunConfiguration.setLogRemoteExecutionLocally(wbLogRemoteExecutionLocally.getSelection());
}
});
Button wbShowTransformations = new Button(wcRemote, SWT.CHECK);
wbShowTransformations.setSelection(defaultRunConfiguration.isShowTransformations());
wbShowTransformations.setVisible(defaultRunConfiguration.isClustered());
props.setLook(wbShowTransformations);
wbShowTransformations.setText(BaseMessages.getString(PKG, "DefaultRunConfigurationDialog.Checkbox.ShowTransformation"));
FormData fdbShowTransformations = new FormData();
fdbShowTransformations.top = new FormAttachment(wbLogRemoteExecutionLocally, 10);
fdbShowTransformations.left = new FormAttachment(0);
wbShowTransformations.setLayoutData(fdbShowTransformations);
wbShowTransformations.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent selectionEvent) {
defaultRunConfiguration.setShowTransformations(wbShowTransformations.getSelection());
}
});
FormData fdcRemote = new FormData();
fdcRemote.left = new FormAttachment(vSpacer, 20);
fdcRemote.top = new FormAttachment(0);
fdcRemote.right = new FormAttachment(100);
fdcRemote.bottom = new FormAttachment(100);
wcRemote.setLayoutData(fdcRemote);
AbstractMeta meta = (AbstractMeta) spoonSupplier.get().getActiveMeta();
if (meta instanceof TransMeta && !Utils.isEmpty(((TransMeta) meta).getClusterSchemas())) {
wcSlaveServer.add(CLUSTERED);
}
for (int i = 0; i < meta.getSlaveServers().size(); i++) {
SlaveServer slaveServer = meta.getSlaveServers().get(i);
wcSlaveServer.add(slaveServer.toString());
}
if (!Utils.isEmpty(defaultRunConfiguration.getServer())) {
wcSlaveServer.setText(defaultRunConfiguration.getServer());
}
wcLocal.setVisible(defaultRunConfiguration.isLocal());
wcPentaho.setVisible(defaultRunConfiguration.isPentaho());
wcRemote.setVisible(defaultRunConfiguration.isRemote() || defaultRunConfiguration.isClustered());
wcSlaveServer.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent selectionEvent) {
if (wcSlaveServer.getText().equals(CLUSTERED)) {
defaultRunConfiguration.setClustered(true);
defaultRunConfiguration.setLocal(false);
defaultRunConfiguration.setRemote(false);
wbLogRemoteExecutionLocally.setVisible(true);
wbShowTransformations.setVisible(true);
wbSendResources.setVisible(false);
} else {
defaultRunConfiguration.setRemote(true);
defaultRunConfiguration.setLocal(false);
defaultRunConfiguration.setClustered(false);
defaultRunConfiguration.setServer(wcSlaveServer.getText());
wbLogRemoteExecutionLocally.setVisible(false);
wbShowTransformations.setVisible(false);
wbSendResources.setVisible(true);
}
checkOKEnabled();
}
});
wbLocal.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent selectionEvent) {
wcLocal.setVisible(wbLocal.getSelection());
wcPentaho.setVisible(wbPentaho.getSelection());
wcRemote.setVisible(wbRemote.getSelection());
defaultRunConfiguration.setLocal(true);
defaultRunConfiguration.setPentaho(false);
defaultRunConfiguration.setRemote(false);
defaultRunConfiguration.setClustered(false);
checkOKEnabled();
}
});
wbPentaho.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent selectionEvent) {
wcLocal.setVisible(wbLocal.getSelection());
wcPentaho.setVisible(wbPentaho.getSelection());
wcRemote.setVisible(wbRemote.getSelection());
defaultRunConfiguration.setLocal(false);
defaultRunConfiguration.setPentaho(true);
defaultRunConfiguration.setRemote(false);
defaultRunConfiguration.setClustered(false);
checkOKEnabled();
}
});
wbRemote.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent selectionEvent) {
wcLocal.setVisible(wbLocal.getSelection());
wcPentaho.setVisible(wbPentaho.getSelection());
wcRemote.setVisible(wbRemote.getSelection());
defaultRunConfiguration.setLocal(false);
defaultRunConfiguration.setPentaho(false);
if (Utils.isEmpty(wcSlaveServer.getText())) {
if (meta instanceof TransMeta && !Utils.isEmpty(((TransMeta) meta).getClusterSchemas())) {
wcSlaveServer.setText(CLUSTERED);
} else if (meta.getSlaveServers().size() > 0) {
wcSlaveServer.setText(meta.getSlaveServers().get(0).getName());
}
}
if (!wcSlaveServer.getText().equals(CLUSTERED)) {
defaultRunConfiguration.setRemote(true);
defaultRunConfiguration.setClustered(false);
wbSendResources.setVisible(true);
wbShowTransformations.setVisible(false);
wbLogRemoteExecutionLocally.setVisible(false);
} else {
defaultRunConfiguration.setClustered(true);
defaultRunConfiguration.setRemote(false);
wbSendResources.setVisible(false);
wbShowTransformations.setVisible(true);
wbLogRemoteExecutionLocally.setVisible(true);
}
checkOKEnabled();
if (!Utils.isEmpty(wcSlaveServer.getText())) {
defaultRunConfiguration.setServer(wcSlaveServer.getText());
}
}
});
if (defaultRunConfiguration.isClustered()) {
wcSlaveServer.setText(CLUSTERED);
wbSendResources.setVisible(false);
wbShowTransformations.setVisible(true);
wbLogRemoteExecutionLocally.setVisible(true);
}
}
use of org.pentaho.di.base.AbstractMeta in project pentaho-kettle by pentaho.
the class SchedulerRequestTest method testBuildSchedulerRequestEntity.
@Test
@SuppressWarnings("ResultOfMethodCallIgnored")
public void testBuildSchedulerRequestEntity() throws UnknownParamException, UnsupportedEncodingException {
AbstractMeta meta = mock(JobMeta.class);
RepositoryDirectoryInterface repositoryDirectory = mock(RepositoryDirectoryInterface.class);
doReturn(repositoryDirectory).when(meta).getRepositoryDirectory();
doReturn(TEST_REPOSITORY_DIRECTORY).when(repositoryDirectory).getPath();
doReturn(TEST_JOB_NAME).when(meta).getName();
doReturn(JOB_EXTENSION).when(meta).getDefaultExtension();
doReturn(LogLevel.getLogLevelForCode(TEST_LOG_LEVEL_PARAM_VALUE)).when(meta).getLogLevel();
doReturn(Boolean.valueOf(TEST_CLEAR_LOG_PARAM_VALUE)).when(meta).isClearingLog();
doReturn(Boolean.valueOf(TEST_RUN_SAFE_MODE_PARAM_VALUE)).when(meta).isSafeModeEnabled();
doReturn(Boolean.valueOf(TEST_GATHERING_METRICS_PARAM_VALUE)).when(meta).isGatheringMetrics();
doReturn(TEST_START_COPY_NAME_PARAM_VALUE).when((JobMeta) meta).getStartCopyName();
doReturn(Boolean.valueOf(TEST_EXPANDING_REMOTE_JOB_PARAM_VALUE)).when((JobMeta) meta).isExpandingRemoteJob();
doReturn(ARRAY_WITH_TEST_PDI_PARAM_NAME).when(meta).listParameters();
doReturn(TEST_PDI_PARAM_VALUE).when(meta).getParameterValue(TEST_PDI_PARAM_NAME);
doCallRealMethod().when(schedulerRequest).buildSchedulerRequestEntity(meta);
assertTrue(compareContentOfStringEntities(schedulerRequest.buildSchedulerRequestEntity(meta), new StringEntity(REFERENCE_TEST_REQUEST)));
}
use of org.pentaho.di.base.AbstractMeta in project pentaho-kettle by pentaho.
the class RunConfigurationTreeDelegateExtension method callExtensionPoint.
@Override
public void callExtensionPoint(LogChannelInterface log, Object extension) throws KettleException {
SpoonTreeDelegateExtension treeDelExt = (SpoonTreeDelegateExtension) extension;
int caseNumber = treeDelExt.getCaseNumber();
AbstractMeta meta = treeDelExt.getTransMeta();
String[] path = treeDelExt.getPath();
List<TreeSelection> objects = treeDelExt.getObjects();
TreeSelection object = null;
if (path[2].equals(RunConfigurationViewTreeExtension.TREE_LABEL)) {
switch(caseNumber) {
case 3:
object = new TreeSelection(path[2], RunConfiguration.class, meta);
break;
case 4:
try {
final String name = path[3];
if (!name.equalsIgnoreCase(DefaultRunConfigurationProvider.DEFAULT_CONFIG_NAME)) {
object = new TreeSelection(path[3], path[3], meta);
}
} catch (Exception e) {
// Do Nothing
}
break;
}
}
if (object != null) {
objects.add(object);
}
}
use of org.pentaho.di.base.AbstractMeta in project pentaho-kettle by pentaho.
the class Spoon method updateTreeForActiveAbstractMetas.
/*
Fix for PDI-18593 Hadoop cluster items not refreshed when switching from local<->repo.
Updates the tree on repository connection or disconnection without closing active Jobs or Transformations.
*/
public void updateTreeForActiveAbstractMetas() {
for (TabMapEntry entry : delegates.tabs.getTabs()) {
Object managedObject = entry.getObject().getManagedObject();
if (managedObject instanceof AbstractMeta) {
if (managedObject instanceof TransMeta) {
selectionTreeManager.create((AbstractMeta) managedObject, STRING_TRANSFORMATIONS, props.isOnlyActiveFileShownInTree());
}
if (managedObject instanceof JobMeta) {
selectionTreeManager.create((AbstractMeta) managedObject, STRING_JOBS, props.isOnlyActiveFileShownInTree());
}
selectionTreeManager.show((AbstractMeta) managedObject);
refreshTree((AbstractMeta) managedObject);
}
}
}
Aggregations