use of org.pentaho.di.trans.TransMeta in project pentaho-kettle by pentaho.
the class XulDatabaseExplorerController method dataProfile.
public void dataProfile() {
if (model.getTable() == null) {
return;
}
Shell dbShell = (Shell) dbExplorerDialog.getRootObject();
try {
TransProfileFactory profileFactory = new TransProfileFactory(this.model.getDatabaseMeta(), getSchemaAndTable(this.model));
TransMeta transMeta = profileFactory.generateTransformation(new LoggingObject(model.getTable()));
TransPreviewProgressDialog progressDialog = new TransPreviewProgressDialog(dbShell, transMeta, new String[] { TransProfileFactory.RESULT_STEP_NAME }, new int[] { 25000 });
progressDialog.open();
if (!progressDialog.isCancelled()) {
Trans trans = progressDialog.getTrans();
String loggingText = progressDialog.getLoggingText();
if (trans.getResult() != null && trans.getResult().getNrErrors() > 0) {
EnterTextDialog etd = new EnterTextDialog(dbShell, BaseMessages.getString(PKG, "System.Dialog.PreviewError.Title"), BaseMessages.getString(PKG, "System.Dialog.PreviewError.Message"), loggingText, true);
etd.setReadOnly();
etd.open();
}
PreviewRowsDialog prd = new PreviewRowsDialog(dbShell, transMeta, SWT.NONE, TransProfileFactory.RESULT_STEP_NAME, progressDialog.getPreviewRowsMeta(TransProfileFactory.RESULT_STEP_NAME), progressDialog.getPreviewRows(TransProfileFactory.RESULT_STEP_NAME), loggingText);
prd.open();
}
} catch (Exception e) {
new ErrorDialog(this.dbExplorerDialog.getShell(), BaseMessages.getString(PKG, "DatabaseExplorerDialog.UnexpectedProfilingError.Title"), BaseMessages.getString(PKG, "DatabaseExplorerDialog.UnexpectedProfilingError.Message"), e);
}
}
use of org.pentaho.di.trans.TransMeta in project pentaho-kettle by pentaho.
the class XMLInputStreamDialog method preview.
// Preview the data
private void preview() {
// execute a complete preview transformation in the background.
// This is how we do it...
//
XMLInputStreamMeta oneMeta = new XMLInputStreamMeta();
getInfo(oneMeta);
TransMeta previewMeta = TransPreviewFactory.generatePreviewTransformation(transMeta, oneMeta, wStepname.getText());
EnterNumberDialog numberDialog = new EnterNumberDialog(shell, props.getDefaultPreviewSize(), BaseMessages.getString(PKG, "XMLInputStreamDialog.Dialog.EnterPreviewSize.Title"), BaseMessages.getString(PKG, "XMLInputStreamDialog.Dialog.EnterPreviewSize.Message"));
int previewSize = numberDialog.open();
if (previewSize > 0) {
TransPreviewProgressDialog progressDialog = new TransPreviewProgressDialog(shell, previewMeta, new String[] { wStepname.getText() }, new int[] { previewSize });
progressDialog.open();
Trans trans = progressDialog.getTrans();
String loggingText = progressDialog.getLoggingText();
if (!progressDialog.isCancelled()) {
if (trans.getResult() != null && trans.getResult().getNrErrors() > 0) {
EnterTextDialog etd = new EnterTextDialog(shell, BaseMessages.getString(PKG, "System.Dialog.PreviewError.Title"), BaseMessages.getString(PKG, "System.Dialog.PreviewError.Message"), loggingText, true);
etd.setReadOnly();
etd.open();
}
}
PreviewRowsDialog prd = new PreviewRowsDialog(shell, transMeta, SWT.NONE, wStepname.getText(), progressDialog.getPreviewRowsMeta(wStepname.getText()), progressDialog.getPreviewRows(wStepname.getText()), loggingText);
prd.open();
}
}
use of org.pentaho.di.trans.TransMeta in project pentaho-kettle by pentaho.
the class XMLJoinMeta method getFields.
public void getFields(RowMetaInterface row, String name, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore) throws KettleStepException {
ValueMetaInterface v = new ValueMeta(this.getValueXMLfield(), ValueMetaInterface.TYPE_STRING);
v.setOrigin(name);
TransMeta transMeta = (TransMeta) space;
try {
// source fields.
for (String fieldName : transMeta.getStepFields(transMeta.findStep(getSourceXMLstep()), null, null).getFieldNames()) {
row.removeValueMeta(fieldName);
}
} catch (KettleValueException e) {
// Pass
}
row.addValueMeta(v);
}
use of org.pentaho.di.trans.TransMeta in project pentaho-kettle by pentaho.
the class MissingPluginTransIT method testForPluginMissingStep.
/**
* Given a transformation having a step which's plugin is missing in current Kettle installation.
* When this transformation is executed, then execution should fail.
*/
@Test
public void testForPluginMissingStep() throws Exception {
InputStream is = new FileInputStream(new File(this.getClass().getResource("missing_plugin_trans.ktr").getFile()));
TransMeta transMeta = new TransMeta(is, null, false, null, null);
Trans trans = new Trans(transMeta);
LogChannelInterface log = mock(LogChannelInterface.class);
trans.setLog(log);
try {
trans.prepareExecution(null);
fail();
} catch (KettleException e) {
verify(log, times(1)).logError("Step [JSON Input.0] failed to initialize!");
}
}
use of org.pentaho.di.trans.TransMeta in project pentaho-kettle by pentaho.
the class TransformationHasNoDisabledHopsImportRule method verifyRule.
@Override
public List<ImportValidationFeedback> verifyRule(Object subject) {
List<ImportValidationFeedback> feedback = new ArrayList<ImportValidationFeedback>();
if (!isEnabled()) {
return feedback;
}
if (!(subject instanceof TransMeta)) {
return feedback;
}
TransMeta transMeta = (TransMeta) subject;
for (int i = 0; i < transMeta.nrTransHops(); i++) {
TransHopMeta hop = transMeta.getTransHop(i);
if (!hop.isEnabled()) {
feedback.add(new ImportValidationFeedback(this, ImportValidationResultType.ERROR, "There is a disabled hop in the transformation."));
}
}
if (feedback.isEmpty()) {
feedback.add(new ImportValidationFeedback(this, ImportValidationResultType.APPROVAL, "All hops are enabled in this transformation."));
}
return feedback;
}
Aggregations