Search in sources :

Example 11 with SharedObjects

use of org.pentaho.di.shared.SharedObjects in project pentaho-kettle by pentaho.

the class Spoon method newJobFile.

public void newJobFile() {
    try {
        JobMeta jobMeta = new JobMeta();
        jobMeta.addObserver(this);
        // Set the variables that were previously defined in this session on
        // the transformation metadata too.
        // 
        setJobMetaVariables(jobMeta);
        // Pass repository information
        // 
        jobMeta.setRepository(rep);
        jobMeta.setMetaStore(metaStore);
        try {
            // TODO: MAKE LIKE TRANS
            SharedObjects sharedObjects = rep != null ? rep.readJobMetaSharedObjects(jobMeta) : jobMeta.readSharedObjects();
            sharedObjectsFileMap.put(sharedObjects.getFilename(), sharedObjects);
            if (rep == null) {
                jobMeta.setSharedObjects(sharedObjects);
            }
            jobMeta.importFromMetaStore();
        } catch (Exception e) {
            new ErrorDialog(shell, BaseMessages.getString(PKG, "Spoon.Dialog.ErrorReadingSharedObjects.Title"), BaseMessages.getString(PKG, "Spoon.Dialog.ErrorReadingSharedObjects.Message", delegates.tabs.makeTabName(jobMeta, true)), e);
        }
        // Set the location of the new jobMeta to that of the default location or the last saved location
        jobMeta.setRepositoryDirectory(getDefaultSaveLocation(jobMeta));
        int nr = 1;
        jobMeta.setName(STRING_JOB + " " + nr);
        // loaded...
        while (findJob(delegates.tabs.makeTabName(jobMeta, false)) != null) {
            nr++;
            // rename
            jobMeta.setName(STRING_JOB + " " + nr);
        }
        jobMeta.clearChanged();
        addJobGraph(jobMeta);
        applyVariables();
        // 
        if (setDesignMode()) {
            // No refresh done yet, do so
            refreshTree();
        }
        loadPerspective(MainSpoonPerspective.ID);
    } catch (Exception e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "Spoon.Exception.ErrorCreatingNewJob.Title"), BaseMessages.getString(PKG, "Spoon.Exception.ErrorCreatingNewJob.Message"), e);
    }
}
Also used : JobMeta(org.pentaho.di.job.JobMeta) 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) Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint)

Example 12 with SharedObjects

use of org.pentaho.di.shared.SharedObjects in project pentaho-kettle by pentaho.

the class Spoon method newTransFile.

public void newTransFile() {
    TransMeta transMeta = new TransMeta();
    transMeta.addObserver(this);
    // Set the variables that were previously defined in this session on the
    // transformation metadata too.
    // 
    setTransMetaVariables(transMeta);
    // Pass repository information
    // 
    transMeta.setRepository(rep);
    transMeta.setMetaStore(metaStore);
    try {
        SharedObjects sharedObjects = rep != null ? rep.readTransSharedObjects(transMeta) : transMeta.readSharedObjects();
        sharedObjectsFileMap.put(sharedObjects.getFilename(), sharedObjects);
        if (rep == null) {
            transMeta.setSharedObjects(sharedObjects);
        }
        transMeta.importFromMetaStore();
        transMeta.clearChanged();
    } catch (Exception e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "Spoon.Exception.ErrorReadingSharedObjects.Title"), BaseMessages.getString(PKG, "Spoon.Exception.ErrorReadingSharedObjects.Message"), e);
    }
    // Set the location of the new transMeta to that of the default location or the last saved location
    transMeta.setRepositoryDirectory(getDefaultSaveLocation(transMeta));
    int nr = 1;
    transMeta.setName(STRING_TRANSFORMATION + " " + nr);
    // 
    while (findTransformation(delegates.tabs.makeTabName(transMeta, false)) != null) {
        nr++;
        // rename
        transMeta.setName(STRING_TRANSFORMATION + " " + nr);
    }
    addTransGraph(transMeta);
    applyVariables();
    // 
    if (setDesignMode()) {
        // No refresh done yet, do so
        refreshTree();
    }
    loadPerspective(MainSpoonPerspective.ID);
    try {
        ExtensionPointHandler.callExtensionPoint(log, KettleExtensionPoint.TransformationCreateNew.id, transMeta);
    } catch (KettleException e) {
        log.logError("Failed to call extension point", e);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) TransMeta(org.pentaho.di.trans.TransMeta) 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) Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint)

Example 13 with SharedObjects

use of org.pentaho.di.shared.SharedObjects in project pentaho-kettle by pentaho.

the class PrivateDatabasesTestTemplate method doTest_NoPrivate.

protected void doTest_NoPrivate() throws Exception {
    T meta = createMeta();
    String xml = toXml(meta);
    SharedObjects fakeSharedObjects = createFakeSharedObjects();
    T loaded = fromXml(xml, fakeSharedObjects);
    Set<String> privateDatabases = loaded.getPrivateDatabases();
    assertNotNull(privateDatabases);
    assertTrue(privateDatabases.isEmpty());
}
Also used : SharedObjects(org.pentaho.di.shared.SharedObjects)

Example 14 with SharedObjects

use of org.pentaho.di.shared.SharedObjects in project pentaho-kettle by pentaho.

the class PrivateDatabasesTestTemplate method createFakeSharedObjects.

@SuppressWarnings("unchecked")
protected SharedObjects createFakeSharedObjects(DatabaseMeta... shared) throws Exception {
    SharedObjects fake = new SharedObjects();
    Map map = fake.getObjectsMap();
    map.clear();
    if (shared != null) {
        // hacky solution
        for (DatabaseMeta meta : shared) {
            map.put(new Object(), meta);
        }
    }
    return fake;
}
Also used : SharedObjects(org.pentaho.di.shared.SharedObjects) Map(java.util.Map) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta)

Example 15 with SharedObjects

use of org.pentaho.di.shared.SharedObjects in project pentaho-kettle by pentaho.

the class PrivateDatabasesTestTemplate method doTest_OnePrivate_NoShared.

protected void doTest_OnePrivate_NoShared() throws Exception {
    T meta = createMeta();
    DatabaseMeta privateMeta = createDatabase("privateMeta");
    meta.addDatabase(privateMeta);
    String xml = toXml(meta);
    SharedObjects fakeSharedObjects = createFakeSharedObjects();
    T loaded = fromXml(xml, fakeSharedObjects);
    List<String> loadedDbs = Arrays.asList(loaded.getDatabaseNames());
    assertTrue(loadedDbs.contains("privateMeta"));
    Set<String> privateDatabases = loaded.getPrivateDatabases();
    assertNotNull(privateDatabases);
    assertEquals(1, privateDatabases.size());
    assertTrue(privateDatabases.contains(privateMeta.getName()));
}
Also used : SharedObjects(org.pentaho.di.shared.SharedObjects) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta)

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