use of org.pentaho.di.repository.StringObjectId in project pentaho-kettle by pentaho.
the class KettleFileRepository method saveRepositoryDirectory.
@Override
public void saveRepositoryDirectory(RepositoryDirectoryInterface dir) throws KettleException {
try {
String filename = calcDirectoryName(dir);
ObjectId objectId = new StringObjectId(calcRelativeElementDirectory(dir));
FileObject fileObject = KettleVFS.getFileObject(filename);
// also create parents
fileObject.createFolder();
dir.setObjectId(objectId);
log.logDetailed("New id of directory = " + dir.getObjectId());
} catch (Exception e) {
throw new KettleException("Unable to save directory [" + dir + "] in the repository", e);
}
}
use of org.pentaho.di.repository.StringObjectId in project pentaho-kettle by pentaho.
the class KettleFileRepository method renameObject.
private ObjectId renameObject(ObjectId id, RepositoryDirectoryInterface newDirectory, String newName, String extension) throws KettleException {
try {
// In case of a root object, the ID is the same as the relative filename...
//
FileObject fileObject = KettleVFS.getFileObject(calcDirectoryName(null) + id.getId());
// Same name, different folder?
if (Utils.isEmpty(newName)) {
newName = calcObjectName(id);
}
// The new filename can be anywhere so we re-calculate a new ID...
//
String newFilename = calcDirectoryName(newDirectory) + newName + extension;
FileObject newObject = KettleVFS.getFileObject(newFilename);
fileObject.moveTo(newObject);
return new StringObjectId(calcObjectId(newDirectory, newName, extension));
} catch (Exception e) {
throw new KettleException("Unable to rename object with ID [" + id + "] to [" + newName + "]", e);
}
}
use of org.pentaho.di.repository.StringObjectId 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.StringObjectId in project pentaho-kettle by pentaho.
the class KettleFileRepository method save.
public void save(RepositoryElementInterface repositoryElement, String versionComment, ProgressMonitorListener monitor, ObjectId parentId, boolean used) throws KettleException {
try {
if (!(repositoryElement instanceof XMLInterface) && !(repositoryElement instanceof SharedObjectInterface)) {
throw new KettleException("Class [" + repositoryElement.getClass().getName() + "] needs to implement the XML Interface in order to save it to disk");
}
if (!Utils.isEmpty(versionComment)) {
insertLogEntry("Save repository element : " + repositoryElement.toString() + " : " + versionComment);
}
ObjectId objectId = new StringObjectId(calcObjectId(repositoryElement));
FileObject fileObject = getFileObject(repositoryElement);
String xml = ((XMLInterface) repositoryElement).getXML();
OutputStream os = KettleVFS.getOutputStream(fileObject, false);
os.write(xml.getBytes(Const.XML_ENCODING));
os.close();
if (repositoryElement instanceof ChangedFlagInterface) {
((ChangedFlagInterface) repositoryElement).clearChanged();
}
//
if (repositoryElement.getObjectId() != null && !repositoryElement.getObjectId().equals(objectId)) {
delObject(repositoryElement.getObjectId());
}
repositoryElement.setObjectId(objectId);
//
if (repositoryElement instanceof TransMeta) {
((TransMeta) repositoryElement).saveMetaStoreObjects(this, metaStore);
}
if (repositoryElement instanceof JobMeta) {
((JobMeta) repositoryElement).saveMetaStoreObjects(this, metaStore);
}
} catch (Exception e) {
throw new KettleException("Unable to save repository element [" + repositoryElement + "] to XML file : " + calcFilename(repositoryElement), e);
}
}
use of org.pentaho.di.repository.StringObjectId in project pentaho-kettle by pentaho.
the class KettleFileRepository method loadRepositoryDirectoryTree.
@Override
public RepositoryDirectoryInterface loadRepositoryDirectoryTree() throws KettleException {
RepositoryDirectory root = new RepositoryDirectory();
root.setObjectId(new StringObjectId("/"));
return loadRepositoryDirectoryTree(root);
}
Aggregations