use of org.pentaho.di.shared.SharedObjects in project pentaho-kettle by pentaho.
the class TransGraph method editProperties.
public static boolean editProperties(TransMeta transMeta, Spoon spoon, Repository rep, boolean allowDirectoryChange, TransDialog.Tabs currentTab) {
if (transMeta == null) {
return false;
}
TransDialog tid = new TransDialog(spoon.getShell(), SWT.NONE, transMeta, rep, currentTab);
tid.setDirectoryChangeAllowed(allowDirectoryChange);
TransMeta ti = tid.open();
//
if (tid.isSharedObjectsFileChanged()) {
try {
SharedObjects sharedObjects = rep != null ? rep.readTransSharedObjects(transMeta) : transMeta.readSharedObjects();
spoon.sharedObjectsFileMap.put(sharedObjects.getFilename(), sharedObjects);
} catch (KettleException e) {
// CHECKSTYLE:LineLength:OFF
new ErrorDialog(spoon.getShell(), BaseMessages.getString(PKG, "Spoon.Dialog.ErrorReadingSharedObjects.Title"), BaseMessages.getString(PKG, "Spoon.Dialog.ErrorReadingSharedObjects.Message", spoon.makeTabName(transMeta, true)), e);
}
// If we added properties, add them to the variables too, so that they appear in the CTRL-SPACE variable
// completion.
//
spoon.setParametersAsVariablesInUI(transMeta, transMeta);
spoon.refreshTree();
// cheap operation, might as will do it anyway
spoon.delegates.tabs.renameTabs();
}
spoon.setShellText();
return ti != null;
}
use of org.pentaho.di.shared.SharedObjects in project pentaho-kettle by pentaho.
the class RepositoryImporter method loadSharedObjects.
/**
* Load the shared objects up front, replace them in the xforms/jobs loaded from XML. We do this for performance
* reasons.
*
* @throws KettleException
*/
protected void loadSharedObjects() throws KettleException {
sharedObjects = new SharedObjects();
for (ObjectId id : rep.getDatabaseIDs(false)) {
DatabaseMeta databaseMeta = rep.loadDatabaseMeta(id, null);
validateImportedElement(importRules, databaseMeta);
sharedObjects.storeObject(databaseMeta);
}
ObjectId[] slaveIDs = rep.getSlaveIDs(false);
List<SlaveServer> slaveServers = new ArrayList<SlaveServer>(slaveIDs.length);
for (ObjectId id : slaveIDs) {
SlaveServer slaveServer = rep.loadSlaveServer(id, null);
validateImportedElement(importRules, slaveServer);
sharedObjects.storeObject(slaveServer);
slaveServers.add(slaveServer);
}
for (ObjectId id : rep.getClusterIDs(false)) {
ClusterSchema clusterSchema = rep.loadClusterSchema(id, slaveServers, null);
validateImportedElement(importRules, clusterSchema);
sharedObjects.storeObject(clusterSchema);
}
for (ObjectId id : rep.getPartitionSchemaIDs(false)) {
PartitionSchema partitionSchema = rep.loadPartitionSchema(id, null);
validateImportedElement(importRules, partitionSchema);
sharedObjects.storeObject(partitionSchema);
}
}
use of org.pentaho.di.shared.SharedObjects in project pentaho-kettle by pentaho.
the class AbstractMetaTest method testGetSetSharedObjects.
@Test
public void testGetSetSharedObjects() throws Exception {
SharedObjects sharedObjects = mock(SharedObjects.class);
meta.setSharedObjects(sharedObjects);
assertEquals(sharedObjects, meta.getSharedObjects());
meta.setSharedObjects(null);
AbstractMeta spyMeta = spy(meta);
doThrow(KettleException.class).when(spyMeta).environmentSubstitute(anyString());
assertNull(spyMeta.getSharedObjects());
}
use of org.pentaho.di.shared.SharedObjects in project pentaho-kettle by pentaho.
the class PrivateDatabasesTestTemplate method doTest_OnePrivate_TwoShared.
protected void doTest_OnePrivate_TwoShared() throws Exception {
T meta = createMeta();
DatabaseMeta privateMeta = createDatabase("privateMeta");
meta.addDatabase(privateMeta);
String xml = toXml(meta);
DatabaseMeta meta1 = createDatabase("meta1");
meta1.setShared(true);
DatabaseMeta meta2 = createDatabase("meta2");
meta2.setShared(true);
SharedObjects fakeSharedObjects = createFakeSharedObjects(meta1, meta2);
T loaded = fromXml(xml, fakeSharedObjects);
List<String> loadedDbs = Arrays.asList(loaded.getDatabaseNames());
assertEquals(3, loadedDbs.size());
assertThat(loadedDbs, JUnitMatchers.hasItems("meta1", "meta2", "privateMeta"));
Set<String> privateDatabases = loaded.getPrivateDatabases();
assertNotNull(privateDatabases);
assertEquals(1, privateDatabases.size());
assertTrue(privateDatabases.contains("privateMeta"));
}
use of org.pentaho.di.shared.SharedObjects in project pentaho-kettle by pentaho.
the class Spoon method shareObject.
protected void shareObject(SharedObjectInterface sharedObject) {
sharedObject.setShared(true);
EngineMetaInterface meta = getActiveMeta();
try {
if (meta != null) {
SharedObjects sharedObjects = null;
if (meta instanceof TransMeta) {
sharedObjects = ((TransMeta) meta).getSharedObjects();
}
if (meta instanceof JobMeta) {
sharedObjects = ((JobMeta) meta).getSharedObjects();
}
if (sharedObjects != null) {
sharedObjects.storeObject(sharedObject);
sharedObjects.saveToFile();
}
}
} catch (Exception e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "Spoon.Dialog.ErrorWritingSharedObjects.Title"), BaseMessages.getString(PKG, "Spoon.Dialog.ErrorWritingSharedObjects.Message"), e);
}
refreshTree();
}
Aggregations