Search in sources :

Example 31 with RepositoryElementMetaInterface

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);
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) ObjectId(org.pentaho.di.repository.ObjectId) UIDatabaseConnection(org.pentaho.di.ui.repository.repositoryexplorer.model.UIDatabaseConnection) ArrayList(java.util.ArrayList) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) RepositoryElementMetaInterface(org.pentaho.di.repository.RepositoryElementMetaInterface) UIObjectCreationException(org.pentaho.di.ui.repository.repositoryexplorer.model.UIObjectCreationException)

Example 32 with RepositoryElementMetaInterface

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);
        }
    }
}
Also used : SimpleDateFormat(java.text.SimpleDateFormat) RepositoryElementMetaInterface(org.pentaho.di.repository.RepositoryElementMetaInterface)

Example 33 with RepositoryElementMetaInterface

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()));
}
Also used : RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) RepositoryObject(org.pentaho.di.repository.RepositoryObject) ObjectId(org.pentaho.di.repository.ObjectId) StringObjectId(org.pentaho.di.repository.StringObjectId) StringObjectId(org.pentaho.di.repository.StringObjectId) RepositoryElementMetaInterface(org.pentaho.di.repository.RepositoryElementMetaInterface) Test(org.junit.Test)

Aggregations

RepositoryElementMetaInterface (org.pentaho.di.repository.RepositoryElementMetaInterface)33 Test (org.junit.Test)13 RepositoryDirectoryInterface (org.pentaho.di.repository.RepositoryDirectoryInterface)13 ArrayList (java.util.ArrayList)11 KettleException (org.pentaho.di.core.exception.KettleException)11 RepositoryDirectory (org.pentaho.di.repository.RepositoryDirectory)8 ObjectId (org.pentaho.di.repository.ObjectId)7 LongObjectId (org.pentaho.di.repository.LongObjectId)5 Repository (org.pentaho.di.repository.Repository)5 RepositoryObject (org.pentaho.di.repository.RepositoryObject)5 RepositoryObjectType (org.pentaho.di.repository.RepositoryObjectType)5 StringObjectId (org.pentaho.di.repository.StringObjectId)5 IOException (java.io.IOException)4 List (java.util.List)4 TreeItem (org.eclipse.swt.widgets.TreeItem)4 KettleFileException (org.pentaho.di.core.exception.KettleFileException)4 EERepositoryObject (org.pentaho.di.repository.pur.model.EERepositoryObject)4 SimpleDateFormat (java.text.SimpleDateFormat)3 Date (java.util.Date)3 RepositoryLock (org.pentaho.di.repository.pur.model.RepositoryLock)3