Search in sources :

Example 31 with RepositoryObject

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

the class KettleDatabaseRepository_GetObjectInformation_Test method assertIsDeletedNotSet_ForExistingObject.

private void assertIsDeletedNotSet_ForExistingObject(KettleDatabaseRepositoryTransDelegate transDelegate, KettleDatabaseRepositoryJobDelegate jobDelegate, RepositoryObjectType objectType) throws Exception {
    repository.transDelegate = transDelegate;
    repository.jobDelegate = jobDelegate;
    when(directoryInterface.findDirectory(any(ObjectId.class))).thenReturn(null);
    RepositoryObject object = repository.getObjectInformation(new StringObjectId(EXISTING_ID), objectType);
    assertFalse(object.isDeleted());
}
Also used : RepositoryObject(org.pentaho.di.repository.RepositoryObject) StringObjectId(org.pentaho.di.repository.StringObjectId) ObjectId(org.pentaho.di.repository.ObjectId) StringObjectId(org.pentaho.di.repository.StringObjectId)

Example 32 with RepositoryObject

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

the class GetRepositoryNamesTest method prepareExtendedRepository.

@SuppressWarnings("deprecation")
private static void prepareExtendedRepository() throws KettleException {
    repoExtended = mock(RepositoryExtended.class);
    when(repoExtended.loadRepositoryDirectoryTree(anyString(), anyString(), anyInt(), anyBoolean(), anyBoolean(), anyBoolean())).then(new Answer<RepositoryDirectoryInterface>() {

        @Override
        public RepositoryDirectoryInterface answer(InvocationOnMock invocation) throws Throwable {
            Object[] args = invocation.getArguments();
            RepositoryDirectoryInterface root = new RepositoryDirectory();
            root.setName("/");
            RepositoryDirectoryInterface subdir1 = new RepositoryDirectory(root, "subdir1");
            RepositoryDirectoryInterface subdir2 = new RepositoryDirectory(subdir1, "subdir2");
            RepositoryElementMetaInterface trans1 = new RepositoryObject(null, "Trans1", subdir1, "user", null, RepositoryObjectType.TRANSFORMATION, "", false);
            RepositoryElementMetaInterface trans2 = new RepositoryObject(null, "Trans2", subdir2, "user", null, RepositoryObjectType.TRANSFORMATION, "", false);
            RepositoryElementMetaInterface job1 = new RepositoryObject(null, "Job1", subdir1, "user", null, RepositoryObjectType.JOB, "", false);
            RepositoryElementMetaInterface job2 = new RepositoryObject(null, "Job2", subdir2, "user", null, RepositoryObjectType.JOB, "", false);
            List<RepositoryElementMetaInterface> list1 = new ArrayList<RepositoryElementMetaInterface>();
            List<RepositoryElementMetaInterface> list2 = new ArrayList<RepositoryElementMetaInterface>();
            if (((String) args[1]).contains("ktr")) {
                list1.add(trans1);
                list2.add(trans2);
            }
            if (((String) args[1]).contains("kjb")) {
                list1.add(job1);
                list2.add(job2);
            }
            subdir1.setRepositoryObjects(list1);
            subdir2.setRepositoryObjects(list2);
            if (((Integer) args[2]) == -1) {
                subdir1.addSubdirectory(subdir2);
                root.addSubdirectory(subdir1);
            }
            String actualPath = ((String) args[0]);
            if (actualPath.equals("/")) {
                return root;
            } else if (actualPath.equals(subdir1.getPath())) {
                return subdir1;
            } else if (actualPath.equals(subdir2.getPath())) {
                return subdir2;
            } else {
                return null;
            }
        }
    });
    IUser user = Mockito.mock(IUser.class);
    Mockito.when(user.isAdmin()).thenReturn(true);
    Mockito.when(repoExtended.getUserInfo()).thenReturn(user);
}
Also used : RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) RepositoryDirectory(org.pentaho.di.repository.RepositoryDirectory) RepositoryObject(org.pentaho.di.repository.RepositoryObject) Mockito.anyString(org.mockito.Mockito.anyString) InvocationOnMock(org.mockito.invocation.InvocationOnMock) IUser(org.pentaho.di.repository.IUser) RepositoryExtended(org.pentaho.di.repository.RepositoryExtended) ArrayList(java.util.ArrayList) List(java.util.List) RepositoryElementMetaInterface(org.pentaho.di.repository.RepositoryElementMetaInterface)

Example 33 with RepositoryObject

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

the class PurRepository_DatabaseNames_IT method saveDatabaseModifiedDate.

@Test
public void saveDatabaseModifiedDate() throws Exception {
    Long testStart = System.currentTimeMillis();
    final String name = UUID.randomUUID().toString();
    DatabaseMeta db = saveDatabase(name);
    RepositoryObject info = purRepository.getObjectInformation(db.getObjectId(), RepositoryObjectType.DATABASE);
    assertNotNull(info.getModifiedDate());
    assertTrue(testStart <= info.getModifiedDate().getTime());
}
Also used : RepositoryObject(org.pentaho.di.repository.RepositoryObject) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) Test(org.junit.Test)

Example 34 with RepositoryObject

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

the class SimpleMappingDialog method getByReferenceData.

private void getByReferenceData(ObjectId transObjectId) {
    try {
        if (repository == null) {
            throw new KettleException(BaseMessages.getString(PKG, "SimpleMappingDialog.Exception.NotConnectedToRepository.Message"));
        }
        RepositoryObject transInf = repository.getObjectInformation(transObjectId, RepositoryObjectType.TRANSFORMATION);
        String path = DialogUtils.getPath(transMeta.getRepositoryDirectory().getPath(), transInf.getRepositoryDirectory().getPath());
        String fullPath = Const.NVL(path, "") + "/" + Const.NVL(transInf.getName(), "");
        wPath.setText(fullPath);
    } catch (KettleException e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "SimpleMappingDialog.Exception.UnableToReferenceObjectId.Title"), BaseMessages.getString(PKG, "SimpleMappingDialog.Exception.UnableToReferenceObjectId.Message"), e);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) RepositoryObject(org.pentaho.di.repository.RepositoryObject) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog)

Example 35 with RepositoryObject

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

the class TransExecutorDialog method selectRepositoryTrans.

private void selectRepositoryTrans() {
    RepositoryObject repositoryObject = DialogHelper.selectRepositoryObject("*.ktr", log);
    try {
        if (repositoryObject != null) {
            loadRepositoryTrans(repositoryObject.getName(), repositoryObject.getRepositoryDirectory());
            String path = DialogUtils.getPath(transMeta.getRepositoryDirectory().getPath(), executorTransMeta.getRepositoryDirectory().getPath());
            String fullPath = (path.equals("/") ? "/" : path + "/") + executorTransMeta.getName();
            wPath.setText(fullPath);
            specificationMethod = ObjectLocationSpecificationMethod.REPOSITORY_BY_NAME;
        }
    } catch (KettleException ke) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "TransExecutorDialog.ErrorSelectingObject.DialogTitle"), BaseMessages.getString(PKG, "TransExecutorDialog.ErrorSelectingObject.DialogMessage"), ke);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) RepositoryObject(org.pentaho.di.repository.RepositoryObject) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog)

Aggregations

RepositoryObject (org.pentaho.di.repository.RepositoryObject)46 KettleException (org.pentaho.di.core.exception.KettleException)31 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)15 RepositoryDirectoryInterface (org.pentaho.di.repository.RepositoryDirectoryInterface)11 StringObjectId (org.pentaho.di.repository.StringObjectId)9 ObjectId (org.pentaho.di.repository.ObjectId)7 ArrayList (java.util.ArrayList)6 Date (java.util.Date)6 Test (org.junit.Test)6 KettleFileException (org.pentaho.di.core.exception.KettleFileException)5 RepositoryElementMetaInterface (org.pentaho.di.repository.RepositoryElementMetaInterface)5 IOException (java.io.IOException)4 FileSystemException (org.apache.commons.vfs2.FileSystemException)4 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)4 FileDialogOperation (org.pentaho.di.ui.core.FileDialogOperation)4 FileObject (org.apache.commons.vfs2.FileObject)3 RowMetaAndData (org.pentaho.di.core.RowMetaAndData)3 RepositoryObjectInterface (org.pentaho.di.repository.RepositoryObjectInterface)3 Serializable (java.io.Serializable)2 List (java.util.List)2