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();
}
}
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();
}
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();
}
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();
}
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();
}
Aggregations