use of org.pentaho.di.repository.RepositoryObject in project pentaho-kettle by pentaho.
the class RepositoryBrowserController method populateFiles.
private void populateFiles(RepositoryDirectory repositoryDirectory, RepositoryDirectoryInterface repositoryDirectoryInterface, String filter) throws KettleException {
Date latestDate = null;
for (RepositoryObjectInterface repositoryObject : getRepositoryElements(repositoryDirectoryInterface)) {
org.pentaho.di.repository.RepositoryObject ro = (org.pentaho.di.repository.RepositoryObject) repositoryObject;
String extension = ro.getObjectType().getExtension();
if (!Util.isFiltered(extension, filter)) {
RepositoryFile repositoryFile = RepositoryFile.build(ro);
repositoryDirectory.addChild(repositoryFile);
}
if (latestDate == null || ro.getModifiedDate().after(latestDate)) {
latestDate = ro.getModifiedDate();
}
}
repositoryDirectory.setDate(latestDate);
}
use of org.pentaho.di.repository.RepositoryObject in project pentaho-kettle by pentaho.
the class RepositoryBrowserController method search.
public List<org.pentaho.repo.model.RepositoryObject> search(String path, String filter) {
RepositoryDirectoryInterface repositoryDirectoryInterface = findDirectory(path);
List<org.pentaho.repo.model.RepositoryObject> repositoryObjects = new ArrayList<>();
List<RepositoryObjectInterface> repositoryObjects1 = ((RepositoryExtended) getRepository()).getChildren(repositoryDirectoryInterface.getObjectId().getId(), filter);
for (RepositoryObjectInterface repositoryObject : repositoryObjects1) {
if (repositoryObject instanceof RepositoryDirectoryInterface) {
RepositoryDirectory repositoryDirectory = new RepositoryDirectory();
repositoryDirectory.setPath(path + "/" + repositoryObject.getName());
repositoryDirectory.setName(repositoryObject.getName());
repositoryDirectory.setObjectId(repositoryObject.getObjectId());
repositoryObjects.add(repositoryDirectory);
} else {
RepositoryFile repositoryFile = new RepositoryFile();
repositoryFile.setPath(path + "/" + repositoryObject.getName());
repositoryFile.setName(repositoryObject.getName());
repositoryFile.setType(((RepositoryObject) repositoryObject).getObjectType() == RepositoryObjectType.TRANSFORMATION ? TRANSFORMATION : JOB);
repositoryFile.setObjectId(repositoryObject.getObjectId());
repositoryObjects.add(repositoryFile);
}
}
return repositoryObjects;
}
use of org.pentaho.di.repository.RepositoryObject in project pentaho-kettle by pentaho.
the class RepositoryOpenSaveExtensionPoint method callExtensionPoint.
@Override
public void callExtensionPoint(LogChannelInterface logChannelInterface, Object o) throws KettleException {
FileDialogOperation fileDialogOperation = (FileDialogOperation) o;
PropsUI propsUI = propsUISupplier.get();
String startingDir = null;
if (fileDialogOperation.getRepository() == null) {
String username = getRepository().getUserInfo() != null ? getRepository().getUserInfo().getLogin() : "";
String repoAndUser = getRepository().getName() + ":" + username;
List<LastUsedFile> lastUsedFileList = propsUI.getLastUsedRepoFiles().getOrDefault(repoAndUser, Collections.emptyList());
startingDir = getStartingDir(fileDialogOperation, lastUsedFileList);
} else {
startingDir = fileDialogOperation.getStartDir();
}
RepositoryOpenSaveDialog repositoryOpenSaveDialog = new RepositoryOpenSaveDialog(spoonSupplier.get().getShell(), WIDTH, HEIGHT);
repositoryOpenSaveDialog.open(fileDialogOperation.getRepository(), startingDir, fileDialogOperation.getCommand(), fileDialogOperation.getTitle(), fileDialogOperation.getFilter(), fileDialogOperation.getOrigin(), fileDialogOperation.getFilename(), fileDialogOperation.getFileType());
if (!Utils.isEmpty(repositoryOpenSaveDialog.getObjectName())) {
RepositoryObject repositoryObject = new RepositoryObject();
repositoryObject.setObjectId(repositoryOpenSaveDialog::getObjectId);
repositoryObject.setName(repositoryOpenSaveDialog.getObjectName());
repositoryObject.setRepositoryDirectory(getRepository().findDirectory(repositoryOpenSaveDialog.getObjectDirectory()));
repositoryObject.setObjectType(repositoryOpenSaveDialog.getObjectType().equals(TRANSFORMATION) ? RepositoryObjectType.TRANSFORMATION : RepositoryObjectType.JOB);
fileDialogOperation.setRepositoryObject(repositoryObject);
}
}
use of org.pentaho.di.repository.RepositoryObject in project pentaho-kettle by pentaho.
the class SimpleMappingMeta method getXML.
public String getXML() {
StringBuilder retval = new StringBuilder(300);
retval.append(" ").append(XMLHandler.addTagValue("specification_method", specificationMethod == null ? null : specificationMethod.getCode()));
retval.append(" ").append(XMLHandler.addTagValue("trans_object_id", transObjectId == null ? null : transObjectId.toString()));
//
if (repository != null && transObjectId != null) {
try {
RepositoryObject objectInformation = repository.getObjectInformation(transObjectId, RepositoryObjectType.TRANSFORMATION);
if (objectInformation != null) {
transName = objectInformation.getName();
directoryPath = objectInformation.getRepositoryDirectory().getPath();
}
} catch (KettleException e) {
// Ignore object reference problems. It simply means that the reference is no longer valid.
}
}
retval.append(" ").append(XMLHandler.addTagValue("trans_name", transName));
retval.append(" ").append(XMLHandler.addTagValue("filename", fileName));
retval.append(" ").append(XMLHandler.addTagValue("directory_path", directoryPath));
retval.append(" ").append(XMLHandler.openTag("mappings")).append(Const.CR);
retval.append(" ").append(XMLHandler.openTag("input")).append(Const.CR);
retval.append(inputMapping.getXML());
retval.append(" ").append(XMLHandler.closeTag("input")).append(Const.CR);
retval.append(" ").append(XMLHandler.openTag("output")).append(Const.CR);
retval.append(outputMapping.getXML());
retval.append(" ").append(XMLHandler.closeTag("output")).append(Const.CR);
// Add the mapping parameters too
//
retval.append(" ").append(mappingParameters.getXML()).append(Const.CR);
retval.append(" ").append(XMLHandler.closeTag("mappings")).append(Const.CR);
return retval.toString();
}
use of org.pentaho.di.repository.RepositoryObject in project pentaho-kettle by pentaho.
the class Spoon method saveToRepository.
public boolean saveToRepository(EngineMetaInterface meta, boolean ask_name) throws KettleException {
if (log.isDetailed()) {
// "Save to repository..."
//
log.logDetailed(BaseMessages.getString(PKG, "Spoon.Log.SaveToRepository"));
}
if (rep != null) {
// If the repository directory is root then get the default save directory
if (meta.getRepositoryDirectory() == null || meta.getRepositoryDirectory().isRoot()) {
meta.setRepositoryDirectory(rep.getDefaultSaveDirectory(meta));
}
if (ask_name) {
try {
String fileType = meta.getFileType().equals(LastUsedFile.FILE_TYPE_TRANSFORMATION) ? FileDialogOperation.TRANSFORMATION : FileDialogOperation.JOB;
FileDialogOperation fileDialogOperation = new FileDialogOperation(FileDialogOperation.SAVE, FileDialogOperation.ORIGIN_SPOON);
fileDialogOperation.setFileType(fileType);
fileDialogOperation.setStartDir(meta.getRepositoryDirectory().getPath());
// Set the filename so it can be used as the default filename in the save dialog
fileDialogOperation.setFilename(meta.getFilename());
ExtensionPointHandler.callExtensionPoint(log, KettleExtensionPoint.SpoonOpenSaveRepository.id, fileDialogOperation);
if (fileDialogOperation.getRepositoryObject() != null) {
RepositoryObject repositoryObject = (RepositoryObject) fileDialogOperation.getRepositoryObject();
meta.setRepositoryDirectory(repositoryObject.getRepositoryDirectory());
meta.setName(repositoryObject.getName());
delegates.tabs.renameTabs();
return saveToRepositoryConfirmed(meta);
}
} catch (KettleException ke) {
// Ignore
}
} else {
return saveToRepositoryConfirmed(meta);
}
} else {
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
// "There is no repository connection available."
mb.setMessage(BaseMessages.getString(PKG, "Spoon.Dialog.NoRepositoryConnection.Message"));
// "No repository available."
mb.setText(BaseMessages.getString(PKG, "Spoon.Dialog.NoRepositoryConnection.Title"));
mb.open();
}
return false;
}
Aggregations