Search in sources :

Example 81 with ObjectId

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

the class TrashBrowseController method undelete.

public void undelete() {
    // make a copy because the selected trash items changes as soon as trashService.undelete is called
    List<UIDeletedObject> selectedTrashFileItemsSnapshot = new ArrayList<UIDeletedObject>(selectedTrashFileItems);
    if (selectedTrashFileItemsSnapshot != null && selectedTrashFileItemsSnapshot.size() > 0) {
        List<ObjectId> ids = new ArrayList<ObjectId>();
        for (UIDeletedObject uiObj : selectedTrashFileItemsSnapshot) {
            ids.add(uiObj.getId());
        }
        try {
            trashService.undelete(ids);
            setTrash(trashService.getTrash());
            for (UIDeletedObject uiObj : selectedTrashFileItemsSnapshot) {
                // find the closest UIRepositoryDirectory that is in the dirMap
                RepositoryDirectoryInterface dir = repository.findDirectory(uiObj.getOriginalParentPath());
                while (dir != null && dirMap.get(dir.getObjectId()) == null) {
                    dir = dir.getParent();
                }
                // now refresh that UIRepositoryDirectory so that the file/folders deck instantly refreshes on undelete
                if (dir != null) {
                    dirMap.get(dir.getObjectId()).refresh();
                }
                // if transformation or directory with transformations call extension to restore data services references.
                if (RepositoryObjectType.TRANSFORMATION.name().equals(uiObj.getType())) {
                    TransMeta transMeta = repository.loadTransformation(uiObj.getId(), null);
                    ExtensionPointHandler.callExtensionPoint(LogChannel.GENERAL, KettleExtensionPoint.TransAfterOpen.id, transMeta);
                    transMeta.clearChanged();
                } else if (!RepositoryObjectType.JOB.name().equals(uiObj.getType())) {
                    // if not a transformation and not a job then is a Directory
                    RepositoryDirectoryInterface actualDir = repository.findDirectory(uiObj.getOriginalParentPath() + RepositoryDirectory.DIRECTORY_SEPARATOR + uiObj.getName());
                    if (actualDir != null) {
                        List<RepositoryElementMetaInterface> transformations = new ArrayList<>();
                        getAllTransformations(actualDir, transformations);
                        for (RepositoryElementMetaInterface repositoryElementMetaInterface : transformations) {
                            TransMeta transMeta = repository.loadTransformation(repositoryElementMetaInterface.getObjectId(), null);
                            ExtensionPointHandler.callExtensionPoint(LogChannel.GENERAL, KettleExtensionPoint.TransAfterOpen.id, transMeta);
                            transMeta.clearChanged();
                        }
                    } else {
                        displayExceptionMessage(BaseMessages.getString(PKG, "TrashBrowseController.UnableToRestoreDirectory", uiObj.getOriginalParentPath() + RepositoryDirectory.DIRECTORY_SEPARATOR + uiObj.getName()));
                    }
                }
            }
            deck.setSelectedIndex(1);
        } catch (Throwable th) {
            if (mainController == null || !mainController.handleLostRepository(th)) {
                displayExceptionMessage(BaseMessages.getString(PKG, "TrashBrowseController.UnableToRestoreFile", // $NON-NLS-1$
                th.getLocalizedMessage()));
            }
        }
    } else {
        // ui probably allowed the button to be enabled when it shouldn't have been enabled
        throw new RuntimeException();
    }
}
Also used : RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) ObjectId(org.pentaho.di.repository.ObjectId) ArrayList(java.util.ArrayList) TransMeta(org.pentaho.di.trans.TransMeta) ArrayList(java.util.ArrayList) List(java.util.List) RepositoryElementMetaInterface(org.pentaho.di.repository.RepositoryElementMetaInterface)

Example 82 with ObjectId

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

the class PurRepositoryStressTest method testLockRenameTransformation.

public void testLockRenameTransformation() throws Exception {
    ObjectId objId = mock(ObjectId.class);
    doReturn("id1").when(objId).getId();
    RepositoryDirectoryInterface rdi = mock(RepositoryDirectoryInterface.class);
    assertNotNull(purRepository.renameTransformation(objId, "vComment", rdi, "newTransName"));
    verify(objId, times(2)).getId();
}
Also used : RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) StringObjectId(org.pentaho.di.repository.StringObjectId) ObjectId(org.pentaho.di.repository.ObjectId)

Example 83 with ObjectId

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

the class PurRepositoryStressTest method testLockUndeleteObject.

public void testLockUndeleteObject() throws Exception {
    ObjectId objId = mock(ObjectId.class);
    doReturn("id1").when(objId).getId();
    RepositoryElementMetaInterface rem = mock(RepositoryElementMetaInterface.class);
    doReturn(objId).when(rem).getObjectId();
    purRepository.undeleteObject(rem);
    verify(rem, times(1)).getObjectId();
    verify(objId, times(1)).getId();
}
Also used : StringObjectId(org.pentaho.di.repository.StringObjectId) ObjectId(org.pentaho.di.repository.ObjectId) RepositoryElementMetaInterface(org.pentaho.di.repository.RepositoryElementMetaInterface)

Example 84 with ObjectId

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

the class PurRepositoryStressTest method testLocksDeleteRepositoryDirectory.

public void testLocksDeleteRepositoryDirectory() throws Exception {
    ObjectId objId = mock(ObjectId.class);
    doReturn("id1").when(objId).getId();
    RepositoryDirectoryInterface repFile = mock(RepositoryDirectoryInterface.class);
    doReturn(objId).when(repFile).getObjectId();
    purRepository.deleteRepositoryDirectory(repFile, true);
    verify(repFile, times(2)).getObjectId();
}
Also used : RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) StringObjectId(org.pentaho.di.repository.StringObjectId) ObjectId(org.pentaho.di.repository.ObjectId)

Example 85 with ObjectId

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

the class PurRepositoryStressTest method testLockLoadPartitionSchema.

public void testLockLoadPartitionSchema() throws Exception {
    ObjectId objId = mock(ObjectId.class);
    doReturn("id1").when(objId).getId();
    assertNotNull(purRepository.loadPartitionSchema(objId, "v1"));
    verify(objId, times(3)).getId();
}
Also used : StringObjectId(org.pentaho.di.repository.StringObjectId) ObjectId(org.pentaho.di.repository.ObjectId)

Aggregations

ObjectId (org.pentaho.di.repository.ObjectId)233 KettleException (org.pentaho.di.core.exception.KettleException)94 LongObjectId (org.pentaho.di.repository.LongObjectId)76 StringObjectId (org.pentaho.di.repository.StringObjectId)76 RowMetaAndData (org.pentaho.di.core.RowMetaAndData)49 RepositoryDirectoryInterface (org.pentaho.di.repository.RepositoryDirectoryInterface)38 Test (org.junit.Test)37 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)37 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)34 ValueMetaInteger (org.pentaho.di.core.row.value.ValueMetaInteger)33 ArrayList (java.util.ArrayList)30 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)29 MessageBox (org.eclipse.swt.widgets.MessageBox)26 Repository (org.pentaho.di.repository.Repository)18 RepositoryFile (org.pentaho.platform.api.repository2.unified.RepositoryFile)18 SlaveServer (org.pentaho.di.cluster.SlaveServer)15 KettleDatabaseException (org.pentaho.di.core.exception.KettleDatabaseException)14 PartitionSchema (org.pentaho.di.partition.PartitionSchema)14 Matchers.anyString (org.mockito.Matchers.anyString)13 MetaStoreException (org.pentaho.metastore.api.exceptions.MetaStoreException)13