use of org.pentaho.di.repository.ObjectId 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.ObjectId 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.ObjectId 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.ObjectId 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.ObjectId in project pentaho-kettle by pentaho.
the class KettleDatabaseRepository method insertClusterSlave.
public synchronized ObjectId insertClusterSlave(ClusterSchema clusterSchema, SlaveServer slaveServer) throws KettleException {
ObjectId id = connectionDelegate.getNextClusterSlaveID();
RowMetaAndData table = new RowMetaAndData();
table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_CLUSTER_SLAVE_ID_CLUSTER_SLAVE), id);
table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_CLUSTER_SLAVE_ID_CLUSTER), clusterSchema.getObjectId());
table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_CLUSTER_SLAVE_ID_SLAVE), slaveServer.getObjectId());
connectionDelegate.insertTableRow(KettleDatabaseRepository.TABLE_R_CLUSTER_SLAVE, table);
return id;
}
Aggregations