Search in sources :

Example 46 with AbstractMeta

use of org.pentaho.di.base.AbstractMeta in project pentaho-kettle by pentaho.

the class PurRepository_MoveAndRename_IT method move_FailsIfANameConflictOccurs.

private void move_FailsIfANameConflictOccurs(Assistant assistant) throws Exception {
    final String fileName = "move_FailsIfANameConflictOccurs";
    AbstractMeta meta = assistant.createNew();
    AbstractMeta anotherMeta = assistant.createNew();
    RepositoryDirectoryInterface directory = getPublicDir();
    assistant.save(meta, fileName, directory);
    RepositoryDirectoryInterface destFolder = getDirInsidePublic(fileName);
    assistant.save(anotherMeta, fileName, destFolder);
    assistant.move(meta, destFolder);
}
Also used : RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) AbstractMeta(org.pentaho.di.base.AbstractMeta)

Example 47 with AbstractMeta

use of org.pentaho.di.base.AbstractMeta in project pentaho-kettle by pentaho.

the class PurRepository_SharedObjects_Links_IT method testReadSharedObjects.

@SuppressWarnings("unchecked")
private void testReadSharedObjects(GenericMeta gMeta) throws Exception {
    PurRepository pur = (PurRepository) repository;
    RepositoryDirectoryInterface rootDir = initRepo();
    SlaveServer slave1 = createSlaveServer("slave1");
    SlaveServer slave2 = createSlaveServer("slave2");
    pur.save(slave1, VERSION_COMMENT_V1, null);
    pur.save(slave2, VERSION_COMMENT_V1, null);
    AbstractMeta meta = gMeta.createFilled();
    meta.getSlaveServers().add(slave1);
    meta.getSlaveServers().add(slave2);
    rootDir.findDirectory(DIR_TRANSFORMATIONS);
    pur.save(meta, VERSION_COMMENT_V1, null);
    String xmlText = meta.getXML();
    try {
        // import transformation from file
        meta = gMeta.createEmpty();
        DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
        DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
        Document doc = dBuilder.parse(IOUtils.toInputStream(xmlText));
        gMeta.loadFromXml(doc.getParentNode());
        List<SharedObjectInterface> sharedObjects = (List<SharedObjectInterface>) pur.loadAndCacheSharedObjects(false).get(RepositoryObjectType.SLAVE_SERVER);
        for (int i = 0; i < meta.getSlaveServers().size(); i++) {
            for (int j = 0; j < sharedObjects.size(); j++) {
                SlaveServer s1 = meta.getSlaveServers().get(i);
                SlaveServer s2 = (SlaveServer) sharedObjects.get(j);
                if (s1 == s2) {
                    fail("Trans/job has direct links on slave servers from cache");
                }
            }
        }
    } finally {
        pur.deleteSlave(slave1.getObjectId());
        pur.deleteSlave(slave2.getObjectId());
        pur.clearSharedObjectCache();
    }
}
Also used : RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) DocumentBuilder(javax.xml.parsers.DocumentBuilder) AbstractMeta(org.pentaho.di.base.AbstractMeta) SharedObjectInterface(org.pentaho.di.shared.SharedObjectInterface) List(java.util.List) SlaveServer(org.pentaho.di.cluster.SlaveServer) Document(org.w3c.dom.Document)

Example 48 with AbstractMeta

use of org.pentaho.di.base.AbstractMeta in project pentaho-metaverse by pentaho.

the class KettleAnalyzerUtilTest method tesBuildDocument.

@Test
public void tesBuildDocument() throws MetaverseException {
    final IMetaverseBuilder builder = new BaseMetaverseBuilder(null);
    final AbstractMeta transMeta = Mockito.mock(TransMeta.class);
    final String transName = "MyTransMeta";
    Mockito.doReturn(transName).when(transMeta).getName();
    Mockito.doReturn("ktr").when(transMeta).getDefaultExtension();
    final String id = "path.ktr";
    final String namespaceId = "MyNamespace";
    final INamespace namespace = new Namespace(namespaceId);
    assertNull(KettleAnalyzerUtil.buildDocument(null, transMeta, id, namespace));
    IDocument document = KettleAnalyzerUtil.buildDocument(builder, transMeta, id, namespace);
    assertNotNull(document);
    assertEquals(namespace, document.getNamespace());
    assertEquals(transMeta, document.getContent());
    assertEquals(id, document.getStringID());
    assertEquals(transName, document.getName());
    assertEquals("ktr", document.getExtension());
    assertEquals(DictionaryConst.CONTEXT_RUNTIME, document.getContext().getContextName());
    assertEquals(document.getName(), document.getProperty(DictionaryConst.PROPERTY_NAME));
    assertEquals(KettleAnalyzerUtil.normalizeFilePath("path.ktr"), document.getProperty(DictionaryConst.PROPERTY_PATH));
    assertEquals(namespaceId, document.getProperty(DictionaryConst.PROPERTY_NAMESPACE));
}
Also used : BaseMetaverseBuilder(org.pentaho.metaverse.api.model.BaseMetaverseBuilder) INamespace(org.pentaho.metaverse.api.INamespace) AbstractMeta(org.pentaho.di.base.AbstractMeta) Matchers.anyString(org.mockito.Matchers.anyString) IMetaverseBuilder(org.pentaho.metaverse.api.IMetaverseBuilder) INamespace(org.pentaho.metaverse.api.INamespace) Namespace(org.pentaho.metaverse.api.Namespace) IDocument(org.pentaho.metaverse.api.IDocument) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 49 with AbstractMeta

use of org.pentaho.di.base.AbstractMeta in project pentaho-kettle by pentaho.

the class ConnectionDelegate method delete.

public void delete(String label) {
    ConnectionDeleteDialog connectionDeleteDialog = new ConnectionDeleteDialog(spoonSupplier.get().getShell());
    if (connectionDeleteDialog.open(label) == SWT.YES) {
        ConnectionManager connectionManager = ConnectionManager.getInstance();
        connectionManager.delete(label);
        spoonSupplier.get().getShell().getDisplay().asyncExec(() -> spoonSupplier.get().refreshTree(ConnectionFolderProvider.STRING_VFS_CONNECTIONS));
        EngineMetaInterface engineMetaInterface = spoonSupplier.get().getActiveMeta();
        if (engineMetaInterface instanceof AbstractMeta) {
            ((AbstractMeta) engineMetaInterface).setChanged();
        }
    }
}
Also used : ConnectionManager(org.pentaho.di.connections.ConnectionManager) AbstractMeta(org.pentaho.di.base.AbstractMeta) EngineMetaInterface(org.pentaho.di.core.EngineMetaInterface)

Example 50 with AbstractMeta

use of org.pentaho.di.base.AbstractMeta in project pentaho-kettle by pentaho.

the class ConnectionTreeDelegateExtension method callExtensionPoint.

@Override
public void callExtensionPoint(LogChannelInterface log, Object extension) throws KettleException {
    SpoonTreeDelegateExtension treeDelExt = (SpoonTreeDelegateExtension) extension;
    int caseNumber = treeDelExt.getCaseNumber();
    AbstractMeta meta = treeDelExt.getTransMeta();
    String[] path = treeDelExt.getPath();
    List<TreeSelection> objects = treeDelExt.getObjects();
    TreeSelection object = null;
    if (path[2].equals(ConnectionFolderProvider.STRING_VFS_CONNECTIONS)) {
        switch(caseNumber) {
            case 3:
                object = new TreeSelection(path[2], VFSConnectionDetails.class, meta);
                break;
            case 4:
                try {
                    final String name = path[3];
                    object = new TreeSelection(name, new ConnectionTreeItem(name), meta);
                } catch (Exception e) {
                // Do Nothing
                }
                break;
        }
    }
    if (object != null) {
        objects.add(object);
    }
}
Also used : TreeSelection(org.pentaho.di.ui.spoon.TreeSelection) AbstractMeta(org.pentaho.di.base.AbstractMeta) SpoonTreeDelegateExtension(org.pentaho.di.ui.spoon.delegates.SpoonTreeDelegateExtension) VFSConnectionDetails(org.pentaho.di.connections.vfs.VFSConnectionDetails) ExtensionPoint(org.pentaho.di.core.extension.ExtensionPoint) KettleException(org.pentaho.di.core.exception.KettleException)

Aggregations

AbstractMeta (org.pentaho.di.base.AbstractMeta)50 Test (org.junit.Test)18 KettleException (org.pentaho.di.core.exception.KettleException)10 RepositoryDirectoryInterface (org.pentaho.di.repository.RepositoryDirectoryInterface)7 LogChannelInterface (org.pentaho.di.core.logging.LogChannelInterface)6 JobMeta (org.pentaho.di.job.JobMeta)6 TransMeta (org.pentaho.di.trans.TransMeta)6 FileObject (org.apache.commons.vfs2.FileObject)5 ExtensionPointWrapper (org.pentaho.di.ui.core.events.dialog.extension.ExtensionPointWrapper)5 SlaveServer (org.pentaho.di.cluster.SlaveServer)4 EngineMetaInterface (org.pentaho.di.core.EngineMetaInterface)4 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)4 RunConfiguration (org.pentaho.di.engine.configuration.api.RunConfiguration)4 SelectionEvent (org.eclipse.swt.events.SelectionEvent)3 EmbeddedMetaStore (org.pentaho.di.core.attributes.metastore.EmbeddedMetaStore)3 ExtensionPoint (org.pentaho.di.core.extension.ExtensionPoint)3 SimpleLoggingObject (org.pentaho.di.core.logging.SimpleLoggingObject)3 EmbeddedRunConfigurationManager (org.pentaho.di.engine.configuration.impl.EmbeddedRunConfigurationManager)3 RunConfigurationManager (org.pentaho.di.engine.configuration.impl.RunConfigurationManager)3 RepositoryObject (org.pentaho.di.repository.RepositoryObject)3