use of org.pentaho.di.repository.RepositoryObjectType in project pentaho-kettle by pentaho.
the class Spoon method exploreRepository.
public void exploreRepository() {
if (rep != null) {
final RepositoryExplorerCallback cb = new RepositoryExplorerCallback() {
@Override
public boolean open(UIRepositoryContent element, String revision) throws Exception {
String objName = element.getName();
if (objName != null) {
RepositoryObjectType objectType = element.getRepositoryElementType();
RepositoryDirectory repDir = element.getRepositoryDirectory();
if (element.getObjectId() != null) {
// new way
loadObjectFromRepository(element.getObjectId(), objectType, revision);
} else {
// old way
loadObjectFromRepository(objName, objectType, repDir, revision);
}
}
// do not close explorer
return false;
}
@Override
public boolean error(String message) throws Exception {
closeRepository();
return true;
}
};
try {
final KettleWaitBox box = (KettleWaitBox) this.mainSpoonContainer.getDocumentRoot().createElement("iconwaitbox");
box.setIndeterminate(true);
box.setCanCancel(false);
box.setIcon("ui/images/kettle_logo_small.svg");
box.setTitle(BaseMessages.getString(RepositoryDialogInterface.class, "RepositoryExplorerDialog.Connection.Wait.Title"));
box.setMessage(BaseMessages.getString(RepositoryDialogInterface.class, "RepositoryExplorerDialog.Explorer.Wait.Message"));
box.setDialogParent(shell);
box.setRunnable(new WaitBoxRunnable(box) {
@Override
public void run() {
shell.getDisplay().syncExec(new Runnable() {
@Override
public void run() {
RepositoryExplorer explorer;
try {
try {
explorer = new RepositoryExplorer(shell, rep, cb, Variables.getADefaultVariableSpace(), sharedObjectSyncUtil);
} catch (final KettleRepositoryLostException krle) {
handleRepositoryLost(krle);
closeRepository();
return;
} finally {
box.stop();
}
if (explorer.isInitialized()) {
explorer.show();
} else {
return;
}
explorer.dispose();
} catch (final Throwable e) {
shell.getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
new ErrorDialog(shell, BaseMessages.getString(PKG, "Spoon.Error"), e.getMessage(), e);
}
});
}
}
});
}
@Override
public void cancel() {
}
});
box.start();
} catch (Throwable e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "Spoon.Error"), e.getMessage(), e);
}
}
}
use of org.pentaho.di.repository.RepositoryObjectType in project pentaho-kettle by pentaho.
the class JobMeta method lookupRepositoryReferences.
/**
* Look up the references after import
*
* @param repository the repository to reference.
*/
public void lookupRepositoryReferences(Repository repository) throws KettleException {
KettleException lastThrownException = null;
Map<String, RepositoryObjectType> notFoundedReferences = new HashMap<>();
for (JobEntryCopy copy : jobcopies) {
if (copy.getEntry().hasRepositoryReferences()) {
try {
copy.getEntry().lookupRepositoryReferences(repository);
} catch (IdNotFoundException e) {
lastThrownException = e;
String path = e.getPathToObject();
String name = e.getObjectName();
String key = StringUtils.isEmpty(path) || path.equals("null") ? name : path + "/" + name;
notFoundedReferences.put(key, e.getObjectType());
}
}
}
if (lastThrownException != null && !notFoundedReferences.isEmpty()) {
throw new LookupReferencesException(lastThrownException, notFoundedReferences);
}
}
use of org.pentaho.di.repository.RepositoryObjectType in project pentaho-kettle by pentaho.
the class PurRepository_SharedObjects_IT method loadAllShared.
@Test
public void loadAllShared() throws Exception {
ClusterSchema cluster = cluster();
DatabaseMeta database = database();
SlaveServer slaveServer = slaveServer();
PartitionSchema partition = partition();
purRepository.save(cluster, null, null);
purRepository.save(database, null, null);
purRepository.save(slaveServer, null, null);
purRepository.save(partition, null, null);
Map<RepositoryObjectType, List<? extends SharedObjectInterface>> map = map();
purRepository.readSharedObjects(map, RepositoryObjectType.CLUSTER_SCHEMA, RepositoryObjectType.DATABASE, RepositoryObjectType.SLAVE_SERVER, RepositoryObjectType.PARTITION_SCHEMA);
RepositoryElementInterface[] saved = new RepositoryElementInterface[] { cluster, database, slaveServer, partition };
assertEquals(saved.length, map.size());
for (RepositoryElementInterface sharedObject : saved) {
List<? extends SharedObjectInterface> list = map.get(sharedObject.getRepositoryElementType());
assertEquals(1, list.size());
assertEquals(sharedObject, list.get(0));
}
}
use of org.pentaho.di.repository.RepositoryObjectType in project pentaho-kettle by pentaho.
the class PurRepository_SharedObjects_IT method testLoadSharedObjects.
private void testLoadSharedObjects(RepositoryElementInterface sharedObject) throws Exception {
purRepository.save(sharedObject, null, null);
Map<RepositoryObjectType, List<? extends SharedObjectInterface>> map = map();
purRepository.readSharedObjects(map, sharedObject.getRepositoryElementType());
List<? extends SharedObjectInterface> objects = map.get(sharedObject.getRepositoryElementType());
assertNotNull(objects);
assertEquals(1, objects.size());
SharedObjectInterface object = objects.get(0);
assertEquals(sharedObject, object);
}
use of org.pentaho.di.repository.RepositoryObjectType in project pentaho-kettle by pentaho.
the class PurRepositoryIT method testNewNonAmbiguousNaming.
@Test
public void testNewNonAmbiguousNaming() throws Exception {
PurRepository repo = (PurRepository) repository;
System.setProperty("KETTLE_COMPATIBILITY_PUR_OLD_NAMING_MODE", "N");
// $NON-NLS-1$
PartitionSchema partSchema1 = createPartitionSchema("find.me");
// $NON-NLS-1$
PartitionSchema partSchema2 = createPartitionSchema("find|me");
repository.save(partSchema1, VERSION_COMMENT_V1, null);
repository.save(partSchema2, VERSION_COMMENT_V1, null);
Map<RepositoryObjectType, List<? extends SharedObjectInterface>> sharedObjectsByType = new HashMap<RepositoryObjectType, List<? extends SharedObjectInterface>>();
repo.readSharedObjects(sharedObjectsByType, RepositoryObjectType.PARTITION_SCHEMA);
List<PartitionSchema> partitionSchemas = (List<PartitionSchema>) sharedObjectsByType.get(RepositoryObjectType.PARTITION_SCHEMA);
assertEquals(2, partitionSchemas.size());
System.setProperty("KETTLE_COMPATIBILITY_PUR_OLD_NAMING_MODE", "Y");
// $NON-NLS-1$
PartitionSchema partSchema3 = createPartitionSchema("another.one");
// $NON-NLS-1$
PartitionSchema partSchema4 = createPartitionSchema("another|one");
repository.save(partSchema3, VERSION_COMMENT_V1, null);
repository.save(partSchema4, VERSION_COMMENT_V1, null);
sharedObjectsByType = new HashMap<RepositoryObjectType, List<? extends SharedObjectInterface>>();
repo.readSharedObjects(sharedObjectsByType, RepositoryObjectType.PARTITION_SCHEMA);
partitionSchemas = (List<PartitionSchema>) sharedObjectsByType.get(RepositoryObjectType.PARTITION_SCHEMA);
assertEquals(3, partitionSchemas.size());
}
Aggregations