use of org.pentaho.di.repository.RepositoryElementMetaInterface in project pentaho-kettle by pentaho.
the class KettleFileRepository method getTransformationObjects.
@Override
public List<RepositoryElementMetaInterface> getTransformationObjects(ObjectId idDirectory, boolean includeDeleted) throws KettleException {
try {
List<RepositoryElementMetaInterface> list = new ArrayList<RepositoryElementMetaInterface>();
RepositoryDirectoryInterface tree = loadRepositoryDirectoryTree();
RepositoryDirectoryInterface directory = tree.findDirectory(idDirectory);
String folderName = calcDirectoryName(directory);
FileObject folder = KettleVFS.getFileObject(folderName);
for (FileObject child : folder.getChildren()) {
if (child.getType().equals(FileType.FILE)) {
if (!child.isHidden() || !repositoryMeta.isHidingHiddenFiles()) {
String name = child.getName().getBaseName();
if (name.endsWith(EXT_TRANSFORMATION)) {
String transName = name.substring(0, name.length() - 4);
ObjectId id = new StringObjectId(calcObjectId(directory, transName, EXT_TRANSFORMATION));
Date date = new Date(child.getContent().getLastModifiedTime());
list.add(new RepositoryObject(id, transName, directory, "-", date, RepositoryObjectType.TRANSFORMATION, "", false));
}
}
}
}
return list;
} catch (Exception e) {
throw new KettleException("Unable to get list of transformations in folder with id : " + idDirectory, e);
}
}
use of org.pentaho.di.repository.RepositoryElementMetaInterface in project pentaho-kettle by pentaho.
the class KettleFileRepository method getJobObjects.
@Override
public List<RepositoryElementMetaInterface> getJobObjects(ObjectId id_directory, boolean includeDeleted) throws KettleException {
try {
List<RepositoryElementMetaInterface> list = new ArrayList<RepositoryElementMetaInterface>();
RepositoryDirectoryInterface tree = loadRepositoryDirectoryTree();
RepositoryDirectoryInterface directory = tree.findDirectory(id_directory);
String folderName = calcDirectoryName(directory);
FileObject folder = KettleVFS.getFileObject(folderName);
for (FileObject child : folder.getChildren()) {
if (child.getType().equals(FileType.FILE)) {
if (!child.isHidden() || !repositoryMeta.isHidingHiddenFiles()) {
String name = child.getName().getBaseName();
if (name.endsWith(EXT_JOB)) {
String jobName = name.substring(0, name.length() - 4);
ObjectId id = new StringObjectId(calcObjectId(directory, jobName, EXT_JOB));
Date date = new Date(child.getContent().getLastModifiedTime());
list.add(new RepositoryObject(id, jobName, directory, "-", date, RepositoryObjectType.JOB, "", false));
}
}
}
}
return list;
} catch (Exception e) {
throw new KettleException("Unable to get list of jobs in folder with id : " + id_directory, e);
}
}
use of org.pentaho.di.repository.RepositoryElementMetaInterface in project pentaho-kettle by pentaho.
the class RepositoryDirectoryUI method loadRepositoryObjects.
protected static List<RepositoryElementMetaInterface> loadRepositoryObjects(RepositoryDirectoryInterface dir, boolean getTransformations, boolean getJobs, Repository rep) throws KettleDatabaseException {
// Then show the transformations & jobs in that directory...
List<RepositoryElementMetaInterface> repositoryObjects = new ArrayList<RepositoryElementMetaInterface>();
if (dir.getRepositoryObjects() == null) {
try {
dir.setRepositoryObjects(rep.getJobAndTransformationObjects(dir.getObjectId(), false));
} catch (KettleException e) {
throw new KettleDatabaseException(e);
}
}
List<RepositoryObjectType> allowedTypes = new ArrayList<>(2);
if (getTransformations) {
allowedTypes.add(RepositoryObjectType.TRANSFORMATION);
}
if (getJobs) {
allowedTypes.add(RepositoryObjectType.JOB);
}
for (RepositoryElementMetaInterface repoObject : dir.getRepositoryObjects()) {
if (allowedTypes.contains(repoObject.getObjectType())) {
repositoryObjects.add(repoObject);
}
}
return repositoryObjects;
}
use of org.pentaho.di.repository.RepositoryElementMetaInterface in project pentaho-kettle by pentaho.
the class RepositoryDirectoryUI method getTreeWithNames.
/**
* Set the name of this directory on a TreeItem. Also, create children on this TreeItem to reflect the subdirectories.
* In these sub-directories, fill in the available transformations from the repository.
*
* @param ti
* The TreeItem to set the name on and to create the subdirectories
* @param rep
* The repository
* @param objectMap
* The tree path to repository object mapping to populate.
* @param dircolor
* The color in which the directories will be drawn.
* @param sortPosition
* The sort position
* @param ascending
* The ascending flag
* @param getTransformations
* Include transformations in the tree or not
* @param getJobs
* Include jobs in the tree or not
* @throws KettleDatabaseException
*/
public static void getTreeWithNames(TreeItem ti, Repository rep, Color dircolor, int sortPosition, boolean includeDeleted, boolean ascending, boolean getTransformations, boolean getJobs, RepositoryDirectoryInterface dir, String filterString, Pattern pattern) throws KettleDatabaseException {
ti.setText(dir.getName());
ti.setData(dir);
ti.setData("isFolder", true);
// First, we draw the directories
List<RepositoryDirectoryInterface> children = dir.getChildren();
Collections.sort(children, new Comparator<RepositoryDirectoryInterface>() {
@Override
public int compare(RepositoryDirectoryInterface o1, RepositoryDirectoryInterface o2) {
return o1.getName().compareToIgnoreCase(o2.getName());
}
});
for (int i = 0; i < children.size(); i++) {
RepositoryDirectory subdir = (RepositoryDirectory) children.get(i);
TreeItem subti = new TreeItem(ti, SWT.NONE);
subti.setImage(GUIResource.getInstance().getImageFolder());
subti.setData("isFolder", true);
getTreeWithNames(subti, rep, dircolor, sortPosition, includeDeleted, ascending, getTransformations, getJobs, subdir, filterString, pattern);
}
List<RepositoryElementMetaInterface> repositoryObjects = loadRepositoryObjects(dir, getTransformations, getJobs, rep);
// Sort the directory list appropriately...
RepositoryObject.sortRepositoryObjects(repositoryObjects, sortPosition, ascending);
addToTree(ti, filterString, pattern, repositoryObjects);
ti.setExpanded(dir.isRoot());
}
use of org.pentaho.di.repository.RepositoryElementMetaInterface in project pentaho-kettle by pentaho.
the class RepositoryExplorerDialog method restoreSelectedObjects.
public boolean restoreSelectedObjects() {
TreeItem[] items = wTree.getSelection();
boolean error = false;
for (int i = 0; i < items.length; i++) {
final RepositoryElementMetaInterface repositoryObject = objectMap.get(ConstUI.getTreePath(items[i], 0));
if (repositoryObject != null) {
try {
rep.undeleteObject(repositoryObject);
} catch (Exception e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "RepositoryExplorerDialog.Trans.Delete.ErrorRestoring.Title"), BaseMessages.getString(PKG, "RepositoryExplorerDialog.Trans.Delete.ErrorRestoring.Message"), e);
error = true;
}
}
}
refreshTree();
return !error;
}
Aggregations