use of org.pentaho.di.repository.RepositoryElementMetaInterface in project pentaho-kettle by pentaho.
the class ConnectionsController method refreshConnectionList.
// package-local visibility for testing purposes
void refreshConnectionList() {
final List<UIDatabaseConnection> tmpList = new ArrayList<UIDatabaseConnection>();
Runnable r = new Runnable() {
@Override
public void run() {
try {
ObjectId[] dbIdList = repository.getDatabaseIDs(false);
for (ObjectId dbId : dbIdList) {
DatabaseMeta dbMeta = repository.loadDatabaseMeta(dbId, null);
RepositoryElementMetaInterface repoMeta = repository.getObjectInformation(dbId, RepositoryObjectType.DATABASE);
UIDatabaseConnection conn = null;
try {
conn = UIObjectRegistry.getInstance().constructUIDatabaseConnection(dbMeta, repository);
} catch (UIObjectCreationException uoe) {
conn = new UIDatabaseConnection(dbMeta, repository);
}
if (conn != null) {
conn.setRepositoryElementMetaInterface(repoMeta);
tmpList.add(conn);
}
}
} catch (KettleException e) {
if (mainController == null || !mainController.handleLostRepository(e)) {
// convert to runtime exception so it bubbles up through the UI
throw new RuntimeException(e);
}
}
}
};
doWithBusyIndicator(r);
dbConnectionList.setChildren(tmpList);
}
use of org.pentaho.di.repository.RepositoryElementMetaInterface in project pentaho-kettle by pentaho.
the class RepositoryDirectoryUI method addToTree.
private static void addToTree(TreeItem ti, String filterString, Pattern pattern, List<RepositoryElementMetaInterface> repositoryObjects) {
for (int i = 0; i < repositoryObjects.size(); i++) {
boolean add = false;
RepositoryElementMetaInterface repositoryObject = repositoryObjects.get(i);
if (filterString == null && pattern == null) {
add = true;
} else {
add |= addItem(repositoryObject.getName(), filterString, pattern);
add |= addItem(repositoryObject.getDescription(), filterString, pattern);
add |= addItem(repositoryObject.getModifiedUser(), filterString, pattern);
if (!add && repositoryObject.getModifiedDate() != null) {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(DATE_FORMAT);
add = addItem(simpleDateFormat.format(repositoryObject.getModifiedDate()), filterString, pattern);
}
if (!add && repositoryObject.getObjectType() != null) {
add = addItem(repositoryObject.getObjectType().getTypeDescription(), filterString, pattern);
}
}
if (add) {
createTreeItem(ti, repositoryObject);
}
}
}
use of org.pentaho.di.repository.RepositoryElementMetaInterface in project pdi-dataservice-server-plugin by pentaho.
the class ServiceTransTest method testRepoPathStorageMethod.
@Test
public void testRepoPathStorageMethod() throws KettleException {
ObjectId transId = new StringObjectId("transId");
when(repository.loadTransformation(eq(transId), isNull(String.class))).thenReturn(transMeta);
RepositoryDirectoryInterface root = mock(RepositoryDirectoryInterface.class);
ObjectId rootId = new StringObjectId("dirId");
when(root.getObjectId()).thenReturn(rootId);
when(repository.loadRepositoryDirectoryTree()).thenReturn(root);
RepositoryDirectoryInterface dir = mock(RepositoryDirectoryInterface.class);
when(root.findDirectory(eq("/existing"))).thenReturn(dir, null);
when(repository.getTransformationID(eq("Trans"), eq(dir))).thenReturn(null);
RepositoryElementMetaInterface transInfo = mock(RepositoryElementMetaInterface.class);
when(transInfo.getName()).thenReturn("Trans");
when(transInfo.getObjectId()).thenReturn(transId);
when(repository.getTransformationObjects(eq(rootId), eq(true))).thenReturn(Arrays.asList(transInfo));
ServiceTrans.StorageMethod method = ServiceTrans.StorageMethod.REPO_PATH;
assertThat(method.exists(repository, "/existing/Trans"), is(true));
RepositoryObject transObjectInfo = mock(RepositoryObject.class);
when(transObjectInfo.isDeleted()).thenReturn(false, true);
when(repository.getObjectInformation(eq(transId), eq(RepositoryObjectType.TRANSFORMATION))).thenReturn(transObjectInfo);
assertThat(method.load(repository, "/existing/Trans"), is(transMeta));
assertThat(method.load(repository, "/existing/Trans"), is(nullValue()));
}
Aggregations