Search in sources :

Example 46 with ObjectId

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

use of org.pentaho.di.repository.ObjectId 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)

Example 48 with ObjectId

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

the class KettleDatabaseRepositoryMetaStore method createNamespace.

@Override
public void createNamespace(String namespace) throws MetaStoreException, MetaStoreNamespaceExistsException {
    try {
        ObjectId namespaceId = delegate.getNamespaceId(namespace);
        if (namespaceId != null) {
            throw new MetaStoreNamespaceExistsException("Namespace with name '" + namespace + "' already exists");
        }
        // insert namespace into R_NAMESPACE
        // 
        delegate.insertNamespace(namespace);
        repository.commit();
    } catch (Exception e) {
        repository.rollback();
        throw new MetaStoreException(e);
    }
}
Also used : MetaStoreNamespaceExistsException(org.pentaho.metastore.api.exceptions.MetaStoreNamespaceExistsException) MetaStoreException(org.pentaho.metastore.api.exceptions.MetaStoreException) LongObjectId(org.pentaho.di.repository.LongObjectId) ObjectId(org.pentaho.di.repository.ObjectId) 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 49 with ObjectId

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

the class JobEntryJobTest method testConnectedLoad_RepByRef_Guess.

/**
 * When connected to the repository and {@link JobEntryJob} references a child job by {@link ObjectId},
 * guess {@link ObjectLocationSpecificationMethod} as {@code REPOSITORY_BY_REFERENCE}.
 * Load the job from the repository using the specified {@link ObjectId}.
 */
@Test
public void testConnectedLoad_RepByRef_Guess() throws Exception {
    Repository myrepo = mock(Repository.class);
    doReturn(true).when(myrepo).isConnected();
    doReturn(null).when(myrepo).getJobEntryAttributeString(any(ObjectId.class), anyString());
    doReturn(JOB_ENTRY_JOB_OBJECT_ID.toString()).when(myrepo).getJobEntryAttributeString(JOB_ENTRY_JOB_OBJECT_ID, "job_object_id");
    JobEntryJob jej = getJej();
    jej.loadRep(myrepo, store, JOB_ENTRY_JOB_OBJECT_ID, databases, servers);
    jej.getJobMeta(myrepo, store, space);
    assertEquals(ObjectLocationSpecificationMethod.REPOSITORY_BY_REFERENCE, jej.getSpecificationMethod());
    verify(myrepo, times(1)).loadJob(JOB_ENTRY_JOB_OBJECT_ID, null);
}
Also used : Repository(org.pentaho.di.repository.Repository) StringObjectId(org.pentaho.di.repository.StringObjectId) ObjectId(org.pentaho.di.repository.ObjectId) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 50 with ObjectId

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

the class JobEntryJobTest method testConnectedLoad_RepByRef.

/**
 * When connected to the repository and {@link JobEntryJob} references a child job by {@link ObjectId},
 * keep {@link ObjectLocationSpecificationMethod} as {@code REPOSITORY_BY_REFERENCE}.
 * Load the job from the repository using the specified {@link ObjectId}.
 */
@Test
public void testConnectedLoad_RepByRef() throws Exception {
    Repository myrepo = mock(Repository.class);
    doReturn(true).when(myrepo).isConnected();
    doReturn(null).when(myrepo).getJobEntryAttributeString(any(ObjectId.class), anyString());
    doReturn("rep_ref").when(myrepo).getJobEntryAttributeString(JOB_ENTRY_JOB_OBJECT_ID, "specification_method");
    doReturn(JOB_ENTRY_JOB_OBJECT_ID.toString()).when(myrepo).getJobEntryAttributeString(JOB_ENTRY_JOB_OBJECT_ID, "job_object_id");
    JobEntryJob jej = getJej();
    jej.loadRep(myrepo, store, JOB_ENTRY_JOB_OBJECT_ID, databases, servers);
    jej.getJobMeta(myrepo, store, space);
    assertEquals(ObjectLocationSpecificationMethod.REPOSITORY_BY_REFERENCE, jej.getSpecificationMethod());
    verify(myrepo, times(1)).loadJob(JOB_ENTRY_JOB_OBJECT_ID, null);
}
Also used : Repository(org.pentaho.di.repository.Repository) StringObjectId(org.pentaho.di.repository.StringObjectId) ObjectId(org.pentaho.di.repository.ObjectId) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

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