Search in sources :

Example 61 with RowMetaAndData

use of org.pentaho.di.core.RowMetaAndData in project pentaho-kettle by pentaho.

the class KettleDatabaseRepositoryDatabaseDelegate method getNrDatabases.

public synchronized int getNrDatabases() throws KettleException {
    int retval = 0;
    String sql = "SELECT COUNT(*) FROM " + quoteTable(KettleDatabaseRepository.TABLE_R_DATABASE);
    RowMetaAndData r = repository.connectionDelegate.getOneRow(sql);
    if (r != null) {
        retval = (int) r.getInteger(0, 0L);
    }
    return retval;
}
Also used : RowMetaAndData(org.pentaho.di.core.RowMetaAndData) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString)

Example 62 with RowMetaAndData

use of org.pentaho.di.core.RowMetaAndData in project pentaho-kettle by pentaho.

the class KettleDatabaseRepositoryDatabaseDelegate method createAttributeRow.

private RowMetaAndData createAttributeRow(ObjectId idDatabase, String code, String strValue) throws KettleException {
    ObjectId id = repository.connectionDelegate.getNextDatabaseAttributeID();
    RowMetaAndData table = new RowMetaAndData();
    table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_DATABASE_ATTRIBUTE_ID_DATABASE_ATTRIBUTE), id);
    table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_DATABASE_ATTRIBUTE_ID_DATABASE), idDatabase);
    table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_DATABASE_ATTRIBUTE_CODE), code);
    table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_DATABASE_ATTRIBUTE_VALUE_STR), strValue);
    return table;
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) RowMetaAndData(org.pentaho.di.core.RowMetaAndData) LongObjectId(org.pentaho.di.repository.LongObjectId) ObjectId(org.pentaho.di.repository.ObjectId) ValueMetaInteger(org.pentaho.di.core.row.value.ValueMetaInteger)

Example 63 with RowMetaAndData

use of org.pentaho.di.core.RowMetaAndData in project pentaho-kettle by pentaho.

the class KettleDatabaseRepositoryDirectoryDelegate method insertDirectory.

/*
   * public synchronized RepositoryDirectory refreshRepositoryDirectoryTree() throws KettleException { try {
   * RepositoryDirectory tree = new RepositoryDirectory(); loadRepositoryDirectory(tree, tree.getID());
   * repository.setDirectoryTree(tree); return tree; } catch (KettleException e) { repository.setDirectoryTree( new
   * RepositoryDirectory() ); throw new KettleException("Unable to read the directory tree from the repository!", e); }
   * }
   */
private synchronized ObjectId insertDirectory(ObjectId id_directory_parent, RepositoryDirectoryInterface dir) throws KettleException {
    ObjectId id = repository.connectionDelegate.getNextDirectoryID();
    String tablename = KettleDatabaseRepository.TABLE_R_DIRECTORY;
    RowMetaAndData table = new RowMetaAndData();
    table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_DIRECTORY_ID_DIRECTORY), id);
    table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_DIRECTORY_ID_DIRECTORY_PARENT), id_directory_parent);
    table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_DIRECTORY_DIRECTORY_NAME), dir.getName());
    repository.connectionDelegate.getDatabase().prepareInsert(table.getRowMeta(), tablename);
    repository.connectionDelegate.getDatabase().setValuesInsert(table);
    repository.connectionDelegate.getDatabase().insertRow();
    repository.connectionDelegate.getDatabase().closeInsert();
    return id;
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) RowMetaAndData(org.pentaho.di.core.RowMetaAndData) LongObjectId(org.pentaho.di.repository.LongObjectId) ObjectId(org.pentaho.di.repository.ObjectId) ValueMetaInteger(org.pentaho.di.core.row.value.ValueMetaInteger) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString)

Example 64 with RowMetaAndData

use of org.pentaho.di.core.RowMetaAndData in project pentaho-kettle by pentaho.

the class KettleDatabaseRepositoryDirectoryDelegate method loadPathToRoot.

public RepositoryDirectoryInterface loadPathToRoot(ObjectId id_directory) throws KettleException {
    List<RepositoryDirectory> path = new ArrayList<>();
    ObjectId directoryId = id_directory;
    RowMetaAndData directoryRow = getDirectory(directoryId);
    Long parentId = directoryRow.getInteger(1);
    // 
    while (parentId != null && parentId >= 0) {
        RepositoryDirectory directory = new RepositoryDirectory();
        // Name of the directory
        directory.setName(directoryRow.getString(2, null));
        directory.setObjectId(directoryId);
        path.add(directory);
        // System.out.println( "+ dir '" + directory.getName() + "'" );
        directoryId = new LongObjectId(parentId);
        directoryRow = getDirectory(directoryId);
        parentId = directoryRow.getInteger(KettleDatabaseRepository.FIELD_DIRECTORY_ID_DIRECTORY_PARENT);
    }
    RepositoryDirectory root = new RepositoryDirectory();
    root.setObjectId(new LongObjectId(0));
    path.add(root);
    // 
    for (int i = 0; i < path.size() - 1; i++) {
        RepositoryDirectory item = path.get(i);
        RepositoryDirectory parent = path.get(i + 1);
        item.setParent(parent);
        parent.addSubdirectory(item);
    }
    RepositoryDirectory repositoryDirectory = path.get(0);
    return repositoryDirectory;
}
Also used : RepositoryDirectory(org.pentaho.di.repository.RepositoryDirectory) RowMetaAndData(org.pentaho.di.core.RowMetaAndData) LongObjectId(org.pentaho.di.repository.LongObjectId) ObjectId(org.pentaho.di.repository.ObjectId) ArrayList(java.util.ArrayList) LongObjectId(org.pentaho.di.repository.LongObjectId)

Example 65 with RowMetaAndData

use of org.pentaho.di.core.RowMetaAndData in project pentaho-kettle by pentaho.

the class KettleDatabaseRepositoryDirectoryDelegate method loadRepositoryDirectory.

public void loadRepositoryDirectory(RepositoryDirectory repositoryDirectory, ObjectId id_directory) throws KettleException {
    if (id_directory == null) {
        // This is the root directory, id = OL
        id_directory = new LongObjectId(0L);
    }
    try {
        RowMetaAndData row = getDirectory(id_directory);
        if (row != null) {
            repositoryDirectory.setObjectId(id_directory);
            // Content?
            // 
            repositoryDirectory.setName(row.getString("DIRECTORY_NAME", null));
            // The sub-directories?
            // 
            ObjectId[] subids = repository.getSubDirectoryIDs(repositoryDirectory.getObjectId());
            for (int i = 0; i < subids.length; i++) {
                RepositoryDirectory subdir = new RepositoryDirectory();
                loadRepositoryDirectory(subdir, subids[i]);
                repositoryDirectory.addSubdirectory(subdir);
            }
        }
    } catch (Exception e) {
        throw new KettleException(BaseMessages.getString(PKG, "Repository.LoadRepositoryDirectory.ErrorLoading.Exception"), e);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) RowMetaAndData(org.pentaho.di.core.RowMetaAndData) RepositoryDirectory(org.pentaho.di.repository.RepositoryDirectory) LongObjectId(org.pentaho.di.repository.LongObjectId) ObjectId(org.pentaho.di.repository.ObjectId) LongObjectId(org.pentaho.di.repository.LongObjectId) KettleException(org.pentaho.di.core.exception.KettleException)

Aggregations

RowMetaAndData (org.pentaho.di.core.RowMetaAndData)563 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)225 ArrayList (java.util.ArrayList)172 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)145 TransMeta (org.pentaho.di.trans.TransMeta)116 Test (org.junit.Test)108 ValueMetaInteger (org.pentaho.di.core.row.value.ValueMetaInteger)94 KettleException (org.pentaho.di.core.exception.KettleException)89 StepMeta (org.pentaho.di.trans.step.StepMeta)80 LongObjectId (org.pentaho.di.repository.LongObjectId)75 StepInterface (org.pentaho.di.trans.step.StepInterface)75 RowStepCollector (org.pentaho.di.trans.RowStepCollector)73 Trans (org.pentaho.di.trans.Trans)73 PluginRegistry (org.pentaho.di.core.plugins.PluginRegistry)71 TransHopMeta (org.pentaho.di.trans.TransHopMeta)71 KettleValueException (org.pentaho.di.core.exception.KettleValueException)58 RowProducer (org.pentaho.di.trans.RowProducer)56 DummyTransMeta (org.pentaho.di.trans.steps.dummytrans.DummyTransMeta)54 KettleDatabaseException (org.pentaho.di.core.exception.KettleDatabaseException)53 RowMeta (org.pentaho.di.core.row.RowMeta)51