Search in sources :

Example 6 with SharedObjects

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;
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) TransMeta(org.pentaho.di.trans.TransMeta) TransDialog(org.pentaho.di.ui.trans.dialog.TransDialog) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) SharedObjects(org.pentaho.di.shared.SharedObjects)

Example 7 with SharedObjects

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);
    }
}
Also used : PartitionSchema(org.pentaho.di.partition.PartitionSchema) ArrayList(java.util.ArrayList) SharedObjects(org.pentaho.di.shared.SharedObjects) SlaveServer(org.pentaho.di.cluster.SlaveServer) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) ClusterSchema(org.pentaho.di.cluster.ClusterSchema)

Example 8 with SharedObjects

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());
}
Also used : SharedObjects(org.pentaho.di.shared.SharedObjects) Test(org.junit.Test)

Example 9 with SharedObjects

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"));
}
Also used : SharedObjects(org.pentaho.di.shared.SharedObjects) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta)

Example 10 with SharedObjects

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();
}
Also used : JobMeta(org.pentaho.di.job.JobMeta) TransMeta(org.pentaho.di.trans.TransMeta) EngineMetaInterface(org.pentaho.di.core.EngineMetaInterface) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) SharedObjects(org.pentaho.di.shared.SharedObjects) SWTException(org.eclipse.swt.SWTException) KettleRowException(org.pentaho.di.core.exception.KettleRowException) FileSystemException(org.apache.commons.vfs2.FileSystemException) MetaStoreException(org.pentaho.metastore.api.exceptions.MetaStoreException) KettleValueException(org.pentaho.di.core.exception.KettleValueException) KettleAuthException(org.pentaho.di.core.exception.KettleAuthException) KettleRepositoryLostException(org.pentaho.di.repository.KettleRepositoryLostException) KettleXMLException(org.pentaho.di.core.exception.KettleXMLException) LifecycleException(org.pentaho.di.core.lifecycle.LifecycleException) KettleMissingPluginsException(org.pentaho.di.core.exception.KettleMissingPluginsException) KettleFileException(org.pentaho.di.core.exception.KettleFileException) KettleException(org.pentaho.di.core.exception.KettleException) MalformedURLException(java.net.MalformedURLException)

Aggregations

SharedObjects (org.pentaho.di.shared.SharedObjects)25 KettleException (org.pentaho.di.core.exception.KettleException)13 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)10 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)8 KettleFileException (org.pentaho.di.core.exception.KettleFileException)6 KettleValueException (org.pentaho.di.core.exception.KettleValueException)6 KettleRepositoryLostException (org.pentaho.di.repository.KettleRepositoryLostException)6 MetaStoreException (org.pentaho.metastore.api.exceptions.MetaStoreException)6 MalformedURLException (java.net.MalformedURLException)5 FileSystemException (org.apache.commons.vfs2.FileSystemException)5 SWTException (org.eclipse.swt.SWTException)5 KettleAuthException (org.pentaho.di.core.exception.KettleAuthException)5 KettleMissingPluginsException (org.pentaho.di.core.exception.KettleMissingPluginsException)5 KettleRowException (org.pentaho.di.core.exception.KettleRowException)5 KettleXMLException (org.pentaho.di.core.exception.KettleXMLException)5 LifecycleException (org.pentaho.di.core.lifecycle.LifecycleException)5 JobMeta (org.pentaho.di.job.JobMeta)5 TransMeta (org.pentaho.di.trans.TransMeta)5 SlaveServer (org.pentaho.di.cluster.SlaveServer)4 KettleExtensionPoint (org.pentaho.di.core.extension.KettleExtensionPoint)4