Search in sources :

Example 26 with RepositoryElementMetaInterface

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

the class RepositoryDirectoryUITest method testLoadRepositoryObjectsFilled.

@Test
public void testLoadRepositoryObjectsFilled() throws Exception {
    RepositoryDirectory root = new RepositoryDirectory();
    root.setObjectId(new LongObjectId(0L));
    RepositoryDirectory dir = new RepositoryDirectory();
    dir.setObjectId(new LongObjectId(1L));
    root.addSubdirectory(dir);
    RepositoryElementMetaInterface meta = mock(RepositoryElementMetaInterface.class);
    when(meta.getObjectType()).thenReturn(RepositoryObjectType.TRANSFORMATION);
    root.setRepositoryObjects(Collections.emptyList());
    dir.setRepositoryObjects(Collections.singletonList(meta));
    Repository repo = mock(Repository.class);
    assertTrue(RepositoryDirectoryUI.loadRepositoryObjects(root, true, true, repo).isEmpty());
    assertEquals(1, RepositoryDirectoryUI.loadRepositoryObjects(dir, true, true, repo).size());
    verifyZeroInteractions(repo);
}
Also used : Repository(org.pentaho.di.repository.Repository) RepositoryDirectory(org.pentaho.di.repository.RepositoryDirectory) LongObjectId(org.pentaho.di.repository.LongObjectId) RepositoryElementMetaInterface(org.pentaho.di.repository.RepositoryElementMetaInterface) Test(org.junit.Test)

Example 27 with RepositoryElementMetaInterface

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

the class UIDatabaseConnectionTest method testModifiedDate.

@Test
public void testModifiedDate() {
    final Long timestamp = 100000L;
    SimpleDateFormat sdf = new SimpleDateFormat("d MMM yyyy HH:mm:ss z");
    UIDatabaseConnection uiconn = new UIDatabaseConnection();
    RepositoryElementMetaInterface repoMeta = mock(RepositoryElementMetaInterface.class);
    when(repoMeta.getModifiedDate()).thenReturn(new Date(timestamp));
    uiconn.setRepositoryElementMetaInterface(repoMeta);
    assertEquals(sdf.format(new Date(timestamp)), uiconn.getDateModified());
}
Also used : SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) RepositoryElementMetaInterface(org.pentaho.di.repository.RepositoryElementMetaInterface) Test(org.junit.Test)

Example 28 with RepositoryElementMetaInterface

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

the class DialogUtilsTest method nullDirectory.

@Test
public void nullDirectory() {
    RepositoryElementMetaInterface object = mock(RepositoryElementMetaInterface.class);
    when(object.getRepositoryDirectory()).thenReturn(null);
    assertNull(getPathOf(object));
}
Also used : RepositoryElementMetaInterface(org.pentaho.di.repository.RepositoryElementMetaInterface) Test(org.junit.Test)

Example 29 with RepositoryElementMetaInterface

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

the class DialogUtilsTest method deletedObject.

@Test
public void deletedObject() {
    RepositoryElementMetaInterface object = mock(RepositoryElementMetaInterface.class);
    when(object.isDeleted()).thenReturn(true);
    assertNull(getPathOf(object));
}
Also used : RepositoryElementMetaInterface(org.pentaho.di.repository.RepositoryElementMetaInterface) Test(org.junit.Test)

Example 30 with RepositoryElementMetaInterface

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

the class PurRepository method getPdiObjects.

protected List<RepositoryElementMetaInterface> getPdiObjects(ObjectId dirId, List<RepositoryObjectType> objectTypes, boolean includeDeleted) throws KettleException {
    try {
        // RepositoryDirectoryInterface repDir = getRootDir().findDirectory( dirId );
        RepositoryFile dirFile = pur.getFileById(dirId.getId());
        RepositoryDirectory repDir = new RepositoryDirectory();
        repDir.setObjectId(dirId);
        repDir.setName(dirFile.getName());
        List<RepositoryElementMetaInterface> list = new ArrayList<RepositoryElementMetaInterface>();
        List<RepositoryFile> nonDeletedChildren = getAllFilesOfType(dirId, objectTypes);
        for (RepositoryFile file : nonDeletedChildren) {
            RepositoryLock lock = unifiedRepositoryLockService.getLock(file);
            RepositoryObjectType objectType = getObjectType(file.getName());
            list.add(new EERepositoryObject(file, repDir, null, objectType, null, lock, false));
        }
        if (includeDeleted) {
            String dirPath = null;
            if (dirId != null) {
                // derive path using id
                dirPath = pur.getFileById(dirId.getId()).getPath();
            }
            List<RepositoryFile> deletedChildren = getAllDeletedFilesOfType(dirPath, objectTypes);
            for (RepositoryFile file : deletedChildren) {
                RepositoryLock lock = unifiedRepositoryLockService.getLock(file);
                RepositoryObjectType objectType = getObjectType(file.getName());
                list.add(new EERepositoryObject(file, repDir, null, objectType, null, lock, true));
            }
        }
        return list;
    } catch (Exception e) {
        throw new KettleException("Unable to get list of objects from directory [" + dirId + "]", e);
    }
}
Also used : EERepositoryObject(org.pentaho.di.repository.pur.model.EERepositoryObject) KettleException(org.pentaho.di.core.exception.KettleException) RepositoryDirectory(org.pentaho.di.repository.RepositoryDirectory) ArrayList(java.util.ArrayList) RepositoryObjectType(org.pentaho.di.repository.RepositoryObjectType) RepositoryFile(org.pentaho.platform.api.repository2.unified.RepositoryFile) RepositoryLock(org.pentaho.di.repository.pur.model.RepositoryLock) MetaStoreNamespaceExistsException(org.pentaho.metastore.api.exceptions.MetaStoreNamespaceExistsException) KettleFileException(org.pentaho.di.core.exception.KettleFileException) MetaStoreException(org.pentaho.metastore.api.exceptions.MetaStoreException) UnifiedRepositoryCreateFileException(org.pentaho.platform.api.repository2.unified.UnifiedRepositoryCreateFileException) UnifiedRepositoryUpdateFileException(org.pentaho.platform.api.repository2.unified.UnifiedRepositoryUpdateFileException) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) KettleException(org.pentaho.di.core.exception.KettleException) IdNotFoundException(org.pentaho.di.core.exception.IdNotFoundException) KettleSecurityException(org.pentaho.di.core.exception.KettleSecurityException) RepositoryElementMetaInterface(org.pentaho.di.repository.RepositoryElementMetaInterface)

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