use of org.pentaho.di.repository.StringObjectId in project pentaho-kettle by pentaho.
the class KettleFileRepository method getRootObjectIDs.
private ObjectId[] getRootObjectIDs(String extension) throws KettleException {
try {
// Get all the files in the root directory with a certain extension...
//
List<ObjectId> list = new ArrayList<ObjectId>();
String folderName = repositoryMeta.getBaseDirectory();
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(extension)) {
list.add(new StringObjectId(name));
}
}
}
}
return list.toArray(new ObjectId[list.size()]);
} catch (Exception e) {
throw new KettleException("Unable to get root object ids for extension [" + extension + "]", e);
}
}
use of org.pentaho.di.repository.StringObjectId in project pentaho-kettle by pentaho.
the class KettleFileRepository method loadJob.
@Override
public JobMeta loadJob(String jobname, RepositoryDirectoryInterface repdir, ProgressMonitorListener monitor, String versionName) throws KettleException {
// This is a standard load of a transformation serialized in XML...
//
String filename = calcDirectoryName(repdir) + jobname + EXT_JOB;
JobMeta jobMeta = new JobMeta(filename, this);
jobMeta.setFilename(null);
jobMeta.setName(jobname);
jobMeta.setObjectId(new StringObjectId(calcObjectId(repdir, jobname, EXT_JOB)));
jobMeta.setRepository(this);
jobMeta.setMetaStore(getMetaStore());
readDatabases(jobMeta, true);
jobMeta.clearChanged();
return jobMeta;
}
use of org.pentaho.di.repository.StringObjectId in project pentaho-kettle by pentaho.
the class KettleFileRepository method renameRepositoryDirectory.
@Override
public ObjectId renameRepositoryDirectory(ObjectId id, RepositoryDirectoryInterface newParentDir, String newName) throws KettleException {
if (newParentDir != null || newName != null) {
try {
// In case of a root object, the ID is the same as the relative filename...
RepositoryDirectoryInterface tree = loadRepositoryDirectoryTree();
RepositoryDirectoryInterface dir = tree.findDirectory(id);
if (dir == null) {
throw new KettleException("Could not find folder [" + id + "]");
}
// If newName is null, keep the current name
newName = (newName != null) ? newName : dir.getName();
FileObject folder = KettleVFS.getFileObject(dir.getPath());
String newFolderName = null;
if (newParentDir != null) {
FileObject newParentFolder = KettleVFS.getFileObject(newParentDir.getPath());
newFolderName = newParentFolder.toString() + "/" + newName;
} else {
newFolderName = folder.getParent().toString() + "/" + newName;
}
FileObject newFolder = KettleVFS.getFileObject(newFolderName);
folder.moveTo(newFolder);
return new StringObjectId(dir.getObjectId());
} catch (Exception e) {
throw new KettleException("Unable to rename directory folder to [" + id + "]");
}
}
return (id);
}
use of org.pentaho.di.repository.StringObjectId in project pentaho-kettle by pentaho.
the class KettleFileRepository method insertLogEntry.
@Override
public ObjectId insertLogEntry(String description) throws KettleException {
String logfile = calcDirectoryName(null) + LOG_FILE;
try {
OutputStream outputStream = KettleVFS.getOutputStream(logfile, true);
outputStream.write(description.getBytes());
outputStream.write(Const.CR.getBytes());
outputStream.close();
return new StringObjectId(logfile);
} catch (IOException e) {
throw new KettleException("Unable to write log entry to file [" + logfile + "]");
}
}
use of org.pentaho.di.repository.StringObjectId in project pentaho-kettle by pentaho.
the class KettleFileRepository method loadTransformation.
@Override
public TransMeta loadTransformation(String transname, RepositoryDirectoryInterface repdir, ProgressMonitorListener monitor, boolean setInternalVariables, String versionName) throws KettleException {
// This is a standard load of a transformation serialized in XML...
//
String filename = calcDirectoryName(repdir) + transname + ".ktr";
TransMeta transMeta = new TransMeta(filename, this, setInternalVariables);
transMeta.setRepository(this);
transMeta.setMetaStore(getMetaStore());
transMeta.setFilename(null);
transMeta.setName(transname);
transMeta.setObjectId(new StringObjectId(calcObjectId(repdir, transname, EXT_TRANSFORMATION)));
readDatabases(transMeta, true);
transMeta.clearChanged();
return transMeta;
}
Aggregations