Search in sources :

Example 31 with RowMetaAndData

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

the class KettleDatabaseRepositoryTransDelegate method insertDependency.

private synchronized ObjectId insertDependency(ObjectId id_transformation, ObjectId id_database, String tablename, String fieldname) throws KettleException {
    ObjectId id = repository.connectionDelegate.getNextDepencencyID();
    RowMetaAndData table = new RowMetaAndData();
    table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_DEPENDENCY_ID_DEPENDENCY), id);
    table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_DEPENDENCY_ID_TRANSFORMATION), id_transformation);
    table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_DEPENDENCY_ID_DATABASE), id_database);
    table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_DEPENDENCY_TABLE_NAME), tablename);
    table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_DEPENDENCY_FIELD_NAME), fieldname);
    repository.connectionDelegate.getDatabase().prepareInsert(table.getRowMeta(), KettleDatabaseRepository.TABLE_R_DEPENDENCY);
    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)

Example 32 with RowMetaAndData

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

the class KettleDatabaseRepositoryUserDelegate method loadUserInfo.

// Load user with login from repository, don't verify password...
public IUser loadUserInfo(IUser userInfo, String login) throws KettleException {
    try {
        userInfo.setObjectId(getUserID(login));
        if (userInfo.getObjectId() != null) {
            RowMetaAndData r = getUser(userInfo.getObjectId());
            if (r != null) {
                userInfo.setLogin(r.getString("LOGIN", null));
                userInfo.setPassword(Encr.decryptPassword(r.getString("PASSWORD", null)));
                userInfo.setUsername(r.getString("NAME", null));
                userInfo.setDescription(r.getString("DESCRIPTION", null));
                userInfo.setEnabled(r.getBoolean("ENABLED", false));
                return userInfo;
            } else {
                throw new KettleDatabaseException(BaseMessages.getString(PKG, "UserInfo.Error.UserNotFound", login));
            }
        } else {
            throw new KettleDatabaseException(BaseMessages.getString(PKG, "UserInfo.Error.UserNotFound", login));
        }
    } catch (KettleDatabaseException dbe) {
        throw new KettleException(BaseMessages.getString(PKG, "UserInfo.Error.UserNotLoaded", login, ""), dbe);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) RowMetaAndData(org.pentaho.di.core.RowMetaAndData) KettleDatabaseException(org.pentaho.di.core.exception.KettleDatabaseException)

Example 33 with RowMetaAndData

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

the class KettleDatabaseRepositoryMetaStore method getElements.

@Override
public List<IMetaStoreElement> getElements(String namespace, IMetaStoreElementType elementType) throws MetaStoreException {
    try {
        IMetaStoreElementType type = getElementTypeByName(namespace, elementType.getName());
        if (type == null) {
            return new ArrayList<IMetaStoreElement>();
        }
        Collection<RowMetaAndData> elementRows = delegate.getElements(new LongObjectId(new StringObjectId(type.getId())));
        List<IMetaStoreElement> elements = new ArrayList<IMetaStoreElement>();
        for (RowMetaAndData elementRow : elementRows) {
            IMetaStoreElement element = delegate.parseElement(elementType, elementRow);
            elements.add(element);
        }
        return elements;
    } catch (Exception e) {
        throw new MetaStoreException("Unable to get list of elements from namespace '" + namespace + "' and for element type '" + elementType.getName() + "'", e);
    }
}
Also used : MetaStoreException(org.pentaho.metastore.api.exceptions.MetaStoreException) IMetaStoreElementType(org.pentaho.metastore.api.IMetaStoreElementType) RowMetaAndData(org.pentaho.di.core.RowMetaAndData) ArrayList(java.util.ArrayList) IMetaStoreElement(org.pentaho.metastore.api.IMetaStoreElement) 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 34 with RowMetaAndData

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

the class KettleDatabaseRepositoryMetaStore method getNamespaces.

// Handle namespaces...
@Override
public List<String> getNamespaces() throws MetaStoreException {
    try {
        List<String> namespaces = new ArrayList<String>();
        Collection<RowMetaAndData> namespaceRows = delegate.getNamespaces();
        for (RowMetaAndData namespaceRow : namespaceRows) {
            String namespace = namespaceRow.getString(KettleDatabaseRepository.FIELD_NAMESPACE_NAME, null);
            if (!Utils.isEmpty(namespace)) {
                namespaces.add(namespace);
            }
        }
        return namespaces;
    } catch (Exception e) {
        throw new MetaStoreException(e);
    }
}
Also used : MetaStoreException(org.pentaho.metastore.api.exceptions.MetaStoreException) RowMetaAndData(org.pentaho.di.core.RowMetaAndData) ArrayList(java.util.ArrayList) 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 35 with RowMetaAndData

use of org.pentaho.di.core.RowMetaAndData 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)

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