Search in sources :

Example 11 with LongObjectId

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

the class KettleDatabaseRepositoryMetaStore method getElementByName.

@Override
public IMetaStoreElement getElementByName(String namespace, IMetaStoreElementType elementType, String name) throws MetaStoreException {
    try {
        LongObjectId namespaceId = delegate.getNamespaceId(namespace);
        if (namespaceId == null) {
            return null;
        }
        LongObjectId elementTypeId = delegate.getElementTypeId(namespaceId, elementType.getName());
        if (elementTypeId == null) {
            return null;
        }
        LongObjectId elementId = delegate.getElementId(elementTypeId, name);
        if (elementId == null) {
            return null;
        }
        RowMetaAndData elementRow = delegate.getElement(elementId);
        if (elementRow == null) {
            return null;
        }
        return delegate.parseElement(elementType, elementRow);
    } catch (Exception e) {
        throw new MetaStoreException("Unable to get element by name '" + name + "' from namespace '" + namespace + "'", e);
    }
}
Also used : MetaStoreException(org.pentaho.metastore.api.exceptions.MetaStoreException) RowMetaAndData(org.pentaho.di.core.RowMetaAndData) LongObjectId(org.pentaho.di.repository.LongObjectId) MetaStoreNamespaceExistsException(org.pentaho.metastore.api.exceptions.MetaStoreNamespaceExistsException) MetaStoreException(org.pentaho.metastore.api.exceptions.MetaStoreException) MetaStoreDependenciesExistsException(org.pentaho.metastore.api.exceptions.MetaStoreDependenciesExistsException) MetaStoreElementExistException(org.pentaho.metastore.api.exceptions.MetaStoreElementExistException) MetaStoreElementTypeExistsException(org.pentaho.metastore.api.exceptions.MetaStoreElementTypeExistsException)

Example 12 with LongObjectId

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

the class KettleDatabaseRepositoryMetaStore method getElementType.

@Override
public IMetaStoreElementType getElementType(String namespace, String elementTypeId) throws MetaStoreException {
    try {
        ObjectId namespaceId = delegate.getNamespaceId(namespace);
        if (namespaceId == null) {
            return null;
        }
        RowMetaAndData elementTypeRow = delegate.getElementType(new LongObjectId(new StringObjectId(elementTypeId)));
        return delegate.parseElementType(namespace, namespaceId, elementTypeRow);
    } catch (Exception e) {
        throw new MetaStoreException("Unable to get element type with id '" + elementTypeId + "' in namespace '" + namespace + "'", e);
    }
}
Also used : MetaStoreException(org.pentaho.metastore.api.exceptions.MetaStoreException) RowMetaAndData(org.pentaho.di.core.RowMetaAndData) LongObjectId(org.pentaho.di.repository.LongObjectId) ObjectId(org.pentaho.di.repository.ObjectId) StringObjectId(org.pentaho.di.repository.StringObjectId) LongObjectId(org.pentaho.di.repository.LongObjectId) StringObjectId(org.pentaho.di.repository.StringObjectId) MetaStoreNamespaceExistsException(org.pentaho.metastore.api.exceptions.MetaStoreNamespaceExistsException) MetaStoreException(org.pentaho.metastore.api.exceptions.MetaStoreException) MetaStoreDependenciesExistsException(org.pentaho.metastore.api.exceptions.MetaStoreDependenciesExistsException) MetaStoreElementExistException(org.pentaho.metastore.api.exceptions.MetaStoreElementExistException) MetaStoreElementTypeExistsException(org.pentaho.metastore.api.exceptions.MetaStoreElementTypeExistsException)

Example 13 with LongObjectId

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

the class KettleDatabaseRepositoryConditionDelegate method lookupValue.

public synchronized ObjectId lookupValue(String name, String type, String value_str, boolean isnull) throws KettleException {
    RowMetaAndData table = new RowMetaAndData();
    table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_VALUE_NAME), name);
    table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_VALUE_VALUE_TYPE), type);
    table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_VALUE_VALUE_STR), value_str);
    table.addValue(new ValueMetaBoolean(KettleDatabaseRepository.FIELD_VALUE_IS_NULL), Boolean.valueOf(isnull));
    String sql = "SELECT " + quote(KettleDatabaseRepository.FIELD_VALUE_ID_VALUE) + " FROM " + quoteTable(KettleDatabaseRepository.TABLE_R_VALUE) + " ";
    sql += "WHERE " + quote(KettleDatabaseRepository.FIELD_VALUE_NAME) + "       = ? ";
    sql += "AND   " + quote(KettleDatabaseRepository.FIELD_VALUE_VALUE_TYPE) + " = ? ";
    sql += "AND   " + quote(KettleDatabaseRepository.FIELD_VALUE_VALUE_STR) + "  = ? ";
    sql += "AND   " + quote(KettleDatabaseRepository.FIELD_VALUE_IS_NULL) + "    = ? ";
    RowMetaAndData result = repository.connectionDelegate.getOneRow(sql, table.getRowMeta(), table.getData());
    if (result != null && result.getData() != null && result.isNumeric(0)) {
        return new LongObjectId(result.getInteger(0, 0L));
    } else {
        return null;
    }
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) RowMetaAndData(org.pentaho.di.core.RowMetaAndData) ValueMetaBoolean(org.pentaho.di.core.row.value.ValueMetaBoolean) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) LongObjectId(org.pentaho.di.repository.LongObjectId)

Example 14 with LongObjectId

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

the class KettleDatabaseRepositoryConnectionDelegate method getTransAttributes.

public synchronized List<Object[]> getTransAttributes(ObjectId id_transformation, String code, long nr) throws KettleException {
    String sql = "SELECT *" + " FROM " + databaseMeta.getQuotedSchemaTableCombination(null, KettleDatabaseRepository.TABLE_R_TRANS_ATTRIBUTE) + " WHERE " + quote(KettleDatabaseRepository.FIELD_TRANS_ATTRIBUTE_ID_TRANSFORMATION) + " = ? AND " + quote(KettleDatabaseRepository.FIELD_TRANS_ATTRIBUTE_CODE) + " = ? AND " + quote(KettleDatabaseRepository.FIELD_TRANS_ATTRIBUTE_NR) + " = ?" + " ORDER BY " + quote(KettleDatabaseRepository.FIELD_TRANS_ATTRIBUTE_VALUE_NUM);
    RowMetaAndData table = new RowMetaAndData();
    table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_TRANS_ATTRIBUTE_ID_TRANSFORMATION), new LongObjectId(id_transformation));
    table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_TRANS_ATTRIBUTE_CODE), code);
    table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_TRANS_ATTRIBUTE_NR), new Long(nr));
    return callRead(() -> database.getRows(sql, table.getRowMeta(), table.getData(), ResultSet.FETCH_FORWARD, false, 0, null));
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) RowMetaAndData(org.pentaho.di.core.RowMetaAndData) ValueMetaInteger(org.pentaho.di.core.row.value.ValueMetaInteger) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) LongObjectId(org.pentaho.di.repository.LongObjectId)

Example 15 with LongObjectId

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

the class KettleDatabaseRepositoryConnectionDelegate method getIDWithValue.

public synchronized ObjectId getIDWithValue(String tablename, String idfield, String lookupfield, String value, String lookupkey, ObjectId key) throws KettleException {
    RowMetaAndData par = new RowMetaAndData();
    par.addValue(new ValueMetaString("value"), value);
    par.addValue(new ValueMetaInteger("key"), new LongObjectId(key));
    RowMetaAndData result = getOneRow("SELECT " + idfield + " FROM " + tablename + " WHERE " + lookupfield + " = ? AND " + lookupkey + " = ?", par.getRowMeta(), par.getData());
    if (result != null && result.getRowMeta() != null && result.getData() != null && result.isNumeric(0)) {
        return new LongObjectId(result.getInteger(0, 0));
    }
    return null;
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) RowMetaAndData(org.pentaho.di.core.RowMetaAndData) ValueMetaInteger(org.pentaho.di.core.row.value.ValueMetaInteger) LongObjectId(org.pentaho.di.repository.LongObjectId)

Aggregations

LongObjectId (org.pentaho.di.repository.LongObjectId)81 RowMetaAndData (org.pentaho.di.core.RowMetaAndData)54 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)36 ObjectId (org.pentaho.di.repository.ObjectId)30 KettleException (org.pentaho.di.core.exception.KettleException)18 Test (org.junit.Test)17 ValueMetaInteger (org.pentaho.di.core.row.value.ValueMetaInteger)17 KettleDatabaseException (org.pentaho.di.core.exception.KettleDatabaseException)14 Matchers.anyString (org.mockito.Matchers.anyString)10 MetaStoreException (org.pentaho.metastore.api.exceptions.MetaStoreException)10 ArrayList (java.util.ArrayList)9 RepositoryDirectory (org.pentaho.di.repository.RepositoryDirectory)9 RepositoryObject (org.pentaho.di.repository.RepositoryObject)8 MetaStoreDependenciesExistsException (org.pentaho.metastore.api.exceptions.MetaStoreDependenciesExistsException)8 MetaStoreElementExistException (org.pentaho.metastore.api.exceptions.MetaStoreElementExistException)8 MetaStoreElementTypeExistsException (org.pentaho.metastore.api.exceptions.MetaStoreElementTypeExistsException)8 MetaStoreNamespaceExistsException (org.pentaho.metastore.api.exceptions.MetaStoreNamespaceExistsException)8 SimpleLoggingObject (org.pentaho.di.core.logging.SimpleLoggingObject)7 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)7 StringObjectId (org.pentaho.di.repository.StringObjectId)7