Search in sources :

Example 76 with ObjectId

use of org.pentaho.di.repository.ObjectId in project pentaho-kettle by pentaho.

the class RepositoryExplorerDialog method exportTransformations.

public void exportTransformations(RepositoryDirectoryInterface root) {
    try {
        DirectoryDialog dialog = new DirectoryDialog(shell, SWT.OPEN);
        if (dialog.open() != null) {
            String directory = dialog.getFilterPath();
            ObjectId[] dirids = ((root == null) ? directoryTree : root).getDirectoryIDs();
            for (int d = 0; d < dirids.length; d++) {
                RepositoryDirectoryInterface repdir = directoryTree.findDirectory(dirids[d]);
                String[] trans = rep.getTransformationNames(dirids[d], false);
                // See if the directory exists...
                File dir = new File(directory + repdir.getPath());
                if (!dir.exists()) {
                    dir.mkdir();
                    log.logBasic("Exporting transformation", "Created directory [" + dir.getName() + "]");
                }
                for (int i = 0; i < trans.length; i++) {
                    // reads last version
                    TransMeta ti = rep.loadTransformation(trans[i], repdir, null, true, null);
                    if (log.isBasic()) {
                        log.logBasic("Exporting transformation", "[" + trans[i] + "] in directory [" + repdir.getPath() + "]");
                    }
                    String xml = XMLHandler.getXMLHeader() + ti.getXML();
                    String filename = directory + repdir.getPath() + Const.FILE_SEPARATOR + fixFileName(trans[i]) + ".ktr";
                    File f = new File(filename);
                    try {
                        FileOutputStream fos = new FileOutputStream(f);
                        fos.write(xml.getBytes(Const.XML_ENCODING));
                        fos.close();
                    } catch (IOException e) {
                        throw new RuntimeException("Exporting transformation: Couldn't create file [" + filename + "]", e);
                    }
                }
            }
        }
    } catch (Exception e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "RepositoryExplorerDialog.ExportTrans.UnexpectedError.Title"), BaseMessages.getString(PKG, "RepositoryExplorerDialog.ExportTrans.UnexpectedError.Message"), e);
    }
}
Also used : RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) ObjectId(org.pentaho.di.repository.ObjectId) TransMeta(org.pentaho.di.trans.TransMeta) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) IOException(java.io.IOException) IOException(java.io.IOException) KettleException(org.pentaho.di.core.exception.KettleException) FileOutputStream(java.io.FileOutputStream) File(java.io.File) DirectoryDialog(org.eclipse.swt.widgets.DirectoryDialog)

Example 77 with ObjectId

use of org.pentaho.di.repository.ObjectId in project pentaho-kettle by pentaho.

the class RepositoryExplorerDialog method newDatabase.

public void newDatabase() {
    try {
        DatabaseMeta databaseMeta = new DatabaseMeta();
        databaseMeta.initializeVariablesFrom(null);
        getDatabaseDialog().setDatabaseMeta(databaseMeta);
        String name = getDatabaseDialog().open();
        if (name != null) {
            // See if this user already exists...
            ObjectId idDatabase = rep.getDatabaseID(name);
            if (idDatabase == null) {
                rep.insertLogEntry("Creating new database '" + databaseMeta.getName() + "'");
                rep.save(databaseMeta, Const.VERSION_COMMENT_INITIAL_VERSION, null);
            } else {
                MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
                mb.setMessage(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Connection.Create.AlreadyExists.Message"));
                mb.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Connection.Create.AlreadyExists.Title"));
                mb.open();
            }
            // Refresh tree...
            refreshTree();
        }
    } catch (KettleException e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "RepositoryExplorerDialog.Connection.Create.UnexpectedError.Title"), BaseMessages.getString(PKG, "RepositoryExplorerDialog.Connection.Create.UnexpectedError.Message"), e);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) ObjectId(org.pentaho.di.repository.ObjectId) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 78 with ObjectId

use of org.pentaho.di.repository.ObjectId in project pentaho-kettle by pentaho.

the class JsonInputMetaTest method verifyReadingRepoSetsAcceptFilenames.

@Test
public void verifyReadingRepoSetsAcceptFilenames() throws Exception {
    ObjectId objectId = () -> "id";
    when(repository.getStepAttributeBoolean(objectId, "IsInFields")).thenReturn(true);
    jsonInputMeta.readRep(repository, null, objectId, null);
    assertTrue(jsonInputMeta.isInFields());
    assertTrue(jsonInputMeta.inputFiles.acceptingFilenames);
}
Also used : ObjectId(org.pentaho.di.repository.ObjectId) Test(org.junit.Test)

Example 79 with ObjectId

use of org.pentaho.di.repository.ObjectId in project pentaho-kettle by pentaho.

the class PurRepository method deleteDatabaseMeta.

@Override
public void deleteDatabaseMeta(final String databaseName) throws KettleException {
    RepositoryFile fileToDelete = null;
    ObjectId idDatabase = null;
    try {
        readWriteLock.writeLock().lock();
        try {
            fileToDelete = pur.getFile(getPath(databaseName, null, RepositoryObjectType.DATABASE));
            idDatabase = new StringObjectId(fileToDelete.getId().toString());
            permanentlyDeleteSharedObject(idDatabase);
            removeFromSharedObjectCache(RepositoryObjectType.DATABASE, idDatabase);
        } finally {
            readWriteLock.writeLock().unlock();
        }
    } catch (Exception e) {
        throw new KettleException("Unable to delete database with name [" + databaseName + "]", e);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) StringObjectId(org.pentaho.di.repository.StringObjectId) ObjectId(org.pentaho.di.repository.ObjectId) RepositoryFile(org.pentaho.platform.api.repository2.unified.RepositoryFile) StringObjectId(org.pentaho.di.repository.StringObjectId) MetaStoreException(org.pentaho.metastore.api.exceptions.MetaStoreException) UnifiedRepositoryCreateFileException(org.pentaho.platform.api.repository2.unified.UnifiedRepositoryCreateFileException) UnifiedRepositoryUpdateFileException(org.pentaho.platform.api.repository2.unified.UnifiedRepositoryUpdateFileException) IdNotFoundException(org.pentaho.di.core.exception.IdNotFoundException) URISyntaxException(java.net.URISyntaxException) MetaStoreNamespaceExistsException(org.pentaho.metastore.api.exceptions.MetaStoreNamespaceExistsException) KettleFileException(org.pentaho.di.core.exception.KettleFileException) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) KettleException(org.pentaho.di.core.exception.KettleException) KettleSecurityException(org.pentaho.di.core.exception.KettleSecurityException)

Example 80 with ObjectId

use of org.pentaho.di.repository.ObjectId in project pentaho-kettle by pentaho.

the class PurRepository method getDatabaseID.

@Override
public ObjectId getDatabaseID(final String name) throws KettleException {
    try {
        ObjectId objectId = getObjectId(name, null, RepositoryObjectType.DATABASE, false);
        if (objectId == null) {
            List<RepositoryFile> allDatabases = getAllFilesOfType(null, RepositoryObjectType.DATABASE, false);
            String[] existingNames = new String[allDatabases.size()];
            for (int i = 0; i < allDatabases.size(); i++) {
                RepositoryFile file = allDatabases.get(i);
                existingNames[i] = file.getTitle();
            }
            int index = DatabaseMeta.indexOfName(existingNames, name);
            if (index != -1) {
                return new StringObjectId(allDatabases.get(index).getId().toString());
            }
        }
        return objectId;
    } catch (Exception e) {
        throw new KettleException("Unable to get ID for database [" + name + "]", e);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) StringObjectId(org.pentaho.di.repository.StringObjectId) ObjectId(org.pentaho.di.repository.ObjectId) RepositoryFile(org.pentaho.platform.api.repository2.unified.RepositoryFile) StringObjectId(org.pentaho.di.repository.StringObjectId) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint) MetaStoreException(org.pentaho.metastore.api.exceptions.MetaStoreException) UnifiedRepositoryCreateFileException(org.pentaho.platform.api.repository2.unified.UnifiedRepositoryCreateFileException) UnifiedRepositoryUpdateFileException(org.pentaho.platform.api.repository2.unified.UnifiedRepositoryUpdateFileException) IdNotFoundException(org.pentaho.di.core.exception.IdNotFoundException) URISyntaxException(java.net.URISyntaxException) MetaStoreNamespaceExistsException(org.pentaho.metastore.api.exceptions.MetaStoreNamespaceExistsException) KettleFileException(org.pentaho.di.core.exception.KettleFileException) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) KettleException(org.pentaho.di.core.exception.KettleException) KettleSecurityException(org.pentaho.di.core.exception.KettleSecurityException)

Aggregations

ObjectId (org.pentaho.di.repository.ObjectId)233 KettleException (org.pentaho.di.core.exception.KettleException)94 LongObjectId (org.pentaho.di.repository.LongObjectId)76 StringObjectId (org.pentaho.di.repository.StringObjectId)76 RowMetaAndData (org.pentaho.di.core.RowMetaAndData)49 RepositoryDirectoryInterface (org.pentaho.di.repository.RepositoryDirectoryInterface)38 Test (org.junit.Test)37 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)37 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)34 ValueMetaInteger (org.pentaho.di.core.row.value.ValueMetaInteger)33 ArrayList (java.util.ArrayList)30 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)29 MessageBox (org.eclipse.swt.widgets.MessageBox)26 Repository (org.pentaho.di.repository.Repository)18 RepositoryFile (org.pentaho.platform.api.repository2.unified.RepositoryFile)18 SlaveServer (org.pentaho.di.cluster.SlaveServer)15 KettleDatabaseException (org.pentaho.di.core.exception.KettleDatabaseException)14 PartitionSchema (org.pentaho.di.partition.PartitionSchema)14 Matchers.anyString (org.mockito.Matchers.anyString)13 MetaStoreException (org.pentaho.metastore.api.exceptions.MetaStoreException)13