Search in sources :

Example 6 with LongObjectId

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

the class KettleDatabaseRepositoryTransDelegate method loadTransDependency.

public TransDependency loadTransDependency(ObjectId id_dependency, List<DatabaseMeta> databases) throws KettleException {
    TransDependency transDependency = new TransDependency();
    try {
        transDependency.setObjectId(id_dependency);
        RowMetaAndData r = getTransDependency(id_dependency);
        if (r != null) {
            long id_connection = r.getInteger("ID_DATABASE", 0);
            transDependency.setDatabase(DatabaseMeta.findDatabase(databases, new LongObjectId(id_connection)));
            transDependency.setTablename(r.getString("TABLE_NAME", null));
            transDependency.setFieldname(r.getString("FIELD_NAME", null));
        }
        return transDependency;
    } catch (KettleException dbe) {
        throw new KettleException(BaseMessages.getString(PKG, "TransDependency.Exception.UnableToLoadTransformationDependency") + id_dependency, dbe);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) RowMetaAndData(org.pentaho.di.core.RowMetaAndData) TransDependency(org.pentaho.di.trans.TransDependency) LongObjectId(org.pentaho.di.repository.LongObjectId)

Example 7 with LongObjectId

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

the class KettleDatabaseRepositoryTransDelegate method loadTransHopMeta.

public TransHopMeta loadTransHopMeta(ObjectId id_trans_hop, List<StepMeta> steps) throws KettleException {
    TransHopMeta hopTransMeta = new TransHopMeta();
    try {
        hopTransMeta.setObjectId(id_trans_hop);
        RowMetaAndData r = getTransHop(id_trans_hop);
        hopTransMeta.setEnabled(r.getBoolean("ENABLED", false));
        long id_step_from = r.getInteger("ID_STEP_FROM", 0);
        long id_step_to = r.getInteger("ID_STEP_TO", 0);
        StepMeta fromStep = StepMeta.findStep(steps, new LongObjectId(id_step_from));
        // 
        if (fromStep == null && id_step_from > 0) {
            // Simply load this, we only want the name, we don't care about the
            // rest...
            // 
            StepMeta stepMeta = repository.stepDelegate.loadStepMeta(new LongObjectId(id_step_from), new ArrayList<DatabaseMeta>(), new ArrayList<PartitionSchema>());
            fromStep = StepMeta.findStep(steps, stepMeta.getName());
        }
        if (fromStep == null) {
            log.logError("Unable to determine source step of transformation hop with ID: " + id_trans_hop);
            // Invalid hop, simply ignore. See: PDI-2446
            return null;
        }
        hopTransMeta.setFromStep(fromStep);
        hopTransMeta.getFromStep().setDraw(true);
        hopTransMeta.setToStep(StepMeta.findStep(steps, new LongObjectId(id_step_to)));
        // 
        if (hopTransMeta.getToStep() == null && id_step_to > 0) {
            // Simply load this, we only want the name, we don't care about
            // the rest...
            StepMeta stepMeta = repository.stepDelegate.loadStepMeta(new LongObjectId(id_step_to), new ArrayList<DatabaseMeta>(), new ArrayList<PartitionSchema>());
            hopTransMeta.setToStep(StepMeta.findStep(steps, stepMeta.getName()));
        }
        if (hopTransMeta.getFromStep() == null || hopTransMeta.getFromStep() == null) {
            // 
            return null;
        }
        hopTransMeta.getToStep().setDraw(true);
        return hopTransMeta;
    } catch (KettleDatabaseException dbe) {
        throw new KettleException(BaseMessages.getString(PKG, "TransHopMeta.Exception.LoadTransformationHopInfo") + id_trans_hop, dbe);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) RowMetaAndData(org.pentaho.di.core.RowMetaAndData) PartitionSchema(org.pentaho.di.partition.PartitionSchema) KettleDatabaseException(org.pentaho.di.core.exception.KettleDatabaseException) TransHopMeta(org.pentaho.di.trans.TransHopMeta) LongObjectId(org.pentaho.di.repository.LongObjectId) StepMeta(org.pentaho.di.trans.step.StepMeta) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta)

Example 8 with LongObjectId

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

the class KettleDatabaseRepositoryTransDelegate method getTransformationsWithIDList.

public String[] getTransformationsWithIDList(ObjectId[] ids) throws KettleException {
    String[] transList = new String[ids.length];
    for (int i = 0; i < ids.length; i++) {
        ObjectId id_transformation = ids[i];
        if (id_transformation != null) {
            RowMetaAndData transRow = getTransformation(id_transformation);
            if (transRow != null) {
                String transName = transRow.getString(KettleDatabaseRepository.FIELD_TRANSFORMATION_NAME, "<name not found>");
                long id_directory = transRow.getInteger(KettleDatabaseRepository.FIELD_TRANSFORMATION_ID_DIRECTORY, -1L);
                RepositoryDirectoryInterface dir = repository.loadRepositoryDirectoryTree().findDirectory(new LongObjectId(id_directory));
                transList[i] = dir.getPathObjectCombination(transName);
            }
        }
    }
    return transList;
}
Also used : RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) RowMetaAndData(org.pentaho.di.core.RowMetaAndData) LongObjectId(org.pentaho.di.repository.LongObjectId) ObjectId(org.pentaho.di.repository.ObjectId) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) LongObjectId(org.pentaho.di.repository.LongObjectId)

Example 9 with LongObjectId

use of org.pentaho.di.repository.LongObjectId 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 10 with LongObjectId

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

the class KettleDatabaseRepositoryMetaStore method updateElementType.

@Override
public void updateElementType(String namespace, IMetaStoreElementType elementType) throws MetaStoreException {
    try {
        ObjectId namespaceId = delegate.verifyNamespace(namespace);
        String elementTypeId = elementType.getId();
        if (elementTypeId == null) {
            IMetaStoreElementType type = getElementTypeByName(namespace, elementType.getName());
            if (type != null) {
                elementTypeId = type.getId();
            }
        }
        if (elementTypeId != null) {
            delegate.updateElementType(namespaceId, new LongObjectId(new StringObjectId(elementType.getId())), elementType);
            repository.commit();
        } else {
            throw new MetaStoreException("Unable to update element type: no id was provided and the name '" + elementType.getName() + "' didn't match");
        }
    } catch (MetaStoreException e) {
        throw e;
    } catch (Exception e) {
        repository.rollback();
        throw new MetaStoreException("Unable to update element type", e);
    }
}
Also used : MetaStoreException(org.pentaho.metastore.api.exceptions.MetaStoreException) IMetaStoreElementType(org.pentaho.metastore.api.IMetaStoreElementType) 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)

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