use of org.pentaho.di.repository.RepositoryDirectoryInterface in project pentaho-kettle by pentaho.
the class Spoon method handleStartOptions.
public void handleStartOptions(CommandLineOption[] options) {
// note that at this point the rep object is populated by previous calls
StringBuilder optionRepname = getCommandLineOption(options, "rep").getArgument();
StringBuilder optionFilename = getCommandLineOption(options, "file").getArgument();
StringBuilder optionDirname = getCommandLineOption(options, "dir").getArgument();
StringBuilder optionTransname = getCommandLineOption(options, "trans").getArgument();
StringBuilder optionJobname = getCommandLineOption(options, "job").getArgument();
try {
// Read kettle transformation specified on command-line?
if (!Utils.isEmpty(optionRepname) || !Utils.isEmpty(optionFilename)) {
if (!Utils.isEmpty(optionRepname)) {
if (rep != null) {
if (Utils.isEmpty(optionDirname)) {
optionDirname = new StringBuilder(RepositoryDirectory.DIRECTORY_SEPARATOR);
}
// Options /file, /job and /trans are mutually
// exclusive
int t = (Utils.isEmpty(optionFilename) ? 0 : 1) + (Utils.isEmpty(optionJobname) ? 0 : 1) + (Utils.isEmpty(optionTransname) ? 0 : 1);
if (t > 1) {
// "More then one mutually exclusive options /file, /job and /trans are specified."
log.logError(BaseMessages.getString(PKG, "Spoon.Log.MutuallyExcusive"));
} else if (t == 1) {
if (!Utils.isEmpty(optionFilename)) {
openFile(optionFilename.toString(), false);
} else {
// OK, if we have a specified job or
// transformation, try to load it...
// If not, keep the repository logged
// in.
RepositoryDirectoryInterface rdi = rep.findDirectory(optionDirname.toString());
if (rdi == null) {
log.logError(BaseMessages.getString(PKG, "Spoon.Log.UnableFindDirectory", optionDirname.toString()));
} else {
if (!Utils.isEmpty(optionTransname)) {
TransMeta transMeta = // reads
rep.loadTransformation(optionTransname.toString(), rdi, null, true, null);
// last
// version
transMeta.clearChanged();
transMeta.setInternalKettleVariables();
addTransGraph(transMeta);
} else {
// Try to load a specified job
// if any
// reads
JobMeta jobMeta = rep.loadJob(optionJobname.toString(), rdi, null, null);
// last
// version
jobMeta.clearChanged();
jobMeta.setInternalKettleVariables();
addJobGraph(jobMeta);
}
}
}
}
} else {
// "No repositories defined on this system."
log.logError(BaseMessages.getString(PKG, "Spoon.Log.NoRepositoriesDefined"));
}
} else if (!Utils.isEmpty(optionFilename)) {
openFile(optionFilename.toString(), false);
}
}
} catch (KettleException ke) {
hideSplash();
log.logError(BaseMessages.getString(PKG, "Spoon.Log.ErrorOccurred") + Const.CR + ke.getMessage());
log.logError(Const.getStackTracker(ke));
// do not just eat the exception
new ErrorDialog(shell, BaseMessages.getString(PKG, "Spoon.Log.ErrorOccurred"), BaseMessages.getString(PKG, "Spoon.Log.ErrorOccurred") + Const.CR + ke.getMessage(), ke);
rep = null;
}
}
use of org.pentaho.di.repository.RepositoryDirectoryInterface in project pentaho-kettle by pentaho.
the class Spoon method loadLastUsedFile.
private void loadLastUsedFile(LastUsedFile lastUsedFile, String repositoryName, boolean trackIt, boolean isStartup) throws KettleException {
boolean useRepository = repositoryName != null;
//
if (lastUsedFile.isSourceRepository()) {
if (!Utils.isEmpty(lastUsedFile.getRepositoryName())) {
if (useRepository && !lastUsedFile.getRepositoryName().equalsIgnoreCase(repositoryName)) {
// We just asked...
useRepository = false;
}
}
}
if (useRepository && lastUsedFile.isSourceRepository()) {
if (rep != null) {
// load from this repository...
if (rep.getName().equalsIgnoreCase(lastUsedFile.getRepositoryName())) {
RepositoryDirectoryInterface rdi = rep.findDirectory(lastUsedFile.getDirectory());
if (rdi != null) {
// does the file exist in the repo?
final RepositoryObjectType fileType = lastUsedFile.isJob() ? RepositoryObjectType.JOB : RepositoryObjectType.TRANSFORMATION;
if (!rep.exists(lastUsedFile.getFilename(), rdi, fileType)) {
// opening this file
if (isStartup) {
if (log.isDetailed()) {
log.logDetailed(BaseMessages.getString(PKG, "Spoon.log.openingMissingFile"));
}
} else {
final Dialog dlg = new SimpleMessageDialog(shell, BaseMessages.getString(PKG, "Spoon.Dialog.MissingRecentFile.Title"), BaseMessages.getString(PKG, "Spoon.Dialog.MissingRecentFile.Message", lastUsedFile.getLongFileType().toLowerCase()), MessageDialog.ERROR, BaseMessages.getString(PKG, "System.Button.Close"), MISSING_RECENT_DLG_WIDTH, SimpleMessageDialog.BUTTON_WIDTH);
dlg.open();
}
} else {
// Are we loading a transformation or a job?
if (lastUsedFile.isTransformation()) {
if (log.isDetailed()) {
// "Auto loading transformation ["+lastfiles[0]+"] from repository directory ["+lastdirs[0]+"]"
log.logDetailed(BaseMessages.getString(PKG, "Spoon.Log.AutoLoadingTransformation", lastUsedFile.getFilename(), lastUsedFile.getDirectory()));
}
TransLoadProgressDialog tlpd = new TransLoadProgressDialog(shell, rep, lastUsedFile.getFilename(), rdi, null);
TransMeta transMeta = tlpd.open();
if (transMeta != null) {
if (trackIt) {
props.addLastFile(LastUsedFile.FILE_TYPE_TRANSFORMATION, lastUsedFile.getFilename(), rdi.getPath(), true, rep.getName(), getUsername(), null);
}
// transMeta.setFilename(lastUsedFile.getFilename());
transMeta.clearChanged();
addTransGraph(transMeta);
refreshTree();
}
} else if (lastUsedFile.isJob()) {
JobLoadProgressDialog progressDialog = new JobLoadProgressDialog(shell, rep, lastUsedFile.getFilename(), rdi, null);
JobMeta jobMeta = progressDialog.open();
if (jobMeta != null) {
if (trackIt) {
props.addLastFile(LastUsedFile.FILE_TYPE_JOB, lastUsedFile.getFilename(), rdi.getPath(), true, rep.getName(), getUsername(), null);
}
jobMeta.clearChanged();
addJobGraph(jobMeta);
}
}
refreshTree();
}
}
}
}
}
// open files stored locally, not in the repository
if (!lastUsedFile.isSourceRepository() && !Utils.isEmpty(lastUsedFile.getFilename())) {
if (lastUsedFile.isTransformation()) {
openFile(lastUsedFile.getFilename(), rep != null);
}
if (lastUsedFile.isJob()) {
openFile(lastUsedFile.getFilename(), false);
}
refreshTree();
}
}
use of org.pentaho.di.repository.RepositoryDirectoryInterface in project pentaho-kettle by pentaho.
the class TransDialog method addTransTab.
private void addTransTab() {
// ////////////////////////
// START OF TRANS TAB///
// /
wTransTab = new CTabItem(wTabFolder, SWT.NONE);
wTransTab.setText(BaseMessages.getString(PKG, "TransDialog.TransTab.Label"));
Composite wTransComp = new Composite(wTabFolder, SWT.NONE);
props.setLook(wTransComp);
FormLayout transLayout = new FormLayout();
transLayout.marginWidth = Const.FORM_MARGIN;
transLayout.marginHeight = Const.FORM_MARGIN;
wTransComp.setLayout(transLayout);
// Transformation name:
Label wlTransname = new Label(wTransComp, SWT.RIGHT);
wlTransname.setText(BaseMessages.getString(PKG, "TransDialog.Transname.Label"));
props.setLook(wlTransname);
FormData fdlTransname = new FormData();
fdlTransname.left = new FormAttachment(0, 0);
fdlTransname.right = new FormAttachment(middle, -margin);
fdlTransname.top = new FormAttachment(0, margin);
wlTransname.setLayoutData(fdlTransname);
wTransname = new Text(wTransComp, rep == null ? SWT.SINGLE | SWT.LEFT | SWT.BORDER : SWT.SINGLE | SWT.LEFT | SWT.BORDER | SWT.READ_ONLY);
wTransname.setEnabled(rep == null);
props.setLook(wTransname);
wTransname.addModifyListener(lsMod);
FormData fdTransname = new FormData();
fdTransname.left = new FormAttachment(middle, 0);
fdTransname.top = new FormAttachment(0, margin);
fdTransname.right = new FormAttachment(100, 0);
wTransname.setLayoutData(fdTransname);
// Transformation name:
Label wlTransFilename = new Label(wTransComp, SWT.RIGHT);
wlTransFilename.setText(BaseMessages.getString(PKG, "TransDialog.TransFilename.Label"));
props.setLook(wlTransFilename);
FormData fdlTransFilename = new FormData();
fdlTransFilename.left = new FormAttachment(0, 0);
fdlTransFilename.right = new FormAttachment(middle, -margin);
fdlTransFilename.top = new FormAttachment(wTransname, margin);
wlTransFilename.setLayoutData(fdlTransFilename);
wTransFilename = new Text(wTransComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wTransFilename);
wTransFilename.addModifyListener(lsMod);
FormData fdTransFilename = new FormData();
fdTransFilename.left = new FormAttachment(middle, 0);
fdTransFilename.top = new FormAttachment(wTransname, margin);
fdTransFilename.right = new FormAttachment(100, 0);
wTransFilename.setLayoutData(fdTransFilename);
wTransFilename.setEditable(false);
wTransFilename.setBackground(GUIResource.getInstance().getColorLightGray());
// Transformation description:
Label wlTransdescription = new Label(wTransComp, SWT.RIGHT);
wlTransdescription.setText(BaseMessages.getString(PKG, "TransDialog.Transdescription.Label"));
props.setLook(wlTransdescription);
FormData fdlTransdescription = new FormData();
fdlTransdescription.left = new FormAttachment(0, 0);
fdlTransdescription.right = new FormAttachment(middle, -margin);
fdlTransdescription.top = new FormAttachment(wTransFilename, margin);
wlTransdescription.setLayoutData(fdlTransdescription);
wTransdescription = new Text(wTransComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wTransdescription);
wTransdescription.addModifyListener(lsMod);
FormData fdTransdescription = new FormData();
fdTransdescription.left = new FormAttachment(middle, 0);
fdTransdescription.top = new FormAttachment(wTransFilename, margin);
fdTransdescription.right = new FormAttachment(100, 0);
wTransdescription.setLayoutData(fdTransdescription);
// Transformation Extended description
wlExtendeddescription = new Label(wTransComp, SWT.RIGHT);
wlExtendeddescription.setText(BaseMessages.getString(PKG, "TransDialog.Extendeddescription.Label"));
props.setLook(wlExtendeddescription);
fdlExtendeddescription = new FormData();
fdlExtendeddescription.left = new FormAttachment(0, 0);
fdlExtendeddescription.top = new FormAttachment(wTransdescription, margin);
fdlExtendeddescription.right = new FormAttachment(middle, -margin);
wlExtendeddescription.setLayoutData(fdlExtendeddescription);
wExtendeddescription = new Text(wTransComp, SWT.MULTI | SWT.LEFT | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
props.setLook(wExtendeddescription, Props.WIDGET_STYLE_FIXED);
wExtendeddescription.addModifyListener(lsMod);
fdExtendeddescription = new FormData();
fdExtendeddescription.left = new FormAttachment(middle, 0);
fdExtendeddescription.top = new FormAttachment(wTransdescription, margin);
fdExtendeddescription.right = new FormAttachment(100, 0);
fdExtendeddescription.bottom = new FormAttachment(50, -margin);
wExtendeddescription.setLayoutData(fdExtendeddescription);
// Trans Status
wlTransstatus = new Label(wTransComp, SWT.RIGHT);
wlTransstatus.setText(BaseMessages.getString(PKG, "TransDialog.Transstatus.Label"));
props.setLook(wlTransstatus);
fdlTransstatus = new FormData();
fdlTransstatus.left = new FormAttachment(0, 0);
fdlTransstatus.right = new FormAttachment(middle, 0);
fdlTransstatus.top = new FormAttachment(wExtendeddescription, margin * 2);
wlTransstatus.setLayoutData(fdlTransstatus);
wTransstatus = new CCombo(wTransComp, SWT.SINGLE | SWT.READ_ONLY | SWT.BORDER);
wTransstatus.add(BaseMessages.getString(PKG, "TransDialog.Draft_Transstatus.Label"));
wTransstatus.add(BaseMessages.getString(PKG, "TransDialog.Production_Transstatus.Label"));
wTransstatus.add("");
// +1: starts at -1
wTransstatus.select(-1);
wTransstatus.addSelectionListener(lsModSel);
props.setLook(wTransstatus);
fdTransstatus = new FormData();
fdTransstatus.left = new FormAttachment(middle, 0);
fdTransstatus.top = new FormAttachment(wExtendeddescription, margin * 2);
fdTransstatus.right = new FormAttachment(100, 0);
wTransstatus.setLayoutData(fdTransstatus);
// Transformation Transversion:
Label wlTransversion = new Label(wTransComp, SWT.RIGHT);
wlTransversion.setText(BaseMessages.getString(PKG, "TransDialog.Transversion.Label"));
props.setLook(wlTransversion);
FormData fdlTransversion = new FormData();
fdlTransversion.left = new FormAttachment(0, 0);
fdlTransversion.right = new FormAttachment(middle, -margin);
fdlTransversion.top = new FormAttachment(wTransstatus, margin);
wlTransversion.setLayoutData(fdlTransversion);
wTransversion = new Text(wTransComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wTransversion);
wTransversion.addModifyListener(lsMod);
FormData fdTransversion = new FormData();
fdTransversion.left = new FormAttachment(middle, 0);
fdTransversion.top = new FormAttachment(wTransstatus, margin);
fdTransversion.right = new FormAttachment(100, 0);
wTransversion.setLayoutData(fdTransversion);
// Directory:
wlDirectory = new Label(wTransComp, SWT.RIGHT);
wlDirectory.setText(BaseMessages.getString(PKG, "TransDialog.Directory.Label"));
props.setLook(wlDirectory);
FormData fdlDirectory = new FormData();
fdlDirectory.left = new FormAttachment(0, 0);
fdlDirectory.right = new FormAttachment(middle, -margin);
fdlDirectory.top = new FormAttachment(wTransversion, margin);
wlDirectory.setLayoutData(fdlDirectory);
wbDirectory = new Button(wTransComp, SWT.PUSH);
wbDirectory.setToolTipText(BaseMessages.getString(PKG, "TransDialog.selectTransFolder.Tooltip"));
wbDirectory.setImage(GUIResource.getInstance().getImageArrow());
props.setLook(wbDirectory);
FormData fdbDirectory = new FormData();
fdbDirectory.right = new FormAttachment(100, 0);
fdbDirectory.top = new FormAttachment(wTransversion, 0);
wbDirectory.setLayoutData(fdbDirectory);
wbDirectory.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent arg0) {
RepositoryDirectoryInterface directoryFrom = transMeta.getRepositoryDirectory();
RepositoryDirectoryInterface rd = RepositoryDirectoryUI.chooseDirectory(shell, rep, directoryFrom);
if (rd == null) {
return;
}
// We need to change this in the repository as well!!
// We do this when the user pressed OK
newDirectory = rd;
wDirectory.setText(rd.getPath());
}
});
wDirectory = new Text(wTransComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wDirectory);
wDirectory.setEditable(false);
wDirectory.setEnabled(false);
FormData fdDirectory = new FormData();
fdDirectory.left = new FormAttachment(middle, 0);
fdDirectory.top = new FormAttachment(wTransversion, margin);
fdDirectory.right = new FormAttachment(wbDirectory, 0);
wDirectory.setLayoutData(fdDirectory);
// Create User:
Label wlCreateUser = new Label(wTransComp, SWT.RIGHT);
wlCreateUser.setText(BaseMessages.getString(PKG, "TransDialog.CreateUser.Label"));
props.setLook(wlCreateUser);
FormData fdlCreateUser = new FormData();
fdlCreateUser.left = new FormAttachment(0, 0);
fdlCreateUser.right = new FormAttachment(middle, -margin);
fdlCreateUser.top = new FormAttachment(wDirectory, margin);
wlCreateUser.setLayoutData(fdlCreateUser);
wCreateUser = new Text(wTransComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wCreateUser);
wCreateUser.setEditable(false);
wCreateUser.addModifyListener(lsMod);
FormData fdCreateUser = new FormData();
fdCreateUser.left = new FormAttachment(middle, 0);
fdCreateUser.top = new FormAttachment(wDirectory, margin);
fdCreateUser.right = new FormAttachment(100, 0);
wCreateUser.setLayoutData(fdCreateUser);
// Created Date:
Label wlCreateDate = new Label(wTransComp, SWT.RIGHT);
wlCreateDate.setText(BaseMessages.getString(PKG, "TransDialog.CreateDate.Label"));
props.setLook(wlCreateDate);
FormData fdlCreateDate = new FormData();
fdlCreateDate.left = new FormAttachment(0, 0);
fdlCreateDate.right = new FormAttachment(middle, -margin);
fdlCreateDate.top = new FormAttachment(wCreateUser, margin);
wlCreateDate.setLayoutData(fdlCreateDate);
wCreateDate = new Text(wTransComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wCreateDate);
wCreateDate.setEditable(false);
wCreateDate.addModifyListener(lsMod);
FormData fdCreateDate = new FormData();
fdCreateDate.left = new FormAttachment(middle, 0);
fdCreateDate.top = new FormAttachment(wCreateUser, margin);
fdCreateDate.right = new FormAttachment(100, 0);
wCreateDate.setLayoutData(fdCreateDate);
// Modified User:
Label wlModUser = new Label(wTransComp, SWT.RIGHT);
wlModUser.setText(BaseMessages.getString(PKG, "TransDialog.LastModifiedUser.Label"));
props.setLook(wlModUser);
FormData fdlModUser = new FormData();
fdlModUser.left = new FormAttachment(0, 0);
fdlModUser.right = new FormAttachment(middle, -margin);
fdlModUser.top = new FormAttachment(wCreateDate, margin);
wlModUser.setLayoutData(fdlModUser);
wModUser = new Text(wTransComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wModUser);
wModUser.setEditable(false);
wModUser.addModifyListener(lsMod);
FormData fdModUser = new FormData();
fdModUser.left = new FormAttachment(middle, 0);
fdModUser.top = new FormAttachment(wCreateDate, margin);
fdModUser.right = new FormAttachment(100, 0);
wModUser.setLayoutData(fdModUser);
// Modified Date:
Label wlModDate = new Label(wTransComp, SWT.RIGHT);
wlModDate.setText(BaseMessages.getString(PKG, "TransDialog.LastModifiedDate.Label"));
props.setLook(wlModDate);
FormData fdlModDate = new FormData();
fdlModDate.left = new FormAttachment(0, 0);
fdlModDate.right = new FormAttachment(middle, -margin);
fdlModDate.top = new FormAttachment(wModUser, margin);
wlModDate.setLayoutData(fdlModDate);
wModDate = new Text(wTransComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wModDate);
wModDate.setEditable(false);
wModDate.addModifyListener(lsMod);
FormData fdModDate = new FormData();
fdModDate.left = new FormAttachment(middle, 0);
fdModDate.top = new FormAttachment(wModUser, margin);
fdModDate.right = new FormAttachment(100, 0);
wModDate.setLayoutData(fdModDate);
FormData fdTransComp = new FormData();
fdTransComp.left = new FormAttachment(0, 0);
fdTransComp.top = new FormAttachment(0, 0);
fdTransComp.right = new FormAttachment(100, 0);
fdTransComp.bottom = new FormAttachment(100, 0);
wTransComp.setLayoutData(fdTransComp);
wTransComp.layout();
wTransTab.setControl(wTransComp);
// ///////////////////////////////////////////////////////////
// / END OF TRANS TAB
// ///////////////////////////////////////////////////////////
}
use of org.pentaho.di.repository.RepositoryDirectoryInterface in project pentaho-metaverse by pentaho.
the class JobExecutorStepAnalyzer method customAnalyze.
@Override
protected void customAnalyze(JobExecutorMeta meta, IMetaverseNode node) throws MetaverseAnalyzerException {
String jobPath = meta.getFileName();
JobMeta subJobMeta = null;
Repository repo = parentTransMeta.getRepository();
switch(meta.getSpecificationMethod()) {
case FILENAME:
jobPath = parentTransMeta.environmentSubstitute(meta.getFileName());
try {
String normalized = KettleAnalyzerUtil.normalizeFilePath(jobPath);
subJobMeta = getSubJobMeta(parentTransMeta, normalized);
jobPath = normalized;
} catch (Exception e) {
throw new MetaverseAnalyzerException("Sub transformation can not be found - " + jobPath, e);
}
break;
case REPOSITORY_BY_NAME:
if (repo != null) {
String dir = parentTransMeta.environmentSubstitute(meta.getDirectoryPath());
String file = parentTransMeta.environmentSubstitute(meta.getJobName());
try {
RepositoryDirectoryInterface rdi = repo.findDirectory(dir);
subJobMeta = repo.loadJob(file, rdi, null, null);
String filename = subJobMeta.getFilename() == null ? subJobMeta.toString() : subJobMeta.getFilename();
jobPath = filename + "." + subJobMeta.getDefaultExtension();
} catch (KettleException e) {
throw new MetaverseAnalyzerException("Sub transformation can not be found in repository - " + file, e);
}
} else {
throw new MetaverseAnalyzerException("Not connected to a repository, can't get the transformation");
}
break;
case REPOSITORY_BY_REFERENCE:
if (repo != null) {
try {
subJobMeta = repo.loadJob(meta.getJobObjectId(), null);
String filename = subJobMeta.getFilename() == null ? subJobMeta.toString() : subJobMeta.getFilename();
jobPath = filename + "." + subJobMeta.getDefaultExtension();
} catch (KettleException e) {
throw new MetaverseAnalyzerException("Sub transformation can not be found by reference - " + meta.getJobObjectId(), e);
}
} else {
throw new MetaverseAnalyzerException("Not connected to a repository, can't get the transformation");
}
break;
}
// analyze the sub trans?
IComponentDescriptor ds = new MetaverseComponentDescriptor(subJobMeta.getName(), DictionaryConst.NODE_TYPE_JOB, descriptor.getNamespace().getParentNamespace());
IMetaverseNode jobNode = createNodeFromDescriptor(ds);
jobNode.setProperty(DictionaryConst.PROPERTY_NAMESPACE, ds.getNamespaceId());
jobNode.setProperty(DictionaryConst.PROPERTY_PATH, jobPath);
jobNode.setLogicalIdGenerator(DictionaryConst.LOGICAL_ID_GENERATOR_DOCUMENT);
metaverseBuilder.addLink(node, DictionaryConst.LINK_EXECUTES, jobNode);
connectToSubJobOutputFields(meta, subJobMeta, jobNode, descriptor);
node.setProperty(JOB_TO_EXECUTE, jobPath);
if (StringUtils.isNotEmpty(meta.getExecutionResultTargetStep())) {
node.setProperty(EXECUTION_RESULTS_TARGET, meta.getExecutionResultTargetStep());
}
if (StringUtils.isNotEmpty(meta.getResultFilesTargetStep())) {
node.setProperty(RESULT_FILES_TARGET, meta.getResultFilesTargetStep());
}
}
use of org.pentaho.di.repository.RepositoryDirectoryInterface in project pentaho-metaverse by pentaho.
the class TransExecutorStepAnalyzer method customAnalyze.
@Override
protected void customAnalyze(TransExecutorMeta meta, IMetaverseNode node) throws MetaverseAnalyzerException {
String transPath = meta.getFileName();
TransMeta subTransMeta = null;
Repository repo = parentTransMeta.getRepository();
switch(meta.getSpecificationMethod()) {
case FILENAME:
transPath = parentTransMeta.environmentSubstitute(meta.getFileName());
try {
String normalized = KettleAnalyzerUtil.normalizeFilePath(transPath);
subTransMeta = getSubTransMeta(normalized);
transPath = normalized;
} catch (Exception e) {
throw new MetaverseAnalyzerException("Sub transformation can not be found - " + transPath, e);
}
break;
case REPOSITORY_BY_NAME:
if (repo != null) {
String dir = parentTransMeta.environmentSubstitute(meta.getDirectoryPath());
String file = parentTransMeta.environmentSubstitute(meta.getTransName());
try {
RepositoryDirectoryInterface rdi = repo.findDirectory(dir);
subTransMeta = repo.loadTransformation(file, rdi, null, true, null);
transPath = subTransMeta.getPathAndName() + "." + subTransMeta.getDefaultExtension();
} catch (KettleException e) {
throw new MetaverseAnalyzerException("Sub transformation can not be found in repository - " + file, e);
}
} else {
throw new MetaverseAnalyzerException("Not connected to a repository, can't get the transformation");
}
break;
case REPOSITORY_BY_REFERENCE:
if (repo != null) {
try {
subTransMeta = repo.loadTransformation(meta.getTransObjectId(), null);
transPath = subTransMeta.getPathAndName() + "." + subTransMeta.getDefaultExtension();
} catch (KettleException e) {
throw new MetaverseAnalyzerException("Sub transformation can not be found by reference - " + meta.getTransObjectId(), e);
}
} else {
throw new MetaverseAnalyzerException("Not connected to a repository, can't get the transformation");
}
break;
}
// analyze the sub trans?
IComponentDescriptor ds = new MetaverseComponentDescriptor(subTransMeta.getName(), DictionaryConst.NODE_TYPE_TRANS, descriptor.getNamespace().getParentNamespace());
IMetaverseNode transformationNode = createNodeFromDescriptor(ds);
transformationNode.setProperty(DictionaryConst.PROPERTY_NAMESPACE, ds.getNamespaceId());
transformationNode.setProperty(DictionaryConst.PROPERTY_PATH, transPath);
transformationNode.setLogicalIdGenerator(DictionaryConst.LOGICAL_ID_GENERATOR_DOCUMENT);
metaverseBuilder.addLink(node, DictionaryConst.LINK_EXECUTES, transformationNode);
connectToSubTransInputFields(meta, subTransMeta, transformationNode, descriptor);
connectToSubTransOutputFields(meta, subTransMeta, transformationNode, descriptor);
node.setProperty(TRANSFORMATION_TO_EXECUTE, transPath);
if (StringUtils.isNotEmpty(meta.getExecutionResultTargetStep())) {
node.setProperty(EXECUTION_RESULTS_TARGET, meta.getExecutionResultTargetStep());
}
if (StringUtils.isNotEmpty(meta.getOutputRowsSourceStep())) {
node.setProperty(OUTPUT_ROWS_TARGET, meta.getOutputRowsSourceStep());
}
if (StringUtils.isNotEmpty(meta.getResultFilesTargetStep())) {
node.setProperty(RESULT_FILES_TARGET, meta.getResultFilesTargetStep());
}
}
Aggregations