use of org.pentaho.di.repository.RepositoryDirectoryInterface in project pentaho-kettle by pentaho.
the class RepositoryExplorerDialog method renameJob.
public void renameJob(TreeItem treeitem, String jobname, RepositoryDirectoryInterface repositorydir) {
final TreeItem ti = treeitem;
final String name = jobname;
final RepositoryDirectoryInterface repdir = repositorydir;
TreeEditor editor = new TreeEditor(wTree);
editor.setItem(ti);
final Text text = new Text(wTree, SWT.NONE);
props.setLook(text);
text.setText(name);
text.addFocusListener(new FocusAdapter() {
@Override
public void focusLost(FocusEvent arg0) {
// Focus is lost: apply changes
String newname = text.getText();
if (renameJob(name, repdir, newname)) {
ti.setText(newname);
}
text.dispose();
}
});
text.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
// ESC --> Don't change tree item...
if (e.keyCode == SWT.ESC) {
text.dispose();
}
// ENTER --> Save changes...
if (e.character == SWT.CR) {
String newname = text.getText();
if (renameJob(name, repdir, newname)) {
ti.setText(newname);
}
text.dispose();
}
}
});
editor.horizontalAlignment = SWT.LEFT;
editor.grabHorizontal = true;
editor.grabVertical = true;
editor.minimumWidth = 50;
text.selectAll();
text.setFocus();
editor.layout();
editor.setEditor(text);
}
use of org.pentaho.di.repository.RepositoryDirectoryInterface in project pentaho-kettle by pentaho.
the class RepositoryExplorerDialog method renameJob.
public boolean renameJob(String name, RepositoryDirectoryInterface repdir) {
boolean retval = false;
final TreeItem ti = wTree.getSelection()[0];
if (ti.getItemCount() == 0) {
final String fname = name;
final RepositoryDirectoryInterface frepdir = repdir;
TreeEditor editor = new TreeEditor(wTree);
editor.setItem(ti);
final Text text = new Text(wTree, SWT.NONE);
props.setLook(text);
text.setText(name);
text.addFocusListener(new FocusAdapter() {
@Override
public void focusLost(FocusEvent arg0) {
// Focus is lost: apply changes
String newname = text.getText();
if (renameJob(fname, newname, frepdir)) {
ti.setText(newname);
}
text.dispose();
}
});
text.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
// ESC --> Don't change tree item...
if (e.keyCode == SWT.ESC) {
text.dispose();
}
// ENTER --> Save changes...
if (e.character == SWT.CR) {
String newname = text.getText();
if (renameJob(fname, newname, frepdir)) {
ti.setText(newname);
}
text.dispose();
}
}
});
editor.horizontalAlignment = SWT.LEFT;
editor.grabHorizontal = true;
editor.grabVertical = true;
editor.minimumWidth = 50;
text.selectAll();
text.setFocus();
editor.layout();
editor.setEditor(text);
}
return retval;
}
use of org.pentaho.di.repository.RepositoryDirectoryInterface in project pentaho-kettle by pentaho.
the class RepositoryExplorerDialog method renameDirectory.
public void renameDirectory(TreeItem treeitem, RepositoryDirectoryInterface rd) {
final TreeItem ti = treeitem;
final RepositoryDirectoryInterface repdir = rd;
final String name = ti.getText();
TreeEditor editor = new TreeEditor(wTree);
editor.setItem(ti);
final Text text = new Text(wTree, SWT.NONE);
props.setLook(text);
text.setText(name);
text.addFocusListener(new FocusAdapter() {
@Override
public void focusLost(FocusEvent arg0) {
// Focus is lost: apply changes
String newname = text.getText();
if (renameDirectory(repdir, name, newname)) {
ti.setText(newname);
}
text.dispose();
}
});
text.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
// ESC --> Don't change tree item...
if (e.keyCode == SWT.ESC) {
text.dispose();
}
// ENTER --> Save changes...
if (e.character == SWT.CR) {
String newname = text.getText();
if (renameDirectory(repdir, name, newname)) {
ti.setText(newname);
}
text.dispose();
}
}
});
editor.horizontalAlignment = SWT.LEFT;
editor.grabHorizontal = true;
editor.grabVertical = true;
editor.minimumWidth = 50;
text.selectAll();
text.setFocus();
editor.layout();
editor.setEditor(text);
}
use of org.pentaho.di.repository.RepositoryDirectoryInterface in project pentaho-kettle by pentaho.
the class MetaInjectMeta method loadTransformationMeta.
public static final synchronized TransMeta loadTransformationMeta(MetaInjectMeta injectMeta, Repository rep, IMetaStore metaStore, VariableSpace space) throws KettleException {
TransMeta mappingTransMeta = null;
CurrentDirectoryResolver resolver = new CurrentDirectoryResolver();
VariableSpace tmpSpace = resolver.resolveCurrentDirectory(injectMeta.getSpecificationMethod(), space, rep, injectMeta.getParentStepMeta(), injectMeta.getFileName());
switch(injectMeta.getSpecificationMethod()) {
case FILENAME:
String realFilename = tmpSpace.environmentSubstitute(injectMeta.getFileName());
try {
//
if (rep != null) {
// need to try to load from the repository
realFilename = resolver.normalizeSlashes(realFilename);
try {
String dirStr = realFilename.substring(0, realFilename.lastIndexOf("/"));
String tmpFilename = realFilename.substring(realFilename.lastIndexOf("/") + 1);
RepositoryDirectoryInterface dir = rep.findDirectory(dirStr);
mappingTransMeta = rep.loadTransformation(tmpFilename, dir, null, true, null);
} catch (KettleException ke) {
// try without extension
if (realFilename.endsWith(Const.STRING_TRANS_DEFAULT_EXT)) {
try {
String tmpFilename = realFilename.substring(realFilename.lastIndexOf("/") + 1, realFilename.indexOf("." + Const.STRING_TRANS_DEFAULT_EXT));
String dirStr = realFilename.substring(0, realFilename.lastIndexOf("/"));
RepositoryDirectoryInterface dir = rep.findDirectory(dirStr);
mappingTransMeta = rep.loadTransformation(tmpFilename, dir, null, true, null);
} catch (KettleException ke2) {
// fall back to try loading from file system (transMeta is going to be null)
}
}
}
}
if (mappingTransMeta == null) {
mappingTransMeta = new TransMeta(realFilename, metaStore, rep, false, tmpSpace, null);
mappingTransMeta.getLogChannel().logDetailed("Loading Mapping from repository", "Mapping transformation was loaded from XML file [" + realFilename + "]");
}
} catch (Exception e) {
throw new KettleException(BaseMessages.getString(PKG, "MetaInjectMeta.Exception.UnableToLoadTransformationFromFile", realFilename), e);
}
break;
case REPOSITORY_BY_NAME:
String realTransname = tmpSpace.environmentSubstitute(injectMeta.getTransName());
String realDirectory = tmpSpace.environmentSubstitute(injectMeta.getDirectoryPath());
if (rep != null) {
if (!Utils.isEmpty(realTransname) && !Utils.isEmpty(realDirectory) && rep != null) {
RepositoryDirectoryInterface repdir = rep.findDirectory(realDirectory);
if (repdir != null) {
try {
// reads the last revision in the repository...
//
// TODO: FIXME: see if we need to pass external MetaStore references to the repository?
//
mappingTransMeta = rep.loadTransformation(realTransname, repdir, null, true, null);
mappingTransMeta.getLogChannel().logDetailed("Loading Mapping from repository", "Mapping transformation [" + realTransname + "] was loaded from the repository");
} catch (Exception e) {
throw new KettleException("Unable to load transformation [" + realTransname + "]", e);
}
} else {
throw new KettleException(BaseMessages.getString(PKG, "MetaInjectMeta.Exception.UnableToLoadTransformationFromRepository", realTransname, realDirectory));
}
}
} else {
try {
mappingTransMeta = new TransMeta(realDirectory + "/" + realTransname, metaStore, rep, true, tmpSpace, null);
} catch (KettleException ke) {
try {
// add .ktr extension and try again
mappingTransMeta = new TransMeta(realDirectory + "/" + realTransname + "." + Const.STRING_TRANS_DEFAULT_EXT, metaStore, rep, true, tmpSpace, null);
} catch (KettleException ke2) {
throw new KettleException(BaseMessages.getString(PKG, "StepWithMappingMeta.Exception.UnableToLoadTrans", realTransname) + realDirectory);
}
}
}
break;
case REPOSITORY_BY_REFERENCE:
// Read the last revision by reference...
mappingTransMeta = rep.loadTransformation(injectMeta.getTransObjectId(), null);
break;
default:
break;
}
// Pass some important information to the mapping transformation metadata:
//
mappingTransMeta.copyVariablesFrom(space);
mappingTransMeta.setRepository(rep);
mappingTransMeta.setFilename(mappingTransMeta.getFilename());
return mappingTransMeta;
}
use of org.pentaho.di.repository.RepositoryDirectoryInterface in project pentaho-kettle by pentaho.
the class PurRepository method getObjectInformation.
@Override
public RepositoryObject getObjectInformation(ObjectId objectId, RepositoryObjectType objectType) throws KettleException {
try {
RepositoryFile repositoryFile;
try {
repositoryFile = pur.getFileById(objectId.getId());
} catch (Exception e) {
// javax.jcr.Session throws exception, if a node with specified ID does not exist
// see http://jira.pentaho.com/browse/BISERVER-12758
log.logError("Error when trying to obtain a file by id: " + objectId.getId(), e);
return null;
}
if (repositoryFile == null) {
return null;
}
RepositoryFileAcl repositoryFileAcl = pur.getAcl(repositoryFile.getId());
String parentPath = getParentPath(repositoryFile.getPath());
String name = repositoryFile.getTitle();
String description = repositoryFile.getDescription();
Date modifiedDate = repositoryFile.getLastModifiedDate();
// String creatorId = repositoryFile.getCreatorId();
String ownerName = repositoryFileAcl != null ? repositoryFileAcl.getOwner().getName() : "";
boolean deleted = isDeleted(repositoryFile);
RepositoryDirectoryInterface directory = findDirectory(parentPath);
return new RepositoryObject(objectId, name, directory, ownerName, modifiedDate, objectType, description, deleted);
} catch (Exception e) {
throw new KettleException("Unable to get object information for object with id=" + objectId, e);
}
}
Aggregations