Search in sources :

Example 16 with RepositoryObject

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);
}
Also used : RepositoryObject(org.pentaho.di.repository.RepositoryObject) RepositoryObject(org.pentaho.di.repository.RepositoryObject) RepositoryFile(org.pentaho.repo.model.RepositoryFile) RepositoryObjectInterface(org.pentaho.di.repository.RepositoryObjectInterface) Date(java.util.Date)

Example 17 with RepositoryObject

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;
}
Also used : RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) RepositoryDirectory(org.pentaho.repo.model.RepositoryDirectory) RepositoryObject(org.pentaho.di.repository.RepositoryObject) ArrayList(java.util.ArrayList) RepositoryExtended(org.pentaho.di.repository.RepositoryExtended) RepositoryFile(org.pentaho.repo.model.RepositoryFile) RepositoryObjectInterface(org.pentaho.di.repository.RepositoryObjectInterface)

Example 18 with RepositoryObject

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);
    }
}
Also used : RepositoryObject(org.pentaho.di.repository.RepositoryObject) RepositoryOpenSaveDialog(org.pentaho.repo.dialog.RepositoryOpenSaveDialog) LastUsedFile(org.pentaho.di.core.LastUsedFile) FileDialogOperation(org.pentaho.di.ui.core.FileDialogOperation) PropsUI(org.pentaho.di.ui.core.PropsUI)

Example 19 with 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();
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) RepositoryObject(org.pentaho.di.repository.RepositoryObject)

Example 20 with RepositoryObject

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;
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) RepositoryObject(org.pentaho.di.repository.RepositoryObject) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) FileDialogOperation(org.pentaho.di.ui.core.FileDialogOperation) MessageBox(org.eclipse.swt.widgets.MessageBox)

Aggregations

RepositoryObject (org.pentaho.di.repository.RepositoryObject)46 KettleException (org.pentaho.di.core.exception.KettleException)31 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)15 RepositoryDirectoryInterface (org.pentaho.di.repository.RepositoryDirectoryInterface)11 StringObjectId (org.pentaho.di.repository.StringObjectId)9 ObjectId (org.pentaho.di.repository.ObjectId)7 ArrayList (java.util.ArrayList)6 Date (java.util.Date)6 Test (org.junit.Test)6 KettleFileException (org.pentaho.di.core.exception.KettleFileException)5 RepositoryElementMetaInterface (org.pentaho.di.repository.RepositoryElementMetaInterface)5 IOException (java.io.IOException)4 FileSystemException (org.apache.commons.vfs2.FileSystemException)4 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)4 FileDialogOperation (org.pentaho.di.ui.core.FileDialogOperation)4 FileObject (org.apache.commons.vfs2.FileObject)3 RowMetaAndData (org.pentaho.di.core.RowMetaAndData)3 RepositoryObjectInterface (org.pentaho.di.repository.RepositoryObjectInterface)3 Serializable (java.io.Serializable)2 List (java.util.List)2