use of org.pentaho.di.core.exception.KettleException in project pentaho-kettle by pentaho.
the class SingleThreaderDialog method selectRepositoryTrans.
private void selectRepositoryTrans() {
RepositoryObject repositoryObject = DialogHelper.selectRepositoryObject("*.ktr", log);
try {
if (repositoryObject != null) {
loadRepositoryTrans(repositoryObject.getName(), repositoryObject.getRepositoryDirectory());
String path = DialogUtils.getPath(transMeta.getRepositoryDirectory().getPath(), mappingTransMeta.getRepositoryDirectory().getPath());
String fullPath = (path.equals("/") ? "/" : path + "/") + mappingTransMeta.getName();
wPath.setText(fullPath);
specificationMethod = ObjectLocationSpecificationMethod.REPOSITORY_BY_NAME;
}
} catch (KettleException ke) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "SingleThreaderDialog.ErrorSelectingObject.DialogTitle"), BaseMessages.getString(PKG, "SingleThreaderDialog.ErrorSelectingObject.DialogMessage"), ke);
}
}
use of org.pentaho.di.core.exception.KettleException in project pentaho-kettle by pentaho.
the class SingleThreaderDialog method loadTransformation.
private void loadTransformation() throws KettleException {
String filename = wPath.getText();
if (repository != null) {
specificationMethod = ObjectLocationSpecificationMethod.REPOSITORY_BY_NAME;
} else {
specificationMethod = ObjectLocationSpecificationMethod.FILENAME;
}
switch(specificationMethod) {
case FILENAME:
if (Utils.isEmpty(filename)) {
return;
}
if (!filename.endsWith(".ktr")) {
filename = filename + ".ktr";
wPath.setText(filename);
}
loadFileTrans(filename);
break;
case REPOSITORY_BY_NAME:
if (Utils.isEmpty(filename)) {
return;
}
if (filename.endsWith(".ktr")) {
filename = filename.replace(".ktr", "");
wPath.setText(filename);
}
String transPath = transMeta.environmentSubstitute(filename);
String realTransname = transPath;
String realDirectory = "";
int index = transPath.lastIndexOf("/");
if (index != -1) {
realTransname = transPath.substring(index + 1);
realDirectory = transPath.substring(0, index);
}
if (Utils.isEmpty(realDirectory) || Utils.isEmpty(realTransname)) {
throw new KettleException(BaseMessages.getString(PKG, "SingleThreaderDialog.Exception.NoValidMappingDetailsFound"));
}
RepositoryDirectoryInterface repdir = repository.findDirectory(realDirectory);
if (repdir == null) {
throw new KettleException(BaseMessages.getString(PKG, "SingleThreaderDialog.Exception.UnableToFindRepositoryDirectory)"));
}
loadRepositoryTrans(realTransname, repdir);
break;
case REPOSITORY_BY_REFERENCE:
// load the last version
mappingTransMeta = repository.loadTransformation(referenceObjectId, null);
mappingTransMeta.clearChanged();
break;
default:
break;
}
wInjectStep.setText(getInjectorStep(mappingTransMeta));
}
use of org.pentaho.di.core.exception.KettleException in project pentaho-kettle by pentaho.
the class YamlInputDialog method preview.
// Preview the data
private void preview() {
try {
// Create the XML input step
YamlInputMeta oneMeta = new YamlInputMeta();
getInfo(oneMeta);
TransMeta previewMeta = TransPreviewFactory.generatePreviewTransformation(transMeta, oneMeta, wStepname.getText());
EnterNumberDialog numberDialog = new EnterNumberDialog(shell, props.getDefaultPreviewSize(), BaseMessages.getString(PKG, "YamlInputDialog.NumberRows.DialogTitle"), BaseMessages.getString(PKG, "YamlInputDialog.NumberRows.DialogMessage"));
int previewSize = numberDialog.open();
if (previewSize > 0) {
TransPreviewProgressDialog progressDialog = new TransPreviewProgressDialog(shell, previewMeta, new String[] { wStepname.getText() }, new int[] { previewSize });
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(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();
}
}
} catch (KettleException e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "YamlInputDialog.ErrorPreviewingData.DialogTitle"), BaseMessages.getString(PKG, "YamlInputDialog.ErrorPreviewingData.DialogMessage"), e);
}
}
use of org.pentaho.di.core.exception.KettleException in project pentaho-kettle by pentaho.
the class ZipFileDialog method get.
private void get() {
if (!gotPreviousFields) {
gotPreviousFields = true;
String source = wSourceFileNameField.getText();
String target = wTargetFileNameField.getText();
String base = wBaseFolderField.getText();
try {
wSourceFileNameField.removeAll();
wTargetFileNameField.removeAll();
wBaseFolderField.removeAll();
RowMetaInterface r = transMeta.getPrevStepFields(stepname);
if (r != null) {
String[] fields = r.getFieldNames();
wSourceFileNameField.setItems(fields);
wTargetFileNameField.setItems(fields);
wBaseFolderField.setItems(fields);
}
} catch (KettleException ke) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "ZipFileDialog.FailedToGetFields.DialogTitle"), BaseMessages.getString(PKG, "ZipFileDialog.FailedToGetFields.DialogMessage"), ke);
} finally {
if (source != null) {
wSourceFileNameField.setText(source);
}
if (target != null) {
wTargetFileNameField.setText(target);
}
if (base != null) {
wBaseFolderField.setText(base);
}
}
}
}
use of org.pentaho.di.core.exception.KettleException in project pentaho-kettle by pentaho.
the class TextFileInputDialog method getFirst.
// Get the first x lines
private List<String> getFirst(int nrlines, boolean skipHeaders) throws KettleException {
TextFileInputMeta meta = new TextFileInputMeta();
getInfo(meta);
FileInputList textFileList = meta.getTextFileList(transMeta);
InputStream fi;
CompressionInputStream f = null;
StringBuilder lineStringBuilder = new StringBuilder(256);
int fileFormatType = meta.getFileFormatTypeNr();
List<String> retval = new ArrayList<String>();
if (textFileList.nrOfFiles() > 0) {
FileObject file = textFileList.getFile(0);
try {
fi = KettleVFS.getInputStream(file);
CompressionProvider provider = CompressionProviderFactory.getInstance().createCompressionProviderInstance(meta.getFileCompression());
f = provider.createInputStream(fi);
InputStreamReader reader;
if (meta.getEncoding() != null && meta.getEncoding().length() > 0) {
reader = new InputStreamReader(f, meta.getEncoding());
} else {
reader = new InputStreamReader(f);
}
EncodingType encodingType = EncodingType.guessEncodingType(reader.getEncoding());
int linenr = 0;
int maxnr = nrlines + (meta.hasHeader() ? meta.getNrHeaderLines() : 0);
if (skipHeaders) {
// Skip the header lines first if more then one, it helps us position
if (meta.isLayoutPaged() && meta.getNrLinesDocHeader() > 0) {
int skipped = 0;
String line = TextFileInput.getLine(log, reader, encodingType, fileFormatType, lineStringBuilder);
while (line != null && skipped < meta.getNrLinesDocHeader() - 1) {
skipped++;
line = TextFileInput.getLine(log, reader, encodingType, fileFormatType, lineStringBuilder);
}
}
// Skip the header lines first if more then one, it helps us position
if (meta.hasHeader() && meta.getNrHeaderLines() > 0) {
int skipped = 0;
String line = TextFileInput.getLine(log, reader, encodingType, fileFormatType, lineStringBuilder);
while (line != null && skipped < meta.getNrHeaderLines() - 1) {
skipped++;
line = TextFileInput.getLine(log, reader, encodingType, fileFormatType, lineStringBuilder);
}
}
}
String line = TextFileInput.getLine(log, reader, encodingType, fileFormatType, lineStringBuilder);
while (line != null && (linenr < maxnr || nrlines == 0)) {
retval.add(line);
linenr++;
line = TextFileInput.getLine(log, reader, encodingType, fileFormatType, lineStringBuilder);
}
} catch (Exception e) {
throw new KettleException(BaseMessages.getString(PKG, "TextFileInputDialog.Exception.ErrorGettingFirstLines", "" + nrlines, file.getName().getURI()), e);
} finally {
try {
if (f != null) {
f.close();
}
} catch (Exception e) {
// Ignore errors
}
}
}
return retval;
}
Aggregations