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);
}
}
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);
}
}
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);
}
}
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);
}
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);
}
Aggregations